本文整理汇总了Java中org.apache.cxf.BusFactory.setThreadDefaultBus方法的典型用法代码示例。如果您正苦于以下问题:Java BusFactory.setThreadDefaultBus方法的具体用法?Java BusFactory.setThreadDefaultBus怎么用?Java BusFactory.setThreadDefaultBus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.BusFactory
的用法示例。
在下文中一共展示了BusFactory.setThreadDefaultBus方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testInvokeGreeter
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Test
public void testInvokeGreeter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
Bus clientBus = context.getRegistry().lookupByNameAndType("client-bus", Bus.class);
assertNotNull(clientBus);
BusFactory.setThreadDefaultBus(clientBus);
try {
Service service = Service.create(SERVICE_NAME);
service.addPort(PORT_NAME, "http://schemas.xmlsoap.org/soap/",
"http://localhost:" + CXFTestSupport.getPort1() + "/CxfConsumerWSRMTest/router");
Greeter greeter = service.getPort(PORT_NAME, Greeter.class);
greeter.greetMeOneWay("test");
} finally {
BusFactory.setThreadDefaultBus(null);
}
assertMockEndpointsSatisfied();
}
示例2: testSettingClientBus
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Test
public void testSettingClientBus() throws Exception {
ExtensionManagerBus bus = (ExtensionManagerBus) BusFactory.newInstance().createBus();
bus.setId("oldCXF");
BusFactory.setThreadDefaultBus(bus);
ExtensionManagerBus newBus = (ExtensionManagerBus) BusFactory.newInstance().createBus();
newBus.setId("newCXF");
CxfComponent cxfComponent = new CxfComponent(new DefaultCamelContext());
CxfEndpoint endpoint = (CxfEndpoint)cxfComponent.createEndpoint(routerEndpointURI);
endpoint.setBus(newBus);
CamelCxfClientImpl client = (CamelCxfClientImpl)endpoint.createClient();
assertEquals("CamelCxfClientImpl should has the same bus with CxfEndpoint", newBus, client.getBus());
endpoint = (CxfEndpoint)cxfComponent.createEndpoint(wsdlEndpointURI);
endpoint.setBus(newBus);
client = (CamelCxfClientImpl)endpoint.createClient();
assertEquals("CamelCxfClientImpl should has the same bus with CxfEndpoint", newBus, client.getBus());
}
示例3: testSignature
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Test
public void testSignature() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterSignaturePort();
((BindingProvider)greeter).getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:" + CXFTestSupport.getPort2()
+ "/WSSecurityRouteTest/GreeterSignaturePort"
);
assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
示例4: testUsernameToken
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Test
public void testUsernameToken() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterUsernameTokenPort();
((BindingProvider)greeter).getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:" + CXFTestSupport.getPort2()
+ "/WSSecurityRouteTest/GreeterUsernameTokenPort"
);
assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
示例5: testEncryption
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Test
public void testEncryption() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterEncryptionPort();
((BindingProvider)greeter).getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:" + CXFTestSupport.getPort2()
+ "/WSSecurityRouteTest/GreeterEncryptionPort"
);
assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
示例6: testSecurityPolicy
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Test
public void testSecurityPolicy() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = WSSecurityRouteTest.class.getResource("../client/wssec.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
GreeterService gs = new GreeterService();
Greeter greeter = gs.getGreeterSecurityPolicyPort();
((BindingProvider)greeter).getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:" + CXFTestSupport.getPort2()
+ "/WSSecurityRouteTest/GreeterSecurityPolicyPort"
);
assertEquals("Get a wrong response", "Hello Security", greeter.greetMe("Security"));
}
示例7: callRequestHandler
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public static void callRequestHandler(HttpServletRequest req, HttpServletResponse res, ServletContext ctx, Bus bus,
Endpoint endpoint) throws ServletException
{
try
{
BusFactory.setThreadDefaultBus(bus);
//set the current endpoint into the threadlocal association that is later
//used by the EndpointAssociationInterceptor for linking the message exchange
//related to this invocation to the proper endpoint serving it (the bus, and
//hence the interceptor, can span multiple invocation related to multiple
//endpoints)
EndpointAssociation.setEndpoint(endpoint);
RequestHandler requestHandler = (RequestHandler) endpoint.getRequestHandler();
requestHandler.handleHttpRequest(endpoint, req, res, ctx);
}
catch (IOException ioe)
{
throw new ServletException(ioe);
}
finally
{
EndpointAssociation.removeEndpoint();
BusFactory.setThreadDefaultBus(null);
}
}
示例8: testNoClientCallback
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
/**
* No CallbackHandler is provided in STSCLient. Username and password provided instead.
*
* @throws Exception
*/
@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void testNoClientCallback() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
try {
BusFactory.setThreadDefaultBus(bus);
final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService");
final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService");
final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port");
URL stsURL = new URL(serviceURL.getProtocol(), serviceURL.getHost(), serviceURL.getPort(), "/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl");
WSTrustTestUtils.setupWsseAndSTSClientNoCallbackHandler(proxy, bus, stsURL.toString(), stsServiceName, stsPortName);
assertEquals("WS-Trust Hello World!", proxy.sayHello());
} finally {
bus.shutdown(true);
}
}
示例9: testDigestAuthFail
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Test
@RunAsClient
public void testDigestAuthFail() throws Exception
{
final Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
try {
QName serviceName = new QName("http://jboss.org/http/security", "HelloService");
URL wsdlURL = getResourceURL("jaxws/cxf/httpauth/WEB-INF/wsdl/hello.wsdl");
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
Hello proxy = (Hello)service.getPort(Hello.class);
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL.toString());
((BindingProvider)proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jbossws");
((BindingProvider)proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "wrongPwd");
HTTPConduit cond = (HTTPConduit)ClientProxy.getClient(proxy).getConduit();
cond.setAuthSupplier(new DigestAuthSupplier());
try {
proxy.helloRequest("number");
fail("Authorization exception expected!");
} catch (Exception e) {
assertTrue(e.getCause().getMessage().contains("Authorization"));
}
} finally {
bus.shutdown(true);
}
}
示例10: 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;
}
示例11: 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);
}
示例12: test
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Test
@RunAsClient
public void test() throws Exception
{
final Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
try {
QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "SimpleService");
URL wsdlURL = getResourceURL("jaxws/samples/wsrm/WEB-INF/wsdl/SimpleService.wsdl");
Service service = Service.create(wsdlURL, serviceName);
SimpleService proxy = (SimpleService)service.getPort(SimpleService.class);
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, baseURL + "/jaxws-samples-wsrm-api/SimpleService");
assertEquals("Hello World!", proxy.echo("Hello World!")); // request response call
proxy.ping(); // one way call
} finally {
bus.shutdown(true);
}
}
示例13: testGZIPUsingFeatureOnClient
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public boolean testGZIPUsingFeatureOnClient() throws Exception
{
Bus bus = BusFactory.newInstance().createBus();
try
{
BusFactory.setThreadDefaultBus(bus);
HelloWorld port = getPort();
ClientConfigurer configurer = ClientConfigUtil.resolveClientConfigurer();
configurer.setConfigProperties(port, "jaxws-client-config.xml", "Feature Client Config");
return "foo".equals(port.echo("foo"));
}
finally
{
bus.shutdown(true);
}
}
示例14: destroy
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public void destroy() {
// Clean up the BusFactory's defaultBus
// This method is not called magically, blueprint
// needs you to set the destroy-method.
BusFactory.setDefaultBus(null);
BusFactory.setThreadDefaultBus(null);
}
示例15: CxfServer
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public CxfServer() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = WSSecurityRouteTest.class.getResource("../server/wssec.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
}