Package org.jboss.as.ee.component

Examples of org.jboss.as.ee.component.EEModuleClassDescription


            final AnnotationValue typeValue = annotation.value("type");
            final String type = typeValue != null ? typeValue.asClass().name().toString() : null;
            if (annotationTarget instanceof FieldInfo) {
                FieldInfo fieldInfo = (FieldInfo) annotationTarget;
                ClassInfo classInfo = fieldInfo.declaringClass();
                EEModuleClassDescription classDescription = applicationClasses.getOrAddClassByName(classInfo.name().toString());
                processFieldResource(phaseContext, fieldInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses);
            } else if (annotationTarget instanceof MethodInfo) {
                MethodInfo methodInfo = (MethodInfo) annotationTarget;
                ClassInfo classInfo = methodInfo.declaringClass();
                EEModuleClassDescription classDescription = applicationClasses.getOrAddClassByName(classInfo.name().toString());
                processMethodResource(phaseContext, methodInfo, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses);
            } else if (annotationTarget instanceof ClassInfo) {
                ClassInfo classInfo = (ClassInfo) annotationTarget;
                EEModuleClassDescription classDescription = applicationClasses.getOrAddClassByName(classInfo.name().toString());
                processClassResource(phaseContext, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses);
            }
        }
        final List<AnnotationInstance> resourcesAnnotations = index.getAnnotations(RESOURCES_ANNOTATION_NAME);
        for (AnnotationInstance outerAnnotation : resourcesAnnotations) {
            final AnnotationTarget annotationTarget = outerAnnotation.target();
            if (annotationTarget instanceof ClassInfo) {
                final ClassInfo classInfo = (ClassInfo) annotationTarget;
                final AnnotationInstance[] values = outerAnnotation.value("value").asNestedArray();
                for (AnnotationInstance annotation : values) {
                    final AnnotationValue nameValue = annotation.value("name");
                    final String name = nameValue != null ? nameValue.asString() : null;
                    final AnnotationValue typeValue = annotation.value("type");
                    final String type = typeValue != null ? typeValue.asClass().name().toString() : null;
                    EEModuleClassDescription classDescription = applicationClasses.getOrAddClassByName(classInfo.name().toString());
                    processClassResource(phaseContext, name, type, classDescription, annotation, eeModuleDescription, module, applicationClasses);
                }
            }
        }
    }
View Full Code Here


        if (!(target instanceof MethodInfo)) {
            throw new IllegalArgumentException("@AroundInvoke is only valid on method targets.");
        }
        final MethodInfo methodInfo = MethodInfo.class.cast(target);
        final ClassInfo classInfo = methodInfo.declaringClass();
        final EEModuleClassDescription classDescription = applicationClasses.getOrAddClassByName(classInfo.name().toString());

        validateArgumentType(classInfo, methodInfo);
        classDescription.setAroundInvokeMethod(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class));
    }
View Full Code Here

        Class<?> c = componentClass;
        while (c != null && c != Object.class) {

            final ClassReflectionIndex<?> classIndex = index.getClassIndex(c);

            final EEModuleClassDescription description = applicationClasses.getClassByName(c.getName());
            if (description != null) {
                ClassAnnotationInformation<A, T> annotationData = description.getAnnotationInformation(annotationType);
                if (annotationData != null) {

                    if (!annotationData.getClassLevelAnnotations().isEmpty()) {
                        classAnnotations.put(c.getName(), annotationData.getClassLevelAnnotations());
                    }
View Full Code Here

        if (!(target instanceof MethodInfo)) {
            throw new IllegalArgumentException(annotationType + " is only valid on method targets.");
        }
        final MethodInfo methodInfo = MethodInfo.class.cast(target);
        final ClassInfo classInfo = methodInfo.declaringClass();
        final EEModuleClassDescription classDescription = applicationClasses.getOrAddClassByName(classInfo.name().toString());

        final Type[] args = methodInfo.args();
        if (args.length > 1) {
            log.warn("Invalid number of arguments for method " + methodInfo.name() + " annotated with " + annotationType + " on class " + classInfo.name());
            return;
        } else if (args.length == 1 && !args[0].name().toString().equals(InvocationContext.class.getName())) {
            log.warn("Invalid signature for method " + methodInfo.name() + " annotated with " + annotationType + " on class " + classInfo.name() + ", signature must be void methodName(InvocationContext ctx)");
            return;
        }

        final MethodIdentifier methodIdentifier;
        if (args.length == 0) {
            methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name());
        } else {
            methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name(), InvocationContext.class);
        }
        if (annotationType == POST_CONSTRUCT_ANNOTATION) {
            classDescription.setPostConstructMethod(methodIdentifier);
        } else {
            classDescription.setPreDestroyMethod(methodIdentifier);
        }
    }
