Package javax.xml.rpc.handler

Examples of javax.xml.rpc.handler.HandlerChain


        public TestHandlerInfoChainFactory(List handlerInfos) {
            super(handlerInfos);
        }

        public HandlerChain createHandlerChain() {
            HandlerChain chain = super.createHandlerChain();
            handlers = new AAAHandler[chain.size()];
            for (int i = 0; i < chain.size(); i++) {
                handlers[i] = (AAAHandler) chain.get(i);
            }
            return chain;
        }
View Full Code Here


    public List getHandlerInfos() {
        return this.handlerInfos;
    }

    public HandlerChain createHandlerChain() {
        HandlerChain hc = new HandlerChainImpl(handlerInfos);
        hc.setRoles(getRoles());
        return hc;
       
    }
View Full Code Here

            this.operation = operation;
        }

        @AroundInvoke
        public Object intercept(InvocationContext context) throws Exception {
            HandlerChain handlerChain = new HandlerChainImpl(handlerInfos);
            try {
                Object invocationResult = null;

                try {
                    if (handlerChain.handleRequest(messageContext)) {
                        // update arguments as handlers could change the soap msg
                        context.setParameters(getArguments());

                        invocationResult = context.proceed();

                        // update the soap msg so that handlers see invocation result
                        if (!handlerChain.isEmpty()) {
                            createResult(invocationResult);
                        }

                    } else {
                        /* The Handler implementation class has the responsibility of setting
                         * the response SOAP message in the handleRequest method and perform
                         * additional processing in the handleResponse method.
                         */
                        invocationResult = null;
                    }
                } catch (SOAPFaultException e) {
                    handlerChain.handleFault(messageContext);
                    throw e;
                }

                handlerChain.handleResponse(messageContext);

                if (!handlerChain.isEmpty()) {
                    /*
                     * Deserialize the result value from soap msg as handers could have
                     * changed it.
                     */
                    try {
                        invocationResult = demarshallResult();
                    } catch (Exception e) {
                        // if this fails, return invocationResult from above
                    }
                }

                return invocationResult;
            } finally {
                handlerChain.destroy();
            }
        }
