private InterceptorFactory createInterceptorFactoryForContainerInterceptor(final Method method, final Constructor interceptorConstructor) { // The managed reference is going to be ConstructedValue, using the container-interceptor's constructor final ConstructedValue interceptorInstanceValue = new ConstructedValue(interceptorConstructor, Collections.<Value<?>>emptyList()); // we *don't* create multiple instances of the container-interceptor class, but we just reuse a single instance and it's *not* // tied to the EJB component instance lifecycle. final CachedValue cachedInterceptorInstanceValue = new CachedValue(interceptorInstanceValue); // ultimately create the managed reference which is backed by the CachedValue final ManagedReference interceptorInstanceRef = new ValueManagedReference(cachedInterceptorInstanceValue); // return the ContainerInterceptorMethodInterceptorFactory which is responsible for creating an Interceptor // which can invoke the container-interceptor's around-invoke/around-timeout methods return new ContainerInterceptorMethodInterceptorFactory(interceptorInstanceRef, method); } }
/** * Get a cached value for some opaque value. If the value is already cached, it is returned as-is. * * @param value the value to wrap * @param <T> the value type * @return a cached value */ public static <T> Value<T> cached(Value<T> value) { if (value instanceof CachedValue || value instanceof ImmediateValue) { return value; } else { return new CachedValue<T>(value); } }
/** * Get a cached value for some opaque value. If the value is already cached, it is returned as-is. * * @param value the value to wrap * @param <T> the value type * @return a cached value */ public static <T> Value<T> cached(Value<T> value) { if (value instanceof CachedValue || value instanceof ImmediateValue) { return value; } else { return new CachedValue<T>(value); } }
private InterceptorFactory createInterceptorFactoryForContainerInterceptor(final Method method, final Constructor interceptorConstructor) { // The managed reference is going to be ConstructedValue, using the container-interceptor's constructor final ConstructedValue interceptorInstanceValue = new ConstructedValue(interceptorConstructor, Collections.<Value<?>>emptyList()); // we *don't* create multiple instances of the container-interceptor class, but we just reuse a single instance and it's *not* // tied to the EJB component instance lifecycle. final CachedValue cachedInterceptorInstanceValue = new CachedValue(interceptorInstanceValue); // ultimately create the managed reference which is backed by the CachedValue final ManagedReference interceptorInstanceRef = new ValueManagedReference(cachedInterceptorInstanceValue); // return the ContainerInterceptorMethodInterceptorFactory which is responsible for creating a Interceptor // which can invoke the container-interceptor's around-invoke/around-timeout methods return new ContainerInterceptorMethodInterceptorFactory(interceptorInstanceRef, method); } }