Java Code Examples for org.apache.cxf.BusFactory#getThreadDefaultBus()
The following examples show how to use
org.apache.cxf.BusFactory#getThreadDefaultBus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractMessageResponseTimeInterceptor.java From cxf with Apache License 2.0 | 6 votes |
private void increaseCounter(Exchange ex, MessageHandlingTimeRecorder mhtr) { Bus bus = ex.getBus(); if (null == bus) { LOG.log(Level.INFO, "CAN_NOT_GET_BUS_FROM_EXCHANGE"); bus = BusFactory.getThreadDefaultBus(); } CounterRepository cr = bus.getExtension(CounterRepository.class); if (null == cr) { LOG.log(Level.WARNING, "NO_COUNTER_REPOSITORY"); return; } ObjectName serviceCountername = this.getServiceCounterName(ex); cr.increaseCounter(serviceCountername, mhtr); ObjectName operationCounter = this.getOperationCounterName(ex, serviceCountername); cr.increaseCounter(operationCounter, mhtr); }
Example 2
Source File: STSClientTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testConfigureViaEPR() throws Exception { final Set<Class<?>> addressingClasses = new HashSet<>(); addressingClasses.add(org.apache.cxf.ws.addressing.wsdl.ObjectFactory.class); addressingClasses.add(org.apache.cxf.ws.addressing.ObjectFactory.class); JAXBContext ctx = JAXBContextCache.getCachedContextAndSchemas(addressingClasses, null, null, null, true).getContext(); Unmarshaller um = ctx.createUnmarshaller(); InputStream inStream = getClass().getResourceAsStream("epr.xml"); JAXBElement<?> el = (JAXBElement<?>)um.unmarshal(inStream); EndpointReferenceType ref = (EndpointReferenceType)el.getValue(); Bus bus = BusFactory.getThreadDefaultBus(); STSClient client = new STSClient(bus); client.configureViaEPR(ref, false); assertEquals("http://localhost:8080/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl", client.getWsdlLocation()); assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService"), client.getServiceQName()); assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"), client.getEndpointQName()); }
Example 3
Source File: EndpointImpl.java From cxf with Apache License 2.0 | 6 votes |
public EndpointImpl(Bus bus, Service s, EndpointInfo ei) throws EndpointException { if (ei == null) { throw new NullPointerException("EndpointInfo can not be null!"); } if (bus == null) { this.bus = BusFactory.getThreadDefaultBus(); } else { this.bus = bus; } service = s; endpointInfo = ei; createBinding(endpointInfo.getBinding()); inFaultObserver = new InFaultChainInitiatorObserver(bus); outFaultObserver = new OutFaultChainInitiatorObserver(bus); getInFaultInterceptors().add(new ClientFaultConverter()); getOutInterceptors().add(new MessageSenderInterceptor()); getOutFaultInterceptors().add(new MessageSenderInterceptor()); }
Example 4
Source File: CachedOutputStream.java From cxf with Apache License 2.0 | 6 votes |
private void readBusProperties() { Bus b = BusFactory.getThreadDefaultBus(false); if (b != null) { String v = getBusProperty(b, CachedConstants.THRESHOLD_BUS_PROP, null); if (v != null && threshold == defaultThreshold) { threshold = Integer.parseInt(v); } v = getBusProperty(b, CachedConstants.MAX_SIZE_BUS_PROP, null); if (v != null) { maxSize = Integer.parseInt(v); } v = getBusProperty(b, CachedConstants.CIPHER_TRANSFORMATION_BUS_PROP, null); if (v != null) { cipherTransformation = v; } v = getBusProperty(b, CachedConstants.OUTPUT_DIRECTORY_BUS_PROP, null); if (v != null) { File f = new File(v); if (f.exists() && f.isDirectory()) { outputDir = f; } } } }
Example 5
Source File: STSClientTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testConfigureViaEPR() throws Exception { final Set<Class<?>> addressingClasses = new HashSet<Class<?>>(); addressingClasses.add(org.apache.cxf.ws.addressing.wsdl.ObjectFactory.class); addressingClasses.add(org.apache.cxf.ws.addressing.ObjectFactory.class); JAXBContext ctx = JAXBContextCache.getCachedContextAndSchemas(addressingClasses, null, null, null, true).getContext(); Unmarshaller um = ctx.createUnmarshaller(); InputStream inStream = getClass().getResourceAsStream("epr.xml"); JAXBElement<?> el = (JAXBElement<?>)um.unmarshal(inStream); EndpointReferenceType ref = (EndpointReferenceType)el.getValue(); Bus bus = BusFactory.getThreadDefaultBus(); STSClient client = new STSClient(bus); client.configureViaEPR(ref, false); assertEquals("http://localhost:8080/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl", client.getWsdlLocation()); assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService"), client.getServiceQName()); assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"), client.getEndpointQName()); }
Example 6
Source File: STSClientTest.java From steady with Apache License 2.0 | 6 votes |
@Test public void testConfigureViaEPR() throws Exception { final Set<Class<?>> addressingClasses = new HashSet<Class<?>>(); addressingClasses.add(org.apache.cxf.ws.addressing.wsdl.ObjectFactory.class); addressingClasses.add(org.apache.cxf.ws.addressing.ObjectFactory.class); JAXBContext ctx = JAXBContextCache.getCachedContextAndSchemas(addressingClasses, null, null, null, true).getContext(); Unmarshaller um = ctx.createUnmarshaller(); InputStream inStream = getClass().getResourceAsStream("epr.xml"); JAXBElement<?> el = (JAXBElement<?>)um.unmarshal(inStream); EndpointReferenceType ref = (EndpointReferenceType)el.getValue(); Bus bus = BusFactory.getThreadDefaultBus(); STSClient client = new STSClient(bus); client.configureViaEPR(ref, false); assertEquals("http://localhost:8080/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl", client.getWsdlLocation()); assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService"), client.getServiceQName()); assertEquals(new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port"), client.getEndpointQName()); }
Example 7
Source File: ProtobufClient.java From fuchsia with Apache License 2.0 | 5 votes |
/** * @return the bus */ public Bus getBus() { if (bus == null) { bus = BusFactory.getThreadDefaultBus(); } return bus; }
Example 8
Source File: EmbeddedJMSBrokerLauncher.java From cxf with Apache License 2.0 | 5 votes |
public static void updateWsdlExtensors(Bus bus, String wsdlLocation, String url, String encodedUrl) { try { if (encodedUrl == null) { encodedUrl = url; } if (bus == null) { bus = BusFactory.getThreadDefaultBus(); } Definition def = bus.getExtension(WSDLManager.class) .getDefinition(wsdlLocation); Map<?, ?> map = def.getAllServices(); for (Object o : map.values()) { Service service = (Service)o; Map<?, ?> ports = service.getPorts(); adjustExtensibilityElements(service.getExtensibilityElements(), url, encodedUrl); for (Object p : ports.values()) { Port port = (Port)p; adjustExtensibilityElements(port.getExtensibilityElements(), url, encodedUrl); adjustExtensibilityElements(port.getBinding().getExtensibilityElements(), url, encodedUrl); } } } catch (Exception e) { e.printStackTrace(); } }
Example 9
Source File: Server.java From cxf with Apache License 2.0 | 5 votes |
protected void run() { Object implementor = new HelloImpl(); String address = "http://localhost:" + PORT + "/wsa/responses"; ep = new EndpointImpl(BusFactory.getThreadDefaultBus(), implementor, null, getWsdl()); ep.publish(address); }
Example 10
Source File: StaticSTSProperties.java From cxf with Apache License 2.0 | 5 votes |
private ResourceManager getResourceManager() { Bus b = bus; if (b == null) { b = BusFactory.getThreadDefaultBus(); } return b.getExtension(ResourceManager.class); }
Example 11
Source File: ServerProviderFactory.java From cxf with Apache License 2.0 | 5 votes |
public static ServerProviderFactory createInstance(Bus bus) { if (bus == null) { bus = BusFactory.getThreadDefaultBus(); } ServerProviderFactory factory = new ServerProviderFactory(bus); ProviderFactory.initFactory(factory); factory.setProviders(false, false, new WebApplicationExceptionMapper(), new NioMessageBodyWriter()); factory.setBusProviders(); return factory; }
Example 12
Source File: ProtobufBindingFactory.java From fuchsia with Apache License 2.0 | 5 votes |
@Override public Bus getBus() { if (cxfbus == null) cxfbus = BusFactory.getThreadDefaultBus(); return cxfbus; }
Example 13
Source File: STSTokenRetrieverTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testSTSAsymmetricBinding() throws Exception { Bus bus = BusFactory.getThreadDefaultBus(); STSClient stsClient = initStsClientAsymmeticBinding(bus); MessageImpl message = prepareMessage(bus, stsClient, SERVICE_ENDPOINT_ASSYMETRIC); STSTokenRetriever.TokenRequestParams params = new STSTokenRetriever.TokenRequestParams(); SecurityToken token = STSTokenRetriever.getToken(message, params); validateSecurityToken(token); }
Example 14
Source File: ProtobufferExporterTest.java From fuchsia with Apache License 2.0 | 5 votes |
private AddressBookProtos.AddressBookService connectExportedProtobufAddress(ExportDeclaration declaration) throws EndpointException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, BinderException { ProtobufferExportDeclarationWrapper pojo = ProtobufferExportDeclarationWrapper.create(declaration); Bus cxfbus = BusFactory.getThreadDefaultBus(); BindingFactoryManager mgr = cxfbus.getExtension(BindingFactoryManager.class); mgr.registerBindingFactory(ProtobufBindingFactory.PROTOBUF_BINDING_ID, new ProtobufBindingFactory(cxfbus)); Class<?> bufferService = AddressBookProtos.AddressBookService.class; Class<?> bufferMessage = AddressBookProtos.AddressBookServiceMessage.class; Class<? extends Message> generic = bufferMessage.asSubclass(Message.class); RpcChannel channel = new SimpleRpcChannel(pojo.getAddress(), generic); Method method = bufferService.getMethod("newStub", RpcChannel.class); Object service = method.invoke(bufferService, channel); AddressBookProtos.AddressBookService addressBook = (AddressBookProtos.AddressBookService) service; return addressBook; }
Example 15
Source File: AsyncHTTPConduitTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testCallAsyncWithFullWorkQueue() throws Exception { Bus bus = BusFactory.getThreadDefaultBus(); WorkQueueManager workQueueManager = bus.getExtension(WorkQueueManager.class); AutomaticWorkQueueImpl automaticWorkQueue1 = (AutomaticWorkQueueImpl)workQueueManager.getAutomaticWorkQueue(); updateAddressPort(g, PORT); Client client = ClientProxy.getClient(g); HTTPConduit http = (HTTPConduit) client.getConduit(); HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); int asyncExecuteTimeout = 500; httpClientPolicy.setAsyncExecuteTimeout(asyncExecuteTimeout); http.setClient(httpClientPolicy); long repeat = automaticWorkQueue1.getHighWaterMark() + automaticWorkQueue1.getMaxSize() + 1; CountDownLatch initialThreadsLatch = new CountDownLatch(automaticWorkQueue1.getHighWaterMark()); CountDownLatch doneLatch = new CountDownLatch((int) repeat); AtomicInteger threadCount = new AtomicInteger(); for (long i = 0; i < repeat; i++) { g.greetMeLaterAsync(-50, res -> { try { int myCount = threadCount.getAndIncrement(); if (myCount < automaticWorkQueue1.getHighWaterMark()) { // Sleep long enough so that the workqueue will fill up and then // handleResponseOnWorkqueue will fail for the calls from both // responseReceived and consumeContent Thread.sleep(3 * asyncExecuteTimeout); initialThreadsLatch.countDown(); } else { Thread.sleep(50); } initialThreadsLatch.await(); doneLatch.countDown(); } catch (Exception e) { throw new RuntimeException(e); } }); } doneLatch.await(30, TimeUnit.SECONDS); assertEquals("All responses should be handled eventually", 0, doneLatch.getCount()); }
Example 16
Source File: WSDLRefValidator.java From cxf with Apache License 2.0 | 4 votes |
public WSDLRefValidator(Definition wsdl, Document doc) { this(wsdl, doc, BusFactory.getThreadDefaultBus()); }
Example 17
Source File: JsServiceFactoryBean.java From cxf with Apache License 2.0 | 4 votes |
public Bus getBus() { if (bus == null) { bus = BusFactory.getThreadDefaultBus(); } return bus; }
Example 18
Source File: ClassHelper.java From cxf with Apache License 2.0 | 4 votes |
private static Bus getBus(Bus bus) { return bus == null ? BusFactory.getThreadDefaultBus() : bus; }
Example 19
Source File: JAXRSServiceFactoryBean.java From cxf with Apache License 2.0 | 4 votes |
public Bus getBus() { Bus bus = super.getBus(); return bus == null ? BusFactory.getThreadDefaultBus() : bus; }
Example 20
Source File: JCacheOAuthDataProvider.java From cxf with Apache License 2.0 | 4 votes |
public JCacheOAuthDataProvider(boolean storeJwtTokenKeyOnly) { this(DEFAULT_CONFIG_URL, BusFactory.getThreadDefaultBus(true), storeJwtTokenKeyOnly); }