Search in sources :

Example 6 with BindingFactoryManager

use of org.apache.cxf.binding.BindingFactoryManager in project tomee by apache.

the class CxfUtil method initDefaultBus.

private static Bus initDefaultBus() {
    final ClassLoader cl = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(CxfUtil.class.getClassLoader());
    try {
        // create the bus reusing cxf logic but skipping factory lookup
        final Bus bus = BusFactory.newInstance(CXFBusFactory.class.getName()).createBus();
        bus.setId(SystemInstance.get().getProperty("openejb.cxf.bus.id", "openejb.cxf.bus"));
        final BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
        bindingFactoryMap = (Map<String, BindingFactory>) Reflections.get(bfm, "bindingFactories");
        bus.setExtension(new OpenEJBHttpDestinationFactory(), HttpDestinationFactory.class);
        // ensure client proxies can use app classes
        CXFBusFactory.setDefaultBus(Bus.class.cast(Proxy.newProxyInstance(CxfUtil.class.getClassLoader(), new Class<?>[] { Bus.class }, new ClientAwareBusHandler())));
        bus.setProperty(ClassUnwrapper.class.getName(), new ClassUnwrapper() {

            @Override
            public Class<?> getRealClass(final Object o) {
                final Class<?> aClass = o.getClass();
                Class<?> c = aClass;
                while (c.getName().contains("$$")) {
                    c = c.getSuperclass();
                }
                return c == Object.class ? aClass : c;
            }
        });
        SystemInstance.get().addObserver(new LifecycleManager());
        initAuthenticators();
        // we keep as internal the real bus and just expose to cxf the client aware bus to be able to cast it easily
        return bus;
    } finally {
        Thread.currentThread().setContextClassLoader(cl);
    }
}
Also used : Bus(org.apache.cxf.Bus) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) ClassUnwrapper(org.apache.cxf.common.util.ClassUnwrapper) OpenEJBHttpDestinationFactory(org.apache.openejb.server.cxf.transport.OpenEJBHttpDestinationFactory) BindingFactory(org.apache.cxf.binding.BindingFactory)

Aggregations

BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)6 JAXRSBindingFactory (org.apache.cxf.jaxrs.JAXRSBindingFactory)4 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)3 JsonParseException (com.fasterxml.jackson.core.JsonParseException)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)2 ServiceException (com.netsteadfast.greenstep.base.exception.ServiceException)2 Bus (org.apache.cxf.Bus)2 CommonsDigester (org.apache.tika.parser.utils.CommonsDigester)2 TbSysWsConfig (com.netsteadfast.greenstep.po.hbm.TbSysWsConfig)1 ArrayList (java.util.ArrayList)1 Endpoint (javax.xml.ws.Endpoint)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 GnuParser (org.apache.commons.cli.GnuParser)1 HelpFormatter (org.apache.commons.cli.HelpFormatter)1 Options (org.apache.commons.cli.Options)1 BindingFactory (org.apache.cxf.binding.BindingFactory)1 ClassUnwrapper (org.apache.cxf.common.util.ClassUnwrapper)1 ResourceProvider (org.apache.cxf.jaxrs.lifecycle.ResourceProvider)1 SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)1