Search in sources :

Example 1 with EEModuleClassDescription

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

the class JPAAnnotationProcessor method processPersistenceAnnotations.

private void processPersistenceAnnotations(final DeploymentUnit deploymentUnit, final EEModuleDescription eeModuleDescription, List<AnnotationInstance> persistenceContexts, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
    for (AnnotationInstance annotation : persistenceContexts) {
        ClassInfo declaringClass;
        final AnnotationTarget annotationTarget = annotation.target();
        if (annotationTarget instanceof FieldInfo) {
            FieldInfo fieldInfo = (FieldInfo) annotationTarget;
            declaringClass = fieldInfo.declaringClass();
            EEModuleClassDescription eeModuleClassDescription = eeModuleDescription.addOrGetLocalClassDescription(declaringClass.name().toString());
            this.processField(deploymentUnit, annotation, fieldInfo, eeModuleClassDescription);
        } else if (annotationTarget instanceof MethodInfo) {
            MethodInfo methodInfo = (MethodInfo) annotationTarget;
            declaringClass = methodInfo.declaringClass();
            EEModuleClassDescription eeModuleClassDescription = eeModuleDescription.addOrGetLocalClassDescription(declaringClass.name().toString());
            this.processMethod(deploymentUnit, annotation, methodInfo, eeModuleClassDescription);
        } else if (annotationTarget instanceof ClassInfo) {
            declaringClass = (ClassInfo) annotationTarget;
            EEModuleClassDescription eeModuleClassDescription = eeModuleDescription.addOrGetLocalClassDescription(declaringClass.name().toString());
            this.processClass(deploymentUnit, annotation, eeModuleClassDescription);
        }
    }
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) MethodInfo(org.jboss.jandex.MethodInfo) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) AnnotationInstance(org.jboss.jandex.AnnotationInstance) FieldInfo(org.jboss.jandex.FieldInfo) ClassInfo(org.jboss.jandex.ClassInfo)

Example 2 with EEModuleClassDescription

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

the class WSIntegrationProcessorJAXWS_HANDLER method processAnnotation.

