Beispiel #1
0
 @Override
 public <T> T getRepository(Class<T> repositoryType) {
   RepositoryTypeMetadata repositoryMetadata =
       sessionContext.getMetadataProvider().getRepositoryMetadata(repositoryType);
   RepositoryProxyMethodService<Entity, Relation> proxyMethodService =
       new RepositoryProxyMethodService<>(sessionContext);
   RepositoryInvocationHandler invocationHandler =
       new RepositoryInvocationHandler(proxyMethodService, this);
   T instance =
       sessionContext
           .getProxyFactory()
           .createInstance(invocationHandler, new Class<?>[0], repositoryType);
   return sessionContext.getInterceptorFactory().addInterceptor(instance, repositoryType);
 }
Beispiel #2
0
 /**
  * Setup an example entity.
  *
  * @param type The type.
  * @param example The provided example.
  * @param <T> The type.
  * @return The example.
  */
 private <T> Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> prepareExample(
     Example<T> example, Class<?> type, Class<?>... types) {
   Map<PrimitivePropertyMethodMetadata<PropertyMetadata>, Object> exampleEntity = new HashMap<>();
   InstanceInvocationHandler invocationHandler =
       new InstanceInvocationHandler(
           exampleEntity, new ExampleProxyMethodService(type, sessionContext));
   List<Class<?>> effectiveTypes = new ArrayList<>();
   effectiveTypes.add(type);
   effectiveTypes.addAll(Arrays.asList(types));
   T instance =
       sessionContext
           .getProxyFactory()
           .createInstance(
               invocationHandler,
               effectiveTypes.toArray(new Class<?>[effectiveTypes.size()]),
               CompositeObject.class);
   example.prepare(instance);
   return exampleEntity;
 }