本文整理汇总了Java中org.apache.cxf.BusFactory.getThreadDefaultBus方法的典型用法代码示例。如果您正苦于以下问题:Java BusFactory.getThreadDefaultBus方法的具体用法?Java BusFactory.getThreadDefaultBus怎么用?Java BusFactory.getThreadDefaultBus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.BusFactory
的用法示例。
在下文中一共展示了BusFactory.getThreadDefaultBus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBusCreation
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public static void testBusCreation() throws BusTestException
{
Bus initialDefaultBus = BusFactory.getDefaultBus(false);
Bus initialThreadBus = BusFactory.getThreadDefaultBus(false);
BusFactory factory = BusFactory.newInstance();
Bus bus = factory.createBus();
assert (bus != null);
if (initialThreadBus == null) //if the thread bus was not set before, it should now be
{
checkThreadBus(bus);
}
checkDefaultBus(initialDefaultBus);
BusFactory.setThreadDefaultBus(initialThreadBus);
checkThreadBus(initialThreadBus);
checkDefaultBus(initialDefaultBus);
}
示例2: testSOAPConnection
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public static void testSOAPConnection(String host) throws BusTestException, Exception
{
Bus initialDefaultBus = BusFactory.getDefaultBus(false);
Bus initialThreadBus = BusFactory.getThreadDefaultBus(false);
//first call... the thread bus is reused if not null, otherwise a new one is created
performSOAPCall(getEndpointURL(host));
checkDefaultBus(initialDefaultBus);
if (initialThreadBus != null)
{
checkThreadBus(initialThreadBus);
}
else
{
initialThreadBus = BusFactory.getThreadDefaultBus(false);
}
//second call...
performSOAPCall(getEndpointURL(host));
checkThreadBus(initialThreadBus);
checkDefaultBus(initialDefaultBus);
}
示例3: testWebServiceRef
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public static void testWebServiceRef(Endpoint port) throws BusTestException
{
Bus initialDefaultBus = BusFactory.getDefaultBus(false);
Bus threadBus = BusFactory.getThreadDefaultBus(false);
performInvocation(port); //does not change anything to the bus, as the port is already created when injecting serviceref
checkDefaultBus(initialDefaultBus);
checkThreadBus(threadBus);
try
{
BusFactory.setThreadDefaultBus(null);
performInvocation(port); //does not change anything to the bus, as the port is already created when injecting serviceref
checkDefaultBus(initialDefaultBus);
checkThreadBus(null);
BusFactory factory = BusFactory.newInstance();
Bus bus = factory.createBus(); //internally sets the thread bus
performInvocation(port); //does not change anything to the bus, as the port is already created when injecting serviceref
checkDefaultBus(initialDefaultBus);
checkThreadBus(bus);
}
finally
{
BusFactory.setThreadDefaultBus(threadBus);
}
}
示例4: createServiceDelegate
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public ServiceDelegate createServiceDelegate(URL url, QName qname, Class cls)
{
final String busStrategy = ClientBusSelector.getInstance().selectStrategy();
ClassLoader origClassLoader = getContextClassLoader();
boolean restoreTCCL = false;
Bus orig = null;
try
{
restoreTCCL = checkAndFixContextClassLoader(origClassLoader);
orig = BusFactory.getThreadDefaultBus(false);
Bus bus = getOrCreateBus(busStrategy, origClassLoader);
ServiceDelegate serviceDelegate = new JBossWSServiceImpl(bus, url, qname, cls);
setDisableCacheSchema(bus);
return serviceDelegate;
}
finally
{
restoreThreadDefaultBus(busStrategy, orig);
if (restoreTCCL)
setContextClassLoader(origClassLoader);
}
}
示例5: createDispatch
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public <T> Dispatch<T> createDispatch(Class<T> type, Mode mode) throws IOException {
if (this.wsdlService == null) {
Bus bus = BusFactory.getThreadDefaultBus();
BusFactory.setThreadDefaultBus(this.mcf.getBus());
try {
this.wsdlService = Service.create(this.mcf.getWsdlUrl(), this.mcf.getServiceQName());
} finally {
BusFactory.setThreadDefaultBus(bus);
}
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_WS, "Created the WSDL service for", this.mcf.getWsdl()); //$NON-NLS-1$
}
}
Dispatch<T> dispatch = this.wsdlService.createDispatch(this.mcf.getPortQName(), type, mode);
configureWSSecurity(dispatch);
setDispatchProperties(dispatch, "SOAP12"); //$NON-NLS-1$
return dispatch;
}
示例6: setUpCXFCamelContext
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
/**
* Initialize CamelTransportFactory without Spring
*/
@Before
public void setUpCXFCamelContext() {
bus = BusFactory.getThreadDefaultBus();
// make sure the CamelTransportFactory is injected with right camel context
bus.getExtension(CamelTransportFactory.class).setCamelContext(context);
}
示例7: newInstance
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public static WinRm newInstance(Bus bus) {
Bus prevBus = BusFactory.getAndSetThreadDefaultBus(bus);
try {
// The default thread bus is set on the ClientImpl and used for further requests
return createService(bus);
} finally {
if (BusFactory.getThreadDefaultBus(false) != prevBus) {
BusFactory.setThreadDefaultBus(prevBus);
}
}
}
示例8: testWebServiceClient
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public static void testWebServiceClient(String host) throws BusTestException, Exception
{
Bus initialDefaultBus = BusFactory.getDefaultBus(false);
performInvocation(getEndpointURL(host));
checkDefaultBus(initialDefaultBus);
//check client usage does not rely on default bus when no thread bus is set
Bus threadBus = BusFactory.getThreadDefaultBus(false);
try
{
final String url = getEndpointURL(host);
BusFactory.setThreadDefaultBus(null);
performInvocation(url); //goes through ServiceDelegate which sets the thread bus if it's null
Bus newThreadBus = BusFactory.getThreadDefaultBus(false);
if (ClientBusSelector.getDefaultStrategy().equals(Constants.THREAD_BUS_STRATEGY)) {
if (newThreadBus == initialDefaultBus)
{
throw new BusTestException("Thread bus set to former default bus " + initialDefaultBus + " instead of a new bus!");
}
else if (newThreadBus == threadBus)
{
throw new BusTestException("Thread bus set to former thread bus " + threadBus + " instead of a new bus!");
}
} else {
if (newThreadBus != null) {
throw new BusTestException("Thread bus set to " + newThreadBus + " instead of null!");
}
}
performInvocation(url);
checkThreadBus(newThreadBus); //the thread bus is not changed as it's not null
checkDefaultBus(initialDefaultBus);
}
finally
{
BusFactory.setThreadDefaultBus(threadBus);
}
}
示例9: checkThreadBus
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
protected static void checkThreadBus(Bus expectedThreadBus) throws BusTestException
{
Bus bus = BusFactory.getThreadDefaultBus(false);
if (expectedThreadBus == null && bus != null)
{
throw new BusTestException("Thread " + Thread.currentThread() + " associated with bus " + bus
+ " instead of expected null bus");
}
if (bus != expectedThreadBus)
{
throw new BusTestException("Thread " + Thread.currentThread() + " associated with bus " + bus
+ " instead of expected bus " + expectedThreadBus);
}
}
示例10: createNewBus
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
private Bus createNewBus(final UnifiedServiceRefMetaData serviceRefMD)
{
final Bus bus;
Bus threadBus = BusFactory.getThreadDefaultBus(false);
bus = threadBus != null ? threadBus : BusFactory.newInstance().createBus();
Configurer configurer = bus.getExtension(Configurer.class);
bus.setExtension(new CXFServiceRefStubPropertyConfigurer(serviceRefMD, configurer), Configurer.class);
return bus;
}
示例11: setValidThreadDefaultBus
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
private Bus setValidThreadDefaultBus()
{
//we need to prevent using the default bus when the current
//thread is not already associated to a bus. In those situations we create
//a new bus from scratch instead and link that to the thread.
Bus bus = BusFactory.getThreadDefaultBus(false);
if (bus == null)
{
bus = ClientBusSelector.getInstance().createNewBus(); //this also set thread local bus internally as it's not set yet
}
return bus;
}
示例12: getConduitInitiator
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
private ConduitInitiator getConduitInitiator(String address) throws SOAPException
{
ConduitInitiator ci = null;
try
{
//do not use getThreadDefaultBus(true) in order to avoid getting the default bus
Bus bus = BusFactory.getThreadDefaultBus(false);
if (bus == null)
{
bus = BusFactory.newInstance().createBus();
}
ConduitInitiatorManager mgr = bus.getExtension(ConduitInitiatorManager.class);
if (address.startsWith("http"))
{
ci = mgr.getConduitInitiator("http://cxf.apache.org/transports/http");
}
if (ci == null)
{
ci = mgr.getConduitInitiatorForUri(address);
}
}
catch (Exception ex)
{
throw MESSAGES.noConduitInitiatorAvailableFor2(address, ex);
}
if (ci == null)
{
throw MESSAGES.noConduitInitiatorAvailableFor(address);
}
return ci;
}
示例13: performInvocation
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
/**
* This overrides org.apache.cxf.jaxws.AbstractInvoker in order for using the JBossWS integration logic
* to invoke the JBoss AS target bean.
*/
@Override
protected Object performInvocation(Exchange exchange, final Object serviceObject, Method m, Object[] paramArray)
throws Exception
{
Endpoint ep = exchange.get(Endpoint.class);
final InvocationHandler invHandler = ep.getInvocationHandler();
final Invocation inv = createInvocation(invHandler, serviceObject, ep, m, paramArray);
if (factory != null) {
inv.getInvocationContext().setProperty("forceTargetBean", true);
}
Bus threadBus = BusFactory.getThreadDefaultBus(false);
BusFactory.setThreadDefaultBus(disableDepUserDefThreadBus ? null : ep.getAttachment(Bus.class));
setNamespaceContextSelector(exchange);
ClassLoader cl = SecurityActions.getContextClassLoader();
SecurityActions.setContextClassLoader(serviceObject.getClass().getClassLoader());
try {
invHandler.invoke(ep, inv);
return inv.getReturnValue();
} finally {
SecurityActions.setContextClassLoader(cl);
//make sure the right bus is restored after coming back from the endpoint method
BusFactory.setThreadDefaultBus(threadBus);
clearNamespaceContextSelector(exchange);
}
}
示例14: handle
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Override
public void handle(HttpExchange ex) throws IOException
{
ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
final Bus origBus = BusFactory.getThreadDefaultBus();
if (bus != null) {
BusFactory.setThreadDefaultBus(bus);
}
try
{
SecurityActions.setContextClassLoader(this.classLoader);
this.handle(new HttpExchangeDelegate(ex));
}
catch (Exception e)
{
LOG.throwing(Handler.class.getName(), "handle(" + HttpExchange.class.getName() + " ex)", e);
if (e instanceof IOException)
{
throw (IOException) e;
}
else
{
throw new RuntimeException(e);
}
}
finally
{
if (bus != null) {
SecurityActions.setContextClassLoader(origClassLoader);
BusFactory.setThreadDefaultBus(origBus);
}
}
}
示例15: handleRequest
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Override
public void handleRequest(HttpServerExchange ex) throws IOException
{
ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
final Bus origBus = BusFactory.getThreadDefaultBus();
if (bus != null) {
BusFactory.setThreadDefaultBus(bus);
}
try
{
SecurityActions.setContextClassLoader(this.classLoader);
super.handleRequest(ex);
}
catch (Exception e)
{
LOG.throwing(SwitchYardHttpHandler.class.getName(), "handle(" + HttpExchange.class.getName() + " ex)", e);
if (e instanceof IOException)
{
throw (IOException) e;
}
else
{
throw new RuntimeException(e);
}
}
finally
{
if (bus != null) {
SecurityActions.setContextClassLoader(origClassLoader);
BusFactory.setThreadDefaultBus(origBus);
}
}
}