private void addInterceptorInstance(Interceptor<Object> interceptor, BeanManagerImpl beanManager, Map<String, SerializableContextualInstance<Interceptor<Object>, Object>> instances, final CreationalContext<Object> creationalContext) { Object instance = beanManager.getReference(interceptor, interceptor.getBeanClass(), creationalContext, true); SerializableContextualInstance<Interceptor<Object>, Object> serializableContextualInstance = beanManager.getServices().get(ContextualStore.class).<Interceptor<Object>, Object>getSerializableContextualInstance(interceptor, instance, creationalContext); instances.put(interceptor.getBeanClass().getName(), serializableContextualInstance); }
private InterceptorBindings getInterceptorBindings(final String ejbName, final BeanManagerImpl manager) { InterceptorBindings retVal = null; if (ejbName != null) { retVal = interceptorSupport.getInterceptorBindings(ejbName, manager); } else { // This is a managed bean SlimAnnotatedType<?> type = (SlimAnnotatedType<?>) manager.createAnnotatedType(componentClass); if (!manager.getInterceptorModelRegistry().containsKey(type)) { EnhancedAnnotatedType<?> enhancedType = manager.getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(type); InterceptionModelInitializer.of(manager, enhancedType, null).init(); } InterceptionModel model = manager.getInterceptorModelRegistry().get(type); if (model != null) { retVal = new InterceptorBindingsAdapter(manager.getInterceptorModelRegistry().get(type)); } } return retVal != null ? retVal : NullInterceptorBindings.INSTANCE; }
final ClassTransformer transformer = beanManager.getServices().get(ClassTransformer.class); @SuppressWarnings("unchecked") final Class<T> clazz = (Class<T>) componentClass; EnhancedAnnotatedType<T> type = transformer.getEnhancedAnnotatedType(clazz, beanManager.getId()); final String bdaId = beanManager.getId() + classLoader.hashCode(); type = transformer.getEnhancedAnnotatedType(clazz, bdaId);
public DecorationHelper(TargetBeanInstance originalInstance, Bean<?> bean, Class<T> proxyClassForDecorator, BeanManagerImpl beanManager, ContextualStore contextualStore, List<Decorator<?>> decorators) { this.originalInstance = Reflections.<T>cast(originalInstance.getInstance()); this.targetBeanInstance = originalInstance; this.beanManager = beanManager; this.contextualStore = contextualStore; this.decorators = new LinkedList<Decorator<?>>(decorators); this.proxyClassForDecorator = proxyClassForDecorator; this.bean = bean; this.instantiator = beanManager.getServices().get(ProxyInstantiator.class); counter = 0; }
public static <T extends Service> void put(ServiceRegistry registry, Class<T> key, Service value) { Service previous = registry.get(key); if (previous == null) { BootstrapLogger.LOG.debugv("Installing additional service {0} ({1})", key.getName(), value.getClass()); registry.add(key, Reflections.<T>cast(value)); } else if (shouldOverride(key, previous, value)) { BootstrapLogger.LOG.debugv("Overriding service implementation for {0}. Previous implementation {1} is replaced with {2}", key.getName(), previous.getClass().getName(), value.getClass().getName()); registry.add(key, Reflections.<T>cast(value)); } }
protected InjectionTargetFactoryImpl(AnnotatedType<T> type, BeanManagerImpl manager) { this.manager = manager; this.originalAnnotatedType = manager.getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(type, manager.getId()); this.injectionTargetService = manager.getServices().get(InjectionTargetService.class); this.injectionServices = manager.getServices().get(InjectionServices.class); }
public DecorationHelper(TargetBeanInstance originalInstance, Bean<?> bean, Class<T> proxyClassForDecorator, BeanManagerImpl beanManager, ContextualStore contextualStore, List<Decorator<?>> decorators) { this.originalInstance = Reflections.<T>cast(originalInstance.getInstance()); this.targetBeanInstance = originalInstance; this.beanManager = beanManager; this.contextualStore = contextualStore; this.decorators = new LinkedList<Decorator<?>>(decorators); this.proxyClassForDecorator = proxyClassForDecorator; this.bean = bean; this.instantiator = beanManager.getServices().get(ProxyInstantiator.class); counter = 0; }
private void checkNoArgsConstructor(EnhancedAnnotatedType<T> type) { if (!beanManager.getServices().get(ProxyInstantiator.class).isUsingConstructor()) { return; } EnhancedAnnotatedConstructor<T> constructor = type.getNoArgsEnhancedConstructor(); if (constructor == null) { throw BeanLogger.LOG.decoratedHasNoNoargsConstructor(this); } else if (constructor.isPrivate()) { throw BeanLogger.LOG .decoratedNoargsConstructorIsPrivate(this, Formats.formatAsStackTraceElement(constructor.getJavaMember())); } }
public static <T extends Service> void put(ServiceRegistry registry, Class<T> key, Service value) { Service previous = registry.get(key); if (previous == null) { BootstrapLogger.LOG.debugv("Installing additional service {0} ({1})", key.getName(), value.getClass()); registry.add(key, Reflections.cast(value)); } else if (shouldOverride(key, previous, value)) { BootstrapLogger.LOG.debugv("Overriding service implementation for {0}. Previous implementation {1} is replaced with {2}", key.getName(), previous.getClass().getName(), value.getClass().getName()); registry.add(key, Reflections.cast(value)); } }
private void checkDecoratedMethods(EnhancedAnnotatedType<T> type, List<Decorator<?>> decorators) { if (type.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithDecoratorsNotAllowed(this); } checkNoArgsConstructor(type); for (Decorator<?> decorator : decorators) { EnhancedAnnotatedType<?> decoratorClass; if (decorator instanceof DecoratorImpl<?>) { DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator; decoratorClass = decoratorBean.getBeanManager().getServices().get(ClassTransformer.class) .getEnhancedAnnotatedType(decoratorBean.getAnnotated()); } else if (decorator instanceof CustomDecoratorWrapper<?>) { decoratorClass = ((CustomDecoratorWrapper<?>) decorator).getEnhancedAnnotated(); } else { throw BeanLogger.LOG.nonContainerDecorator(decorator); } for (EnhancedAnnotatedMethod<?, ?> decoratorMethod : decoratorClass.getEnhancedMethods()) { EnhancedAnnotatedMethod<?, ?> method = type.getEnhancedMethod(decoratorMethod.getSignature()); if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithInterceptorsNotAllowed(this); } } } }
protected InjectionTargetFactoryImpl(AnnotatedType<T> type, BeanManagerImpl manager) { this.manager = manager; this.type = manager.getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(type, manager.getId()); this.injectionTargetService = manager.getServices().get(InjectionTargetService.class); this.injectionServices = manager.getServices().get(InjectionServices.class); }
public DecorationHelper(TargetBeanInstance originalInstance, Bean<?> bean, Class<T> proxyClassForDecorator, BeanManagerImpl beanManager, ContextualStore contextualStore, List<Decorator<?>> decorators) { this.originalInstance = Reflections.<T>cast(originalInstance.getInstance()); this.targetBeanInstance = originalInstance; this.beanManager = beanManager; this.contextualStore = contextualStore; this.decorators = new LinkedList<Decorator<?>>(decorators); this.proxyClassForDecorator = proxyClassForDecorator; this.bean = bean; this.instantiator = beanManager.getServices().get(ProxyInstantiator.class); counter = 0; }
beanManager.getServices().get(InjectionTargetService.class).validateProducer(injectionTarget);
public static <T extends Service> void put(ServiceRegistry registry, Class<T> key, Service value) { Service previous = registry.get(key); if (previous == null) { BootstrapLogger.LOG.debugv("Installing additional service {0} ({1})", key.getName(), value.getClass()); registry.add(key, Reflections.cast(value)); } else if (shouldOverride(key, previous, value)) { BootstrapLogger.LOG.debugv("Overriding service implementation for {0}. Previous implementation {1} is replaced with {2}", key.getName(), previous.getClass().getName(), value.getClass().getName()); registry.add(key, Reflections.cast(value)); } }
protected InjectionTargetFactoryImpl(AnnotatedType<T> type, BeanManagerImpl manager) { this.manager = manager; this.originalAnnotatedType = manager.getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(type, manager.getId()); this.injectionTargetService = manager.getServices().get(InjectionTargetService.class); this.injectionServices = manager.getServices().get(InjectionServices.class); }
public DecorationHelper(TargetBeanInstance originalInstance, Bean<?> bean, Class<T> proxyClassForDecorator, BeanManagerImpl beanManager, ContextualStore contextualStore, List<Decorator<?>> decorators) { this.originalInstance = Reflections.<T>cast(originalInstance.getInstance()); this.targetBeanInstance = originalInstance; this.beanManager = beanManager; this.contextualStore = contextualStore; this.decorators = new LinkedList<Decorator<?>>(decorators); this.proxyClassForDecorator = proxyClassForDecorator; this.bean = bean; this.instantiator = beanManager.getServices().get(ProxyInstantiator.class); counter = 0; }