use of jakarta.xml.ws.WebServiceFeature in project metro-jax-ws by eclipse-ee4j.
the class WebServiceFeatureList method getWebServiceFeatureBeanViaBuilder.
private static WebServiceFeature getWebServiceFeatureBeanViaBuilder(final Annotation annotation, final Class<? extends WebServiceFeature> beanClass) {
try {
final Method featureBuilderMethod = beanClass.getDeclaredMethod("builder");
final Object builder = featureBuilderMethod.invoke(beanClass);
final Method buildMethod = builder.getClass().getDeclaredMethod("build");
for (Method builderMethod : builder.getClass().getDeclaredMethods()) {
if (!builderMethod.equals(buildMethod) && !builderMethod.isSynthetic()) {
final String methodName = builderMethod.getName();
final Method annotationMethod = annotation.annotationType().getDeclaredMethod(methodName);
final Object annotationFieldValue = annotationMethod.invoke(annotation);
final Object[] arg = { annotationFieldValue };
if (skipDuringOrgJvnetWsToComOracleWebservicesPackageMove(builderMethod, annotationFieldValue)) {
continue;
}
builderMethod.invoke(builder, arg);
}
}
final Object result = buildMethod.invoke(builder);
if (result instanceof WebServiceFeature) {
return (WebServiceFeature) result;
} else {
throw new WebServiceException("Not a WebServiceFeature: " + result);
}
} catch (final NoSuchMethodException e) {
LOGGER.log(Level.INFO, "Unable to find builder method on webservice feature: " + beanClass.getName(), e);
return null;
} catch (final IllegalAccessException | InvocationTargetException e) {
throw new WebServiceException(e);
}
}
use of jakarta.xml.ws.WebServiceFeature in project metro-jax-ws by eclipse-ee4j.
the class WebServiceFeatureList method getFeature.
/**
* Returns a corresponding feature for a feature annotation(i.e which has
* {@link WebServiceFeatureAnnotation} meta annotation)
*
* @return corresponding feature for the annotation
* null, if the annotation is nota feature annotation
*/
public static WebServiceFeature getFeature(Annotation a) {
WebServiceFeature ftr = null;
if (!(a.annotationType().isAnnotationPresent(WebServiceFeatureAnnotation.class))) {
ftr = null;
} else if (a instanceof Addressing) {
Addressing addAnn = (Addressing) a;
try {
ftr = new AddressingFeature(addAnn.enabled(), addAnn.required(), addAnn.responses());
} catch (NoSuchMethodError e) {
// throw error. We can't default to Responses.ALL as we dont know if the user has not used 2.2 annotation with responses.
throw new RuntimeModelerException(ModelerMessages.RUNTIME_MODELER_ADDRESSING_RESPONSES_NOSUCHMETHOD(toJar(Which.which(Addressing.class))));
}
} else if (a instanceof MTOM) {
MTOM mtomAnn = (MTOM) a;
ftr = new MTOMFeature(mtomAnn.enabled(), mtomAnn.threshold());
} else if (a instanceof RespectBinding) {
RespectBinding rbAnn = (RespectBinding) a;
ftr = new RespectBindingFeature(rbAnn.enabled());
} else {
ftr = getWebServiceFeatureBean(a);
}
return ftr;
}
use of jakarta.xml.ws.WebServiceFeature 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 jakarta.xml.ws.WebServiceFeature 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 jakarta.xml.ws.WebServiceFeature in project metro-jax-ws by eclipse-ee4j.
the class SDODatabindingTestBase method createProxy.
public static <T> T createProxy(Class<T> proxySEI, Class<?> endpointClass, String db, boolean debug) throws Exception {
DatabindingConfig srvConfig = new DatabindingConfig();
srvConfig.setEndpointClass(endpointClass);
DatabindingModeFeature dbf = new DatabindingModeFeature(db);
WebServiceFeatureList wsfeatures = new WebServiceFeatureList(endpointClass);
WebServiceFeature[] f = { dbf };
// config.setFeatures(wsfeatures.toArray());
srvConfig.setFeatures(f);
DatabindingConfig cliConfig = new DatabindingConfig();
cliConfig.setContractClass(proxySEI);
cliConfig.setFeatures(f);
return createProxy(proxySEI, srvConfig, cliConfig, debug);
}
Aggregations