Search in sources :

Example 1 with DDEndpoint

use of org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint in project jbossws-cxf by jbossws.

the class MetadataBuilder method build.

public DDBeans build(Deployment dep) {
    final SOAPAddressRewriteMetadata sarm = dep.getAttachment(SOAPAddressRewriteMetadata.class);
    Map<QName, String> serviceNameAddressMap = new HashMap<QName, String>();
    Map<String, SOAPAddressWSDLParser> soapAddressWsdlParsers = new HashMap<String, SOAPAddressWSDLParser>();
    DDBeans dd = new DDBeans();
    for (Endpoint ep : dep.getService().getEndpoints()) {
        DDEndpoint ddep = createDDEndpoint(ep.getTargetBeanClass(), (ArchiveDeployment) dep, ep);
        if (ep instanceof HttpEndpoint) {
            ddep.setInvoker(JBossWSInvoker.class.getName());
        }
        processWSDDContribution(ddep, (ArchiveDeployment) dep);
        URL wsdlLocation = getWsdlLocationURL(ddep, ((ArchiveDeployment) dep).getResourceResolver());
        processAddressRewrite(ddep, wsdlLocation, sarm, soapAddressWsdlParsers);
        METADATA_LOGGER.addingServiceEndpointMetadata(METADATA_LOGGER.isDebugEnabled() ? ddep.toStringExtended() : ddep.toString());
        dd.addEndpoint(ddep);
        serviceNameAddressMap.put(ddep.getServiceName(), ddep.getAddress());
    }
    dep.setProperty("ServiceAddressMap", serviceNameAddressMap);
    return dd;
}
Also used : DDBeans(org.jboss.wsf.stack.cxf.metadata.services.DDBeans) DDEndpoint(org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) SOAPAddressRewriteMetadata(org.jboss.wsf.spi.metadata.config.SOAPAddressRewriteMetadata) HttpEndpoint(org.jboss.wsf.spi.deployment.HttpEndpoint) URL(java.net.URL) JBossWSInvoker(org.jboss.wsf.stack.cxf.JBossWSInvoker) HttpEndpoint(org.jboss.wsf.spi.deployment.HttpEndpoint) DDEndpoint(org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint) Endpoint(org.jboss.wsf.spi.deployment.Endpoint) SOAPAddressWSDLParser(org.jboss.ws.common.deployment.SOAPAddressWSDLParser)

Example 2 with DDEndpoint

use of org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint in project jbossws-cxf by jbossws.

the class BusHolder method configure.

/**
 * Update the Bus held by the this instance using the provided parameters.
 * This basically prepares the bus for being used with JBossWS.
 *
 * @param resolver               The ResourceResolver to configure, if any
 * @param configurer             The JBossWSCXFConfigurer to install in the bus, if any
 * @param wsmd                   The current JBossWebservicesMetaData, if any
 * @param dep                    The current deployment
 */
