Search in sources :

Example 1 with JAXBWrapperHelper

use of org.apache.cxf.jaxb.JAXBWrapperHelper 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)

Aggregations

Bus (org.apache.cxf.Bus)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 WrapperHelperClassLoader (org.apache.cxf.jaxb.WrapperHelperClassLoader)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 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1