Refine search
private Set<Class<?>> loadClassInfoSet(Set<ClassInfo> classInfos, ClassLoader classLoader) throws DeploymentUnitProcessingException { Set<Class<?>> classes = new HashSet<Class<?>>(); for (ClassInfo classInfo : classInfos) { Class<?> type; try { type = classLoader.loadClass(classInfo.name().toString()); classes.add(type); } catch (Exception e) { UndertowLogger.ROOT_LOGGER.cannotLoadDesignatedHandleTypes(classInfo, e); } } return classes; } }
private void getAllAsyncListenerClasses(CompositeIndex index, Set<String> classes) { if (index != null) { Set<ClassInfo> classInfos = index.getAllKnownImplementors(ASYNC_LISTENER_INTERFACE); for (ClassInfo classInfo : classInfos) { if(!Modifier.isAbstract(classInfo.flags()) && !Modifier.isInterface(classInfo.flags())) { classes.add(classInfo.name().toString()); } } } } }
private void processMethod(final DeploymentUnit deploymentUnit, final EJBResourceWrapper annotation, final MethodInfo methodInfo, final EEModuleDescription eeModuleDescription) { final String methodName = methodInfo.name(); if (!methodName.startsWith("set") || methodInfo.args().length != 1) { throw EjbLogger.ROOT_LOGGER.onlySetterMethodsAllowedToHaveEJBAnnotation(methodInfo); } final String methodParamType = methodInfo.args()[0].name().toString(); final InjectionTarget targetDescription = new MethodInjectionTarget(methodInfo.declaringClass().name().toString(), methodName, methodParamType); final String localContextName = isEmpty(annotation.name()) ? methodInfo.declaringClass().name().toString() + "/" + methodName.substring(3, 4).toLowerCase(Locale.ENGLISH) + methodName.substring(4) : annotation.name(); final String beanInterfaceType = isEmpty(annotation.beanInterface()) || annotation.beanInterface().equals(Object.class.getName()) ? methodParamType : annotation.beanInterface(); process(deploymentUnit, beanInterfaceType, annotation.beanName(), annotation.lookup(), methodInfo.declaringClass(), targetDescription, localContextName, eeModuleDescription); }
protected void processMethodResource(final DeploymentPhaseContext phaseContext, final MethodInfo methodInfo, final String name, final String type, final EEModuleClassDescription classDescription, final AnnotationInstance annotation, final EEModuleDescription eeModuleDescription, final Module module, final EEApplicationClasses applicationClasses, final PropertyReplacer replacer) throws DeploymentUnitProcessingException { final String methodName = methodInfo.name(); if (!methodName.startsWith("set") || methodInfo.args().length != 1) { throw EeLogger.ROOT_LOGGER.setterMethodOnly("@Resource", methodInfo); } final String contextNameSuffix = methodName.substring(3, 4).toLowerCase(Locale.ENGLISH) + methodName.substring(4); final String localContextName = isEmpty(name) ? methodInfo.declaringClass().name().toString() + "/" + contextNameSuffix : name; final String injectionType = isEmpty(type) || type.equals(Object.class.getName()) ? methodInfo.args()[0].name().toString() : type; final InjectionTarget targetDescription = new MethodInjectionTarget(methodInfo.declaringClass().name().toString(), methodName, methodInfo.args()[0].name().toString()); process(phaseContext, classDescription, annotation, injectionType, localContextName, targetDescription, eeModuleDescription, module, applicationClasses, replacer); }
protected void processFieldResource(final DeploymentPhaseContext phaseContext, final FieldInfo fieldInfo, final String name, final String type, final EEModuleClassDescription classDescription, final AnnotationInstance annotation, final EEModuleDescription eeModuleDescription, final Module module, final EEApplicationClasses applicationClasses, final PropertyReplacer replacer) throws DeploymentUnitProcessingException { final String fieldName = fieldInfo.name(); final String injectionType = isEmpty(type) || type.equals(Object.class.getName()) ? fieldInfo.type().name().toString() : type; final String localContextName = isEmpty(name) ? fieldInfo.declaringClass().name().toString() + "/" + fieldName : name; final InjectionTarget targetDescription = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldInfo.type().name().toString()); process(phaseContext, classDescription, annotation, injectionType, localContextName, targetDescription, eeModuleDescription, module, applicationClasses, replacer); }
/** * Returns true if the passed <code>sessionBeanClass</code> meets the requirements set by the EJB3 spec about * bean implementation classes. The passed <code>sessionBeanClass</code> must not be an interface and must be public * and not final and not abstract. If it passes these requirements then this method returns true. Else it returns false. * * @param sessionBeanClass The session bean class * @return */ private static boolean assertSessionBeanClassValidity(final ClassInfo sessionBeanClass) { final short flags = sessionBeanClass.flags(); final String className = sessionBeanClass.name().toString(); // must *not* be an interface if (Modifier.isInterface(flags)) { EjbLogger.DEPLOYMENT_LOGGER.sessionBeanClassCannotBeAnInterface(className); return false; } // bean class must be public, must *not* be abstract or final if (!Modifier.isPublic(flags) || Modifier.isAbstract(flags) || Modifier.isFinal(flags)) { EjbLogger.DEPLOYMENT_LOGGER.sessionBeanClassMustBePublicNonAbstractNonFinal(className); return false; } // valid class return true; }
private Set<String> findPersistenceTypeNames(PersistenceUnitMetadata pu) { synchronized (CACHED_TYPENAMES) { Set<String> typeNames = CACHED_TYPENAMES.get(pu); if (typeNames != null) { return typeNames; } } Set<String> persistenceTypeNames = new HashSet<String>(); for (Map.Entry<URL, Index> entry : pu.getAnnotationIndex().entrySet()) { List<AnnotationInstance> instances = entry.getValue().getAnnotations(DotName.createSimple(Entity.class.getName())); for (AnnotationInstance instance : instances) { AnnotationTarget target = instance.target(); if (target instanceof ClassInfo) { ClassInfo classInfo = (ClassInfo) target; persistenceTypeNames.add(classInfo.name().toString()); } } } synchronized (CACHED_TYPENAMES) { CACHED_TYPENAMES.put(pu, persistenceTypeNames); } return persistenceTypeNames; }
/** * Returns true if the passed <code>managedBeanClass</code> meets the requirements set by the Managed bean spec about * bean implementation classes. The passed <code>managedBeanClass</code> must not be an interface and must not be final or abstract. * If it passes these requirements then this method returns true. Else it returns false. * * @param managedBeanClass The session bean class * @return */ private static boolean assertManagedBeanClassValidity(final ClassInfo managedBeanClass) { final short flags = managedBeanClass.flags(); final String className = managedBeanClass.name().toString(); // must *not* be an interface if (Modifier.isInterface(flags)) { ROOT_LOGGER.invalidManagedBeanInterface("MB.2.1.1", className); return false; } // bean class must *not* be abstract or final if (Modifier.isAbstract(flags) || Modifier.isFinal(flags)) { ROOT_LOGGER.invalidManagedBeanAbstractOrFinal("MB.2.1.1", className); return false; } // valid class return true; } }
private void handleAnnotations(final CompositeIndex index, final Set<String> managedBeanClasses) throws DeploymentUnitProcessingException { final List<AnnotationInstance> annotations = index.getAnnotations(MANAGED_BEAN_ANNOTATION); if (annotations != null) { for (final AnnotationInstance annotation : annotations) { final AnnotationTarget target = annotation.target(); if (target instanceof ClassInfo) { final String className = ((ClassInfo) target).name().toString(); managedBeanClasses.add(className); } else { throw new DeploymentUnitProcessingException(JSFLogger.ROOT_LOGGER.invalidManagedBeanAnnotation(target)); } } } }
private void validateArgumentType(final ClassInfo classInfo, final MethodInfo methodInfo) { final Type[] args = methodInfo.args(); switch (args.length) { case 0: throw new IllegalArgumentException(EeLogger.ROOT_LOGGER.invalidSignature(methodInfo.name(), AROUND_INVOKE_ANNOTATION_NAME, classInfo.name(), "Object methodName(InvocationContext ctx)")); case 1: if (!InvocationContext.class.getName().equals(args[0].name().toString())) { throw new IllegalArgumentException(EeLogger.ROOT_LOGGER.invalidSignature(methodInfo.name(), AROUND_INVOKE_ANNOTATION_NAME, classInfo.name(), "Object methodName(InvocationContext ctx)")); } break; default: throw new IllegalArgumentException(EeLogger.ROOT_LOGGER.invalidNumberOfArguments(methodInfo.name(), AROUND_INVOKE_ANNOTATION_NAME, classInfo.name())); } if (!methodInfo.returnType().name().toString().equals(Object.class.getName())) { throw EeLogger.ROOT_LOGGER.invalidReturnType(Object.class.getName(), methodInfo.name(), AROUND_INVOKE_ANNOTATION_NAME, classInfo.name()); } } }
private void processField(final DeploymentUnit deploymentUnit, final EJBResourceWrapper annotation, final FieldInfo fieldInfo, final EEModuleDescription eeModuleDescription) { final String fieldName = fieldInfo.name(); final String fieldType = fieldInfo.type().name().toString(); final InjectionTarget targetDescription = new FieldInjectionTarget(fieldInfo.declaringClass().name().toString(), fieldName, fieldType); final String localContextName = isEmpty(annotation.name()) ? fieldInfo.declaringClass().name().toString() + "/" + fieldInfo.name() : annotation.name(); final String beanInterfaceType = isEmpty(annotation.beanInterface()) || annotation.beanInterface().equals(Object.class.getName()) ? fieldType : annotation.beanInterface(); process(deploymentUnit, beanInterfaceType, annotation.beanName(), annotation.lookup(), fieldInfo.declaringClass(), targetDescription, localContextName, eeModuleDescription); }
private List<BindingConfiguration> getAnnotatedClassBindingConfigurations(EEModuleDescription moduleDescription, AnnotationInstance annotationInstance) throws DeploymentUnitProcessingException { final AnnotationTarget target = annotationInstance.target(); if (!(target instanceof ClassInfo)) { throw ROOT_LOGGER.classOnlyAnnotation(annotationInstance.toString(), target); } final ClassInfo classInfo = (ClassInfo) target; return moduleDescription.addOrGetLocalClassDescription(classInfo.name().toString()).getBindingConfigurations(); }
parameterTypes.add(type.toString()); String declaringClass = m.declaringClass().name().toString(); annotation = new AnnotationImpl(declaringClass, cl, parameterTypes, m.name(), true, false, annotationClass); String declaringClass = f.declaringClass().name().toString(); annotation = new AnnotationImpl(declaringClass, cl, null, f.name(), false, true, annotationClass); annotation = new AnnotationImpl(c.name().toString(), cl, null, null, false, false, annotationClass);
private void processAroundInvoke(final AnnotationTarget target, final EEModuleDescription eeModuleDescription) { if (!(target instanceof MethodInfo)) { throw EjbLogger.ROOT_LOGGER.annotationApplicableOnlyForMethods(AROUND_TIMEOUT_ANNOTATION_NAME.toString()); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); validateArgumentType(classInfo, methodInfo); final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundTimeout(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
ClassInfo clazz = (ClassInfo) endpoint.target(); try { Class<?> moduleClass = ClassLoadingUtils.loadClass(clazz.name().toString(), module); if (!Modifier.isAbstract(moduleClass.getModifiers())) { annotatedEndpoints.add(moduleClass); UndertowLogger.ROOT_LOGGER.couldNotLoadWebSocketEndpoint(clazz.name().toString(), e); ClassInfo clazz = (ClassInfo) endpoint.target(); try { Class<?> moduleClass = ClassLoadingUtils.loadClass(clazz.name().toString(), module); if (!Modifier.isAbstract(moduleClass.getModifiers())) { annotatedEndpoints.add(moduleClass); UndertowLogger.ROOT_LOGGER.couldNotLoadWebSocketEndpoint(clazz.name().toString(), e); for (final ClassInfo clazz : subclasses) { try { Class<?> moduleClass = ClassLoadingUtils.loadClass(clazz.name().toString(), module); if (!Modifier.isAbstract(moduleClass.getModifiers())) { config.add((Class) moduleClass); UndertowLogger.ROOT_LOGGER.couldNotLoadWebSocketConfig(clazz.name().toString(), e); for (final ClassInfo clazz : epClasses) { try { Class<?> moduleClass = ClassLoadingUtils.loadClass(clazz.name().toString(), module); if (!Modifier.isAbstract(moduleClass.getModifiers())) { endpoints.add((Class) moduleClass);
private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); final List<AnnotationInstance> classAroundInvokes = classInfo.annotations().get(AROUND_INVOKE_ANNOTATION_NAME); if(classAroundInvokes.size() > 1) { throw EeLogger.ROOT_LOGGER.aroundInvokeAnnotationUsedTooManyTimes(classInfo.name(), classAroundInvokes.size()); } validateArgumentType(classInfo, methodInfo); InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
final Map<DotName, List<TargetAnnotation>> fieldLevel = new HashMap<DotName, List<TargetAnnotation>>(); for (TargetAnnotation instance : annotations) { final DotName targetClass = getAnnotationClass(instance.target()).name(); if (instance.target() instanceof ClassInfo) { List<TargetAnnotation> data = classLevel.get(targetClass); ret.put(clazz.toString(), information);
/** * Returns true if the passed <code>mdbClass</code> meets the requirements set by the EJB3 spec about bean implementation * classes. The passed <code>mdbClass</code> must not be an interface and must be public and not final and not abstract. If * it passes these requirements then this method returns true. Else it returns false. * * @param mdbClass The MDB class * @return * @throws DeploymentUnitProcessingException */ public static Collection<MdbValidityStatus> assertEjbClassValidity(final ClassInfo mdbClass) throws DeploymentUnitProcessingException { Collection<MdbValidityStatus> mdbComplianceIssueList = new ArrayList<>(MdbValidityStatus.values().length); final String className = mdbClass.name().toString(); verifyModifiers(className, mdbClass.flags(), mdbComplianceIssueList); for (MethodInfo method : mdbClass.methods()) { if ("onMessage".equals(method.name())) { verifyOnMessageMethod(className, method.flags(), mdbComplianceIssueList); } if ("finalize".equals(method.name())) { EjbLogger.DEPLOYMENT_LOGGER.mdbCantHaveFinalizeMethod(className); mdbComplianceIssueList.add(MdbValidityStatus.MDB_SHOULD_NOT_HAVE_FINALIZE_METHOD); } } return mdbComplianceIssueList; }