View Full Code Here

                try {
                    injectionTargetClass = classLoader.loadClass(injectionTarget.getInjectionTargetClass());
                } catch (ClassNotFoundException e) {
                    throw new DeploymentUnitProcessingException("Could not load " + injectionTarget.getInjectionTargetClass() + " referenced in env-entry injection point ", e);
                }
                EEModuleClassDescription eeModuleClassDescription = applicationClasses.getOrAddClassByName(injectionTargetClass.getName());
                final ClassReflectionIndex<?> index = deploymentReflectionIndex.getClassIndex(injectionTargetClass);
                String methodName = "set" + injectionTarget.getInjectionTargetName().substring(0, 1).toUpperCase() + injectionTarget.getInjectionTargetName().substring(1);

                boolean methodFound = false;
                Method method = null;
                Field field = null;
                Class<?> injectionTargetType = null;
                String memberName = injectionTarget.getInjectionTargetName();
                Class<?> current = injectionTargetClass;
                while (current != Object.class && current != null && !methodFound) {
                    final Collection<Method> methods = index.getAllMethods(methodName);
                    for (Method m : methods) {
                        if (m.getParameterTypes().length == 1) {
                            if (m.isBridge() || m.isSynthetic()) {
                                continue;
                            }
                            if (methodFound) {
                                throw new DeploymentUnitProcessingException("Two setter methods for " + injectionTarget.getInjectionTargetName() + " on class " + injectionTarget.getInjectionTargetClass() + " found when applying <injection-target> for env-entry");
                            }
                            methodFound = true;
                            method = m;
                            injectionTargetType = m.getParameterTypes()[0];
                            memberName = methodName;
                        }
                    }
                    current = current.getSuperclass();
                }
                if (method == null) {
                    current = injectionTargetClass;
                    while (current != Object.class && current != null && field == null) {
                        field = index.getField(injectionTarget.getInjectionTargetName());
                        if (field != null) {
                            injectionTargetType = field.getType();
                            memberName = injectionTarget.getInjectionTargetName();
                            break;
                        }
                        current = current.getSuperclass();
                    }
                }
                if (field == null && method == null) {
                    throw new DeploymentUnitProcessingException("Could not resolve injection point " + injectionTarget.getInjectionTargetName() + " on class " + injectionTarget.getInjectionTargetClass() + " specified in web.xml");
                }
                if (classType != null) {
                    if (!classType.isAssignableFrom(injectionTargetType)) {
                        throw new DeploymentUnitProcessingException("Injection target " + injectionTarget.getInjectionTargetName() + " on class " + injectionTarget.getInjectionTargetClass() + " is not compatible with the type of injection");
                    }
                } else {
                    classType = injectionTargetType;
                }
                final InjectionTarget injectionTargetDescription = method == null ?
                        new FieldInjectionTarget(eeModuleClassDescription.getClassName(), memberName, classType.getName()) :
                        new MethodInjectionTarget(eeModuleClassDescription.getClassName(), memberName, classType.getName());

                final ResourceInjectionConfiguration injectionConfiguration = new ResourceInjectionConfiguration(injectionTargetDescription, injectionSource);
                eeModuleClassDescription.getConfigurators().add(new ClassConfigurator() {
                    @Override
                    public void configure(DeploymentPhaseContext context, EEModuleClassDescription description, EEModuleClassConfiguration configuration) throws DeploymentUnitProcessingException {
                        configuration.getInjectionConfigurations().add(injectionConfiguration);
                    }
                });
