Search in sources :

Example 1 with CallbackDefaultServiceConfiguration

use of org.talend.esb.mep.requestcallback.impl.wsdl.CallbackDefaultServiceConfiguration in project tesb-rt-se by Talend.

the class CallContext method createCallbackEndpoint.

public static Endpoint createCallbackEndpoint(final Object implementor, final CallbackInfo cbInfo, final String policyAlias) {
    final Bus bus = BusFactory.getThreadDefaultBus();
    final JaxWsServerFactoryBean serverFactory = new JaxWsServerFactoryBean();
    final List<Feature> features = new ArrayList<Feature>();
    features.add(new RequestCallbackFeature());
    if (logging) {
        features.add(new LoggingFeature());
    }
    if (serviceActivityMonitoring) {
        features.add(getEventFeature());
    }
    serverFactory.setFeatures(features);
    final QName cbInterfaceName;
    final String wsdlLocation;
    if (cbInfo == null) {
        cbInterfaceName = null;
        wsdlLocation = null;
    } else {
        cbInterfaceName = cbInfo.getCallbackPortTypeName();
        wsdlLocation = cbInfo.getEffectiveCallbackReceiverWsdlLocation(policyAlias);
    }
    final boolean useWsdlLocation = wsdlLocation != null && cbInfo.getCallbackServiceName() != null && cbInfo.getCallbackPortName() != null;
    if (cbInterfaceName != null) {
        final QName cbServiceName = cbInfo.getCallbackServiceName() == null ? new QName(cbInterfaceName.getNamespaceURI(), cbInterfaceName.getLocalPart() + "Service") : cbInfo.getCallbackServiceName();
        final QName cbEndpointName = cbInfo.getCallbackServiceName() == null ? new QName(cbInterfaceName.getNamespaceURI(), cbInterfaceName.getLocalPart() + "ServicePort") : new QName(cbServiceName.getNamespaceURI(), cbInfo.getCallbackPortName() == null ? cbServiceName.getLocalPart() + "Port" : cbInfo.getCallbackPortName());
        serverFactory.setServiceName(cbServiceName);
        serverFactory.setEndpointName(cbEndpointName);
        final List<AbstractServiceConfiguration> svcConfigs = serverFactory.getServiceFactory().getServiceConfigurations();
        for (ListIterator<AbstractServiceConfiguration> it = svcConfigs.listIterator(); it.hasNext(); ) {
            final AbstractServiceConfiguration cfg = it.next();
            if (cfg instanceof DefaultServiceConfiguration) {
                final AbstractServiceConfiguration ncfg = new CallbackDefaultServiceConfiguration(cbInfo);
                it.set(ncfg);
            }
        }
        if (useWsdlLocation) {
            serverFactory.setWsdlLocation(wsdlLocation);
        }
    }
    final EndpointImpl endpoint = new EndpointImpl(bus, implementor, serverFactory);
    endpoint.setFeatures(features);
    endpoint.getProperties().put(NULL_MEANS_ONEWAY, Boolean.TRUE);
    if (cbInterfaceName != null) {
        endpoint.setEndpointName(serverFactory.getEndpointName());
        endpoint.setServiceName(serverFactory.getServiceName());
        if (useWsdlLocation) {
            endpoint.setWsdlLocation(wsdlLocation);
        }
    }
    return endpoint;
}
Also used : Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) EndpointImpl(org.apache.cxf.jaxws.EndpointImpl) ArrayList(java.util.ArrayList) Feature(org.apache.cxf.feature.Feature) LoggingFeature(org.apache.cxf.feature.LoggingFeature) DefaultServiceConfiguration(org.apache.cxf.wsdl.service.factory.DefaultServiceConfiguration) CallbackDefaultServiceConfiguration(org.talend.esb.mep.requestcallback.impl.wsdl.CallbackDefaultServiceConfiguration) AbstractServiceConfiguration(org.apache.cxf.wsdl.service.factory.AbstractServiceConfiguration) LoggingFeature(org.apache.cxf.feature.LoggingFeature) CallbackDefaultServiceConfiguration(org.talend.esb.mep.requestcallback.impl.wsdl.CallbackDefaultServiceConfiguration) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean)

Aggregations

ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 Bus (org.apache.cxf.Bus)1 Feature (org.apache.cxf.feature.Feature)1 LoggingFeature (org.apache.cxf.feature.LoggingFeature)1 EndpointImpl (org.apache.cxf.jaxws.EndpointImpl)1 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)1 AbstractServiceConfiguration (org.apache.cxf.wsdl.service.factory.AbstractServiceConfiguration)1 DefaultServiceConfiguration (org.apache.cxf.wsdl.service.factory.DefaultServiceConfiguration)1 CallbackDefaultServiceConfiguration (org.talend.esb.mep.requestcallback.impl.wsdl.CallbackDefaultServiceConfiguration)1