Search in sources :

Example 16 with EEModuleClassDescription

use of org.jboss.as.ee.component.EEModuleClassDescription in project wildfly by wildfly.

the class AroundTimeoutAnnotationParsingProcessor method processAroundInvoke.

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());
}
Also used : InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) MethodInfo(org.jboss.jandex.MethodInfo) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) InvocationContext(javax.interceptor.InvocationContext) ClassInfo(org.jboss.jandex.ClassInfo)

Example 17 with EEModuleClassDescription

use of org.jboss.as.ee.component.EEModuleClassDescription in project wildfly by wildfly.

the class WebServiceAnnotationProcessor method deploy.

@SuppressWarnings({ "unchecked", "rawtypes" })
public final void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    if (index == null || eeModuleDescription == null) {
        return;
    }
    for (final ClassAnnotationInformationFactory factory : factories) {
        final Map<String, ClassAnnotationInformation<?, ?>> data = factory.createAnnotationInformation(index, PropertyReplacers.noop());
        for (Map.Entry<String, ClassAnnotationInformation<?, ?>> entry : data.entrySet()) {
            EEModuleClassDescription clazz = eeModuleDescription.addOrGetLocalClassDescription(entry.getKey());
            clazz.addAnnotationInformation(entry.getValue());
        }
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ClassAnnotationInformation(org.jboss.as.ee.metadata.ClassAnnotationInformation) ClassAnnotationInformationFactory(org.jboss.as.ee.metadata.ClassAnnotationInformationFactory) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) Map(java.util.Map)

Example 18 with EEModuleClassDescription

use of org.jboss.as.ee.component.EEModuleClassDescription in project wildfly by wildfly.

the class WSIntegrationProcessorJAXWS_EJB method processAnnotation.

@SuppressWarnings("rawtypes")
private static void processAnnotation(final DeploymentUnit unit, final Class annotationType) {
    final EEModuleDescription moduleDescription = getRequiredAttachment(unit, EE_MODULE_DESCRIPTION);
    final JAXWSDeployment jaxwsDeployment = getJaxwsDeployment(unit);
    for (EEModuleClassDescription description : moduleDescription.getClassDescriptions()) {
        @SuppressWarnings("unchecked") ClassAnnotationInformation classAnnotationInfo = description.getAnnotationInformation(annotationType);
        if (classAnnotationInfo != null && !classAnnotationInfo.getClassLevelAnnotations().isEmpty()) {
            Object obj = classAnnotationInfo.getClassLevelAnnotations().get(0);
            AnnotationTarget target = null;
            if (obj instanceof WebServiceAnnotationInfo) {
                target = ((WebServiceAnnotationInfo) obj).getTarget();
            } else if (obj instanceof WebServiceProviderAnnotationInfo) {
                target = ((WebServiceProviderAnnotationInfo) obj).getTarget();
            } else {
                return;
            }
            final ClassInfo webServiceClassInfo = (ClassInfo) target;
            final String webServiceClassName = webServiceClassInfo.name().toString();
            final List<ComponentDescription> componentDescriptions = moduleDescription.getComponentsByClassName(webServiceClassName);
            final List<SessionBeanComponentDescription> sessionBeans = getSessionBeans(componentDescriptions);
            // TODO: assembly processed for each endpoint!
            final Set<String> securityRoles = getDeclaredSecurityRoles(unit, webServiceClassInfo);
            final WebContextAnnotationWrapper webCtx = getWebContextWrapper(webServiceClassInfo);
            final String authMethod = webCtx.getAuthMethod();
            final boolean isSecureWsdlAccess = webCtx.isSecureWsdlAccess();
            final String transportGuarantee = webCtx.getTransportGuarantee();
            final String realmName = webCtx.getRealmName();
            for (final SessionBeanComponentDescription sessionBean : sessionBeans) {
                if (sessionBean.isStateless() || sessionBean.isSingleton()) {
                    final EJBViewDescription ejbViewDescription = sessionBean.addWebserviceEndpointView();
                    final ServiceName ejbViewName = ejbViewDescription.getServiceName();
                    jaxwsDeployment.addEndpoint(new EJBEndpoint(sessionBean, ejbViewName, securityRoles, authMethod, realmName, isSecureWsdlAccess, transportGuarantee));
                }
            }
        }
    }
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ClassAnnotationInformation(org.jboss.as.ee.metadata.ClassAnnotationInformation) ServiceName(org.jboss.msc.service.ServiceName) EJBEndpoint(org.jboss.as.webservices.metadata.model.EJBEndpoint) JAXWSDeployment(org.jboss.as.webservices.metadata.model.JAXWSDeployment) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ClassInfo(org.jboss.jandex.ClassInfo)

Example 19 with EEModuleClassDescription

use of org.jboss.as.ee.component.EEModuleClassDescription in project wildfly by wildfly.

the class AbstractEEAnnotationProcessor method deploy.

public final void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final CompositeIndex index = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.COMPOSITE_ANNOTATION_INDEX);
    PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
    if (index == null || eeModuleDescription == null) {
        return;
    }
    final List<ClassAnnotationInformationFactory> factories = annotationInformationFactories();
    for (final ClassAnnotationInformationFactory factory : factories) {
        final Map<String, ClassAnnotationInformation<?, ?>> data = factory.createAnnotationInformation(index, propertyReplacer);
        for (Map.Entry<String, ClassAnnotationInformation<?, ?>> entry : data.entrySet()) {
            EEModuleClassDescription clazz = eeModuleDescription.addOrGetLocalClassDescription(entry.getKey());
            clazz.addAnnotationInformation(entry.getValue());
        }
    }
    afterAnnotationsProcessed(phaseContext, deploymentUnit);
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) Map(java.util.Map)

