本文整理匯總了Java中org.apache.cxf.Bus類的典型用法代碼示例。如果您正苦於以下問題:Java Bus類的具體用法?Java Bus怎麽用?Java Bus使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Bus類屬於org.apache.cxf包,在下文中一共展示了Bus類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createSoapClient
import org.apache.cxf.Bus; //導入依賴的package包/類
public <T> T createSoapClient(Class<T> serviceClass, URL endpoint, String namespace)
{
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
Bus bus = new ExtensionManagerBus(null, null, Bus.class.getClassLoader());
factory.setBus(bus);
factory.setServiceClass(serviceClass);
factory.setServiceName(new QName(namespace, serviceClass.getSimpleName()));
factory.setAddress(endpoint.toString());
factory.getServiceFactory().getServiceConfigurations().add(0, new XFireCompatabilityConfiguration());
factory.setDataBinding(new AegisDatabinding());
@SuppressWarnings("unchecked")
T soapClient = (T) factory.create();
Client client = ClientProxy.getClient(soapClient);
client.getRequestContext().put(Message.MAINTAIN_SESSION, true);
HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setReceiveTimeout(600000);
policy.setAllowChunking(false);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
conduit.setClient(policy);
return soapClient;
}
示例2: buildClientForSecurityTokenRequests
import org.apache.cxf.Bus; //導入依賴的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;
}
示例3: buildClientForRelyingPartyTokenResponses
import org.apache.cxf.Bus; //導入依賴的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;
}
示例4: initServerLookupMap
import org.apache.cxf.Bus; //導入依賴的package包/類
/**
* Iterate over all available servers registered on the bus and build a map
* consisting of (namespace, server) pairs for later lookup, so we can
* redirect to the version-specific implementation according to the namespace
* of the incoming message.
*/
private void initServerLookupMap(SoapMessage message) {
Bus bus = message.getExchange().getBus();
ServerRegistry serverRegistry = bus.getExtension(ServerRegistry.class);
if (serverRegistry == null) {
return;
}
List<Server> temp = serverRegistry.getServers();
for (Server server : temp) {
EndpointInfo info = server.getEndpoint().getEndpointInfo();
String address = info.getAddress();
// exclude the 'dummy' routing server
if (CONFIG.getRouterEndpointPath().equals(address)) {
continue;
}
String serverNamespace = info.getName().getNamespaceURI();
actualServers.put(serverNamespace, server);
}
}
示例5: testInvokeGreeter
import org.apache.cxf.Bus; //導入依賴的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: initialize
import org.apache.cxf.Bus; //導入依賴的package包/類
@Override
public void initialize(Client client, Bus bus) {
client.getEndpoint().put("org.apache.cxf.binding.soap.addNamespaceContext", "true");
removeFaultInInterceptorFromClient(client);
// Need to remove some interceptors that are incompatible
// We don't support JAX-WS Holders for PAYLOAD (not needed anyway)
// and thus we need to remove those interceptors to prevent Holder
// object from being created and stuck into the contents list
// instead of Source objects
removeInterceptor(client.getEndpoint().getInInterceptors(),
HolderInInterceptor.class);
removeInterceptor(client.getEndpoint().getOutInterceptors(),
HolderOutInterceptor.class);
// The SoapHeaderInterceptor maps various headers onto method parameters.
// At this point, we expect all the headers to remain as headers, not
// part of the body, so we remove that one.
removeInterceptor(client.getEndpoint().getBinding().getInInterceptors(),
SoapHeaderInterceptor.class);
client.getEndpoint().getBinding().getInInterceptors().add(new ConfigureDocLitWrapperInterceptor(true));
resetPartTypes(client.getEndpoint().getBinding());
LOG.info("Initialized CXF Client: {} in Payload mode with allow streaming: {}", client, allowStreaming);
}
示例7: testBusInjectedBySpring
import org.apache.cxf.Bus; //導入依賴的package包/類
@Test
public void testBusInjectedBySpring() throws Exception {
CamelContext camelContext = (CamelContext) ctx.getBean("camel");
CxfEndpoint endpoint = camelContext.getEndpoint("cxf:bean:routerEndpoint", CxfEndpoint.class);
assertEquals("Get a wrong endpoint uri", "cxf://bean:routerEndpoint", endpoint.getEndpointUri());
Bus cxf1 = endpoint.getBus();
assertEquals(cxf1, ctx.getBean("cxf1"));
assertEquals(cxf1, endpoint.getBus());
assertEquals("barf", endpoint.getBus().getProperty("foo"));
endpoint = camelContext.getEndpoint("cxf:bean:serviceEndpoint", CxfEndpoint.class);
assertEquals("Get a wrong endpoint uri", "cxf://bean:serviceEndpoint", endpoint.getEndpointUri());
Bus cxf2 = endpoint.getBus();
assertEquals(cxf2, ctx.getBean("cxf2"));
assertEquals(cxf2, endpoint.getBus());
assertEquals("snarf", endpoint.getBus().getProperty("foo"));
}
示例8: startAndStopService
import org.apache.cxf.Bus; //導入依賴的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);
}
示例9: startAndStopServiceFromSpring
import org.apache.cxf.Bus; //導入依賴的package包/類
@Test
public void startAndStopServiceFromSpring() throws Exception {
System.setProperty("CamelCxfConsumerContext.port2", Integer.toString(PORT2));
ClassPathXmlApplicationContext applicationContext =
new ClassPathXmlApplicationContext("org/apache/camel/component/cxf/CamelCxfConsumerContext.xml");
Bus bus = applicationContext.getBean("cxf", Bus.class);
// Bus shutdown will be called when the application context is closed.
String orig = System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort", "false");
IOHelper.close(applicationContext);
System.setProperty("org.apache.cxf.transports.http_jetty.DontClosePort",
orig == null ? "true" : "false");
JettyHTTPServerEngineFactory factory = bus.getExtension(JettyHTTPServerEngineFactory.class);
// test if the port is still used
JettyHTTPServerEngine engine = factory.retrieveJettyHTTPServerEngine(PORT2);
assertNull("Jetty engine should be removed", engine);
}
示例10: testSignature
import org.apache.cxf.Bus; //導入依賴的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.Bus; //導入依賴的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.Bus; //導入依賴的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.Bus; //導入依賴的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: CamelConduit
import org.apache.cxf.Bus; //導入依賴的package包/類
public CamelConduit(CamelContext context, Bus b, EndpointInfo epInfo, EndpointReferenceType targetReference,
HeaderFilterStrategy headerFilterStrategy) {
super(getTargetReference(epInfo, targetReference, b));
String address = epInfo.getAddress();
if (address != null) {
targetCamelEndpointUri = address.substring(CamelTransportConstants.CAMEL_TRANSPORT_PREFIX.length());
if (targetCamelEndpointUri.startsWith("//")) {
targetCamelEndpointUri = targetCamelEndpointUri.substring(2);
}
}
camelContext = context;
endpointInfo = epInfo;
bus = b;
initConfig();
this.headerFilterStrategy = headerFilterStrategy;
Endpoint target = getCamelContext().getEndpoint(targetCamelEndpointUri);
try {
producer = target.createProducer();
producer.start();
} catch (Exception e) {
throw new RuntimeCamelException("Cannot create the producer rightly", e);
}
}
示例15: testCamelDestinationConfiguration
import org.apache.cxf.Bus; //導入依賴的package包/類
@Test
public void testCamelDestinationConfiguration() throws Exception {
QName testEndpointQName = new QName("http://camel.apache.org/camel-test", "port");
// set up the bus with configure file
SpringBusFactory bf = new SpringBusFactory();
BusFactory.setDefaultBus(null);
Bus bus = bf.createBus("/org/apache/camel/component/cxf/transport/CamelDestination.xml");
BusFactory.setDefaultBus(bus);
endpointInfo.setAddress("camel://direct:EndpointA");
endpointInfo.setName(testEndpointQName);
CamelDestination destination = new CamelDestination(null, bus, null, endpointInfo);
assertEquals("{http://camel.apache.org/camel-test}port.camel-destination", destination.getBeanName());
CamelContext context = destination.getCamelContext();
assertNotNull("The camel context which get from camel destination is not null", context);
assertEquals("Get the wrong camel context", context.getName(), "dest_context");
assertEquals("The camel context should has two routers", context.getRoutes().size(), 2);
bus.shutdown(false);
}