Search in sources :

Example 1 with WrapperHelperClassLoader

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);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) GeneratedClassClassLoader(org.apache.cxf.common.spi.GeneratedClassClassLoader) Service(org.apache.cxf.service.Service) GeneratedClassClassLoaderCapture(org.apache.cxf.common.spi.GeneratedClassClassLoaderCapture) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) JaxWsImplementorInfo(org.apache.cxf.jaxws.support.JaxWsImplementorInfo) JAXBWrapperHelper(org.apache.cxf.jaxb.JAXBWrapperHelper) WrapperHelperClassLoader(org.apache.cxf.jaxb.WrapperHelperClassLoader) JAXBWrapperHelper(org.apache.cxf.jaxb.JAXBWrapperHelper) WrapperHelper(org.apache.cxf.databinding.WrapperHelper) JAXBDataBinding(org.apache.cxf.jaxb.JAXBDataBinding) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Example 2 with WrapperHelperClassLoader

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();
}
Also used : Bus(org.apache.cxf.Bus) FactoryClassLoader(org.apache.cxf.jaxb.FactoryClassLoader) ExtensionClassLoader(org.apache.cxf.wsdl.ExtensionClassLoader) QName(javax.xml.namespace.QName) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) ExceptionClassLoader(org.apache.cxf.endpoint.dynamic.ExceptionClassLoader) GeneratedNamespaceClassLoader(org.apache.cxf.common.spi.GeneratedNamespaceClassLoader) WrapperHelperClassLoader(org.apache.cxf.jaxb.WrapperHelperClassLoader) WrapperClassLoader(org.apache.cxf.jaxws.spi.WrapperClassLoader)

Example 3 with WrapperHelperClassLoader

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);
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) FactoryClassLoader(org.apache.cxf.jaxb.FactoryClassLoader) ExtensionClassLoader(org.apache.cxf.wsdl.ExtensionClassLoader) GeneratedNamespaceClassLoader(org.apache.cxf.common.spi.GeneratedNamespaceClassLoader) WrapperHelperClassLoader(org.apache.cxf.jaxb.WrapperHelperClassLoader) ExceptionClassLoader(org.apache.cxf.endpoint.dynamic.ExceptionClassLoader) WrapperClassLoader(org.apache.cxf.jaxws.spi.WrapperClassLoader) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus)

Aggregations

Bus (org.apache.cxf.Bus)3 WrapperHelperClassLoader (org.apache.cxf.jaxb.WrapperHelperClassLoader)3 GeneratedNamespaceClassLoader (org.apache.cxf.common.spi.GeneratedNamespaceClassLoader)2 ExceptionClassLoader (org.apache.cxf.endpoint.dynamic.ExceptionClassLoader)2 FactoryClassLoader (org.apache.cxf.jaxb.FactoryClassLoader)2 WrapperClassLoader (org.apache.cxf.jaxws.spi.WrapperClassLoader)2 ExtensionClassLoader (org.apache.cxf.wsdl.ExtensionClassLoader)2 QName (javax.xml.namespace.QName)1 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)1 GeneratedClassClassLoader (org.apache.cxf.common.spi.GeneratedClassClassLoader)1 GeneratedClassClassLoaderCapture (org.apache.cxf.common.spi.GeneratedClassClassLoaderCapture)1 WrapperHelper (org.apache.cxf.databinding.WrapperHelper)1 JAXBDataBinding (org.apache.cxf.jaxb.JAXBDataBinding)1 JAXBWrapperHelper (org.apache.cxf.jaxb.JAXBWrapperHelper)1 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)1 JaxWsImplementorInfo (org.apache.cxf.jaxws.support.JaxWsImplementorInfo)1 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)1 Service (org.apache.cxf.service.Service)1 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1