Skip to content

Commit 0acecc9

Browse files
author
Bart Koelman
committed
Removed Resource Hooks
1 parent 6429275 commit 0acecc9

File tree

122 files changed

+25
-9391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+25
-9391
lines changed

docs/usage/extensibility/services.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ public class TodoItemService : JsonApiResourceService<TodoItem>
1818
public TodoItemService(IResourceRepositoryAccessor repositoryAccessor,
1919
IQueryLayerComposer queryLayerComposer, IPaginationContext paginationContext,
2020
IJsonApiOptions options, ILoggerFactory loggerFactory, IJsonApiRequest request,
21-
IResourceChangeTracker<TodoItem> resourceChangeTracker,
22-
IResourceHookExecutorFacade hookExecutor)
21+
IResourceChangeTracker<TodoItem> resourceChangeTracker)
2322
: base(repositoryAccessor, queryLayerComposer, paginationContext, options,
24-
loggerFactory, request, resourceChangeTracker, hookExecutor)
23+
loggerFactory, request, resourceChangeTracker)
2524
{
2625
_notificationService = notificationService;
2726
}

docs/usage/resources/hooks.md

-771
This file was deleted.

src/JsonApiDotNetCore/Configuration/GenericServiceFactory.cs

-43
This file was deleted.

src/JsonApiDotNetCore/Configuration/IGenericServiceFactory.cs

-33
This file was deleted.

src/JsonApiDotNetCore/Configuration/IInverseNavigationResolver.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ namespace JsonApiDotNetCore.Configuration
55
{
66
/// <summary>
77
/// Responsible for populating <see cref="RelationshipAttribute.InverseNavigationProperty" />. This service is instantiated in the configure phase of the
8-
/// application. When using a data access layer different from EF Core, and when using ResourceHooks that depend on the inverse navigation property
9-
/// (BeforeImplicitUpdateRelationship), you will need to override this service, or set <see cref="RelationshipAttribute.InverseNavigationProperty" />
10-
/// explicitly.
8+
/// application. When using a data access layer different from EF Core, you will need to implement and register this service, or set
9+
/// <see cref="RelationshipAttribute.InverseNavigationProperty" /> explicitly.
1110
/// </summary>
1211
[PublicAPI]
1312
public interface IInverseNavigationResolver

src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs

-10
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,6 @@ internal NamingStrategy SerializerNamingStrategy
118118
/// </summary>
119119
bool AllowClientGeneratedIds { get; }
120120

121-
/// <summary>
122-
/// Whether or not resource hooks are enabled. This is currently an experimental feature and subject to change in future versions. Defaults to False.
123-
/// </summary>
124-
public bool EnableResourceHooks { get; }
125-
126-
/// <summary>
127-
/// Whether or not database values should be included by default for resource hooks. Ignored if EnableResourceHooks is set to false. False by default.
128-
/// </summary>
129-
bool LoadDatabaseValues { get; }
130-
131121
/// <summary>
132122
/// Whether or not to produce an error on unknown query string parameters. False by default.
133123
/// </summary>

src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs

-25
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
using System.Linq;
44
using JsonApiDotNetCore.AtomicOperations;
55
using JsonApiDotNetCore.AtomicOperations.Processors;
6-
using JsonApiDotNetCore.Hooks;
7-
using JsonApiDotNetCore.Hooks.Internal;
8-
using JsonApiDotNetCore.Hooks.Internal.Discovery;
9-
using JsonApiDotNetCore.Hooks.Internal.Execution;
10-
using JsonApiDotNetCore.Hooks.Internal.Traversal;
116
using JsonApiDotNetCore.Middleware;
127
using JsonApiDotNetCore.Queries;
138
using JsonApiDotNetCore.Queries.Internal;
@@ -153,9 +148,6 @@ public void ConfigureServiceContainer(ICollection<Type> dbContextTypes)
153148
AddQueryStringLayer();
154149
AddOperationsLayer();
155150

156-
AddResourceHooks();
157-
158-
_services.AddScoped<IGenericServiceFactory, GenericServiceFactory>();
159151
_services.AddScoped(typeof(IResourceChangeTracker<>), typeof(ResourceChangeTracker<>));
160152
_services.AddScoped<IPaginationContext, PaginationContext>();
161153
_services.AddScoped<IEvaluatedIncludeCache, EvaluatedIncludeCache>();
@@ -256,23 +248,6 @@ private void RegisterDependentService<TCollectionElement, TElementToAdd>()
256248
_services.AddScoped<TCollectionElement>(serviceProvider => serviceProvider.GetRequiredService<TElementToAdd>());
257249
}
258250