@Override
protected void processAnnotation(final DeploymentUnit unit, final EEModuleDescription moduleDescription) throws DeploymentUnitProcessingException {
    final WSEndpointHandlersMapping mapping = getOptionalAttachment(unit, WS_ENDPOINT_HANDLERS_MAPPING_KEY);
    final VirtualFile root = unit.getAttachment(DEPLOYMENT_ROOT).getRoot();
    final JBossWebservicesMetaData jbossWebservicesMD = unit.getAttachment(WSAttachmentKeys.JBOSS_WEBSERVICES_METADATA_KEY);
    final CompositeIndex index = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    final boolean war = DeploymentTypeMarker.isType(DeploymentType.WAR, unit);
    final JBossWebMetaData jwmd = ASHelper.getJBossWebMetaData(unit);
    for (EEModuleClassDescription classDescription : moduleDescription.getClassDescriptions()) {
        ClassInfo classInfo = null;
        ClassAnnotationInformation<WebService, WebServiceAnnotationInfo> annotationInfo = classDescription.getAnnotationInformation(WebService.class);
        if (annotationInfo != null) {
            classInfo = (ClassInfo) annotationInfo.getClassLevelAnnotations().get(0).getTarget();
        }
        final ClassAnnotationInformation<WebServiceProvider, WebServiceProviderAnnotationInfo> providreInfo = classDescription.getAnnotationInformation(WebServiceProvider.class);
        if (providreInfo != null) {
            classInfo = (ClassInfo) providreInfo.getClassLevelAnnotations().get(0).getTarget();
        }
        if (classInfo != null && isJaxwsEndpoint(classInfo, index, false)) {
            final String endpointClassName = classInfo.name().toString();
            final ConfigResolver configResolver = new ConfigResolver(classInfo, jbossWebservicesMD, jwmd, root, war);
            final EndpointConfig config = configResolver.resolveEndpointConfig();
            if (config != null) {
                registerConfigMapping(endpointClassName, config, unit);
            }
            final Set<String> handlers = getHandlers(endpointClassName, config, configResolver, mapping);
            if (!handlers.isEmpty()) {
                if (isEjb3(classInfo)) {
                    for (final EJBEndpoint ejbEndpoint : getJaxwsEjbs(unit)) {
                        if (endpointClassName.equals(ejbEndpoint.getClassName())) {
                            for (final String handlerClassName : handlers) {
                                final String ejbEndpointName = ejbEndpoint.getName();
                                final String handlerName = ejbEndpointName + "-" + handlerClassName;
                                final ComponentDescription jaxwsHandlerDescription = createComponentDescription(unit, handlerName, handlerClassName, ejbEndpointName);
                                propagateNamingContext(jaxwsHandlerDescription, ejbEndpoint);
                            }
                        }
                    }
                } else {
                    for (final POJOEndpoint pojoEndpoint : getJaxwsPojos(unit)) {
                        if (endpointClassName.equals(pojoEndpoint.getClassName())) {
                            for (final String handlerClassName : handlers) {
                                final String pojoEndpointName = pojoEndpoint.getName();
                                final String handlerName = pojoEndpointName + "-" + handlerClassName;
                                createComponentDescription(unit, handlerName, handlerClassName, pojoEndpointName);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) WebService(javax.jws.WebService) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) POJOEndpoint(org.jboss.as.webservices.metadata.model.POJOEndpoint) WSEndpointHandlersMapping(org.jboss.as.webservices.injection.WSEndpointHandlersMapping) WebServiceProvider(javax.xml.ws.WebServiceProvider) JBossWebservicesMetaData(org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData) EJBEndpoint(org.jboss.as.webservices.metadata.model.EJBEndpoint) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) EndpointConfig(org.jboss.wsf.spi.metadata.config.EndpointConfig) ClassInfo(org.jboss.jandex.ClassInfo)

Example 3 with EEModuleClassDescription

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

the class WSIntegrationProcessorJAXWS_POJO method processAnnotation.

// @Override
protected void processAnnotation(final DeploymentUnit unit, final EEModuleDescription moduleDescription) throws DeploymentUnitProcessingException {
    if (!DeploymentTypeMarker.isType(DeploymentType.WAR, unit)) {
        return;
    }
    final Map<String, EEModuleClassDescription> classDescriptionMap = new HashMap<String, org.jboss.as.ee.component.EEModuleClassDescription>();
    final CompositeIndex index = unit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
    for (EEModuleClassDescription classDescritpion : moduleDescription.getClassDescriptions()) {
        if (isJaxwsEndpoint(classDescritpion, index) && !exclude(unit, classDescritpion)) {
            classDescriptionMap.put(classDescritpion.getClassName(), classDescritpion);
        }
    }
    final JBossWebMetaData jbossWebMD = getJBossWebMetaData(unit);
    final JAXWSDeployment jaxwsDeployment = getJaxwsDeployment(unit);
    if (jbossWebMD != null) {
        final Set<String> matchedEps = new HashSet<String>();
        for (final ServletMetaData servletMD : getServlets(jbossWebMD)) {
            final String endpointClassName = getEndpointClassName(servletMD);
            final String endpointName = getEndpointName(servletMD);
            if (classDescriptionMap.containsKey(endpointClassName) || matchedEps.contains(endpointClassName)) {
                // creating component description for POJO endpoint
                final ComponentDescription pojoComponent = createComponentDescription(unit, endpointName, endpointClassName, endpointName);
                final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
                final String urlPattern = getUrlPattern(endpointName, unit);
                jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointName, endpointClassName, pojoViewName, urlPattern));
                classDescriptionMap.remove(endpointClassName);
                matchedEps.add(endpointClassName);
            } else {
                if (unit.getParent() != null && DeploymentTypeMarker.isType(DeploymentType.EAR, unit.getParent())) {
                    final EEModuleDescription eeModuleDescription = unit.getParent().getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
                    final CompositeIndex parentIndex = unit.getParent().getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
                    for (EEModuleClassDescription classDescription : eeModuleDescription.getClassDescriptions()) {
                        if (classDescription.getClassName().equals(endpointClassName) && isJaxwsEndpoint(classDescription, parentIndex)) {
                            final ComponentDescription pojoComponent = createComponentDescription(unit, endpointName, endpointClassName, endpointName);
                            final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
                            final String urlPattern = getUrlPattern(endpointName, unit);
                            jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointName, endpointClassName, pojoViewName, urlPattern));
                        }
                    }
                }
            }
        }
    }
    for (EEModuleClassDescription classDescription : classDescriptionMap.values()) {
        ClassInfo classInfo = null;
        String serviceName = null;
        String urlPattern = null;
        // #1 Override serviceName with the explicit urlPattern from port-component/port-component-uri in jboss-webservices.xml
        EJBEndpoint ejbEndpoint = getWebserviceMetadataEJBEndpoint(jaxwsDeployment, classDescription.getClassName());
        if (ejbEndpoint != null) {
            urlPattern = UrlPatternUtils.getUrlPatternByPortComponentURI(getJBossWebserviceMetaDataPortComponent(unit, ejbEndpoint.getName()));
        }
        // #2 Override serviceName with @WebContext.urlPattern
        if (urlPattern == null) {
            final ClassAnnotationInformation<WebContext, WebContextAnnotationInfo> annotationWebContext = classDescription.getAnnotationInformation(WebContext.class);
            if (annotationWebContext != null) {
                WebContextAnnotationInfo wsInfo = annotationWebContext.getClassLevelAnnotations().get(0);
                if (wsInfo != null && wsInfo.getUrlPattern().length() > 0) {
                    urlPattern = wsInfo.getUrlPattern();
                }
            }
        }
        // #3 use serviceName declared in a class annotation
        if (urlPattern == null) {
            final ClassAnnotationInformation<WebService, WebServiceAnnotationInfo> annotationInfo = classDescription.getAnnotationInformation(WebService.class);
            if (annotationInfo != null) {
                WebServiceAnnotationInfo wsInfo = annotationInfo.getClassLevelAnnotations().get(0);
                serviceName = wsInfo.getServiceName();
                classInfo = (ClassInfo) wsInfo.getTarget();
                urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName);
                if (jaxwsDeployment.contains(urlPattern)) {
                    urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName, wsInfo.getName());
                }
            }
            final ClassAnnotationInformation<WebServiceProvider, WebServiceProviderAnnotationInfo> annotationProviderInfo = classDescription.getAnnotationInformation(WebServiceProvider.class);
            if (annotationProviderInfo != null) {
                WebServiceProviderAnnotationInfo wsInfo = annotationProviderInfo.getClassLevelAnnotations().get(0);
                serviceName = wsInfo.getServiceName();
                classInfo = (ClassInfo) wsInfo.getTarget();
            }
        }
        if (classInfo != null) {
            final String endpointClassName = classDescription.getClassName();
            final ComponentDescription pojoComponent = createComponentDescription(unit, endpointClassName, endpointClassName, endpointClassName);
            final ServiceName pojoViewName = registerView(pojoComponent, endpointClassName);
            if (urlPattern == null) {
                urlPattern = UrlPatternUtils.getUrlPattern(classInfo.name().local(), serviceName);
            }
            // register POJO endpoint
            jaxwsDeployment.addEndpoint(new POJOEndpoint(endpointClassName, pojoViewName, UrlPatternUtils.getUrlPattern(urlPattern)));
        }
    }
}
Also used : JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) ASHelper.getJBossWebMetaData(org.jboss.as.webservices.util.ASHelper.getJBossWebMetaData) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) WebContext(org.jboss.ws.api.annotation.WebContext) HashMap(java.util.HashMap) WebService(javax.jws.WebService) CompositeIndex(org.jboss.as.server.deployment.annotation.CompositeIndex) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EJBEndpoint(org.jboss.as.webservices.metadata.model.EJBEndpoint) ASHelper.getWebserviceMetadataEJBEndpoint(org.jboss.as.webservices.util.ASHelper.getWebserviceMetadataEJBEndpoint) ServletMetaData(org.jboss.metadata.web.spec.ServletMetaData) HashSet(java.util.HashSet) POJOEndpoint(org.jboss.as.webservices.metadata.model.POJOEndpoint) WebServiceProvider(javax.xml.ws.WebServiceProvider) ServiceName(org.jboss.msc.service.ServiceName) JAXWSDeployment(org.jboss.as.webservices.metadata.model.JAXWSDeployment) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) ClassInfo(org.jboss.jandex.ClassInfo)

