当前位置: 首页>>代码示例>>Java>>正文


Java BusFactory.setThreadDefaultBus方法代码示例

本文整理汇总了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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:CxfConsumerWSRMTest.java

示例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());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:CxfEndpointTest.java

示例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"));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:WSSecurityRouteTest.java

示例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"));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:WSSecurityRouteTest.java

示例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"));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:WSSecurityRouteTest.java

示例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"));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:WSSecurityRouteTest.java

示例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);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:26,代码来源:ServletHelper.java

示例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);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:30,代码来源:WSTrustTestCase.java

示例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);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:27,代码来源:HelloDigestTestCase.java

示例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;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:19,代码来源:WSConnectionImpl.java

示例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);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:17,代码来源:AbstractClient.java

示例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);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:20,代码来源:WSReliableMessagingWithAPITestCase.java

示例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);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:20,代码来源:Helper.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:CxfBlueprintEndpoint.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:CxfServer.java


注:本文中的org.apache.cxf.BusFactory.setThreadDefaultBus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。