View Full Code Here

    public List getHandlerInfos() {
        return this.handlerInfos;
    }

    public HandlerChain createHandlerChain() {
        HandlerChain hc = new HandlerChainImpl(handlerInfos);
        hc.setRoles(getRoles());
        return hc;
       
    }
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Enter: AxisClient::invoke");
        }
        String hName = null;
        Handler h = null;
        HandlerChain handlerImpl = null;
       
        // save previous context
        MessageContext previousContext = getCurrentMessageContext();
        try {
            // set active context
            setCurrentMessageContext(msgContext);
            hName = msgContext.getStrProp(MessageContext.ENGINE_HANDLER);
            if (log.isDebugEnabled()) {
                log.debug("EngineHandler: " + hName);
            }
            if (hName != null) {
                h = getHandler(hName);
                if (h != null)
                    h.invoke(msgContext);
                else
                    throw new AxisFault("Client.error",
                            Messages.getMessage("noHandler00",
                                    hName),
                            null, null);
            } else {
                /* Now we do the 'real' work.  The flow is basically:         */
                /*                                                            */
                /*   Service Specific Request Chain                           */
                /*   Global Request Chain                                     */
                /*   Transport Request Chain - must have a send at the end    */
                /*   Transport Response Chain                                 */
                /*   Global Response Chain                                    */
                /*   Service Specific Response Chain                          */
                /*   Protocol Specific-Handler/Checker                        */
                /**************************************************************/
                SOAPService service = null;
                msgContext.setPastPivot(false);

                /* Process the Service Specific Request Chain */
                /**********************************************/
                service = msgContext.getService();
                if (service != null) {
                    h = service.getRequestHandler();
                    if (h != null)
                        h.invoke(msgContext);
                }

                /* Process the Global Request Chain */
                /**********************************/
                if ((h = getGlobalRequest()) != null)
                    h.invoke(msgContext);

                /* Process the JAX-RPC Handlers  - handleRequest.
                 * Make sure to set the pastPivot to true if this returns a
                 * false. In that case we do not invoke the transport request
                 * chain. Also note that if a a false was returned from the
                 * JAX-RPC handler chain, then the chain still holds the index
                 * of the handler that returned false. So when we invoke the
                 * handleResponse method of the chain, it will correctly call
                 * the handleResponse from that specific handler instance. So
                 * do not destroy the chain at this point - the chain will be
                 * destroyed in the finally block.
                 */
                handlerImpl = getJAXRPChandlerChain(msgContext);
                if (handlerImpl != null) {
                    try {
                        if (!handlerImpl.handleRequest(msgContext)) {
                            msgContext.setPastPivot(true);
                        }
                    } catch (RuntimeException re) {
                        handlerImpl.destroy()// WS4EE 1.1 6.2.2.1 Handler Life Cycle. "RuntimeException" --> destroy handler
                        throw re;
                    }
                }

                /** Process the Transport Specific stuff
                 *
                 * NOTE: Somewhere in here there is a handler which actually
                 * sends the message and receives a response.  Generally
                 * this is the pivot point in the Transport chain. But invoke
                 * this only if pivot point has not been set to false. This
                 * can be set to false if any of the JAX-RPC handler's
                 * handleRequest returned false.
                 */
                if (!msgContext.getPastPivot()) {
                    hName = msgContext.getTransportName();
                    if (hName != null && (h = getTransport(hName)) != null) {
                        try {
                            h.invoke(msgContext);
                        } catch (AxisFault e) {
                            throw e;
                        }
                    } else {
                        throw new AxisFault(Messages.getMessage("noTransport00",
                                hName));
                    }
                }
               
                msgContext.setPastPivot(true);
                if (!msgContext.isPropertyTrue(Call.ONE_WAY)) {
                    if ((handlerImpl != null) &&
                            !msgContext.isPropertyTrue(Call.ONE_WAY)) {
                        try {
                            handlerImpl.handleResponse(msgContext);                           
                        } catch (RuntimeException ex) {
                            handlerImpl.destroy()// WS4EE 1.1 6.2.2.1 Handler Life Cycle. "RuntimeException" --> destroy handler
                            throw ex;   
                        }                       
                    }

                    /* Process the Global Response Chain */
                    /***********************************/
                    if ((h = getGlobalResponse()) != null) {
                        h.invoke(msgContext);
                    }
                   
                    /* Process the Service-Specific Response Chain */
                    /***********************************************/
                    if (service != null) {
                        h = service.getResponseHandler();
                        if (h != null) {
                            h.invoke(msgContext);
                        }
                    }

                    // Do SOAP Semantics checks here - this needs to be a call
                    // to a pluggable object/handler/something
                    if (msgContext.isPropertyTrue(Call.CHECK_MUST_UNDERSTAND,
                            true)) {
                        checker.invoke(msgContext);
                    }
                }
            }
        } catch (Exception e) {
            // Should we even bother catching it ?
            if (e instanceof AxisFault) {
                throw (AxisFault) e;
            } else {
                log.debug(Messages.getMessage("exception00"), e);
                throw AxisFault.makeFault(e);
            }
        } finally {
            if (handlerImpl != null) {
                handlerImpl.destroy();
            }
            // restore previous state
            setCurrentMessageContext(previousContext);
        }
        if (log.isDebugEnabled()) {
View Full Code Here

        public TestHandlerInfoChainFactory(List handlerInfos) {
            super(handlerInfos);
        }

        public HandlerChain createHandlerChain() {
            HandlerChain chain = super.createHandlerChain();
            handlers = new AAAHandler[chain.size()];
            for (int i = 0; i < chain.size(); i++) {
                handlers[i] = (AAAHandler) chain.get(i);
            }
            return chain;
        }
View Full Code Here

    }


    private void initHandlerChain(QName portName, HandlerRegistry handlerRegistry,
            HandlerInfo handlerInfo, ArrayList<String> soaprolesToAdd) {
        HandlerChain handlerChain = (HandlerChain) handlerRegistry.getHandlerChain(portName);
        Iterator<Handler> iter = handlerChain.iterator();
        while (iter.hasNext()) {
            Handler handler = iter.next();
            handler.init(handlerInfo);
        }
        String[] soaprolesRegistered = handlerChain.getRoles();
        String [] soaproles = new String[soaprolesRegistered.length + soaprolesToAdd.size()];
        int i;
        for (i = 0;i < soaprolesRegistered.length; i++)
            soaproles[i] = soaprolesRegistered[i];
        for (int j = 0; j < soaprolesToAdd.size(); j++)
            soaproles[i+j] = soaprolesToAdd.get(j);
        handlerChain.setRoles(soaproles);
        handlerRegistry.setHandlerChain(portName, handlerChain);
    }
View Full Code Here

            this.operation = operation;
        }

        @AroundInvoke
        public Object intercept(InvocationContext context) throws Exception {
            HandlerChain handlerChain = new HandlerChainImpl(handlerInfos);
            try {
                Object invocationResult = null;

                try {
                    if (handlerChain.handleRequest(messageContext)) {
                        // update arguments as handlers could change the soap msg
                        context.setParameters(getArguments());

                        invocationResult = context.proceed();

                        // update the soap msg so that handlers see invocation result
                        if (!handlerChain.isEmpty()) {
                            createResult(invocationResult);
                        }

                    } else {
                        /* The Handler implementation class has the responsibility of setting
                         * the response SOAP message in the handleRequest method and perform
                         * additional processing in the handleResponse method.
                         */
                        invocationResult = null;
                    }
                } catch (SOAPFaultException e) {
                    handlerChain.handleFault(messageContext);
                    throw e;
                }

                handlerChain.handleResponse(messageContext);

                if (!handlerChain.isEmpty()) {
                    /*
                     * Deserialize the result value from soap msg as handers could have
                     * changed it.
                     */
                    try {
                        invocationResult = demarshallResult();
                    } catch (Exception e) {
                        // if this fails, return invocationResult from above
                    }
                }

                return invocationResult;
            } finally {
                handlerChain.destroy();
            }
        }
View Full Code Here

        SEIFactory seiFactory = (SEIFactory) portNameToSEIFactoryMap.get(portName);
        if (seiFactory == null) {
            return null;
        }
        HandlerChain handlerChain = seiFactory.createHandlerChain();
        return handlerChain;

    }
View Full Code Here

            throw new ServiceException("Could not construct service instance", e.getTargetException());
        }
    }

    public HandlerChain createHandlerChain() {
        HandlerChain handlerChain = handlerInfoChainFactory.createHandlerChain();
        return handlerChain;
    }
View Full Code Here

TOP

Related Classes of javax.xml.rpc.handler.HandlerChain

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.