當前位置: 首頁>>代碼示例>>Java>>正文


Java BusFactory類代碼示例

本文整理匯總了Java中org.apache.cxf.BusFactory的典型用法代碼示例。如果您正苦於以下問題:Java BusFactory類的具體用法?Java BusFactory怎麽用?Java BusFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BusFactory類屬於org.apache.cxf包,在下文中一共展示了BusFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildClientForSecurityTokenRequests

import org.apache.cxf.BusFactory; //導入依賴的package包/類
/**
 * Build client for security token requests.
 *
 * @param service the rp
 * @return the security token service client
 */
public SecurityTokenServiceClient buildClientForSecurityTokenRequests(final WSFederationRegisteredService service) {
    final Bus cxfBus = BusFactory.getDefaultBus();
    final SecurityTokenServiceClient sts = new SecurityTokenServiceClient(cxfBus);
    sts.setAddressingNamespace(StringUtils.defaultIfBlank(service.getAddressingNamespace(), WSFederationConstants.HTTP_WWW_W3_ORG_2005_08_ADDRESSING));
    sts.setTokenType(StringUtils.defaultIfBlank(service.getTokenType(), WSConstants.WSS_SAML2_TOKEN_TYPE));
    sts.setKeyType(WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER);
    sts.setWsdlLocation(prepareWsdlLocation(service));
    if (StringUtils.isNotBlank(service.getPolicyNamespace())) {
        sts.setWspNamespace(service.getPolicyNamespace());
    }
    final String namespace = StringUtils.defaultIfBlank(service.getNamespace(), WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512);
    sts.setServiceQName(new QName(namespace, StringUtils.defaultIfBlank(service.getWsdlService(), WSFederationConstants.SECURITY_TOKEN_SERVICE)));
    sts.setEndpointQName(new QName(namespace, service.getWsdlEndpoint()));
    sts.getProperties().putAll(new HashMap<>());
    return sts;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:23,代碼來源:SecurityTokenServiceClientBuilder.java

示例2: buildClientForRelyingPartyTokenResponses

import org.apache.cxf.BusFactory; //導入依賴的package包/類
/**
 * Build client for relying party token responses.
 *
 * @param securityToken the security token
 * @param service       the service
 * @return the security token service client
 */
public SecurityTokenServiceClient buildClientForRelyingPartyTokenResponses(final SecurityToken securityToken,
                                                                           final WSFederationRegisteredService service) {
    final Bus cxfBus = BusFactory.getDefaultBus();
    final SecurityTokenServiceClient sts = new SecurityTokenServiceClient(cxfBus);
    sts.setAddressingNamespace(StringUtils.defaultIfBlank(service.getAddressingNamespace(), WSFederationConstants.HTTP_WWW_W3_ORG_2005_08_ADDRESSING));
    sts.setWsdlLocation(prepareWsdlLocation(service));
    final String namespace = StringUtils.defaultIfBlank(service.getNamespace(), WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512);
    sts.setServiceQName(new QName(namespace, service.getWsdlService()));
    sts.setEndpointQName(new QName(namespace, service.getWsdlEndpoint()));
    sts.setEnableAppliesTo(StringUtils.isNotBlank(service.getAppliesTo()));
    sts.setOnBehalfOf(securityToken.getToken());
    sts.setKeyType(WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER);
    sts.setTokenType(StringUtils.defaultIfBlank(service.getTokenType(), WSConstants.WSS_SAML2_TOKEN_TYPE));

    if (StringUtils.isNotBlank(service.getPolicyNamespace())) {
        sts.setWspNamespace(service.getPolicyNamespace());
    }

    return sts;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:28,代碼來源:SecurityTokenServiceClientBuilder.java

示例3: onStartup

import org.apache.cxf.BusFactory; //導入依賴的package包/類
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
	WebApplicationContext context = getContext();
	servletContext.addListener(new ContextLoaderListener(context));
	servletContext.addFilter("characterEncodingFilter", new CharacterEncodingFilter("UTF-8"));

	DispatcherServlet dispatcherServlet = new DispatcherServlet(context);
	dispatcherServlet.setThrowExceptionIfNoHandlerFound(true);

	ServletRegistration.Dynamic dispatcher = servletContext.addServlet("Dispatcher", dispatcherServlet);
	dispatcher.setLoadOnStartup(1);
	dispatcher.addMapping("/*");

	CXFServlet cxf = new CXFServlet();
	BusFactory.setDefaultBus(cxf.getBus());
	ServletRegistration.Dynamic cxfServlet = servletContext.addServlet("CXFServlet", cxf);
	cxfServlet.setLoadOnStartup(1);
	cxfServlet.addMapping("/services/*");

	servletContext.addFilter("springSecurityFilterChain", new DelegatingFilterProxy("springSecurityFilterChain")).addMappingForUrlPatterns(null, false,
			"/*");

	servletContext.getSessionCookieConfig().setSecure(cookieSecure);
}
 
開發者ID:esig,項目名稱:dss-demonstrations,代碼行數:25,代碼來源:AppInitializer.java

示例4: createJaxrsServer

import org.apache.cxf.BusFactory; //導入依賴的package包/類
@Override
public JaxrsServer createJaxrsServer(Class<?> serviceInterface, Object serviceImplementation) {
    final String serviceName = namingStrategy.get().serviceName(serviceInterface);
    final Config serverConfig = configService.createServerConfig(serviceInterface, serviceName);
    final String baseAddress = serverConfig.value(BASE_ADDRESS_PROP).orElse(StringUtils.EMPTY);
    final String serverAddress = serverConfig.value(SERVER_ADDRESS_PROP).orElse(namingStrategy.get().serverAddress(serviceInterface));
    final String fullAddress = baseAddress + serverAddress;
    LOGGER.info("Starting {} JAX-RS server ({})...", serviceInterface.getSimpleName(), fullAddress);

    final DefaultJaxrsServiceDescriptor descriptor = new DefaultJaxrsServiceDescriptor(serviceInterface, serviceName);
    decorate(descriptor, serverConfig);
    final JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setBus(BusFactory.getDefaultBus(true));
    sf.setServiceBean(serviceImplementation);

    sf.setAddress(fullAddress);
    sf.setFeatures(descriptor.getFeatures());
    sf.setProviders(descriptor.getProviders());
    final Server server = sf.create();
    LOGGER.info("Successfully started {} JAX-RS server ({}).", serviceInterface.getSimpleName(), serverAddress);
    return server::destroy;
}
 
開發者ID:Microbule,項目名稱:microbule,代碼行數:23,代碼來源:DefaultJaxrsServerFactory.java

示例5: 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

示例6: startAndStopService

import org.apache.cxf.BusFactory; //導入依賴的package包/類
@Test
public void startAndStopService() throws Exception {
    CamelContext context = new DefaultCamelContext();
    // start a server    
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            from("cxf:http://localhost:" + PORT1 + "/test?serviceClass=org.apache.camel.component.cxf.HelloService")
                .to("log:endpoint");
        }
    });
    
    context.start();
    Thread.sleep(300);
    context.stop();
    Bus bus = BusFactory.getDefaultBus();
    JettyHTTPServerEngineFactory factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
    JettyHTTPServerEngine engine = factory.retrieveJettyHTTPServerEngine(PORT1);
    assertNotNull("Jetty engine should be found there", engine);
    // Need to call the bus shutdown ourselves.
    String orig = System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", "false");
    bus.shutdown(true);
    System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort",
                       orig == null ? "true" : "false");
    engine = factory.retrieveJettyHTTPServerEngine(PORT1);
    assertNull("Jetty engine should be removed", engine);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:27,代碼來源:CxfCustomerStartStopTest.java