public void configure(ResourceResolver resolver, Configurer configurer, JBossWebservicesMetaData wsmd, Deployment dep) {
    if (configured) {
        throw Messages.MESSAGES.busAlreadyConfigured(bus);
    }
    bus.setProperty(org.jboss.wsf.stack.cxf.client.Constants.DEPLOYMENT_BUS, true);
    busHolderListener = new BusHolderLifeCycleListener();
    bus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(busHolderListener);
    setWSDLManagerStreamWrapper(bus);
    if (configurer != null) {
        bus.setExtension(configurer, Configurer.class);
    }
    Map<String, String> props = getProperties(wsmd);
    setInterceptors(bus, dep, props);
    dep.addAttachment(Bus.class, bus);
    try {
        final JASPIAuthenticationProvider jaspiProvider = SPIProvider.getInstance().getSPI(JASPIAuthenticationProvider.class, ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
        if (jaspiProvider != null && jaspiProvider.enableServerAuthentication(dep, wsmd)) {
            bus.getInInterceptors().add(new AuthenticationMgrSubjectCreatingInterceptor());
        }
    } catch (WSFException e) {
        Loggers.DEPLOYMENT_LOGGER.cannotFindJaspiClasses();
    }
    setResourceResolver(bus, resolver);
    if (bus.getExtension(PolicyEngine.class) != null) {
        bus.getExtension(PolicyEngine.class).setAlternativeSelector(getAlternativeSelector(props));
    }
    // *first* enabled cxf management if required, *then* add anything else which could be manageable (e.g. work queues)
    setCXFManagement(bus, props);
    setAdditionalWorkQueues(bus, props);
    setWSDiscovery(bus, props);
    AnnotationsInfo ai = dep.getAttachment(AnnotationsInfo.class);
    if (ai == null || ai.hasAnnotatedClasses(PolicySets.class.getName())) {
        policySetsListener = new PolicySetsAnnotationListener(dep.getClassLoader());
        bus.getExtension(FactoryBeanListenerManager.class).addListener(policySetsListener);
    }
    // default to USE_ORIGINAL_THREAD = true; this can be overridden by simply setting the property in the endpoint or in the message using an interceptor
    // this forces one way operation to use original thread, which is required for ejb webserivce endpoints to avoid authorization failures from ejb container
    // and is a performance improvement in general when running in-container, as CXF needs to cache the message to free the thread, which is expensive
    // (moreover the user can tune the web container thread pool instead of expecting cxf to fork new threads)
    bus.setProperty(OneWayProcessorInterceptor.USE_ORIGINAL_THREAD, true);
    // [JBWS-3135] enable decoupled faultTo. This is an optional feature in cxf and we need this to be default to make it same behavior with native stack
    bus.setProperty("org.apache.cxf.ws.addressing.decoupled_fault_support", true);
    FeatureUtils.addFeatures(bus, bus, props);
    for (DDEndpoint dde : metadata.getEndpoints()) {
        EndpointImpl endpoint = new EndpointImpl(bus, newInstance(dde.getImplementor()));
        if (dde.getInvoker() != null)
            endpoint.setInvoker(newInvokerInstance(dde.getInvoker(), dep));
        endpoint.setAddress(dde.getAddress());
        endpoint.setEndpointName(dde.getPortName());
        endpoint.setServiceName(dde.getServiceName());
        endpoint.setWsdlLocation(dde.getWsdlLocation());
        setHandlers(endpoint, dde);
        if (dde.getProperties() != null) {
            Map<String, Object> p = new HashMap<String, Object>();
            p.putAll(dde.getProperties());
            endpoint.setProperties(p);
        }
        if (dde.isAddressingEnabled()) {
            WSAddressingFeature addressingFeature = new WSAddressingFeature();
            addressingFeature.setAddressingRequired(dde.isAddressingRequired());
            addressingFeature.setResponses(dde.getAddressingResponses());
            endpoint.getFeatures().add(addressingFeature);
        }
        endpoint.setPublishedEndpointUrl(dde.getPublishedEndpointUrl());
        endpoint.setSOAPAddressRewriteMetadata(dep.getAttachment(SOAPAddressRewriteMetadata.class));
        endpoint.publish();
        endpoints.add(endpoint);
        if (dde.isMtomEnabled()) {
            SOAPBinding binding = (SOAPBinding) endpoint.getBinding();
            binding.setMTOMEnabled(true);
        }
    }
    configured = true;
}
Also used : DDEndpoint(org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint) HashMap(java.util.HashMap) EndpointImpl(org.jboss.wsf.stack.cxf.deployment.EndpointImpl) SOAPAddressRewriteMetadata(org.jboss.wsf.spi.metadata.config.SOAPAddressRewriteMetadata) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) SOAPBinding(javax.xml.ws.soap.SOAPBinding) FactoryBeanListenerManager(org.apache.cxf.service.factory.FactoryBeanListenerManager) PolicySetsAnnotationListener(org.jboss.wsf.stack.cxf.extensions.policy.PolicySetsAnnotationListener) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) JASPIAuthenticationProvider(org.jboss.wsf.spi.security.JASPIAuthenticationProvider) WSFException(org.jboss.wsf.spi.WSFException) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) AnnotationsInfo(org.jboss.wsf.spi.deployment.AnnotationsInfo) AuthenticationMgrSubjectCreatingInterceptor(org.jboss.wsf.stack.cxf.security.authentication.AuthenticationMgrSubjectCreatingInterceptor)

Example 3 with DDEndpoint

use of org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint in project jbossws-cxf by jbossws.

the class MetadataBuilder method createDDEndpoint.

