コード例 #1
0
 public static InterceptorMetadata readMetadataForInterceptorClass(
     InterceptorReference<?> interceptorReference) {
   return new SimpleInterceptorMetadata(
       interceptorReference,
       false,
       buildMethodMap(interceptorReference.getClassMetadata(), false));
 }
コード例 #2
0
 public T createFor(InterceptorReference<Object> interceptorReference) {
   if (interceptorReference.getInterceptor() instanceof ClassMetadata<?>) {
     try {
       // this is not a managed instance - assume no-argument constructor exists
       Class<T> clazz = cast(interceptorReference.getClassMetadata().getJavaClass());
       Constructor<T> constructor = SecureReflections.getDeclaredConstructor(clazz);
       T interceptorInstance = SecureReflections.ensureAccessible(constructor).newInstance();
       // inject
       AnnotatedType<T> type = manager.createAnnotatedType(clazz);
       InjectionTarget<T> target = manager.createInjectionTarget(type);
       target.inject(interceptorInstance, creationalContext);
       return interceptorInstance;
     } catch (Exception e) {
       throw new DeploymentException(e);
     }
   }
   if (interceptorReference.getInterceptor() instanceof SerializableContextual) {
     try {
       // this is not a managed instance - assume no-argument constructor exists
       SerializableContextual<Interceptor<T>, T> serializableContextual =
           cast(interceptorReference.getInterceptor());
       return Reflections.<T>cast(
           manager.getReference(serializableContextual.get(), creationalContext, false));
     } catch (Exception e) {
       throw new DeploymentException(e);
     }
   }
   throw new IllegalStateException();
 }