@Override public void shutdown() { synchronized (this) { if (registry != null) { registry.removeDestination(path); } } super.shutdown(); } }
private static DestinationRegistry getDestinationRegistryFromBus(Bus bus) { DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); try { DestinationFactory df = dfm.getDestinationFactory("http://cxf.apache.org/transports/http/configuration"); if (df instanceof HTTPTransportFactory) { HTTPTransportFactory transportFactory = (HTTPTransportFactory) df; return transportFactory.getRegistry(); } } catch (BusException e) { // why are we throwing a busexception if the DF isn't found? } return null; }
private AbstractDestination[] getSOAPEndpoints(AbstractDestination[] destinations, List<String> privateEndpoints) { List<AbstractDestination> soapEndpoints = new ArrayList<>(); for (AbstractDestination sd : destinations) { if (null != sd.getEndpointInfo().getName() && null != sd.getEndpointInfo().getInterface() && !isPrivate(sd.getEndpointInfo(), privateEndpoints)) { soapEndpoints.add(sd); } } return soapEndpoints.toArray(new AbstractDestination[0]); }
final HttpServletRequest req, final HttpServletResponse resp) throws IOException { Message inMessage = retrieveFromContinuation(req); if (inMessage == null) { LOG.fine("Create a new message for processing"); ExchangeImpl exchange = new ExchangeImpl(); exchange.setInMessage(inMessage); setupMessage(inMessage, config, context, resp); exchange.setSession(new HTTPSession(req)); ((MessageImpl)inMessage).setDestination(this); } else { copyKnownRequestAttributes(req, inMessage); incomingObserver.onMessage(inMessage); invokeComplete(context, req, resp, inMessage); } catch (SuspendedInvocationException ex) { if (ex.getRuntimeException() != null) {
if (StringUtils.isEmpty(peferredTransportId) && getBus() != null) { peferredTransportId = (String)getBus().getProperty(AbstractTransportFactory.PREFERRED_TRANSPORT_ID); final Set<String> candidates = dfm.getRegisteredDestinationFactoryNames(); ? dfm.getDestinationFactory(DEFAULT_TRANSPORT_ID) : dfm.getDestinationFactory(peferredTransportId); if (df instanceof HTTPTransportFactory) { HTTPTransportFactory transportFactory = (HTTPTransportFactory)df; return transportFactory.getRegistry();
Headers.getSetProtocolHeaders(inMessage); inMessage.put(Message.RESPONSE_CODE, HttpURLConnection.HTTP_OK); inMessage.setContent(InputStream.class, cos.getInputStream()); incomingObserver.onMessage(inMessage); } catch (IOException e) { logStackTrace(e);
exchange.setInMessage(inMessage); setupMessage(inMessage, null, req.getServletContext(), req, resp); exchange.setSession(new HTTPSession(req)); incomingObserver.onMessage(inMessage); resp.flushBuffer(); } catch (SuspendedInvocationException ex) {
dfm.getDestinationFactory(bindingID); } catch (BusException ex) { DestinationFactory df = dfm.getDestinationFactoryForUri(address); if (df != null && df.getTransportIds() != null && !df.getTransportIds().isEmpty()) { transportId = df.getTransportIds().get(0); } else { transportId = bindingID;
public void run() { try { handleResponseInternal(); } catch (Throwable e) { ((PhaseInterceptorChain)outMessage.getInterceptorChain()).abort(); outMessage.setContent(Exception.class, e); ((PhaseInterceptorChain)outMessage.getInterceptorChain()).unwind(outMessage); MessageObserver mo = outMessage.getInterceptorChain().getFaultObserver(); if (mo == null) { mo = outMessage.getExchange().get(MessageObserver.class); } mo.onMessage(outMessage); } } };
@Override public String getId(Map<String, Object> context) { String id = null; if (isMultiplexWithAddress()) { String address = (String)context.get(Message.PATH_INFO); if (null != address) { int afterLastSlashIndex = address.lastIndexOf("/") + 1; if (afterLastSlashIndex > 0 && afterLastSlashIndex < address.length()) { id = address.substring(afterLastSlashIndex); } } else { getLogger().log(Level.WARNING, new org.apache.cxf.common.i18n.Message( "MISSING_PATH_INFO", LOG).toString()); } } else { return super.getId(context); } return id; }
private void writerSoapEndpoint(PrintWriter writer, String basePath, AbstractDestination sd) { String absoluteURL = getAbsoluteAddress(basePath, sd); if (absoluteURL == null) { return; } writer.write("<tr><td>"); writer.write("<span class=\"porttypename\">" + sd.getEndpointInfo().getInterface().getName().getLocalPart() + "</span>"); writer.write("<ul>"); for (OperationInfo oi : sd.getEndpointInfo().getInterface().getOperations()) { if (!Boolean.TRUE.equals(oi.getProperty("operation.is.synthetic"))) { writer.write("<li>" + oi.getName().getLocalPart() + "</li>"); } } writer.write("</ul>"); writer.write("</td><td>"); writer.write("<span class=\"field\">Endpoint address:</span> " + "<span class=\"value\">" + absoluteURL + "</span>"); writer.write("<br/><span class=\"field\">WSDL :</span> " + "<a href=\"" + absoluteURL + "?wsdl\">" + sd.getEndpointInfo().getService().getName() + "</a>"); writer.write("<br/><span class=\"field\">Target namespace:</span> " + "<span class=\"value\">" + sd.getEndpointInfo().getService().getTargetNamespace() + "</span>"); addAtomLinkIfNeeded(absoluteURL, atomMap, writer); writer.write("</td></tr>"); }
public void close(Message msg) throws IOException { InputStream in = msg.getContent(InputStream.class); try { if (in != null) { int count = 0; byte[] buffer = new byte[1024]; while (in.read(buffer) != -1 && count < 25) { //don't do anything, we just need to pull off the unread data (like //closing tags that we didn't need to read //however, limit it so we don't read off gigabytes of data we won't use. ++count; } } } finally { super.close(msg); } }
public EndpointReferenceType getAddressWithId(String id) { EndpointReferenceType ref = null; if (isMultiplexWithAddress()) { String address = EndpointReferenceUtils.getAddress(reference); ref = EndpointReferenceUtils.duplicate(reference); if (address.endsWith("/")) { EndpointReferenceUtils.setAddress(ref, address + id); } else { EndpointReferenceUtils.setAddress(ref, address + "/" + id); } } else { ref = super.getAddressWithId(id); } return ref; }
private String getAbsoluteAddress(String basePath, AbstractDestination d) { String endpointAddress = (String)d.getEndpointInfo().getProperty("publishedEndpointUrl"); if (endpointAddress != null) { return endpointAddress; } endpointAddress = d.getEndpointInfo().getAddress(); if (d instanceof ServletDestination && (endpointAddress.startsWith("http://") || endpointAddress.startsWith("https://"))) { String path = ((ServletDestination)d).getPath(); return basePath + path; } else if (basePath == null || endpointAddress.startsWith(basePath)) { return endpointAddress; } else { return basePath + endpointAddress; } } }
@Override protected Object invoke(Exchange exchange, Object service, Method method, List<Object> arguments) { if (method.getName().equals("login")) { MessageContentsList mcl = (MessageContentsList) super.invoke(exchange, service, method, arguments); String token = (String) mcl.get(0); exchange.getSession().put("token", token); return mcl; } else { return super.invoke(exchange, service, method, arguments); } }
public static void setAddress(AbstractDestination dest, String absAddress) { dest.getEndpointInfo().setAddress(absAddress); if (dest.getEndpointInfo().getExtensor(AddressType.class) != null) { dest.getEndpointInfo().getExtensor(AddressType.class).setLocation(absAddress); } } }
@Override public void close(Message msg) throws IOException { super.close(msg); if (msg.getExchange() == null) { return; } Message m = msg.getExchange().getInMessage(); if (m == null) { return; } InputStream is = m.getContent(InputStream.class); if (is != null) { try { is.close(); m.removeContent(InputStream.class); } catch (IOException ioex) { //ignore } } } }
private AbstractDestination[] getRestEndpoints(AbstractDestination[] destinations, List<String> privateEndpoints) { List<AbstractDestination> restfulDests = new ArrayList<>(); for (AbstractDestination sd : destinations) { // use some more reasonable check - though this one seems to be the only option at the moment if (null == sd.getEndpointInfo().getInterface() && !isPrivate(sd.getEndpointInfo(), privateEndpoints)) { restfulDests.add(sd); } } return restfulDests.toArray(new AbstractDestination[0]); }
private String getAbsoluteAddress(String basePath, AbstractDestination d) { String endpointAddress = (String)d.getEndpointInfo().getProperty("publishedEndpointUrl"); if (endpointAddress != null) { return endpointAddress; } endpointAddress = d.getEndpointInfo().getAddress(); if (endpointAddress.startsWith("http://") || endpointAddress.startsWith("https://")) { if (endpointAddress.startsWith(basePath) || showForeignContexts) { return endpointAddress; } return null; } String address = basePath; if (address.endsWith("/") && endpointAddress.startsWith("/")) { address = address.substring(0, address.length() - 1); } return address + endpointAddress; }