Example 20 with EEModuleClassDescription

use of org.jboss.as.ee.component.EEModuleClassDescription in project wildfly by wildfly.

the class MethodAnnotationAggregator method runtimeAnnotationInformation.

public static <A extends Annotation, T> RuntimeAnnotationInformation<T> runtimeAnnotationInformation(final Class<?> componentClass, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex index, final Class<A> annotationType) {
    final HashSet<MethodIdentifier> methodIdentifiers = new HashSet<MethodIdentifier>();
    final Map<Method, List<T>> methods = new HashMap<Method, List<T>>();
    final Map<String, List<T>> classAnnotations = new HashMap<String, List<T>>();
    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());
                }
                for (Map.Entry<MethodIdentifier, List<T>> entry : annotationData.getMethodLevelAnnotations().entrySet()) {
                    final Method method = classIndex.getMethod(entry.getKey());
                    if (method != null) {
                        //we do not have to worry about private methods being overridden
                        if (Modifier.isPrivate(method.getModifiers()) || !methodIdentifiers.contains(entry.getKey())) {
                            methods.put(method, entry.getValue());
                        }
                    } else {
                        //but if it does, we give some info
                        throw EeLogger.ROOT_LOGGER.cannotResolveMethod(entry.getKey(), c, entry.getValue());
                    }
                }
            }
        }
        //so we can check if a method is overriden
        for (Method method : (Iterable<Method>) classIndex.getMethods()) {
            //we do not have to worry about private methods being overridden
            if (!Modifier.isPrivate(method.getModifiers())) {
                methodIdentifiers.add(MethodIdentifier.getIdentifierForMethod(method));
            }
        }
        c = c.getSuperclass();
    }
    return new RuntimeAnnotationInformation<T>(classAnnotations, methods);
}
Also used : HashMap(java.util.HashMap) ClassReflectionIndex(org.jboss.as.server.deployment.reflect.ClassReflectionIndex) MethodIdentifier(org.jboss.invocation.proxy.MethodIdentifier) Method(java.lang.reflect.Method) List(java.util.List) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)29 ClassInfo (org.jboss.jandex.ClassInfo)9 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)6 MethodInfo (org.jboss.jandex.MethodInfo)6 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)5 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)4 InterceptorClassDescription (org.jboss.as.ee.component.interceptors.InterceptorClassDescription)4 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Map (java.util.Map)3 InvocationContext (javax.interceptor.InvocationContext)3 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)3 InjectionSource (org.jboss.as.ee.component.InjectionSource)3 EJBEndpoint (org.jboss.as.webservices.metadata.model.EJBEndpoint)3 AnnotationInstance (org.jboss.jandex.AnnotationInstance)3 AnnotationTarget (org.jboss.jandex.AnnotationTarget)3 ServiceName (org.jboss.msc.service.ServiceName)3 WebService (javax.jws.WebService)2 WebServiceProvider (javax.xml.ws.WebServiceProvider)2