View Full Code Here

        final List<ClassAnnotationInformationFactory> factories = annotationInformationFactories();
        for (final ClassAnnotationInformationFactory factory : factories) {
            final Map<String, ClassAnnotationInformation<?, ?>> data = factory.createAnnotationInformation(index);
            for (Map.Entry<String, ClassAnnotationInformation<?, ?>> entry : data.entrySet()) {
                EEModuleClassDescription clazz = applicationClasses.getOrAddClassByName(entry.getKey());
                clazz.addAnnotationInformation(entry.getValue());
            }
        }

        afterAnnotationsProcessed(phaseContext, deploymentUnit);
    }
View Full Code Here

    }

    private void processDataSourceDefinition(final EEModuleDescription eeModuleDescription, final AnnotationInstance datasourceDefinition, final ClassInfo targetClass, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
        // create BindingConfiguration out of the @DataSource annotation
        final BindingConfiguration bindingConfiguration = this.getBindingConfiguration(datasourceDefinition);
        EEModuleClassDescription classDescription = applicationClasses.getOrAddClassByName(targetClass.name().toString());
        // add the binding configuration via a class configurator
        classDescription.getConfigurators().add(new ClassConfigurator() {
            @Override
            public void configure(DeploymentPhaseContext context, EEModuleClassDescription description, EEModuleClassConfiguration configuration) throws DeploymentUnitProcessingException {
                configuration.getBindingConfigurations().add(bindingConfiguration);
            }
        });
View Full Code Here

    }

    @Override
    protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final MessageDrivenComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {

        final EEModuleClassDescription clazz = applicationClasses.getClassByName(componentClass.getName());

        //we only care about annotations on the bean class itself
        if (clazz == null) {
            return;
        }
        final ClassAnnotationInformation<ResourceAdapter, String> resourceAdaptor = clazz.getAnnotationInformation(ResourceAdapter.class);
        if (resourceAdaptor == null) {
            return;
        }
        if (!resourceAdaptor.getClassLevelAnnotations().isEmpty()) {
            componentConfiguration.setResourceAdapterName(resourceAdaptor.getClassLevelAnnotations().get(0));
View Full Code Here

    public RemoveMethodMergingProcessor() {
        super(StatefulComponentDescription.class);
    }

    protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final StatefulComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
        EEModuleClassDescription clazz = applicationClasses.getClassByName(componentClass.getName());
        if (clazz != null) {
            ClassAnnotationInformation<Remove, Boolean> annotations = clazz.getAnnotationInformation(Remove.class);
            if (annotations != null) {
                for(Map.Entry<MethodIdentifier, List<Boolean>> entry : annotations.getMethodLevelAnnotations().entrySet()) {
                    final Boolean retainIfException = entry.getValue().get(0);
                    componentConfiguration.addRemoveMethod(entry.getKey(), retainIfException);
                }
View Full Code Here

        super(SingletonComponentDescription.class);
    }

    @Override
    protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final SingletonComponentDescription description) throws DeploymentUnitProcessingException {
        final EEModuleClassDescription classDescription = applicationClasses.getClassByName(componentClass.getName());
        if(classDescription == null) {
            return;
        }

        final EEApplicationDescription applicationDescription = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_DESCRIPTION);
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);

        //we ony care about annotations on the actual class
        final ClassAnnotationInformation<DependsOn, String[]> dependsOnClassAnnotationInformation = classDescription.getAnnotationInformation(DependsOn.class);
        if (dependsOnClassAnnotationInformation != null) {
            if (!dependsOnClassAnnotationInformation.getClassLevelAnnotations().isEmpty()) {
                final String[] annotationValues = dependsOnClassAnnotationInformation.getClassLevelAnnotations().get(0);
                setupDependencies(description, applicationDescription, deploymentRoot, annotationValues);
            }
View Full Code Here

TOP

Related Classes of org.jboss.as.ee.component.EEModuleClassDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.