.getDeclaredEnhancedConstructor(new ConstructorSignatureImpl(analyzer.getConstructor())); InjectionTargetService injectionTargetService = it.getBeanManager().getServices().get(InjectionTargetService.class); injectionTargetService.addInjectionTargetToBeInitialized(jit.getEnhancedAnnotatedType(), jit); return jit;
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()); if (!type.getJavaClass().equals(componentClass)) { final String bdaId = beanManager.getId() + classLoader.hashCode(); type = transformer.getEnhancedAnnotatedType(clazz, bdaId);
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); } } } }
Set<Bean<?>> beans = beanManager.getBeans(beanClass, new AnnotationLiteral<Any>() {}); if (!eat.isAbstract() || !eat.getJavaClass().isInterface()) { // injectionTargetCannotBeCreatedForInterface ((AbstractClassBean)bean).setProducer(beanManager.getLocalInjectionTargetFactory(eat).createInjectionTarget(eat, bean, false)); if (isReinjectingContext(bean)) { doReloadAbstractClassBean(beanManager, (AbstractClassBean) bean, oldSignatures, reloadStrategy);
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())); } }
protected EnhancedAnnotatedConstructor<T> initEnhancedSubclass(BeanManagerImpl manager, EnhancedAnnotatedType<T> type, Bean<?> bean, ConstructorInjectionPoint<T> originalConstructorInjectionPoint) { ClassTransformer transformer = manager.getServices().get(ClassTransformer.class); EnhancedAnnotatedType<T> enhancedSubclass = transformer.getEnhancedAnnotatedType(createEnhancedSubclass(type, bean, manager), type.slim().getIdentifier().getBdaId()); return findMatchingConstructor(originalConstructorInjectionPoint.getSignature(), enhancedSubclass); }
public static String forProducerMethod(EnhancedAnnotatedMethod<?, ?> method, AbstractClassBean<?> declaringBean) { if (declaringBean.getEnhancedAnnotated().isDiscovered()) { return forProducerMethod(declaringBean.getAnnotated().getIdentifier(), DeclaredMemberIndexer.getIndexForMethod(method.getJavaMember())); } return getPrefix(ProducerMethod.class).append(method.getDeclaringType().slim().getIdentifier()).append(AnnotatedTypes.createCallableId(method)).toString(); }
public ExtensionBean(BeanManagerImpl manager, EnhancedAnnotatedType<E> enhancedAnnotatedType, Metadata<E> instance) { super(new StringBeanIdentifier(BeanIdentifiers.forExtension(enhancedAnnotatedType)), manager, enhancedAnnotatedType.getJavaClass()); this.annotatedType = enhancedAnnotatedType.slim(); this.instance = instance; this.passivationCapable = enhancedAnnotatedType.isSerializable(); this.proxiable = Proxies.isTypeProxyable(enhancedAnnotatedType.getBaseType(), manager.getServices()); checkPublicFields(enhancedAnnotatedType); }
public static String forSessionBean(EnhancedAnnotatedType<?> type, EjbDescriptor<?> descriptor) { StringBuilder builder = getPrefix(SessionBean.class); appendEjbNameAndClass(builder, descriptor); if (!type.isDiscovered()) { builder.append(BEAN_ID_SEPARATOR).append(type.slim().getIdentifier().asString()); } return builder.toString(); }
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; }
public static List<EnhancedAnnotatedMethod<?, ?>> getInterceptableMethods(EnhancedAnnotatedType<?> type) { List<EnhancedAnnotatedMethod<?, ?>> annotatedMethods = new ArrayList<EnhancedAnnotatedMethod<?, ?>>(); for (EnhancedAnnotatedMethod<?, ?> annotatedMethod : type.getEnhancedMethods()) { boolean businessMethod = !annotatedMethod.isStatic() && !annotatedMethod.isAnnotationPresent(Inject.class) && !annotatedMethod.getJavaMember().isBridge(); if (businessMethod && !isInterceptorMethod(annotatedMethod)) { annotatedMethods.add(annotatedMethod); } } return annotatedMethods; }
public void init() { initTargetClassInterceptors(); businessMethods = Beans.getInterceptableMethods(annotatedType); initEjbInterceptors(); initCdiInterceptors(); InterceptionModel interceptionModel = builder.build(); if (interceptionModel.getAllInterceptors().size() > 0 || hasSerializationOrInvocationInterceptorMethods) { if (annotatedType.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithInterceptorsNotAllowed(annotatedType.getJavaClass()); } if (Reflections.isPrivate(constructor.getJavaMember())) { throw new DeploymentException(ValidatorLogger.LOG.notProxyablePrivateConstructor(annotatedType.getJavaClass().getName(), constructor, annotatedType.getJavaClass())); } manager.getInterceptorModelRegistry().put(annotatedType.slim(), interceptionModel); } }
@Override public <T> BeanAttributes<T> createBeanAttributes(AnnotatedType<T> type) { EnhancedAnnotatedType<T> clazz = services.get(ClassTransformer.class).getEnhancedAnnotatedType(type, getId()); if (services.get(EjbDescriptors.class).contains(type.getJavaClass())) { return BeanAttributesFactory.forSessionBean(clazz, services.get(EjbDescriptors.class).getUnique(clazz.getJavaClass()), this); } return BeanAttributesFactory.forBean(clazz, this); }
protected boolean initScopeFromStereotype() { Set<Annotation> possibleScopes = mergedStereotypes.getPossibleScopes(); if (possibleScopes.size() == 1) { this.scope = possibleScopes.iterator().next().annotationType(); return true; } else if (possibleScopes.size() > 1) { String stack; Class<?> declaringClass; if (annotated instanceof EnhancedAnnotatedMember) { EnhancedAnnotatedMember<?, ?, ?> member = (EnhancedAnnotatedMember<?, ?, ?>) annotated; declaringClass = member.getDeclaringType().getJavaClass(); stack = "\n at " + Formats.formatAsStackTraceElement(member.getJavaMember()); } else { declaringClass = annotated.getJavaClass(); stack = ""; } throw BeanLogger.LOG.multipleScopesFoundFromStereotypes(Formats.formatType(declaringClass, false), Formats.formatTypes(mergedStereotypes.getStereotypes(), false), possibleScopes, stack); } else { return false; } }
@Override public <M> EnhancedAnnotatedMethod<M, ?> getEnhancedMethod(MethodSignature signature) { EnhancedAnnotatedMethod<M, ?> method = cast(getDeclaredEnhancedMethod(signature)); if ((method == null) && (superclass != null) && (superclass.getJavaClass() != Object.class)) { method = superclass.getEnhancedMethod(signature); } return method; }
protected void checkType(EnhancedAnnotatedType<T> type) { if (!Reflections.isTopLevelOrStaticNestedClass(type.getJavaClass())) { throw BeanLogger.LOG.simpleBeanAsNonStaticInnerClassNotAllowed(type); } }
@Override protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> type, Bean<?> bean, BeanManagerImpl manager) { return new DecoratorProxyFactory<T>(manager.getContextId(), type.getJavaClass(), delegateInjectionPoint, bean).getProxyClass(); } };
private void buildInterceptionModel(EnhancedAnnotatedType<T> annotatedType, AbstractInstantiator<T> instantiator) { new InterceptionModelInitializer<>(beanManager, annotatedType, annotatedType.getDeclaredEnhancedConstructor( instantiator.getConstructorInjectionPoint().getSignature()), getBean()).init(); }
public boolean isAbstract() { return delegate().isAbstract(); }
@Override public Collection<EnhancedAnnotatedConstructor<?>> getMembersOfDeclaringType(MemberKey<?, AnnotatedConstructor<?>> source) { return cast(source.type.getConstructors()); } }