public Bus createNewBus() { return new JBossWSBusFactory().createBus(); }
@Override public void postShutdown() { JBossWSBusFactory.clearDefaultBusForAnyClassLoader(this.bus); } }
@Override public void start(final Deployment dep) { if (BusFactory.getDefaultBus(false) == null) { //Make sure the default bus is created and set for client side usage //(i.e. no server side integration contribution in it) JBossWSBusFactory.getDefaultBus(Provider.provider().getClass().getClassLoader()); } startDeploymentBus(dep); }
@Override public Bus createBus(Map<Class<?>, Object> extensions, Map<String, Object> properties) { if (extensions == null) { extensions = new HashMap<Class<?>, Object>(); } if (!extensions.containsKey(Configurer.class)) { extensions.put(Configurer.class, new JBossWSConfigurerImpl(new BeanCustomizer())); } //Explicitly ask for the ProviderImpl.class.getClassLoader() to be used for getting //cxf bus extensions (as that classloader is the jaxws-client module one which 'sees' all //extensions, unless different dependencies are explicitly set) ExtensionManagerBus bus = new ExtensionManagerBus(extensions, properties, ProviderImpl.class.getClassLoader()); possiblySetDefaultBus(bus); initializeBus(bus); bus.initialize(); DefaultHTTPConduitFactoryWrapper.install(bus); return bus; }
private Bus getOrCreateBus(String strategy, ClassLoader threadContextClassLoader) { Bus bus = null; if (THREAD_BUS_STRATEGY.equals(strategy)) { bus = setValidThreadDefaultBus(); } else if (NEW_BUS_STRATEGY.equals(strategy)) { bus = ClientBusSelector.getInstance().createNewBus(); //to prevent issues with CXF code using the default thread bus instead of the one returned here, //set the new bus as thread one, given the line above could have not done this if the current //thread is already assigned a bus BusFactory.setThreadDefaultBus(bus); } else if (TCCL_BUS_STRATEGY.equals(strategy)) { bus = JBossWSBusFactory.getClassLoaderDefaultBus(threadContextClassLoader, ClientBusSelector.getInstance()); //to prevent issues with CXF code using the default thread bus instead of the one returned here, //set the bus as thread one, given the line above could have not done this if we already had a //bus for the classloader and hence we did not create a new one BusFactory.setThreadDefaultBus(bus); } return bus; }
@Override protected void prepare(BasicWSDynamicClientBuilder builder, WSConsumer consumer) { this.bus = JBossWSBusFactory.newInstance().createBus(); final Bus prevBus = BusFactory.getThreadDefaultBus(false); try { BusFactory.setThreadDefaultBus(bus); super.prepare(builder, consumer); } finally { BusFactory.setThreadDefaultBus(prevBus); } }
JBossWSBusFactory.getDefaultBus(clientClassLoader);
public BusHolder(DDBeans metadata) { super(); this.metadata = metadata; bus = new JBossWSBusFactory().createBus(); //Force servlet transport to prevent CXF from using Jetty / http server or other transports bus.setExtension(new ServletDestinationFactory(), HttpDestinationFactory.class); }
private void setUserEndpointBus(final Deployment dep) { //first make sure the global default bus is built with visibility over client dependencies only final ClassLoader clientClassLoader = ProviderImpl.class.getClassLoader(); if (BusFactory.getDefaultBus(false) == null) { JBossWSBusFactory.getDefaultBus(clientClassLoader); } final ClassLoader cl = SecurityActions.getContextClassLoader(); try { //then set the TCCL to a delegate classloader adding jbws client integration to user deployment dependencies SecurityActions.setContextClassLoader(createDelegateClassLoader(clientClassLoader, dep.getClassLoader())); final Bus userBus = BusFactory.newInstance().createBus(); //finally, create a new Bus instance to be later assigned to the thread running the user endpoint business methods for (final Endpoint ep : dep.getService().getEndpoints()) { ep.addAttachment(Bus.class, userBus); } } finally { SecurityActions.setContextClassLoader(cl); } }
/** * Gets the default bus for the given classloader * * @param classloader * @return */ public static Bus getClassLoaderDefaultBus(final ClassLoader classloader) { Bus classLoaderBus; synchronized (classLoaderBusses) { classLoaderBus = classLoaderBusses.get(classloader); if (classLoaderBus == null) { classLoaderBus = new JBossWSBusFactory().createBus(); //register a listener for cleaning up the bus from the classloader association in the JBossWSBusFactory BusLifeCycleListener listener = new ClassLoaderDefaultBusLifeCycleListener(classLoaderBus); classLoaderBus.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(listener); classLoaderBusses.put(classloader, classLoaderBus); } } return classLoaderBus; }