use of com.oracle.webservices.api.databinding.ExternalMetadataFeature in project metro-jax-ws by eclipse-ee4j.
the class SDODatabindingTestBase method invmSetup.
protected WebServiceFeature[] invmSetup(final URL wsdlURL, final Class sei, final Class seb, final QName serviceName, final QName portName) {
DatabindingModeFeature dbmf = new DatabindingModeFeature("eclipselink.sdo");
Class implementorClass = seb;
boolean handlersSetInDD = false;
Container container = Container.NONE;
Map<String, SDDocumentSource> docs = new HashMap<String, SDDocumentSource>();
SDDocumentSource primaryWSDL = SDDocumentSource.create(wsdlURL);
docs.put(wsdlURL.toString(), primaryWSDL);
ExternalMetadataFeature exm = ExternalMetadataFeature.builder().setReader(new com.sun.xml.ws.model.ReflectAnnotationReader() {
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Class<?> cls) {
if (WebService.class.equals(annType)) {
final WebService ws = cls.getAnnotation(WebService.class);
return (A) new jakarta.jws.WebService() {
public Class<? extends Annotation> annotationType() {
return WebService.class;
}
@Override
public String endpointInterface() {
return sei.getName();
}
@Override
public String name() {
return (ws != null) ? ws.name() : null;
}
@Override
public String portName() {
return (ws != null) ? ws.portName() : null;
}
@Override
public String serviceName() {
return (ws != null) ? ws.serviceName() : null;
}
@Override
public String targetNamespace() {
return (ws != null) ? ws.targetNamespace() : null;
}
@Override
public String wsdlLocation() {
return (ws != null) ? ws.wsdlLocation() : null;
}
};
}
return cls.getAnnotation(annType);
}
}).build();
BindingID bindingID = BindingID.parse(implementorClass);
WSBinding binding = bindingID.createBinding(dbmf, exm);
final WSEndpoint<?> endpoint = WSEndpoint.create(implementorClass, !handlersSetInDD, null, serviceName, portName, container, binding, primaryWSDL, docs.values(), XmlUtil.createEntityResolver(null), false);
ComponentFeature cf = new ComponentFeature(new com.sun.xml.ws.api.Component() {
public <S> S getSPI(Class<S> spiType) {
if (TransportTubeFactory.class.equals(spiType))
return (S) new TransportTubeFactory() {
public Tube doCreate(ClientTubeAssemblerContext context) {
return new InVmTransportTube(context.getCodec(), context.getBinding(), wsdlURL, endpoint);
}
};
return null;
}
});
WebServiceFeature[] f = { dbmf, cf };
return f;
}
use of com.oracle.webservices.api.databinding.ExternalMetadataFeature in project metro-jax-ws by eclipse-ee4j.
the class DeploymentDescriptorParser method parseAdapters.
private List<A> parseAdapters(XMLStreamReader reader) {
if (!reader.getName().equals(QNAME_ENDPOINTS)) {
failWithFullName("runtime.parser.invalidElement", reader);
}
List<A> adapters = new ArrayList<>();
Attributes attrs = XMLStreamReaderUtil.getAttributes(reader);
String version = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_VERSION);
if (!ATTRVALUE_SUPPORTED_VERSIONS.contains(version)) {
failWithLocalName("runtime.parser.invalidVersionNumber", reader, version);
}
while (XMLStreamReaderUtil.nextElementContent(reader) != XMLStreamConstants.END_ELEMENT) {
if (reader.getName().equals(QNAME_ENDPOINT)) {
attrs = XMLStreamReaderUtil.getAttributes(reader);
String name = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_NAME);
if (!names.add(name)) {
logger.warning(WsservletMessages.SERVLET_WARNING_DUPLICATE_ENDPOINT_NAME());
}
String implementationName = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_IMPLEMENTATION);
Class<?> implementorClass = getImplementorClass(implementationName, reader);
MetadataReader metadataReader = null;
ExternalMetadataFeature externalMetadataFeature = null;
// parse subelements to instantiate externalMetadataReader, if necessary ...
XMLStreamReaderUtil.nextElementContent(reader);
if (reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
externalMetadataFeature = configureExternalMetadataReader(reader);
if (externalMetadataFeature != null) {
metadataReader = externalMetadataFeature.getMetadataReader(implementorClass.getClassLoader(), false);
}
}
QName serviceName = getQNameAttribute(attrs, ATTR_SERVICE);
if (serviceName == null) {
serviceName = EndpointFactory.getDefaultServiceName(implementorClass, metadataReader);
}
QName portName = getQNameAttribute(attrs, ATTR_PORT);
if (portName == null) {
portName = EndpointFactory.getDefaultPortName(serviceName, implementorClass, metadataReader);
}
// get enable-mtom attribute value
String enable_mtom = getAttribute(attrs, ATTR_ENABLE_MTOM);
String mtomThreshold = getAttribute(attrs, ATTR_MTOM_THRESHOLD_VALUE);
String dbMode = getAttribute(attrs, ATTR_DATABINDING);
String bindingId = getAttribute(attrs, ATTR_BINDING);
if (bindingId != null) {
// Convert short-form tokens to API's binding ids
bindingId = getBindingIdForToken(bindingId);
}
WSBinding binding = createBinding(bindingId, implementorClass, enable_mtom, mtomThreshold, dbMode);
if (externalMetadataFeature != null) {
binding.getFeatures().mergeFeatures(new WebServiceFeature[] { externalMetadataFeature }, true);
}
String urlPattern = getMandatoryNonEmptyAttribute(reader, attrs, ATTR_URL_PATTERN);
// TODO use 'docs' as the metadata. If wsdl is non-null it's the primary.
boolean handlersSetInDD = setHandlersAndRoles(binding, reader, serviceName, portName);
EndpointFactory.verifyImplementorClass(implementorClass, metadataReader);
SDDocumentSource primaryWSDL = getPrimaryWSDL(reader, attrs, implementorClass, metadataReader);
WSEndpoint<?> endpoint = WSEndpoint.create(implementorClass, !handlersSetInDD, null, serviceName, portName, container, binding, primaryWSDL, docs.values(), createEntityResolver(), false);
adapters.add(adapterFactory.createAdapter(name, urlPattern, endpoint));
} else {
failWithLocalName("runtime.parser.invalidElement", reader);
}
}
return adapters;
}
use of com.oracle.webservices.api.databinding.ExternalMetadataFeature in project metro-jax-ws by eclipse-ee4j.
the class DeploymentDescriptorParser method configureExternalMetadataReader.
protected ExternalMetadataFeature configureExternalMetadataReader(XMLStreamReader reader) {
ExternalMetadataFeature.Builder featureBuilder = null;
while (QNAME_EXT_METADA.equals(reader.getName())) {
if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
Attributes attrs = XMLStreamReaderUtil.getAttributes(reader);
String file = getAttribute(attrs, ATTR_FILE);
if (file != null) {
if (featureBuilder == null) {
featureBuilder = ExternalMetadataFeature.builder();
}
featureBuilder.addFiles(new File(file));
}
String res = getAttribute(attrs, ATTR_RESOURCE);
if (res != null) {
if (featureBuilder == null) {
featureBuilder = ExternalMetadataFeature.builder();
}
featureBuilder.addResources(res);
}
}
XMLStreamReaderUtil.nextElementContent(reader);
}
return buildFeature(featureBuilder);
}
Aggregations