本文整理汇总了Java中org.apache.cxf.BusFactory.getDefaultBus方法的典型用法代码示例。如果您正苦于以下问题:Java BusFactory.getDefaultBus方法的具体用法?Java BusFactory.getDefaultBus怎么用?Java BusFactory.getDefaultBus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cxf.BusFactory
的用法示例。
在下文中一共展示了BusFactory.getDefaultBus方法的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: 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);
}
示例4: 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);
}
示例5: testSOAPConnection
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public static void testSOAPConnection(String host) throws BusTestException, Exception
{
Bus initialDefaultBus = BusFactory.getDefaultBus(false);
Bus initialThreadBus = BusFactory.getThreadDefaultBus(false);
//first call... the thread bus is reused if not null, otherwise a new one is created
performSOAPCall(getEndpointURL(host));
checkDefaultBus(initialDefaultBus);
if (initialThreadBus != null)
{
checkThreadBus(initialThreadBus);
}
else
{
initialThreadBus = BusFactory.getThreadDefaultBus(false);
}
//second call...
performSOAPCall(getEndpointURL(host));
checkThreadBus(initialThreadBus);
checkDefaultBus(initialDefaultBus);
}
示例6: testWebServiceRef
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public static void testWebServiceRef(Endpoint port) throws BusTestException
{
Bus initialDefaultBus = BusFactory.getDefaultBus(false);
Bus threadBus = BusFactory.getThreadDefaultBus(false);
performInvocation(port); //does not change anything to the bus, as the port is already created when injecting serviceref
checkDefaultBus(initialDefaultBus);
checkThreadBus(threadBus);
try
{
BusFactory.setThreadDefaultBus(null);
performInvocation(port); //does not change anything to the bus, as the port is already created when injecting serviceref
checkDefaultBus(initialDefaultBus);
checkThreadBus(null);
BusFactory factory = BusFactory.newInstance();
Bus bus = factory.createBus(); //internally sets the thread bus
performInvocation(port); //does not change anything to the bus, as the port is already created when injecting serviceref
checkDefaultBus(initialDefaultBus);
checkThreadBus(bus);
}
finally
{
BusFactory.setThreadDefaultBus(threadBus);
}
}
示例7: setUserEndpointBus
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
private void setUserEndpointBus(final Deployment dep) {
//first make sure the global default bus is built with visibility over client dependencies only
final ClassLoader clientClassLoader = ProviderImpl.class.getClassLoader();
if (BusFactory.getDefaultBus(false) == null)
{
JBossWSBusFactory.getDefaultBus(clientClassLoader);
}
final ClassLoader cl = SecurityActions.getContextClassLoader();
try {
//then set the TCCL to a delegate classloader adding jbws client integration to user deployment dependencies
SecurityActions.setContextClassLoader(createDelegateClassLoader(clientClassLoader, dep.getClassLoader()));
final Bus userBus = BusFactory.newInstance().createBus();
//finally, create a new Bus instance to be later assigned to the thread running the user endpoint business methods
for (final Endpoint ep : dep.getService().getEndpoints()) {
ep.addAttachment(Bus.class, userBus);
}
} finally {
SecurityActions.setContextClassLoader(cl);
}
}
示例8: importFrom
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public void importFrom(String url) {
this.wsServices.clear();
this.wsOperations.clear();
this.structures.clear();
this.wsdlLocation = url;
try {
Bus bus = BusFactory.getDefaultBus();
WSDLManager wsdlManager = bus.getExtension(WSDLManager.class);
Definition def = wsdlManager.getDefinition(url);
WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
List<ServiceInfo> services = builder.buildServices(def);
for (ServiceInfo service : services) {
WSService wsService = this.importService(service);
this.wsServices.put(this.namespace + wsService.getName(), wsService);
}
this.importTypes(def.getTypes());
} catch (WSDLException e) {
e.printStackTrace();
}
}
示例9: setUp
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
bus = BusFactory.getDefaultBus();
super.setUp();
}
示例10: disposeBus
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
private static synchronized void disposeBus() {
busUsageCount--;
LOG.ok("bus dispose (usage count = {0})", busUsageCount);
if (busUsageCount == 0) {
Bus bus = BusFactory.getDefaultBus(false);
if (bus != null) {
LOG.ok("Shutting down WinRm CXF bus {0}", bus);
bus.shutdown(true);
LOG.ok("Bus shut down");
}
}
}
示例11: testWebServiceClient
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
public static void testWebServiceClient(String host) throws BusTestException, Exception
{
Bus initialDefaultBus = BusFactory.getDefaultBus(false);
performInvocation(getEndpointURL(host));
checkDefaultBus(initialDefaultBus);
//check client usage does not rely on default bus when no thread bus is set
Bus threadBus = BusFactory.getThreadDefaultBus(false);
try
{
final String url = getEndpointURL(host);
BusFactory.setThreadDefaultBus(null);
performInvocation(url); //goes through ServiceDelegate which sets the thread bus if it's null
Bus newThreadBus = BusFactory.getThreadDefaultBus(false);
if (ClientBusSelector.getDefaultStrategy().equals(Constants.THREAD_BUS_STRATEGY)) {
if (newThreadBus == initialDefaultBus)
{
throw new BusTestException("Thread bus set to former default bus " + initialDefaultBus + " instead of a new bus!");
}
else if (newThreadBus == threadBus)
{
throw new BusTestException("Thread bus set to former thread bus " + threadBus + " instead of a new bus!");
}
} else {
if (newThreadBus != null) {
throw new BusTestException("Thread bus set to " + newThreadBus + " instead of null!");
}
}
performInvocation(url);
checkThreadBus(newThreadBus); //the thread bus is not changed as it's not null
checkDefaultBus(initialDefaultBus);
}
finally
{
BusFactory.setThreadDefaultBus(threadBus);
}
}
示例12: checkDefaultBus
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
protected static void checkDefaultBus(Bus expectedDefaultBus) throws BusTestException
{
Bus bus = BusFactory.getDefaultBus(false);
if (bus != expectedDefaultBus)
{
throw new BusTestException("Default bus set to " + bus + " instead of expected " + expectedDefaultBus);
}
}
示例13: checkAndFixContextClassLoader
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
/**
* Ensure the current context classloader can load this ProviderImpl class.
*
* @return true if the TCCL has been changed, false otherwise
*/
static boolean checkAndFixContextClassLoader(ClassLoader origClassLoader)
{
try
{
origClassLoader.loadClass(ProviderImpl.class.getName());
}
catch (Exception e)
{
//[JBWS-3223] On AS7 the TCCL that's set for basic (non-ws-endpoint) servlet/ejb3
//apps doesn't have visibility on any WS implementation class, nor on any class
//coming from dependencies provided in the ws modules only. This means for instance
//the JAXBContext is not going to find a context impl, etc.
//In general, we need to change the TCCL using the classloader that has been used
//to load this javax.xml.ws.spi.Provider impl, which is the jaxws-client module.
ClassLoader clientClassLoader = ProviderImpl.class.getClassLoader();
//first ensure the default bus is loaded through the client classloader only
//(no deployment classloader contribution)
if (BusFactory.getDefaultBus(false) == null)
{
JBossWSBusFactory.getDefaultBus(clientClassLoader);
}
//then setup a new TCCL having visibility over both the client path (JBossWS
//jaxws-client module on AS7) and the the former TCCL (i.e. the deployment classloader)
setContextClassLoader(createDelegateClassLoader(clientClassLoader, origClassLoader));
return true;
}
return false;
}
示例14: getDefaultBus
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
/**
* Gets (and internally sets) the default bus after having set the thread
* context class loader to the provided one (which affects the Bus
* construction if it's not been created yet). The former thread context
* class loader is restored before returning to the caller.
*
* @param contextClassLoader
* @return the default bus
*/
public static Bus getDefaultBus(ClassLoader contextClassLoader)
{
ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
try
{
SecurityActions.setContextClassLoader(contextClassLoader);
return BusFactory.getDefaultBus();
}
finally
{
SecurityActions.setContextClassLoader(origClassLoader);
}
}
示例15: start
import org.apache.cxf.BusFactory; //导入方法依赖的package包/类
@Override
public void start(final Deployment dep)
{
if (BusFactory.getDefaultBus(false) == null)
{
//Make sure the default bus is created and set for client side usage
//(i.e. no server side integration contribution in it)
JBossWSBusFactory.getDefaultBus(Provider.provider().getClass().getClassLoader());
}
startDeploymentBus(dep);
}