Java Code Examples for org.apache.cxf.endpoint.Endpoint#put()
The following examples show how to use
org.apache.cxf.endpoint.Endpoint#put() .
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: AbstractJAXRSFactoryBean.java From cxf with Apache License 2.0 | 6 votes |
protected void setupFactory(ProviderFactory factory, Endpoint ep) { if (providerComparator != null) { factory.setProviderComparator(providerComparator); } if (entityProviders != null) { factory.setUserProviders(entityProviders); } setDataBindingProvider(factory, ep.getService()); factory.setBus(getBus()); factory.initProviders(serviceFactory.getRealClassResourceInfo()); if (schemaLocations != null) { factory.setSchemaLocations(schemaLocations); } ep.put(factory.getClass().getName(), factory); }
Example 2
Source File: MAPAggregatorImpl.java From cxf with Apache License 2.0 | 6 votes |
/** * Determine if the use of addressing is indicated by the presence of a * the usingAddressing attribute. * * @param message the current message * @pre message is outbound * @pre requestor role */ private boolean hasUsingAddressing(Message message) { boolean ret = false; Endpoint endpoint = message.getExchange().getEndpoint(); if (null != endpoint) { Boolean b = (Boolean)endpoint.get(USING_ADDRESSING); if (null == b) { EndpointInfo endpointInfo = endpoint.getEndpointInfo(); List<ExtensibilityElement> endpointExts = endpointInfo != null ? endpointInfo .getExtensors(ExtensibilityElement.class) : null; List<ExtensibilityElement> bindingExts = endpointInfo != null && endpointInfo.getBinding() != null ? endpointInfo .getBinding().getExtensors(ExtensibilityElement.class) : null; List<ExtensibilityElement> serviceExts = endpointInfo != null && endpointInfo.getService() != null ? endpointInfo .getService().getExtensors(ExtensibilityElement.class) : null; ret = hasUsingAddressing(endpointExts) || hasUsingAddressing(bindingExts) || hasUsingAddressing(serviceExts); b = ret ? Boolean.TRUE : Boolean.FALSE; endpoint.put(USING_ADDRESSING, b); } else { ret = b.booleanValue(); } } return ret; }
Example 3
Source File: AbstractMetricsInterceptor.java From cxf with Apache License 2.0 | 6 votes |
private Object createEndpointMetrics(Message m) { final Endpoint ep = m.getExchange().getEndpoint(); Object o = ep.get(MetricsContext.class.getName()); if (o == null) { List<MetricsContext> contexts = new ArrayList<>(); for (MetricsProvider p : getMetricProviders(m.getExchange().getBus())) { MetricsContext c = p.createEndpointContext(ep, MessageUtils.isRequestor(m), (String)m.getContextualProperty(MetricsProvider.CLIENT_ID)); if (c != null) { contexts.add(c); } if (c instanceof Closeable) { ep.addCleanupHook((Closeable)c); } } if (contexts.size() == 1) { o = contexts.get(0); } else { o = contexts; } ep.put(MetricsContext.class.getName(), o); } return o; }
Example 4
Source File: AbstractJAXRSFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
protected Endpoint createEndpoint() throws BusException, EndpointException { Service service = serviceFactory.getService(); if (service == null) { service = serviceFactory.create(); } EndpointInfo ei = createEndpointInfo(service); Endpoint ep = new EndpointImpl(getBus(), service, ei); if (properties != null) { ep.putAll(properties); } if (getInInterceptors() != null) { ep.getInInterceptors().addAll(getInInterceptors()); } if (getOutInterceptors() != null) { ep.getOutInterceptors().addAll(getOutInterceptors()); } if (getInFaultInterceptors() != null) { ep.getInFaultInterceptors().addAll(getInFaultInterceptors()); } if (getOutFaultInterceptors() != null) { ep.getOutFaultInterceptors().addAll(getOutFaultInterceptors()); } List<ClassResourceInfo> list = serviceFactory.getRealClassResourceInfo(); for (ClassResourceInfo cri : list) { initializeAnnotationInterceptors(ep, cri.getServiceClass()); serviceFactory.sendEvent(FactoryBeanListener.Event.ENDPOINT_SELECTED, ei, ep, cri.getServiceClass(), null); } ep.put(JAXRSServiceFactoryBean.class.getName(), serviceFactory); return ep; }
Example 5
Source File: SpringViewResolverProviderTest.java From cxf with Apache License 2.0 | 5 votes |
@Before public void setUp() { this.viewResolver = new SpringViewResolverProvider(viewResolverMock, localeResolverMock); ExchangeImpl exchange = new ExchangeImpl(); Endpoint endpoint = new MockEndpoint(); endpoint.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance()); exchange.put(Endpoint.class, endpoint); exchange.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance()); MessageImpl message = new MessageImpl(); message.setExchange(exchange); message.put(AbstractHTTPDestination.HTTP_REQUEST, requestMock); message.put(AbstractHTTPDestination.HTTP_RESPONSE, responseMock); message.put(AbstractHTTPDestination.HTTP_CONTEXT, servletContextMock); viewResolver.setMessageContext(new MessageContextImpl(message)); }
Example 6
Source File: RMManager.java From cxf with Apache License 2.0 | 5 votes |
/** * Clones and saves the interceptor chain the first time this is called, so that it can be used for retransmission. * Calls after the first are ignored. * * @param msg */ public void initializeInterceptorChain(Message msg) { Endpoint ep = msg.getExchange().getEndpoint(); synchronized (ep) { if (ep.get(WSRM_RETRANSMIT_CHAIN) == null) { LOG.info("Setting retransmit chain from message"); PhaseInterceptorChain chain = (PhaseInterceptorChain)msg.getInterceptorChain(); chain = chain.cloneChain(); ep.put(WSRM_RETRANSMIT_CHAIN, chain); } } }
Example 7
Source File: AbstractMetricsInterceptor.java From cxf with Apache License 2.0 | 5 votes |
private Map<String, Object> getRestMetricsMap(Endpoint e) { synchronized (e) { Object mmo = e.get(REST_METRICS_MAP); if (mmo == null) { e.put(REST_METRICS_MAP, new ConcurrentHashMap<String, Object>()); mmo = e.get(REST_METRICS_MAP); } return CastUtils.cast((Map<?, ?>)mmo); } }
Example 8
Source File: MicroProfileClientFactoryBean.java From cxf with Apache License 2.0 | 5 votes |
@Override protected void initClient(AbstractClient client, Endpoint ep, boolean addHeaders) { super.initClient(client, ep, addHeaders); TLSClientParameters tlsParams = secConfig.getTlsClientParams(); if (tlsParams.getSSLSocketFactory() != null || tlsParams.getTrustManagers() != null || tlsParams.getHostnameVerifier() != null) { client.getConfiguration().getHttpConduit().setTlsClientParameters(tlsParams); } if (PropertyUtils.isTrue(configuration.getProperty(ClientProperties.HTTP_AUTOREDIRECT_PROP))) { client.getConfiguration().getHttpConduit().getClient().setAutoRedirect(true); } String proxyHost = (String) configuration.getProperty(ClientProperties.HTTP_PROXY_SERVER_PROP); if (proxyHost != null) { client.getConfiguration().getHttpConduit().getClient().setProxyServer(proxyHost); int proxyPort = (int) configuration.getProperty(ClientProperties.HTTP_PROXY_SERVER_PORT_PROP); client.getConfiguration().getHttpConduit().getClient().setProxyServerPort(proxyPort); } MicroProfileClientProviderFactory factory = MicroProfileClientProviderFactory.createInstance(getBus(), comparator); factory.setUserProviders(registeredProviders); ep.put(MicroProfileClientProviderFactory.CLIENT_FACTORY_NAME, factory); }
Example 9
Source File: WadlGeneratorTest.java From cxf with Apache License 2.0 | 5 votes |
private Message mockMessage(String baseAddress, String pathInfo, String query, List<ClassResourceInfo> cris) throws Exception { Message m = new MessageImpl(); Exchange e = new ExchangeImpl(); e.put(Service.class, new JAXRSServiceImpl(cris)); m.setExchange(e); control.reset(); ServletDestination d = control.createMock(ServletDestination.class); EndpointInfo epr = new EndpointInfo(); epr.setAddress(baseAddress); d.getEndpointInfo(); EasyMock.expectLastCall().andReturn(epr).anyTimes(); Endpoint endpoint = new EndpointImpl(null, null, epr); e.put(Endpoint.class, endpoint); endpoint.put(ServerProviderFactory.class.getName(), ServerProviderFactory.getInstance()); e.setDestination(d); BindingInfo bi = control.createMock(BindingInfo.class); epr.setBinding(bi); bi.getProperties(); EasyMock.expectLastCall().andReturn(Collections.emptyMap()).anyTimes(); m.put(Message.REQUEST_URI, pathInfo); m.put(Message.QUERY_STRING, query); m.put(Message.HTTP_REQUEST_METHOD, "GET"); control.replay(); return m; }
Example 10
Source File: FIStaxInInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public void handleMessage(Message message) { if (message.getContent(XMLStreamReader.class) != null || !isHttpVerbSupported(message)) { return; } String ct = (String)message.get(Message.CONTENT_TYPE); if (ct != null && ct.indexOf("fastinfoset") != -1 && message.getContent(InputStream.class) != null && message.getContent(XMLStreamReader.class) == null) { message.setContent(XMLStreamReader.class, getParser(message.getContent(InputStream.class))); //add the StaxInEndingInterceptor which will close the reader message.getInterceptorChain().add(StaxInEndingInterceptor.INSTANCE); ct = ct.replace("fastinfoset", "xml"); if (ct.contains("application/xml")) { ct = ct.replace("application/xml", "text/xml"); } message.put(Message.CONTENT_TYPE, ct); message.getExchange().put(FIStaxOutInterceptor.FI_ENABLED, Boolean.TRUE); if (isRequestor(message)) { //record the fact that is worked so future requests will //automatically be FI enabled Endpoint ep = message.getExchange().getEndpoint(); ep.put(FIStaxOutInterceptor.FI_ENABLED, Boolean.TRUE); } } }
Example 11
Source File: CxfRsHttpListener.java From tomee with Apache License 2.0 | 5 votes |
private JAXRSServerFactoryBean newFactory(final String prefix, final String service, final String endpoint) { final JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean() { @Override protected Endpoint createEndpoint() throws BusException, EndpointException { final Endpoint created = super.createEndpoint(); created.put(ManagedEndpoint.SERVICE_NAME, service); created.put(ManagedEndpoint.ENDPOINT_NAME, endpoint); return created; } }; factory.setDestinationFactory(transportFactory); factory.setBus(CxfUtil.getBus()); factory.setAddress(prefix); return factory; }
Example 12
Source File: JAXRSServerFactoryBean.java From cxf with Apache License 2.0 | 4 votes |
/** * Creates the JAX-RS Server instance * @return the server */ public Server create() { ClassLoaderHolder origLoader = null; try { Bus bus = getBus(); ClassLoader loader = bus.getExtension(ClassLoader.class); if (loader != null) { origLoader = ClassLoaderUtils.setThreadContextClassloader(loader); } serviceFactory.setBus(bus); checkResources(true); if (serviceFactory.getService() == null) { serviceFactory.create(); } Endpoint ep = createEndpoint(); getServiceFactory().sendEvent(FactoryBeanListener.Event.PRE_SERVER_CREATE, server); server = new ServerImpl(getBus(), ep, getDestinationFactory(), getBindingFactory()); Invoker invoker = serviceFactory.getInvoker(); if (invoker == null) { ep.getService().setInvoker(createInvoker()); } else { ep.getService().setInvoker(invoker); } ServerProviderFactory factory = setupFactory(ep); ep.put(Application.class.getName(), appProvider); factory.setRequestPreprocessor( new RequestPreprocessor(languageMappings, extensionMappings)); ep.put(Bus.class.getName(), getBus()); if (documentLocation != null) { ep.put(JAXRSUtils.DOC_LOCATION, documentLocation); } if (rc != null) { ep.put("org.apache.cxf.jaxrs.comparator", rc); } checkPrivateEndpoint(ep); applyBusFeatures(getBus()); applyFeatures(); updateClassResourceProviders(ep); injectContexts(factory, (ApplicationInfo)ep.get(Application.class.getName())); factory.applyDynamicFeatures(getServiceFactory().getClassResourceInfo()); getServiceFactory().sendEvent(FactoryBeanListener.Event.SERVER_CREATED, server, null, null); if (start) { try { server.start(); } catch (RuntimeException re) { server.destroy(); // prevent resource leak throw re; } } } catch (Exception e) { throw new ServiceConstructionException(e); } finally { if (origLoader != null) { origLoader.reset(); } } return server; }
Example 13
Source File: GZIPInInterceptor.java From cxf with Apache License 2.0 | 4 votes |
public void handleMessage(Message message) { if (isGET(message)) { return; } // check for Content-Encoding header - we are only interested in // messages that say they are gzipped. Map<String, List<String>> protocolHeaders = CastUtils.cast((Map<?, ?>)message .get(Message.PROTOCOL_HEADERS)); if (protocolHeaders != null) { List<String> contentEncoding = HttpHeaderHelper.getHeader(protocolHeaders, HttpHeaderHelper.CONTENT_ENCODING); if (contentEncoding == null) { contentEncoding = protocolHeaders.get(GZIPOutInterceptor.SOAP_JMS_CONTENTENCODING); } if (contentEncoding != null && (contentEncoding.contains("gzip") || contentEncoding.contains("x-gzip"))) { try { LOG.fine("Uncompressing response"); InputStream is = message.getContent(InputStream.class); if (is == null) { return; } // wrap an unzipping stream around the original one GZIPInputStream zipInput = new GZIPInputStream(is); message.setContent(InputStream.class, zipInput); // remove content encoding header as we've now dealt with it for (String key : protocolHeaders.keySet()) { if ("Content-Encoding".equalsIgnoreCase(key)) { protocolHeaders.remove(key); break; } } if (isRequestor(message)) { //record the fact that is worked so future requests will //automatically be FI enabled Endpoint ep = message.getExchange().getEndpoint(); ep.put(GZIPOutInterceptor.USE_GZIP_KEY, GZIPOutInterceptor.UseGzip.YES); } } catch (IOException ex) { throw new Fault(new org.apache.cxf.common.i18n.Message("COULD_NOT_UNZIP", BUNDLE), ex); } } } }
Example 14
Source File: Stax2ValidationUtils.java From cxf with Apache License 2.0 | 4 votes |
/** * Create woodstox validator for a schema set. * * @throws XMLStreamException */ private XMLValidationSchema getValidator(Endpoint endpoint, ServiceInfo serviceInfo) throws XMLStreamException { synchronized (endpoint) { XMLValidationSchema ret = (XMLValidationSchema) endpoint.get(KEY); if (ret == null) { if (endpoint.containsKey(KEY)) { return null; } Map<String, Source> sources = new TreeMap<>(); for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) { XmlSchema sch = schemaInfo.getSchema(); String uri = sch.getTargetNamespace(); if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(uri)) { continue; } if (sch.getTargetNamespace() == null && !sch.getExternals().isEmpty()) { for (XmlSchemaExternal xmlSchemaExternal : sch.getExternals()) { addSchema(sources, xmlSchemaExternal.getSchema(), getElement(xmlSchemaExternal.getSchema().getSourceURI())); } continue; } else if (sch.getTargetNamespace() == null) { throw new IllegalStateException("An Schema without imports must have a targetNamespace"); } addSchema(sources, sch, schemaInfo.getElement()); } try { // I don't think that we need the baseURI. Method method = multiSchemaFactory.getMethod("createSchema", String.class, Map.class); ret = (XMLValidationSchema) method.invoke(multiSchemaFactory.newInstance(), null, sources); endpoint.put(KEY, ret); } catch (Throwable t) { LOG.log(Level.INFO, "Problem loading schemas. Falling back to slower method.", ret); endpoint.put(KEY, null); } } return ret; } }