Search in sources :

Example 1 with JAXWSDeployment

use of org.jboss.as.webservices.metadata.model.JAXWSDeployment in project wildfly by wildfly.

the class WSClassVerificationProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final JAXWSDeployment wsDeployment = unit.getAttachment(JAXWS_ENDPOINTS_KEY);
    if (wsDeployment != null) {
        final Module module = unit.getAttachment(Attachments.MODULE);
        final DeploymentReflectionIndex deploymentReflectionIndex = unit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
        final ClassLoader moduleClassLoader = module.getClassLoader();
        for (AbstractEndpoint pojoEndpoint : wsDeployment.getPojoEndpoints()) {
            verifyEndpoint(pojoEndpoint, moduleClassLoader, deploymentReflectionIndex);
        }
        for (AbstractEndpoint ejbEndpoint : wsDeployment.getEjbEndpoints()) {
            verifyEndpoint(ejbEndpoint, moduleClassLoader, deploymentReflectionIndex);
        }
        verifyApacheCXFModuleDependencyRequirement(unit);
    }
}
Also used : AbstractEndpoint(org.jboss.as.webservices.metadata.model.AbstractEndpoint) JAXWSDeployment(org.jboss.as.webservices.metadata.model.JAXWSDeployment) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 2 with JAXWSDeployment

use of org.jboss.as.webservices.metadata.model.JAXWSDeployment 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 3 with JAXWSDeployment

use of org.jboss.as.webservices.metadata.model.JAXWSDeployment in project wildfly by wildfly.

the class AbstractDeploymentModelBuilder method propagateAttachments.

private void propagateAttachments(final DeploymentUnit unit, final ArchiveDeployment dep) {
    dep.addAttachment(DeploymentUnit.class, unit);
    unit.putAttachment(DEPLOYMENT_KEY, dep);
    final JBossWebMetaData webMD = getJBossWebMetaData(unit);
    dep.addAttachment(JBossWebMetaData.class, webMD);
    final WebservicesMetaData webservicesMD = getOptionalAttachment(unit, WEBSERVICES_METADATA_KEY);
    dep.addAttachment(WebservicesMetaData.class, webservicesMD);
    JBossWebservicesMetaData jbossWebservicesMD = getOptionalAttachment(unit, JBOSS_WEBSERVICES_METADATA_KEY);
    if (unit.getParent() != null) {
        jbossWebservicesMD = JBossWebservicesMetaData.merge(getOptionalAttachment(unit.getParent(), JBOSS_WEBSERVICES_METADATA_KEY), jbossWebservicesMD);
    }
    dep.addAttachment(JBossWebservicesMetaData.class, jbossWebservicesMD);
    final JAXWSDeployment jaxwsDeployment = getOptionalAttachment(unit, JAXWS_ENDPOINTS_KEY);
    dep.addAttachment(JAXWSDeployment.class, jaxwsDeployment);
    final EjbJarMetaData ejbJarMD = getOptionalAttachment(unit, EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    dep.addAttachment(EjbJarMetaData.class, ejbJarMD);
    final RejectionRule rr = getOptionalAttachment(unit, REJECTION_RULE_KEY);
    if (rr != null) {
        dep.addAttachment(RejectionRule.class, rr);
    }
}
Also used : JBossWebMetaData(org.jboss.metadata.web.jboss.JBossWebMetaData) ASHelper.getJBossWebMetaData(org.jboss.as.webservices.util.ASHelper.getJBossWebMetaData) RejectionRule(org.jboss.wsf.spi.invocation.RejectionRule) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) JBossWebservicesMetaData(org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData) JBossWebservicesMetaData(org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData) WebservicesMetaData(org.jboss.wsf.spi.metadata.webservices.WebservicesMetaData) JAXWSDeployment(org.jboss.as.webservices.metadata.model.JAXWSDeployment)

Example 4 with JAXWSDeployment

use of org.jboss.as.webservices.metadata.model.JAXWSDeployment 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 5 with JAXWSDeployment

use of org.jboss.as.webservices.metadata.model.JAXWSDeployment in project wildfly by wildfly.

the class GracefulShutdownIntegrationProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final JAXWSDeployment wsDeployment = unit.getAttachment(JAXWS_ENDPOINTS_KEY);
    if (wsDeployment != null) {
        unit.addToAttachmentList(UndertowAttachments.ALLOW_REQUEST_WHEN_SUSPENDED, new AllowWSRequestPredicate());
    }
}
Also used : JAXWSDeployment(org.jboss.as.webservices.metadata.model.JAXWSDeployment) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

JAXWSDeployment (org.jboss.as.webservices.metadata.model.JAXWSDeployment)7 EJBEndpoint (org.jboss.as.webservices.metadata.model.EJBEndpoint)3 JBossWebMetaData (org.jboss.metadata.web.jboss.JBossWebMetaData)3 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)2 EEModuleClassDescription (org.jboss.as.ee.component.EEModuleClassDescription)2 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 ASHelper.getJBossWebMetaData (org.jboss.as.webservices.util.ASHelper.getJBossWebMetaData)2 ClassInfo (org.jboss.jandex.ClassInfo)2 ServiceName (org.jboss.msc.service.ServiceName)2 JBossWebservicesMetaData (org.jboss.wsf.spi.metadata.webservices.JBossWebservicesMetaData)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 WebService (javax.jws.WebService)1 WebServiceProvider (javax.xml.ws.WebServiceProvider)1 ClassAnnotationInformation (org.jboss.as.ee.metadata.ClassAnnotationInformation)1 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)1 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)1 CompositeIndex (org.jboss.as.server.deployment.annotation.CompositeIndex)1