示例7: 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

示例8: testInvokingServiceFromCXFClient

import org.apache.cxf.BusFactory; //導入依賴的package包/類
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(simpleEndpointAddress);
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(BusFactory.getDefaultBus());

    HelloService client = (HelloService) proxyFactory.create();
    assertNotNull(client);

    String result = client.echo(TEST_MESSAGE);
    assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);

    Boolean bool = client.echoBoolean(Boolean.TRUE);
    assertNotNull("The result should not be null", bool);
    assertEquals("We should get the echo boolean result from router ", bool.toString(), "true");
    
    int beforeCallingPing = pingCounter;
    client.ping();
    int afterCallingPing = pingCounter;
    assertTrue("The ping operation doesn't be called", afterCallingPing - beforeCallingPing == 1);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:24,代碼來源:CxfConsumerResponseTest.java

示例9: execTest

import org.apache.cxf.BusFactory; //導入依賴的package包/類
private void execTest(int size) throws Exception {
    buildTestMessage(size);

    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(simpleEndpointAddress);
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(BusFactory.getDefaultBus());

    HelloService client = (HelloService) proxyFactory.create();

    String result = client.echo(testMessage);
    assertEquals("We should get the echo string result from router", "echo Hello World!", result);

    //check received requests
    assertEquals("Lengths of testMessage and receiveMessage should be equal (conversion body to String),", testMessage.length(), receivedMessageStringApplyingXPath.length());
    assertEquals("Lengths of receivedMessageByDom and receivedMessageCxfPayloadApplyingXPath should be equal", receivedMessageCxfPayloadApplyingXPath.length(), receivedMessageByDom.length());
    assertEquals("Lengths of testMessage and receiveMessage should be equal (body is CxfPayload),", testMessage.length(), receivedMessageCxfPayloadApplyingXPath.length());
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:20,代碼來源:CxfConsumerPayloadXPathClientServerTest.java

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: testInvokingServiceFromCXFClient

import org.apache.cxf.BusFactory; //導入依賴的package包/類
@Test
public void testInvokingServiceFromCXFClient() throws Exception {
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(SIMPLE_ENDPOINT_ADDRESS);
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(BusFactory.newInstance().createBus());

    HelloService client = (HelloService) proxyFactory.create();

    String result = client.echo(TEST_MESSAGE);
    assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);

    Boolean bool = client.echoBoolean(Boolean.TRUE);
    assertNotNull("The result should not be null", bool);
    assertEquals("We should get the echo boolean result from router ", bool.toString(), "true");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:CxfConsumerTest.java

示例15: testInvokingServiceFromClient

import org.apache.cxf.BusFactory; //導入依賴的package包/類
@Test
public void testInvokingServiceFromClient() throws Exception {
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(simpleEndpointAddress);
    clientBean.setServiceClass(HelloService.class);
    clientBean.setBus(BusFactory.getDefaultBus());

    HelloService client = (HelloService) proxyFactory.create();

    String result = client.echo(TEST_MESSAGE);
    assertEquals("We should get the echo string result from router", result, "echo " + TEST_MESSAGE);

    Boolean bool = client.echoBoolean(Boolean.TRUE);
    assertNotNull("The result should not be null", bool);
    assertEquals("We should get the echo boolean result from router ", bool.toString(), "true");

}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:CxfConsumerMessageTest.java


注:本文中的org.apache.cxf.BusFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。