259-
private void AddResourceHooks()
260-
{
261-
if (_options.EnableResourceHooks)
262-
{
263-
_services.AddSingleton(typeof(IHooksDiscovery<>), typeof(HooksDiscovery<>));
264-
_services.AddScoped(typeof(IResourceHookContainer<>), typeof(ResourceHooksDefinition<>));
265-
_services.AddTransient<IResourceHookExecutor, ResourceHookExecutor>();
266-
_services.AddTransient<IHookContainerProvider, HookContainerProvider>();
267-
_services.AddScoped<INodeNavigator, NodeNavigator>();
268-
_services.AddScoped<IResourceHookExecutorFacade, ResourceHookExecutorFacade>();
269-
}
270-
else
271-
{
272-
_services.AddSingleton<IResourceHookExecutorFacade, NeverResourceHookExecutorFacade>();
273-
}
274-
}
275-
276251
private void AddSerializationLayer()
277252
{
278253
_services.AddScoped<IIncludedResourceObjectBuilder, IncludedResourceObjectBuilder>();

src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs

-6
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ public sealed class JsonApiOptions : IJsonApiOptions
5858
/// <inheritdoc />
5959
public bool AllowClientGeneratedIds { get; set; }
6060

61-
/// <inheritdoc />
62-
public bool EnableResourceHooks { get; set; }
63-
64-
/// <inheritdoc />
65-
public bool LoadDatabaseValues { get; set; }
66-
6761
/// <inheritdoc />
6862
public bool AllowUnknownQueryStringParameters { get; set; }
6963

src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs

-26
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
43
using System.Reflection;
54
using JetBrains.Annotations;
6-
using JsonApiDotNetCore.Errors;
75
using JsonApiDotNetCore.Repositories;
86
using JsonApiDotNetCore.Resources;
97
using JsonApiDotNetCore.Services;
@@ -134,11 +132,6 @@ private void AddInjectables(IReadOnlyCollection<ResourceDescriptor> resourceDesc
134132
AddServices(assembly, resourceDescriptor);
135133
AddRepositories(assembly, resourceDescriptor);
136134
AddResourceDefinitions(assembly, resourceDescriptor);
137-
138-
if (_options.EnableResourceHooks)
139-
{
140-
AddResourceHookDefinitions(assembly, resourceDescriptor);
141-
}
142135
}
143136
}
144137

@@ -158,25 +151,6 @@ private void AddResource(ResourceDescriptor resourceDescriptor)
158151
_resourceGraphBuilder.Add(resourceDescriptor.ResourceType, resourceDescriptor.IdType);
159152
}
160153

161-
private void AddResourceHookDefinitions(Assembly assembly, ResourceDescriptor identifiable)
162-
{
163-
try
164-
{
165-
Type resourceDefinition = _typeLocator.GetDerivedGenericTypes(assembly, typeof(ResourceHooksDefinition<>), identifiable.ResourceType)
166-
.SingleOrDefault();
167-
168-
if (resourceDefinition != null)
169-
{
170-
_services.AddScoped(typeof(ResourceHooksDefinition<>).MakeGenericType(identifiable.ResourceType), resourceDefinition);
171-
}
172-
}
173-
catch (InvalidOperationException exception)
174-
{
175-
throw new InvalidConfigurationException($"Cannot define multiple ResourceHooksDefinition<> implementations for '{identifiable.ResourceType}'",
176-
exception);
177-
}
178-
}
179-
180154
private void AddServices(Assembly assembly, ResourceDescriptor resourceDescriptor)
181155
{
182156
foreach (Type serviceInterface in ServiceInterfaces)

src/JsonApiDotNetCore/Hooks/IResourceHookExecutorFacade.cs

-56
This file was deleted.

src/JsonApiDotNetCore/Hooks/Internal/Discovery/HooksDiscovery.cs

-98
This file was deleted.

0 commit comments

Comments
 (0)