public static <T> EnhancedAnnotatedType<T> getEjbImplementationClass(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl manager, EnhancedAnnotatedType<T> componentType) { if (ejbDescriptor.getBeanClass().equals(ejbDescriptor.getImplementationClass())) { // no special implementation class is used return componentType; } ClassTransformer transformer = manager.getServices().get(ClassTransformer.class); EnhancedAnnotatedType<T> implementationClass = cast(transformer.getEnhancedAnnotatedType(ejbDescriptor.getImplementationClass(), manager.getId())); manager.getServices().get(SlimAnnotatedTypeStore.class).put(implementationClass.slim()); return implementationClass; }
private Set<InterceptionModel> getInterceptionModelsForType(EnhancedAnnotatedType<T> type, BeanManagerImpl manager, Bean<?> bean) { // if the bean has decorators consider all methods as intercepted // TODO - reduce this to decorated types only if (bean != null && !manager.resolveDecorators(bean.getTypes(), bean.getQualifiers()).isEmpty()) { return null; } SlimAnnotatedTypeStore store = manager.getServices().get(SlimAnnotatedTypeStore.class); Set<InterceptionModel> models = new HashSet<InterceptionModel>(); WeldCollections.addIfNotNull(models, manager.getInterceptorModelRegistry().get(type.slim())); for (SlimAnnotatedType<?> slimType : store.get(type.getJavaClass())) { WeldCollections.addIfNotNull(models, manager.getInterceptorModelRegistry().get(slimType)); } for (InterceptionModel model : models) { if (model.hasTargetClassInterceptors() && model.getTargetClassInterceptorMetadata().isEligible(InterceptionType.AROUND_INVOKE)) { // this means that all methods are intercepted // returning null here means that all methods will be overridden and will delegate to MethodHandler return null; } } return models; }
@Override protected void storeSyntheticAnnotatedType(BeanDeployment deployment, AnnotatedType<?> type, String id) { SlimAnnotatedType<?> annotatedType = transformer.getUnbackedAnnotatedType(type, getBeanManager().getId(), id); Extension extension = getReceiver(); SlimAnnotatedTypeContext<?> annotatedTypeContext = SlimAnnotatedTypeContext.of(annotatedType, extension); ProcessAnnotatedTypeImpl<?> event = events.fireProcessAnnotatedType(getBeanManager(), annotatedTypeContext); if (event == null) { deployment.getBeanDeployer().getEnvironment().addAnnotatedType(annotatedTypeContext); store.put(annotatedType); } else if (event.isVeto()) { return; } else { annotatedType = event.getResultingAnnotatedType(); deployment.getBeanDeployer().getEnvironment().addSyntheticAnnotatedType(annotatedType, extension); store.put(annotatedType); } } }
protected <T> void createNewManagedBean(Class<T> clazz, Type type) { EnhancedAnnotatedType<T> enhancedType = classTransformer.getEnhancedAnnotatedType(clazz, type, manager.getId()); slimAnnotatedTypeStore.put(enhancedType.slim()); getEnvironment().addManagedBean(NewManagedBean.of(BeanAttributesFactory.forNewManagedBean(enhancedType, manager), enhancedType, manager)); }
protected <T> SessionBean<T> createSessionBean(InternalEjbDescriptor<T> descriptor, BeanDeployerEnvironment environment, BeanManagerImpl manager, ClassTransformer transformer) { final SlimAnnotatedType<T> type = transformer.getBackedAnnotatedType(descriptor.getBeanClass(), manager.getId()); manager.getServices().get(SlimAnnotatedTypeStore.class).put(type); return createSessionBean(descriptor, type, environment, manager, transformer); }
protected <T> SessionBean<T> createSessionBean(InternalEjbDescriptor<T> descriptor) { EnhancedAnnotatedType<T> type = classTransformer.getEnhancedAnnotatedType(descriptor.getBeanClass(), getManager().getId()); slimAnnotatedTypeStore.put(type.slim()); return createSessionBean(descriptor, type); } protected <T> SessionBean<T> createSessionBean(InternalEjbDescriptor<T> descriptor, EnhancedAnnotatedType<T> weldClass) {
public void registerAnnotatedTypes() { for (SlimAnnotatedTypeContext<?> ctx : getEnvironment().getAnnotatedTypes()) { annotatedTypeStore.put(ctx.getAnnotatedType()); } }
protected <T> void createNewSessionBean(InternalEjbDescriptor<T> ejbDescriptor, BeanAttributes<?> originalAttributes, EnhancedAnnotatedType<?> type) { slimAnnotatedTypeStore.put(type.slim()); BeanAttributes<T> attributes = Reflections.cast(BeanAttributesFactory.forNewSessionBean(originalAttributes, type.getJavaClass())); getEnvironment().addSessionBean(NewSessionBean.of(attributes, ejbDescriptor, manager)); }
protected <T> void createNewManagedBean(EnhancedAnnotatedType<T> annotatedClass) { // TODO resolve existing beans first slimAnnotatedTypeStore.put(annotatedClass.slim()); getEnvironment().addManagedBean(NewManagedBean.of(BeanAttributesFactory.forNewManagedBean(annotatedClass, manager), annotatedClass, manager)); }
private <T> SessionBean<T> createNewSessionBean(EnhancedAnnotatedType<?> type, InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl beanManager, SlimAnnotatedTypeStore store) { store.put(type.slim()); final BeanAttributes<T> attributes = Reflections.cast(SessionBeans.createBeanAttributesForNew(type, ejbDescriptor, beanManager, type.getJavaClass())); return NewSessionBean.of(attributes, ejbDescriptor, beanManager); }
@Override public <T> AnnotatedType<T> getAnnotatedType(Class<T> type, String id) { checkWithinObserverNotification(); Preconditions.checkArgumentNotNull(type, TYPE_ARGUMENT_NAME); return slimAnnotatedTypeStore.get(type, id); }
private Set<InterceptionModel> getInterceptionModelsForType(EnhancedAnnotatedType<T> type, BeanManagerImpl manager, Bean<?> bean) { // if the bean has decorators consider all methods as intercepted if (bean != null && !manager.resolveDecorators(bean.getTypes(), bean.getQualifiers()).isEmpty()) { return null; } SlimAnnotatedTypeStore store = manager.getServices().get(SlimAnnotatedTypeStore.class); Set<InterceptionModel> models = new HashSet<InterceptionModel>(); WeldCollections.addIfNotNull(models, manager.getInterceptorModelRegistry().get(type.slim())); for (SlimAnnotatedType<?> slimType : store.get(type.getJavaClass())) { WeldCollections.addIfNotNull(models, manager.getInterceptorModelRegistry().get(slimType)); } for (InterceptionModel model : models) { if (model.hasTargetClassInterceptors() && model.getTargetClassInterceptorMetadata().isEligible(InterceptionType.AROUND_INVOKE)) { // this means that all methods are intercepted // returning null here means that all methods will be overridden and will delegate to MethodHandler return null; } } return models; }
@Override protected void storeSyntheticAnnotatedType(BeanDeployment deployment, AnnotatedType<?> type, String id) { SlimAnnotatedType<?> annotatedType = transformer.getUnbackedAnnotatedType(type, getBeanManager().getId(), id); Extension extension = getReceiver(); SlimAnnotatedTypeContext<?> annotatedTypeContext = SlimAnnotatedTypeContext.of(annotatedType, extension); ProcessAnnotatedTypeImpl<?> event = events.fireProcessAnnotatedType(getBeanManager(), annotatedTypeContext); if (event == null) { deployment.getBeanDeployer().getEnvironment().addAnnotatedType(annotatedTypeContext); store.put(annotatedType); } else if (event.isVeto()) { return; } else { annotatedType = event.getResultingAnnotatedType(); deployment.getBeanDeployer().getEnvironment().addSyntheticAnnotatedType(annotatedType, extension); store.put(annotatedType); } } }
protected <T> void createNewManagedBean(Class<T> clazz, Type type) { EnhancedAnnotatedType<T> enhancedType = classTransformer.getEnhancedAnnotatedType(clazz, type, manager.getId()); slimAnnotatedTypeStore.put(enhancedType.slim()); getEnvironment().addManagedBean(NewManagedBean.of(BeanAttributesFactory.forNewManagedBean(enhancedType, manager), enhancedType, manager)); }
public void registerAnnotatedTypes() { for (SlimAnnotatedTypeContext<?> ctx : getEnvironment().getAnnotatedTypes()) { annotatedTypeStore.put(ctx.getAnnotatedType()); } }
@Override public <T> AnnotatedType<T> getAnnotatedType(Class<T> type, String id) { checkWithinObserverNotification(); Preconditions.checkArgumentNotNull(type, TYPE_ARGUMENT_NAME); return slimAnnotatedTypeStore.get(type, id); }
private Set<InterceptionModel> getInterceptionModelsForType(EnhancedAnnotatedType<T> type, BeanManagerImpl manager, Bean<?> bean) { // if the bean has decorators consider all methods as intercepted if (bean != null && !manager.resolveDecorators(bean.getTypes(), bean.getQualifiers()).isEmpty()) { return null; } SlimAnnotatedTypeStore store = manager.getServices().get(SlimAnnotatedTypeStore.class); Set<InterceptionModel> models = new HashSet<InterceptionModel>(); WeldCollections.addIfNotNull(models, manager.getInterceptorModelRegistry().get(type.slim())); for (SlimAnnotatedType<?> slimType : store.get(type.getJavaClass())) { WeldCollections.addIfNotNull(models, manager.getInterceptorModelRegistry().get(slimType)); } for (InterceptionModel model : models) { if (model.hasTargetClassInterceptors() && model.getTargetClassInterceptorMetadata().isEligible(InterceptionType.AROUND_INVOKE)) { // this means that all methods are intercepted // returning null here means that all methods will be overridden and will delegate to MethodHandler return null; } } return models; }
public static <T> EnhancedAnnotatedType<T> getEjbImplementationClass(EjbDescriptor<T> descriptor, BeanManagerImpl manager, EnhancedAnnotatedType<T> componentType) { InternalEjbDescriptor<T> ejbDescriptor = InternalEjbDescriptor.of(descriptor); if (ejbDescriptor.getBeanClass().equals(ejbDescriptor.getImplementationClass())) { // no special implementation class is used return componentType; } ClassTransformer transformer = manager.getServices().get(ClassTransformer.class); EnhancedAnnotatedType<T> implementationClass = cast(transformer.getEnhancedAnnotatedType(ejbDescriptor.getImplementationClass(), manager.getId())); manager.getServices().get(SlimAnnotatedTypeStore.class).put(implementationClass.slim()); return implementationClass; }
@Override protected void storeSyntheticAnnotatedType(BeanDeployment deployment, AnnotatedType<?> type, String id) { SlimAnnotatedType<?> annotatedType = transformer.getUnbackedAnnotatedType(type, getBeanManager().getId(), id); Extension extension = getReceiver(); SlimAnnotatedTypeContext<?> annotatedTypeContext = SlimAnnotatedTypeContext.of(annotatedType, extension); ProcessAnnotatedTypeImpl<?> event = events.fireProcessAnnotatedType(getBeanManager(), annotatedTypeContext); if (event == null) { deployment.getBeanDeployer().getEnvironment().addAnnotatedType(annotatedTypeContext); store.put(annotatedType); } else if (event.isVeto()) { return; } else { annotatedType = event.getResultingAnnotatedType(); deployment.getBeanDeployer().getEnvironment().addSyntheticAnnotatedType(annotatedType, extension); store.put(annotatedType); } } }
protected <T> void createNewManagedBean(Class<T> clazz, Type type) { EnhancedAnnotatedType<T> enhancedType = classTransformer.getEnhancedAnnotatedType(clazz, type, manager.getId()); slimAnnotatedTypeStore.put(enhancedType.slim()); getEnvironment().addManagedBean(NewManagedBean.of(BeanAttributesFactory.forNewManagedBean(enhancedType, manager), enhancedType, manager)); }