Example 4 with EEModuleClassDescription

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

the class WSRefAnnotationProcessor method processRef.

private static void processRef(final DeploymentUnit unit, final String type, final WSRefAnnotationWrapper annotation, final ClassInfo classInfo, final InjectionTarget injectionTarget, final String bindingName) throws DeploymentUnitProcessingException {
    final EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    final AnnotatedElement target = createAnnotatedElement(unit, classInfo, injectionTarget);
    final String componentClassName = classInfo.name().toString();
    final Map<String, String> bindingMap = new HashMap<String, String>();
    boolean isEJB = false;
    for (final ComponentDescription componentDescription : moduleDescription.getComponentsByClassName(componentClassName)) {
        if (componentDescription instanceof SessionBeanComponentDescription) {
            isEJB = true;
            bindingMap.put(componentDescription.getComponentName() + "/" + bindingName, bindingName);
        }
    }
    if (!isEJB) {
        bindingMap.put(bindingName, bindingName);
    }
    for (String refKey : bindingMap.keySet()) {
        String refName = bindingMap.get(refKey);
        ManagedReferenceFactory factory = WebServiceReferences.createWebServiceFactory(unit, type, annotation, target, refName, refKey);
        final EEModuleClassDescription classDescription = moduleDescription.addOrGetLocalClassDescription(classInfo.name().toString());
        // Create the binding from whence our injection comes.
        final InjectionSource serviceRefSource = new FixedInjectionSource(factory, factory);
        final BindingConfiguration bindingConfiguration = new BindingConfiguration(refName, serviceRefSource);
        classDescription.getBindingConfigurations().add(bindingConfiguration);
        // our injection comes from the local lookup, no matter what.
        final ResourceInjectionConfiguration injectionConfiguration = injectionTarget != null ? new ResourceInjectionConfiguration(injectionTarget, new LookupInjectionSource(refName)) : null;
        if (injectionConfiguration != null) {
            classDescription.addResourceInjection(injectionConfiguration);
        }
    }
}
Also used : SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) HashMap(java.util.HashMap) AnnotatedElement(java.lang.reflect.AnnotatedElement) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) LookupInjectionSource(org.jboss.as.ee.component.LookupInjectionSource) InjectionSource(org.jboss.as.ee.component.InjectionSource) FixedInjectionSource(org.jboss.as.ee.component.FixedInjectionSource) FixedInjectionSource(org.jboss.as.ee.component.FixedInjectionSource) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration) LookupInjectionSource(org.jboss.as.ee.component.LookupInjectionSource) ResourceInjectionConfiguration(org.jboss.as.ee.component.ResourceInjectionConfiguration)

Example 5 with EEModuleClassDescription

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

the class TransactionManagementMergingProcessor method handleAnnotations.

@Override
protected void handleAnnotations(final DeploymentUnit deploymentUnit, final EEApplicationClasses applicationClasses, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
    final EEModuleClassDescription clazz = applicationClasses.getClassByName(componentClass.getName());
    //we only care about annotations on the bean class itself
    if (clazz == null) {
        return;
    }
    ClassAnnotationInformation<TransactionManagement, TransactionManagementType> management = clazz.getAnnotationInformation(TransactionManagement.class);
    if (management == null) {
        return;
    }
    if (!management.getClassLevelAnnotations().isEmpty()) {
        componentConfiguration.setTransactionManagementType(management.getClassLevelAnnotations().get(0));
    }
}
Also used : TransactionManagementType(javax.ejb.TransactionManagementType) EEModuleClassDescription(org.jboss.as.ee.component.EEModuleClassDescription) TransactionManagement(javax.ejb.TransactionManagement)

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