本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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());
}
示例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);
}
示例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());
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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");
}
示例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");
}