protected DDEndpoint createDDEndpoint(Class<?> sepClass, ArchiveDeployment dep, Endpoint ep) {
    WebService anWebService = sepClass.getAnnotation(WebService.class);
    WebServiceProvider anWebServiceProvider = sepClass.getAnnotation(WebServiceProvider.class);
    Class<?> seiClass = null;
    String seiName;
    String name = (anWebService != null) ? anWebService.name() : "";
    if (name.length() == 0)
        name = JavaUtils.getJustClassName(sepClass);
    String serviceName = (anWebService != null) ? anWebService.serviceName() : anWebServiceProvider.serviceName();
    if (serviceName.length() == 0) {
        serviceName = JavaUtils.getJustClassName(sepClass) + "Service";
    }
    String serviceNS = (anWebService != null) ? anWebService.targetNamespace() : anWebServiceProvider.targetNamespace();
    if (serviceNS.length() == 0)
        serviceNS = getTypeNamespace(JavaUtils.getPackageName(sepClass));
    String portName = (anWebService != null) ? anWebService.portName() : anWebServiceProvider.portName();
    if (portName.length() == 0) {
        portName = name + "Port";
    }
    String annWsdlLocation;
    if (anWebService != null && anWebService.endpointInterface().length() > 0) {
        seiName = anWebService.endpointInterface();
        ClassLoader runtimeClassLoader = dep.getClassLoader();
        if (null == runtimeClassLoader)
            throw MESSAGES.runtimeLoaderCannotBeNull(dep);
        try {
            seiClass = runtimeClassLoader.loadClass(seiName);
        } catch (ClassNotFoundException cnfe) {
            throw new RuntimeException(cnfe);
        }
        WebService seiAnnotation = seiClass.getAnnotation(WebService.class);
        if (seiAnnotation == null)
            throw MESSAGES.webserviceAnnotationNotFound(seiName);
        if (seiAnnotation.portName().length() > 0 || seiAnnotation.serviceName().length() > 0 || seiAnnotation.endpointInterface().length() > 0)
            throw MESSAGES.webserviceAnnotationSEIAttributes(seiName);
        annWsdlLocation = !"".equals(anWebService.wsdlLocation()) ? anWebService.wsdlLocation() : seiAnnotation.wsdlLocation();
    } else {
        annWsdlLocation = (anWebService != null) ? anWebService.wsdlLocation() : anWebServiceProvider.wsdlLocation();
    }
    DDEndpoint result = new DDEndpoint();
    result.setId(ep.getShortName());
    result.setAddress(SysPropUtils.expandSystemProperty(ep.getAddress()));
    result.setImplementor(ep.getTargetBeanName());
    result.setMtomEnabled(isMtomEnabled(ep.getTargetBeanClass()));
    result.setEpClass(seiClass != null ? seiClass : sepClass);
    result.setPortName(new QName(serviceNS, portName));
    result.setServiceName(new QName(serviceNS, serviceName));
    if (annWsdlLocation.length() > 0) {
        result.setAnnotationWsdlLocation(annWsdlLocation);
    }
    return result;
}
Also used : WebServiceProvider(javax.xml.ws.WebServiceProvider) DDEndpoint(org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint) WebService(javax.jws.WebService) QName(javax.xml.namespace.QName)

Aggregations

DDEndpoint (org.jboss.wsf.stack.cxf.metadata.services.DDEndpoint)3 HashMap (java.util.HashMap)2 QName (javax.xml.namespace.QName)2 SOAPAddressRewriteMetadata (org.jboss.wsf.spi.metadata.config.SOAPAddressRewriteMetadata)2 URL (java.net.URL)1 WebService (javax.jws.WebService)1 WebServiceProvider (javax.xml.ws.WebServiceProvider)1 SOAPBinding (javax.xml.ws.soap.SOAPBinding)1 BusLifeCycleManager (org.apache.cxf.buslifecycle.BusLifeCycleManager)1 FactoryBeanListenerManager (org.apache.cxf.service.factory.FactoryBeanListenerManager)1 WSAddressingFeature (org.apache.cxf.ws.addressing.WSAddressingFeature)1 PolicyEngine (org.apache.cxf.ws.policy.PolicyEngine)1 SOAPAddressWSDLParser (org.jboss.ws.common.deployment.SOAPAddressWSDLParser)1 WSFException (org.jboss.wsf.spi.WSFException)1 AnnotationsInfo (org.jboss.wsf.spi.deployment.AnnotationsInfo)1 Endpoint (org.jboss.wsf.spi.deployment.Endpoint)1 HttpEndpoint (org.jboss.wsf.spi.deployment.HttpEndpoint)1 JASPIAuthenticationProvider (org.jboss.wsf.spi.security.JASPIAuthenticationProvider)1 JBossWSInvoker (org.jboss.wsf.stack.cxf.JBossWSInvoker)1 EndpointImpl (org.jboss.wsf.stack.cxf.deployment.EndpointImpl)1