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;
}
Aggregations