Class SimpleRepositoryInvocationHandler

java.lang.Object
io.github.blyznytsiaorg.bibernate.dao.SimpleRepositoryInvocationHandler
All Implemented Interfaces:
InvocationHandler

public class SimpleRepositoryInvocationHandler extends Object implements InvocationHandler
InvocationHandler implementation for dynamically handling method invocations on repository interfaces. It delegates the invocation to a SimpleRepositoryFactory for handling repository-specific operations.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • simpleRepositoryFactory

      private final SimpleRepositoryFactory simpleRepositoryFactory
      The SimpleRepositoryFactory used for handling repository-specific operations.
  • Constructor Details

    • SimpleRepositoryInvocationHandler

      public SimpleRepositoryInvocationHandler()
      Constructs a SimpleRepositoryInvocationHandler with a new instance of SimpleRepositoryFactory.
  • Method Details

    • invoke

      public Object invoke(Object proxy, Method method, Object[] parameters)
      Handles the method invocation by delegating it to the associated SimpleRepositoryFactory.
      Specified by:
      invoke in interface InvocationHandler
      Parameters:
      proxy - The proxy object.
      method - The method being invoked.
      parameters - The parameters for the method invocation.
      Returns:
      The result of the method invocation.
    • registerRepository

      public <T> T registerRepository(Class<T> repositoryInterface)
      Registers a repository interface and creates a dynamic proxy for it.
      Type Parameters:
      T - The type of the repository interface.
      Parameters:
      repositoryInterface - The repository interface to be registered.
      Returns:
      A dynamic proxy instance for the registered repository interface.