use of com.sun.xml.ws.binding.BindingImpl in project metro-jax-ws by eclipse-ee4j.
the class WSServiceDelegate method createDispatch.
protected Dispatch<Object> createDispatch(QName portName, WSEndpointReference wsepr, JAXBContext jaxbContext, Service.Mode mode, WebServiceFeatureList features) {
PortInfo port = safeGetPort(portName);
ComponentFeature cf = features.get(ComponentFeature.class);
if (cf != null && !Target.STUB.equals(cf.getTarget())) {
throw new IllegalArgumentException();
}
ComponentsFeature csf = features.get(ComponentsFeature.class);
if (csf != null) {
for (ComponentFeature cfi : csf.getComponentFeatures()) {
if (!Target.STUB.equals(cfi.getTarget()))
throw new IllegalArgumentException();
}
}
features.addAll(this.features);
BindingImpl binding = port.createBinding(features, null, null);
binding.setMode(mode);
Dispatch<Object> dispatch = Stubs.createJAXBDispatch(port, binding, jaxbContext, mode, wsepr);
serviceInterceptor.postCreateDispatch((WSBindingProvider) dispatch);
return dispatch;
}
use of com.sun.xml.ws.binding.BindingImpl in project metro-jax-ws by eclipse-ee4j.
the class PortInfo method createBinding.
public BindingImpl createBinding(WebServiceFeatureList webServiceFeatures, Class<?> portInterface, BindingImpl existingBinding) {
if (existingBinding != null) {
webServiceFeatures.addAll(existingBinding.getFeatures());
}
Iterable<WebServiceFeature> configFeatures;
// Even in case of Dispatch, merge all features configured via WSDL/Policy or deployment configuration
if (portModel != null) {
// could have merged features from this.policyMap, but some features are set in WSDLModel which are not there in PolicyMap
// for ex: <wsaw:UsingAddressing> wsdl extn., and since the policyMap features are merged into WSDLModel anyway during postFinished(),
// So, using here WsdlModel for merging is right.
// merge features from WSDL
configFeatures = portModel.getFeatures();
} else {
configFeatures = PolicyUtil.getPortScopedFeatures(policyMap, owner.getServiceName(), portName);
}
webServiceFeatures.mergeFeatures(configFeatures, false);
// merge features from interceptor
webServiceFeatures.mergeFeatures(owner.serviceInterceptor.preCreateBinding(this, portInterface, webServiceFeatures), false);
BindingImpl bindingImpl = BindingImpl.create(bindingId, webServiceFeatures.toArray());
owner.getHandlerConfigurator().configureHandlers(this, bindingImpl);
return bindingImpl;
}
use of com.sun.xml.ws.binding.BindingImpl in project metro-jax-ws by eclipse-ee4j.
the class EndpointFactory method create.
public <T> WSEndpoint<T> create(Class<T> implType, boolean processHandlerAnnotation, @Nullable Invoker invoker, @Nullable QName serviceName, @Nullable QName portName, @Nullable Container container, @Nullable WSBinding binding, @Nullable SDDocumentSource primaryWsdl, @Nullable Collection<? extends SDDocumentSource> metadata, EntityResolver resolver, boolean isTransportSynchronous, boolean isStandard) {
if (implType == null)
throw new IllegalArgumentException();
MetadataReader metadataReader = getExternalMetadatReader(implType, binding);
if (isStandard) {
verifyImplementorClass(implType, metadataReader);
}
if (invoker == null) {
invoker = InstanceResolver.createDefault(implType).createInvoker();
}
// Performance analysis indicates that reading and parsing imported schemas is
// a major component of Endpoint creation time. Therefore, modify SDDocumentSource
// handling to delay iterating collection as long as possible.
Collection<SDDocumentSource> md = new CollectionCollection<>();
if (primaryWsdl != null) {
if (metadata != null) {
Iterator<? extends SDDocumentSource> it = metadata.iterator();
if (it.hasNext() && primaryWsdl.equals(it.next()))
md.addAll(metadata);
else {
md.add(primaryWsdl);
md.addAll(metadata);
}
} else
md.add(primaryWsdl);
} else if (metadata != null)
md.addAll(metadata);
if (container == null)
container = ContainerResolver.getInstance().getContainer();
if (serviceName == null)
serviceName = getDefaultServiceName(implType, metadataReader);
if (portName == null)
portName = getDefaultPortName(serviceName, implType, metadataReader);
{
// error check
String serviceNS = serviceName.getNamespaceURI();
String portNS = portName.getNamespaceURI();
if (!serviceNS.equals(portNS)) {
throw new ServerRtException("wrong.tns.for.port", portNS, serviceNS);
}
}
// setting a default binding
if (binding == null)
binding = BindingImpl.create(BindingID.parse(implType));
if (isStandard && primaryWsdl != null) {
verifyPrimaryWSDL(primaryWsdl, serviceName);
}
QName portTypeName = null;
if (isStandard && implType.getAnnotation(WebServiceProvider.class) == null) {
portTypeName = RuntimeModeler.getPortTypeName(implType, metadataReader);
}
// Categorises the documents as WSDL, Schema etc
Collection<SDDocumentImpl> docList = categoriseMetadata(md.iterator(), serviceName, portTypeName);
// Finds the primary WSDL and makes sure that metadata doesn't have
// two concrete or abstract WSDLs
SDDocumentImpl primaryDoc = primaryWsdl != null ? SDDocumentImpl.create(primaryWsdl, serviceName, portTypeName) : findPrimary(docList);
EndpointAwareTube terminal;
WSDLPort wsdlPort = null;
AbstractSEIModelImpl seiModel = null;
// create WSDL model
if (primaryDoc != null) {
wsdlPort = getWSDLPort(primaryDoc, docList, serviceName, portName, container, resolver);
}
WebServiceFeatureList features = ((BindingImpl) binding).getFeatures();
if (isStandard) {
features.parseAnnotations(implType);
}
PolicyMap policyMap = null;
// create terminal pipe that invokes the application
if (isUseProviderTube(implType, isStandard)) {
// TODO incase of Provider, provide a way to User for complete control of the message processing by giving
// ability to turn off the WSDL/Policy based features and its associated tubes.
// Even in case of Provider, merge all features configured via WSDL/Policy or deployment configuration
Iterable<WebServiceFeature> configFtrs;
if (wsdlPort != null) {
policyMap = wsdlPort.getOwner().getParent().getPolicyMap();
// Merge features from WSDL and other policy configuration
configFtrs = wsdlPort.getFeatures();
} else {
// No WSDL, so try to merge features from Policy configuration
policyMap = PolicyResolverFactory.create().resolve(new PolicyResolver.ServerContext(null, container, implType, false));
configFtrs = PolicyUtil.getPortScopedFeatures(policyMap, serviceName, portName);
}
features.mergeFeatures(configFtrs, true);
terminal = createProviderInvokerTube(implType, binding, invoker, container);
} else {
// Create runtime model for non Provider endpoints
seiModel = createSEIModel(wsdlPort, implType, serviceName, portName, binding, primaryDoc);
if (binding instanceof SOAPBindingImpl) {
// set portKnownHeaders on Binding, so that they can be used for MU processing
((SOAPBindingImpl) binding).setPortKnownHeaders(((SOAPSEIModel) seiModel).getKnownHeaders());
}
// Generate WSDL for SEI endpoints(not for Provider endpoints)
if (primaryDoc == null) {
primaryDoc = generateWSDL(binding, seiModel, docList, container, implType);
// create WSDL model
wsdlPort = getWSDLPort(primaryDoc, docList, serviceName, portName, container, resolver);
seiModel.freeze(wsdlPort);
}
policyMap = wsdlPort.getOwner().getParent().getPolicyMap();
// New Features might have been added in WSDL through Policy.
// Merge features from WSDL and other policy configuration
// This sets only the wsdl features that are not already set(enabled/disabled)
features.mergeFeatures(wsdlPort.getFeatures(), true);
terminal = createSEIInvokerTube(seiModel, invoker, binding);
}
// Process @HandlerChain, if handler-chain is not set via Deployment Descriptor
if (processHandlerAnnotation) {
processHandlerAnnotation(binding, implType, serviceName, portName);
}
// Selects only required metadata for this endpoint from the passed-in metadata
if (primaryDoc != null) {
docList = findMetadataClosure(primaryDoc, docList, resolver);
}
ServiceDefinitionImpl serviceDefiniton = (primaryDoc != null) ? new ServiceDefinitionImpl(docList, primaryDoc) : null;
return create(serviceName, portName, binding, container, seiModel, wsdlPort, implType, serviceDefiniton, terminal, isTransportSynchronous, policyMap);
}
use of com.sun.xml.ws.binding.BindingImpl in project metro-jax-ws by eclipse-ee4j.
the class ServerMessageHandlerTube method setUpHandlersOnce.
private void setUpHandlersOnce() {
handlers = new ArrayList<>();
HandlerConfiguration handlerConfig = ((BindingImpl) getBinding()).getHandlerConfig();
List<MessageHandler> msgHandlersSnapShot = handlerConfig.getMessageHandlers();
if (!msgHandlersSnapShot.isEmpty()) {
handlers.addAll(msgHandlersSnapShot);
roles = new HashSet<>();
roles.addAll(handlerConfig.getRoles());
}
}
use of com.sun.xml.ws.binding.BindingImpl in project metro-jax-ws by eclipse-ee4j.
the class ServerSOAPHandlerTube method setUpHandlersOnce.
private void setUpHandlersOnce() {
handlers = new ArrayList<>();
HandlerConfiguration handlerConfig = ((BindingImpl) getBinding()).getHandlerConfig();
List<SOAPHandler> soapSnapShot = handlerConfig.getSoapHandlers();
if (!soapSnapShot.isEmpty()) {
handlers.addAll(soapSnapShot);
roles = new HashSet<>();
roles.addAll(handlerConfig.getRoles());
}
}
Aggregations