List of usage examples for javax.xml.ws.handler Handler getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:be.fedict.eid.idp.sp.protocol.saml2.artifact.ArtifactServiceClient.java
protected void removeSoapHandler(Class<? extends SOAPHandler> soapHandlerClass) { BindingProvider bindingProvider = (BindingProvider) this.port; Binding binding = bindingProvider.getBinding(); @SuppressWarnings("unchecked") List<Handler> handlerChain = binding.getHandlerChain(); Iterator<Handler> iter = handlerChain.iterator(); while (iter.hasNext()) { Handler handler = iter.next(); if (handler.getClass().isAssignableFrom(soapHandlerClass)) { iter.remove();//from ww w . j a v a 2s.c o m } } }
From source file:io.hummer.util.ws.AbstractNode.java
@WebMethod @SOAPBinding(parameterStyle = ParameterStyle.BARE, style = Style.DOCUMENT, use = Use.LITERAL) @SuppressWarnings("all") public void setHandlerActive(@WebParam final SetHandlerActiveRequest params) throws AbstractNodeException { try {/*from w ww .jav a 2 s . c o m*/ Class<?> clazz = Class.forName(params.handlerSuperClass); List<Handler> fromList = params.active ? inactiveHandlers : activeHandlers; List<Handler> toList = params.active ? activeHandlers : inactiveHandlers; boolean done = false; for (int i = 0; i < fromList.size(); i++) { Handler<?> h = fromList.get(i); if (clazz.isAssignableFrom(h.getClass())) { fromList.remove(i--); if (!toList.contains(h)) { toList.add(h); done = true; } else { done = true; } } } try { if (!done && params.active) { Handler<?> h = (Handler<?>) clazz.newInstance(); boolean alreadyIncluded = false; for (Handler h1 : activeHandlers) { if (clazz.isAssignableFrom(h1.getClass())) alreadyIncluded = true; } if (!alreadyIncluded) activeHandlers.add(h); } } catch (Exception e) { endpoint.getBinding().setHandlerChain(activeHandlers); throw e; } endpoint.getBinding().setHandlerChain(activeHandlers); } catch (Exception e) { throw new AbstractNodeException(e); } }
From source file:org.apache.axis2.jaxws.handler.HandlerChainProcessor.java
private void sortChain() throws WebServiceException { if (handlers.size() == 0) { logicalLength = 0;//from ww w . j a v a 2 s . c o m 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); }
From source file:org.apache.axis2.jaxws.handler.HandlerChainProcessor.java
private void callGenericHandlers_avoidRecursion(int start, int end, Direction direction) { int i = start; if (direction == Direction.OUT) { for (; i <= end; i++) { switchContext(direction, i); Handler handler = (Handler) handlers.get(i); if (log.isDebugEnabled()) { log.debug("Invoking handleMessage on: " + handler.getClass().getName()); }/*from ww w . java2s . c o m*/ callHandleMessageWithTracker(handler); } } else { // IN case for (; i >= end; i--) { switchContext(direction, i); Handler handler = (Handler) handlers.get(i); if (log.isDebugEnabled()) { log.debug("Invoking handleMessage on: " + handler.getClass().getName()); } callHandleMessageWithTracker(handler); } } }
From source file:org.apache.axis2.jaxws.handler.HandlerChainProcessor.java
/** * Calls handleMessage on the Handler. If an exception is thrown and a response is expected, the * MessageContext is updated with the handler information * * @returns SUCCESSFUL if successfully, UNSUCCESSFUL if false, EXCEPTION if exception thrown *//* w w w .j a v a 2 s . c o m*/ private int handleMessage(Handler handler, Direction direction, boolean expectResponse) throws RuntimeException { try { if (log.isDebugEnabled()) { log.debug("Invoking handleMessage on: " + handler.getClass().getName()); } // The pre and post invokers will likely need more than just the handler message context. // They may need access to the axis service object or description objects. currentMC.put(Constants.MEP_CONTEXT, mepCtx); getPreInvoker().preInvoke(currentMC); boolean success = callHandleMessageWithTracker(handler); getPostInvoker().postInvoke(currentMC); if (success) { if (log.isDebugEnabled()) { log.debug("handleMessage() returned true"); } return SUCCESSFUL; } else { if (log.isDebugEnabled()) { log.debug("handleMessage() returned false"); } if (expectResponse) currentMC.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY, (direction != Direction.OUT)); return FAILED; } } catch (RuntimeException re) { // RuntimeException and ProtocolException if (log.isDebugEnabled()) { log.debug("An exception was thrown during the handleMessage() invocation"); log.debug("Exception: ", re); } savedException = re; if (expectResponse) // mark it as reverse direction currentMC.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY, (direction != Direction.OUT)); if (ProtocolException.class.isAssignableFrom(re.getClass())) { convertToFaultMessage(mepCtx, re, proto, true); // just re-initialize the current handler message context since // that will pick up the now-changed message return PROTOCOL_EXCEPTION; } return OTHER_EXCEPTION; } }
From source file:org.apache.axis2.jaxws.handler.HandlerChainProcessor.java
private void callCloseHandlers(int start, int end, Direction direction) { int i = start; if (direction == Direction.OUT) { for (; i <= end; i++) { try { switchContext(direction, i); Handler handler = (Handler) handlers.get(i); if (log.isDebugEnabled()) { log.debug("Invoking close on: " + handler.getClass().getName()); }// w ww . j a va 2s . co m callCloseWithTracker(handler); // TODO when we close, are we done with the handler instance, and thus // may call the PreDestroy annotated method? I don't think so, especially // if we've cached the handler list somewhere. } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("An Exception occurred while calling handler.close()"); log.debug("Exception: " + e.getClass().getName() + ":" + e.getMessage()); } } } } else { // IN case for (; i >= end; i--) { try { switchContext(direction, i); Handler handler = (Handler) handlers.get(i); if (log.isDebugEnabled()) { log.debug("Invoking close on: " + handler.getClass().getName()); } callCloseWithTracker(handler); // TODO when we close, are we done with the handler instance, and thus // may call the PreDestroy annotated method? I don't think so, especially // if we've cached the handler list somewhere. } catch (Exception e) { if (log.isDebugEnabled()) { log.debug("An Exception occurred while calling handler.close()"); log.debug("Exception: " + e.getClass().getName() + ":" + e.getMessage()); } } } } }
From source file:org.apache.axis2.jaxws.handler.HandlerChainProcessor.java
private void callGenericHandleFault(int start, int end, Direction direction) throws RuntimeException { int i = start; // we may be starting in the middle of the list, and therefore may need to switch contexts switchContext(direction, i);/*from ww w.ja va 2s . c om*/ if (direction == Direction.OUT) { for (; i <= end; i++) { Handler handler = (Handler) handlers.get(i); if (log.isDebugEnabled()) { log.debug("Invoking handleFault on: " + handler.getClass().getName()); } boolean success = callHandleFaultWithTracker(handler); if (!success) break; switchContext(direction, i + 1); } } else { // IN case for (; i >= end; i--) { Handler handler = (Handler) handlers.get(i); if (log.isDebugEnabled()) { log.debug("Invoking handleFault on: " + handler.getClass().getName()); } boolean success = callHandleFaultWithTracker(handler); if (!success) break; switchContext(direction, i - 1); } } }
From source file:org.apache.axis2.jaxws.spi.handler.HandlerResolverImpl.java
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); }//from www. jav a2 s .com 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; }