void setUpProcessor() { if (handlers == null) { // Take a snapshot, User may change chain after invocation, Same chain // should be used for the entire MEP handlers = new ArrayList<Handler>(); WSBinding binding = getBinding(); List<LogicalHandler> logicalSnapShot= ((BindingImpl) binding).getHandlerConfig().getLogicalHandlers(); if (!logicalSnapShot.isEmpty()) { handlers.addAll(logicalSnapShot); if (binding.getSOAPVersion() == null) { processor = new XMLHandlerProcessor(this, binding, handlers); } else { processor = new SOAPHandlerProcessor(true, this, binding, handlers); } } } }
@SuppressWarnings("rawtypes") public List<Handler> sortHandlers(List<Handler> handlers) { final int size = handlers.size(); List<Handler> logicalHandlers = new ArrayList<Handler>(size); List<Handler> protocolHandlers = new ArrayList<Handler>(Math.min(10, size)); for (Handler handler : handlers) { if (handler instanceof LogicalHandler) { logicalHandlers.add(handler); } else { protocolHandlers.add(handler); } } if (!protocolHandlers.isEmpty()) { logicalHandlers.addAll(protocolHandlers); } return logicalHandlers; }
void setUpProcessor() { // Take a snapshot, User may change chain after invocation, Same chain // should be used for the entire MEP handlers = new ArrayList<Handler>(); List<LogicalHandler> logicalSnapShot= ((BindingImpl) binding).getHandlerConfig().getLogicalHandlers(); if (!logicalSnapShot.isEmpty()) { handlers.addAll(logicalSnapShot); if (binding.getSOAPVersion() == null) { processor = new XMLHandlerProcessor(this, binding, handlers); } else { processor = new SOAPHandlerProcessor(true, this, binding, handlers); } } }
/** * sorts the handlers into correct order. All of the logical handlers first * followed by the protocol handlers * * @param handlers List * @return sorted list of handlers */ private List<Handler> sortHandlers(final List<Handler> handlers) { final List<LogicalHandler> logicalHandlers = new ArrayList<LogicalHandler>(); final List<Handler> protocolHandlers = new ArrayList<Handler>(); for (final Handler handler : handlers) { if (handler instanceof LogicalHandler) { logicalHandlers.add((LogicalHandler) handler); } else { protocolHandlers.add(handler); } } final List<Handler> sortedHandlers = new ArrayList<Handler>(); sortedHandlers.addAll(logicalHandlers); sortedHandlers.addAll(protocolHandlers); return sortedHandlers; }
/** * sorts the handlers into correct order. All of the logical handlers first * followed by the protocol handlers * * @param handlers * @return sorted list of handlers */ private List<Handler> sortHandlers(final List<Handler> handlers) { final List<LogicalHandler> logicalHandlers = new ArrayList<LogicalHandler>(); final List<Handler> protocolHandlers = new ArrayList<Handler>(); for (final Handler handler : handlers) { if (handler instanceof LogicalHandler) { logicalHandlers.add((LogicalHandler) handler); } else { protocolHandlers.add(handler); } } final List<Handler> sortedHandlers = new ArrayList<Handler>(); sortedHandlers.addAll(logicalHandlers); sortedHandlers.addAll(protocolHandlers); return sortedHandlers; }
/** * This method separates the logical and protocol handlers and * sets the HandlerConfiguration. * Only logical handlers are allowed with HTTPBinding. * Setting SOAPHandlers throws WebServiceException */ public void setHandlerChain(List<Handler> chain) { for (Handler handler : chain) { if (!(handler instanceof LogicalHandler)) { throw new WebServiceException(ClientMessages.NON_LOGICAL_HANDLER_SET(handler.getClass())); } } setHandlerConfig(new HandlerConfiguration(Collections.<String>emptySet(), chain)); }
private void setUpHandlersOnce() { handlers = new ArrayList<Handler>(); List<LogicalHandler> logicalSnapShot= ((BindingImpl) getBinding()).getHandlerConfig().getLogicalHandlers(); if (!logicalSnapShot.isEmpty()) { handlers.addAll(logicalSnapShot); } }
/** * Add a message handler to a SOAP binding * @param binding binding to which we'll add the handler * @param handler the handler to be added */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void addMessageHandler(Object binding, LogicalHandler handler) { final Binding b = ((BindingProvider) binding).getBinding(); List handlerList = b.getHandlerChain(); if (handlerList == null) handlerList = new ArrayList(); handlerList.add(handler); b.setHandlerChain(handlerList); }
/** * Add a message handler to a SOAP binding * @param binding binding to which we'll add the handler * @param index position in the list of handlers * @param handler the handler to be added */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void addMessageHandler(Object binding, int index, LogicalHandler handler) { final Binding b = ((BindingProvider) binding).getBinding(); List handlerList = b.getHandlerChain(); if (handlerList == null) handlerList = new ArrayList(); handlerList.add(index, handler); b.setHandlerChain(handlerList); }
private void sortChain() throws WebServiceException { if (handlers.size() == 0) { logicalLength = 0; return; } ArrayList<Handler> logicalHandlers = new ArrayList<Handler>(); ArrayList<Handler> protocolHandlers = new ArrayList<Handler>(); Iterator handlerIterator = handlers.iterator(); while (handlerIterator.hasNext()) { // this is a safe cast since the handlerResolver and binding.setHandlerChain // and InvocationContext.setHandlerChain verifies it before we get here Handler handler = (Handler)handlerIterator.next(); // JAXWS 9.2.1.2 sort them by Logical, then SOAP if (LogicalHandler.class.isAssignableFrom(handler.getClass())) logicalHandlers.add((LogicalHandler) handler); else if (SOAPHandler.class.isAssignableFrom(handler.getClass())) // instanceof ProtocolHandler protocolHandlers.add((SOAPHandler) handler); else if (Handler.class.isAssignableFrom(handler.getClass())) { throw ExceptionFactory.makeWebServiceException(Messages .getMessage("handlerChainErr1", handler.getClass().getName())); } else { throw ExceptionFactory.makeWebServiceException(Messages .getMessage("handlerChainErr2", handler.getClass().getName())); } } logicalLength = logicalHandlers.size(); // JAXWS 9.2.1.2 sort them by Logical, then SOAP handlers.clear(); handlers.addAll(logicalHandlers); handlers.addAll(protocolHandlers); }
/** * This method separates the logical and protocol handlers and * sets the HandlerConfiguration. * Only logical handlers are allowed with HTTPBinding. * Setting SOAPHandlers throws WebServiceException */ public void setHandlerChain(List<Handler> chain) { List<LogicalHandler> logicalHandlers = new ArrayList<LogicalHandler>(); for (Handler handler : chain) { if (!(handler instanceof LogicalHandler)) { throw new WebServiceException(ClientMessages.NON_LOGICAL_HANDLER_SET(handler.getClass())); } else { logicalHandlers.add((LogicalHandler) handler); } } handlerConfig = new HandlerConfiguration(Collections.<String>emptySet(), chain); }
private void setUpHandlersOnce() { handlers = new ArrayList<Handler>(); List<LogicalHandler> logicalSnapShot= ((BindingImpl) binding).getHandlerConfig().getLogicalHandlers(); if (!logicalSnapShot.isEmpty()) { handlers.addAll(logicalSnapShot); } }
public List<LogicalHandler> getLogicalHandlers() { return logicalHandlers; }
public LogicalConfigDelegateHandler(LogicalHandler<T> delegate, boolean isPre) { super(delegate, isPre); }
@SuppressWarnings({"rawtypes", "unchecked"}) private static List<Handler> convertToHandlers(List<UnifiedHandlerChainMetaData> handlerChains, String bindingID, boolean isPre) { List<Handler> handlers = new LinkedList<Handler>(); if (handlerChains != null && !handlerChains.isEmpty()) { final String protocolBinding = bindingIDs.get(bindingID); for (UnifiedHandlerChainMetaData handlerChain : handlerChains) { if (handlerChain.getPortNamePattern() != null || handlerChain.getServiceNamePattern() != null) { ROOT_LOGGER.filtersNotSupported(); } if (matchProtocolBinding(protocolBinding, handlerChain.getProtocolBindings())) { for (UnifiedHandlerMetaData uhmd : handlerChain.getHandlers()) { if (uhmd.getInitParams() != null && !uhmd.getInitParams().isEmpty()) { ROOT_LOGGER.initParamsNotSupported(); } Object h = newInstance(uhmd.getHandlerClass()); if (h != null) { if (h instanceof Handler) { if (h instanceof LogicalHandler) { handlers.add(new LogicalConfigDelegateHandler((LogicalHandler)h, isPre)); } else if (h instanceof SOAPHandler) { handlers.add(new SOAPConfigDelegateHandler((SOAPHandler)h, isPre)); } else { handlers.add(new ConfigDelegateHandler((Handler)h, isPre)); } } else { throw MESSAGES.notJAXWSHandler(uhmd.getHandlerClass()); } } } } } } return handlers; }
public List<Handler> getHandlerChain(PortInfo portinfo) { ArrayList<Handler> handlers = new ArrayList<Handler>(); Iterator it = handlerChainsType == null ? null : handlerChainsType.getHandlerChain().iterator(); while ((it != null) && (it.hasNext())) { HandlerChainType handlerChainType = ((HandlerChainType)it.next()); // if !match, continue (to next chain) if (!(chainResolvesToPort(handlerChainType, portinfo))) continue; List<HandlerType> handlerTypeList = handlerChainType.getHandler(); Iterator ht = handlerTypeList.iterator(); while (ht.hasNext()) { HandlerType handlerType = (HandlerType)ht.next(); // TODO must do better job comparing the handlerType with the PortInfo param // to see if the current iterator handler is intended for this service. // TODO review: need to check for null getHandlerClass() return? // or will schema not allow it? String portHandler = handlerType.getHandlerClass().getValue(); Handler handler = null; // instantiate portHandler class try { handler = createHandlerInstance(loadClass(portHandler)); } catch (Exception e) { // TODO: should we just ignore this problem? throw ExceptionFactory.makeWebServiceException(e); } if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) { log.debug("Successfully instantiated the class: " + handler.getClass()); } // 9.2.1.2 sort them by Logical, then SOAP if (LogicalHandler.class.isAssignableFrom(handler.getClass())) handlers.add((LogicalHandler) handler); else if (SOAPHandler.class.isAssignableFrom(handler.getClass())) // instanceof ProtocolHandler handlers.add((SOAPHandler) handler); else if (Handler.class.isAssignableFrom(handler.getClass())) { throw ExceptionFactory.makeWebServiceException(Messages .getMessage("handlerChainErr1", handler .getClass().getName())); } else { throw ExceptionFactory.makeWebServiceException(Messages .getMessage("handlerChainErr2", handler .getClass().getName())); } } } return handlers; }