use of org.apache.cxf.jaxb.WrapperHelperClassLoader in project cxf by apache.
the class WrapperNamespaceClassGeneratorTest method testGeneratedFirst.
@org.junit.Test
public void testGeneratedFirst() throws Exception {
JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(AddNumbers2Impl.class);
JaxWsServiceFactoryBean jaxwsFac = new JaxWsServiceFactoryBean(implInfo);
Bus bus = BusFactory.getDefaultBus();
jaxwsFac.setBus(bus);
Capture c = new Capture();
bus.setExtension(c, GeneratedClassClassLoaderCapture.class);
Service service = jaxwsFac.create();
ServiceInfo serviceInfo = service.getServiceInfos().get(0);
InterfaceInfo interfaceInfo = serviceInfo.getInterface();
OperationInfo inf = interfaceInfo.getOperations().iterator().next();
Class<?> requestClass = inf.getInput().getMessagePart(0).getTypeClass();
// Create request wrapper Object
List<String> partNames = Arrays.asList(new String[] { "arg0" });
List<String> elTypeNames = Arrays.asList(new String[] { "list" });
List<Class<?>> partClasses = Arrays.asList(new Class<?>[] { List.class });
// generate class and store it to class loader
new JAXBDataBinding().createWrapperHelper(requestClass, null, partNames, elTypeNames, partClasses);
// now no more generation is allowed
WrapperHelperClassLoader wrapperHelperClassLoader = new WrapperHelperClassLoader(bus);
GeneratedClassClassLoader.TypeHelperClassLoader cl = wrapperHelperClassLoader.getClassLoader();
c.restore(cl);
bus.setExtension(wrapperHelperClassLoader, WrapperHelperCreator.class);
WrapperHelper wh = new JAXBDataBinding().createWrapperHelper(requestClass, null, partNames, elTypeNames, partClasses);
assertFalse("Precompiled class not loaded", wh instanceof JAXBWrapperHelper);
}
use of org.apache.cxf.jaxb.WrapperHelperClassLoader in project quarkus-cxf by quarkiverse.
the class CxfClientProducer method produceCxfClient.
/**
* The main workhorse producing a CXF client proxy.
*
* @param cxfClientInfo
* @return
*/
private Object produceCxfClient(CXFClientInfo cxfClientInfo) {
Class<?> seiClass;
try {
seiClass = Class.forName(cxfClientInfo.getSei(), false, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
LOGGER.error("either webservice interface (client) or implementation (server) is mandatory");
return null;
}
QuarkusClientFactoryBean quarkusClientFactoryBean = new QuarkusClientFactoryBean(cxfClientInfo.getClassNames());
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(quarkusClientFactoryBean);
Bus bus = quarkusClientFactoryBean.getBus(true);
bus.setExtension(new WrapperHelperClassLoader(bus), WrapperHelperCreator.class);
bus.setExtension(new ExtensionClassLoader(bus), ExtensionClassCreator.class);
bus.setExtension(new ExceptionClassLoader(bus), ExceptionClassCreator.class);
bus.setExtension(new WrapperClassLoader(bus), WrapperClassCreator.class);
bus.setExtension(new FactoryClassLoader(bus), FactoryClassCreator.class);
bus.setExtension(new GeneratedNamespaceClassLoader(bus), NamespaceClassCreator.class);
factory.setServiceClass(seiClass);
LOGGER.debugf("using servicename {%s}%s", cxfClientInfo.getWsNamespace(), cxfClientInfo.getWsName());
factory.setServiceName(new QName(cxfClientInfo.getWsNamespace(), cxfClientInfo.getWsName()));
if (cxfClientInfo.getEpName() != null) {
factory.setEndpointName(new QName(cxfClientInfo.getEpNamespace(), cxfClientInfo.getEpName()));
}
factory.setAddress(cxfClientInfo.getEndpointAddress());
if (cxfClientInfo.getSoapBinding() != null) {
factory.setBindingId(cxfClientInfo.getSoapBinding());
}
if (cxfClientInfo.getWsdlUrl() != null && !cxfClientInfo.getWsdlUrl().isEmpty()) {
factory.setWsdlURL(cxfClientInfo.getWsdlUrl());
}
if (cxfClientInfo.getUsername() != null) {
factory.setUsername(cxfClientInfo.getUsername());
}
if (cxfClientInfo.getPassword() != null) {
factory.setPassword(cxfClientInfo.getPassword());
}
for (String feature : cxfClientInfo.getFeatures()) {
addToCols(feature, factory.getFeatures(), Feature.class);
}
for (String handler : cxfClientInfo.getHandlers()) {
addToCols(handler, factory.getHandlers(), Handler.class);
}
for (String inInterceptor : cxfClientInfo.getInInterceptors()) {
addToCols(inInterceptor, factory.getInInterceptors());
}
for (String outInterceptor : cxfClientInfo.getOutInterceptors()) {
addToCols(outInterceptor, factory.getOutInterceptors());
}
for (String outFaultInterceptor : cxfClientInfo.getOutFaultInterceptors()) {
addToCols(outFaultInterceptor, factory.getOutFaultInterceptors());
}
for (String inFaultInterceptor : cxfClientInfo.getInFaultInterceptors()) {
addToCols(inFaultInterceptor, factory.getInFaultInterceptors());
}
LOGGER.debug("cxf client loaded for " + cxfClientInfo.getSei());
return factory.create();
}
use of org.apache.cxf.jaxb.WrapperHelperClassLoader in project cxf by apache.
the class Client method main.
public static void main(String[] args) throws Exception {
if (args.length == 0) {
System.err.println("please provide wsdl");
System.exit(0);
}
final Bus bus = new ExtensionManagerBus();
BusFactory.setDefaultBus(bus);
bus.setExtension(new WrapperHelperClassLoader(bus), WrapperHelperCreator.class);
bus.setExtension(new ExtensionClassLoader(bus), ExtensionClassCreator.class);
bus.setExtension(new ExceptionClassLoader(bus), ExceptionClassCreator.class);
bus.setExtension(new WrapperClassLoader(bus), WrapperClassCreator.class);
bus.setExtension(new FactoryClassLoader(bus), FactoryClassCreator.class);
bus.setExtension(new GeneratedNamespaceClassLoader(bus), NamespaceClassCreator.class);
run(args, bus);
System.exit(0);
}
Aggregations