Skip to content

Removed Resource Hooks #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/usage/extensibility/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ public class TodoItemService : JsonApiResourceService<TodoItem>
public TodoItemService(IResourceRepositoryAccessor repositoryAccessor,
IQueryLayerComposer queryLayerComposer, IPaginationContext paginationContext,
IJsonApiOptions options, ILoggerFactory loggerFactory, IJsonApiRequest request,
IResourceChangeTracker<TodoItem> resourceChangeTracker,
IResourceHookExecutorFacade hookExecutor)
IResourceChangeTracker<TodoItem> resourceChangeTracker)
: base(repositoryAccessor, queryLayerComposer, paginationContext, options,
loggerFactory, request, resourceChangeTracker, hookExecutor)
loggerFactory, request, resourceChangeTracker)
{
_notificationService = notificationService;
}
Expand Down
771 changes: 0 additions & 771 deletions docs/usage/resources/hooks.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/JsonApiDotNetCore/CollectionConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace JsonApiDotNetCore
{
internal class CollectionConverter
internal sealed class CollectionConverter
{
private static readonly Type[] HashSetCompatibleCollectionTypes =
{
Expand Down
43 changes: 0 additions & 43 deletions src/JsonApiDotNetCore/Configuration/GenericServiceFactory.cs

This file was deleted.

33 changes: 0 additions & 33 deletions src/JsonApiDotNetCore/Configuration/IGenericServiceFactory.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ namespace JsonApiDotNetCore.Configuration
{
/// <summary>
/// Responsible for populating <see cref="RelationshipAttribute.InverseNavigationProperty" />. This service is instantiated in the configure phase of the
/// application. When using a data access layer different from EF Core, and when using ResourceHooks that depend on the inverse navigation property
/// (BeforeImplicitUpdateRelationship), you will need to override this service, or set <see cref="RelationshipAttribute.InverseNavigationProperty" />
/// explicitly.
/// application. When using a data access layer different from EF Core, you will need to implement and register this service, or set
/// <see cref="RelationshipAttribute.InverseNavigationProperty" /> explicitly.
/// </summary>
[PublicAPI]
public interface IInverseNavigationResolver
Expand Down
10 changes: 0 additions & 10 deletions src/JsonApiDotNetCore/Configuration/IJsonApiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,6 @@ internal NamingStrategy SerializerNamingStrategy
/// </summary>
bool AllowClientGeneratedIds { get; }

/// <summary>
/// Whether or not resource hooks are enabled. This is currently an experimental feature and subject to change in future versions. Defaults to False.
/// </summary>
public bool EnableResourceHooks { get; }

/// <summary>
/// Whether or not database values should be included by default for resource hooks. Ignored if EnableResourceHooks is set to false. False by default.
/// </summary>
bool LoadDatabaseValues { get; }

/// <summary>
/// Whether or not to produce an error on unknown query string parameters. False by default.
/// </summary>
Expand Down
25 changes: 0 additions & 25 deletions src/JsonApiDotNetCore/Configuration/JsonApiApplicationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
using System.Linq;
using JsonApiDotNetCore.AtomicOperations;
using JsonApiDotNetCore.AtomicOperations.Processors;
using JsonApiDotNetCore.Hooks;
using JsonApiDotNetCore.Hooks.Internal;
using JsonApiDotNetCore.Hooks.Internal.Discovery;
using JsonApiDotNetCore.Hooks.Internal.Execution;
using JsonApiDotNetCore.Hooks.Internal.Traversal;
using JsonApiDotNetCore.Middleware;
using JsonApiDotNetCore.Queries;
using JsonApiDotNetCore.Queries.Internal;
Expand Down Expand Up @@ -153,9 +148,6 @@ public void ConfigureServiceContainer(ICollection<Type> dbContextTypes)
AddQueryStringLayer();
AddOperationsLayer();

AddResourceHooks();

_services.AddScoped<IGenericServiceFactory, GenericServiceFactory>();
_services.AddScoped(typeof(IResourceChangeTracker<>), typeof(ResourceChangeTracker<>));
_services.AddScoped<IPaginationContext, PaginationContext>();
_services.AddScoped<IEvaluatedIncludeCache, EvaluatedIncludeCache>();
Expand Down Expand Up @@ -256,23 +248,6 @@ private void RegisterDependentService<TCollectionElement, TElementToAdd>()
_services.AddScoped<TCollectionElement>(serviceProvider => serviceProvider.GetRequiredService<TElementToAdd>());
}

private void AddResourceHooks()
{
if (_options.EnableResourceHooks)
{
_services.AddSingleton(typeof(IHooksDiscovery<>), typeof(HooksDiscovery<>));
_services.AddScoped(typeof(IResourceHookContainer<>), typeof(ResourceHooksDefinition<>));
_services.AddTransient<IResourceHookExecutor, ResourceHookExecutor>();
_services.AddTransient<IHookContainerProvider, HookContainerProvider>();
_services.AddScoped<INodeNavigator, NodeNavigator>();
_services.AddScoped<IResourceHookExecutorFacade, ResourceHookExecutorFacade>();
}
else
{
_services.AddSingleton<IResourceHookExecutorFacade, NeverResourceHookExecutorFacade>();
}
}

private void AddSerializationLayer()
{
_services.AddScoped<IIncludedResourceObjectBuilder, IncludedResourceObjectBuilder>();
Expand Down
6 changes: 0 additions & 6 deletions src/JsonApiDotNetCore/Configuration/JsonApiOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ public sealed class JsonApiOptions : IJsonApiOptions
/// <inheritdoc />
public bool AllowClientGeneratedIds { get; set; }

/// <inheritdoc />
public bool EnableResourceHooks { get; set; }

/// <inheritdoc />
public bool LoadDatabaseValues { get; set; }

/// <inheritdoc />
public bool AllowUnknownQueryStringParameters { get; set; }

Expand Down
26 changes: 0 additions & 26 deletions src/JsonApiDotNetCore/Configuration/ServiceDiscoveryFacade.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using JetBrains.Annotations;
using JsonApiDotNetCore.Errors;
using JsonApiDotNetCore.Repositories;
using JsonApiDotNetCore.Resources;
using JsonApiDotNetCore.Services;
Expand Down Expand Up @@ -134,11 +132,6 @@ private void AddInjectables(IReadOnlyCollection<ResourceDescriptor> resourceDesc
AddServices(assembly, resourceDescriptor);
AddRepositories(assembly, resourceDescriptor);
AddResourceDefinitions(assembly, resourceDescriptor);

if (_options.EnableResourceHooks)
{
AddResourceHookDefinitions(assembly, resourceDescriptor);
}
}
}

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

private void AddResourceHookDefinitions(Assembly assembly, ResourceDescriptor identifiable)
{
try
{
Type resourceDefinition = _typeLocator.GetDerivedGenericTypes(assembly, typeof(ResourceHooksDefinition<>), identifiable.ResourceType)
.SingleOrDefault();

if (resourceDefinition != null)
{
_services.AddScoped(typeof(ResourceHooksDefinition<>).MakeGenericType(identifiable.ResourceType), resourceDefinition);
}
}
catch (InvalidOperationException exception)
{
throw new InvalidConfigurationException($"Cannot define multiple ResourceHooksDefinition<> implementations for '{identifiable.ResourceType}'",
exception);
}
}

private void AddServices(Assembly assembly, ResourceDescriptor resourceDescriptor)
{
foreach (Type serviceInterface in ServiceInterfaces)
Expand Down
56 changes: 0 additions & 56 deletions src/JsonApiDotNetCore/Hooks/IResourceHookExecutorFacade.cs

This file was deleted.

98 changes: 0 additions & 98 deletions src/JsonApiDotNetCore/Hooks/Internal/Discovery/HooksDiscovery.cs

This file was deleted.

Loading