Class SimpleRepositoryFactory
java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.method.handler.SimpleRepositoryFactory
Factory class for handling dynamic proxy creation and method invocations on repository interfaces.
It registers repository details, collects custom repository implementations, and delegates method execution
to appropriate handlers based on the repository interface and method metadata.
- Since:
- 1.0
- Author:
- Blyzhnytsia Team
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final String
Message for indicating a call to a method with specific details.Message for indicating that an interface is not supported for a repository method.private static final String
Message for indicating that a custom repository should have a default constructor.private static final String
Message for indicating that an implementation for a method is not resolved.private static final String
Message for indicating that method metadata is not found for a method.private static final String
Message for indicating the creation of method handlers.private static final String
Message for indicating that an interface is not supported for a repository method.private static final Map
<String, RepositoryDetails> Message for indicating a call to a method with specific details.private static final String
Message for indicating the resolution of repository details for a method.private final List
<SimpleRepositoryMethodHandler> -
Constructor Summary
ConstructorDescriptionConstructs a SimpleRepositoryFactory and initializes the list of method handlers. -
Method Summary
Modifier and TypeMethodDescriptionprivate <T> void
collectCustomRepositoriesImplementation
(Class<T> repositoryInterface) Collects implementations of custom repositories related to the provided repository interface and adds them to the list of custom repository implementations.private MethodMetadata
getMethodMetadata
(Method method) Retrieves method metadata, including return type and parameters, for the provided method.private MethodMetadata
getMethodMetadata
(Method method, Type genericReturnType) Creates aMethodMetadata
instance based on the providedMethod
and its generic return type.private <T> Map
<String, MethodMetadata> getMethodMetadataMap
(Class<T> repositoryInterface) Retrieves method metadata for all methods in the provided repository interface.Invokes a method on the repository interface, delegates the execution to appropriate handlers, and returns the result.<T> void
registerRepository
(Class<T> repositoryInterface) Registers a repository interface, collects custom repository implementations, and initializes repository metadata information.
-
Field Details
-
CUSTOM_REPOSITORY_SHOULD_HAVE_DEFAULT_CONSTRUCTOR
Message for indicating that a custom repository should have a default constructor.- See Also:
-
REPOSITORY_MEDATA
Message for indicating a call to a method with specific details. -
CUSTOM_REPOSITORY_IMPLEMENTATIONS
Message for indicating that an interface is not supported for a repository method. -
CALL_METHOD_NAME_PARAMETERS_PARAMETER_NAMES_EXTENDS_INTERFACES
Message for indicating a call to a method with specific details.- See Also:
-
NOT_SUPPORTED_INTERFACE_FOR_REPOSITORY_WITH_METHOD
Message for indicating that an interface is not supported for a repository method.- See Also:
-
RESOLVE_REPOSITORY_DETAILS
Message for indicating the resolution of repository details for a method.- See Also:
-
IMPLEMENTATION_FOR_METHOD_S_NOT_RESOLVED
Message for indicating that an implementation for a method is not resolved.- See Also:
-
LOOKS_LIKE_METHOD_METADATA_NOT_FOUND_FOR_METHOD
Message for indicating that method metadata is not found for a method.- See Also:
-
METHOD_HANDLER_CREATION
Message for indicating the creation of method handlers.- See Also:
-
simpleRepositoryMethodHandlers
-
-
Constructor Details
-
SimpleRepositoryFactory
public SimpleRepositoryFactory()Constructs a SimpleRepositoryFactory and initializes the list of method handlers.
-
-
Method Details
-
registerRepository
Registers a repository interface, collects custom repository implementations, and initializes repository metadata information.- Type Parameters:
T
- The type of the repository interface.- Parameters:
repositoryInterface
- The repository interface to be registered.
-
invoke
Invokes a method on the repository interface, delegates the execution to appropriate handlers, and returns the result.- Parameters:
proxy
- The proxy object.method
- The method being invoked.parameters
- The parameters for the method invocation.- Returns:
- The result of the method invocation.
-
collectCustomRepositoriesImplementation
Collects implementations of custom repositories related to the provided repository interface and adds them to the list of custom repository implementations.- Type Parameters:
T
- The type of the repository interface.- Parameters:
repositoryInterface
- The repository interface to collect implementations for.
-
getMethodMetadataMap
Retrieves method metadata for all methods in the provided repository interface.- Type Parameters:
T
- The type of the repository interface.- Parameters:
repositoryInterface
- The repository interface to extract method metadata from.- Returns:
- A map containing method names as keys and corresponding MethodMetadata instances as values.
-
getMethodMetadata
Retrieves method metadata, including return type and parameters, for the provided method.- Parameters:
method
- The method to extract metadata from.- Returns:
- The MethodMetadata instance representing the metadata of the given method.
-
getMethodMetadata
Creates aMethodMetadata
instance based on the providedMethod
and its generic return type.- Parameters:
method
- The method for which metadata is being created.genericReturnType
- The generic return type of the method.- Returns:
- A
MethodMetadata
instance representing the metadata of the given method.
-