Package org.apache.axis2.engine

Examples of org.apache.axis2.engine.Phase


     * Add well-known Phases on the out side
     *
     * @param flow the Flow in which to add these Phases
     */
    private void addOutPhases(ArrayList flow) {
        flow.add(new Phase("MessageOut"));
    }
View Full Code Here


    public void testPhaseRule() throws Exception {
        //TODO Fix me
        phaserul = new PreDispatchPhaseRuleTest("");
        axisSytem = new AxisConfiguration();
        ArrayList inPhase = axisSytem.getInFlowPhases();
        Phase transportIN = new Phase("TransportIn");
        Phase preDispatch = new Phase("PreDispatch");
        DispatchPhase dispatchPhase = new DispatchPhase();
//
        dispatchPhase.setName("Dispatch");
        inPhase.add(transportIN);
        inPhase.add(preDispatch);
View Full Code Here

        }*/
    }

    public void testPhaseLastAndAfter() throws Exception {

        Phase phase = new Phase();

        //////////////// handler 1 //////////////////////////
        PhaseRuleHandler h1 = new PhaseRuleHandler("a");
        HandlerDescription hd1 = new HandlerDescription("a");
        h1.init(hd1);
        hd1.setHandler(h1);
        phase.addHandler(hd1);
        /////////////////////////////////////////////////////

        //////////////// handler 4 //////////////////////////
        PhaseRule rule4 = new PhaseRule();
        rule4.setPhaseLast(true);

        PhaseRuleHandler h4 = new PhaseRuleHandler("d");
        HandlerDescription hd4 = new HandlerDescription("d");
        h4.init(hd4);

        hd4.setHandler(h4);
        hd4.setRules(rule4);
        phase.addHandler(hd4);
        ////////////////////////////////////////////////////

        //////////////// handler 2 //////////////////////////
        PhaseRule rule2 = new PhaseRule();
        rule2.setAfter("a");

        HandlerDescription hd2 = new HandlerDescription("b");
        PhaseRuleHandler h2 = new PhaseRuleHandler("b");
        h2.init(hd2);

        hd2.setHandler(h2);
        hd2.setRules(rule2);
        phase.addHandler(hd2);
        //////////////////////////////////////////////////////

        //////////////// handler 3 //////////////////////////
        PhaseRule rule3 = new PhaseRule();
        rule3.setAfter("b");

        HandlerDescription hd3 = new HandlerDescription("c");
        PhaseRuleHandler h3 = new PhaseRuleHandler("c");
        h3.init(hd3);

        hd3.setHandler(h3);
        hd3.setRules(rule3);
        try {
            phase.addHandler(hd3);
        } catch (Exception e) {
            fail("Adding handlers with after attribute to the phase behaviour failed");
        }
        //////////////////////////////////////////////////////
    }
View Full Code Here

    public void testPhaseRules() throws Exception {
        //TODO fix me
        axisConfig = new AxisConfiguration();
        ArrayList inPhase = axisConfig.getInFlowPhases();
        Phase transportIN = new Phase("TransportIn");
        Phase preDispatch = new Phase("PreDispatch");
        DispatchPhase dispatchPhase = new DispatchPhase();
//
        dispatchPhase.setName("Dispatch");
        inPhase.add(transportIN);
        inPhase.add(preDispatch);
        inPhase.add(dispatchPhase);

        HandlerDescription hm = new HandlerDescription();
        hm.setClassName("org.apache.axis2.handlers.AbstractHandler");
        Handler h1 = new PhaseRuleHandler();
        hm.setHandler(h1);
        hm.getRules().setPhaseName("*");

        PhaseHolder ph = new PhaseHolder(inPhase);
        ph.addHandler(hm);
        boolean found;
        for (int i = 0; i < inPhase.size(); i++) {
            found = false;
            Phase phase = (Phase) inPhase.get(i);
            List handlers = phase.getHandlers();
            for (int j = 0; j < handlers.size(); j++) {
                Handler handler = (Handler) handlers.get(j);
                if (h1.equals(handler)) {
                    found = true;
                }
            }
            if (!found) {
                fail("Some thing has gone wrong hnadler does not exit in the phase :"
                        + phase.getPhaseName());
            }
        }
    }
View Full Code Here

    public void testPhaseRulesWithPhaseFirst() throws Exception {
        super.setUp();
        //TODO fix me
        axisConfig = new AxisConfiguration();
        ArrayList inPhase = axisConfig.getInFlowPhases();
        Phase transportIN = new Phase("TransportIn");
        Phase preDispatch = new Phase("PreDispatch");
        DispatchPhase dispatchPhase = new DispatchPhase();
//
        dispatchPhase.setName("Dispatch");
        inPhase.add(transportIN);
        inPhase.add(preDispatch);
        inPhase.add(dispatchPhase);

        HandlerDescription hm = new HandlerDescription();
        hm.setClassName("org.apache.axis2.handlers.AbstractHandler");
        Handler h1 = new PhaseRuleHandler();
        hm.setHandler(h1);
        hm.getRules().setPhaseName("*");
        hm.getRules().setPhaseFirst(true);

        PhaseHolder ph = new PhaseHolder(inPhase);
        ph.addHandler(hm);
        for (int i = 0; i < inPhase.size(); i++) {
            Phase phase = (Phase) inPhase.get(i);
            List handlers = phase.getHandlers();
            Handler handler = (Handler) handlers.get(0);
            if (!h1.equals(handler)) {
                fail("Some thing has gone wrong hnadler does not exit as phase " +
                        "first handler the phase :"
                        + phase.getPhaseName());
            }
        }
    }
View Full Code Here

    public void testPhaseRulesWithAfter() throws Exception {
        //TODO fix me
        axisConfig = new AxisConfiguration();
        ArrayList inPhase = axisConfig.getInFlowPhases();
        Phase transportIN = new Phase("TransportIn");
        Phase preDispatch = new Phase("PreDispatch");
        DispatchPhase dispatchPhase = new DispatchPhase();
//
        dispatchPhase.setName("Dispatch");
        inPhase.add(transportIN);
        inPhase.add(preDispatch);
        inPhase.add(dispatchPhase);

        HandlerDescription hm = new HandlerDescription();
        hm.setClassName("org.apache.axis2.handlers.AbstractHandler");
        Handler h1 = new PhaseRuleHandler();
        hm.setHandler(h1);
        hm.getRules().setPhaseName("*");
        hm.getRules().setPhaseFirst(true);

        PhaseHolder ph = new PhaseHolder(inPhase);
        ph.addHandler(hm);
        for (int i = 0; i < inPhase.size(); i++) {
            Phase phase = (Phase) inPhase.get(i);
            List handlers = phase.getHandlers();
            Handler handler = (Handler) handlers.get(0);
            assertNull(handler.getHandlerDesc().getRules().getAfter());
        }
    }
View Full Code Here

        while (phases.hasNext()) {
            OMElement phaseelement = (OMElement) phases.next();
            String phaseName =
                    phaseelement.getAttribute(new QName(ATTRIBUTE_NAME)).getAttributeValue();
            String phaseClass = phaseelement.getAttributeValue(new QName(TAG_CLASS_NAME));
            Phase phase;

            try {
                phase = getPhase(phaseClass);
            } catch (Exception e) {
                throw new DeploymentException(
                        Messages.getMessage("phaseclassnotfound", phaseClass, e.getMessage()));
            }

            phase.setName(phaseName);

            Iterator handlers = phaseelement.getChildrenWithName(new QName(TAG_HANDLER));

            while (handlers.hasNext()) {
                OMElement omElement = (OMElement) handlers.next();
                HandlerDescription handler = processHandler(omElement, axisConfig, phaseName);

                handler.getRules().setPhaseName(phaseName);
                try {
                    if (Utils.loadHandler(axisConfig.getSystemClassLoader(), handler)) {
                        try {
                            phase.addHandler(handler);
                        } catch (PhaseException e) {
                            throw new DeploymentException(e);
                        }
                    }
                } catch (UnsupportedClassVersionError e) {
View Full Code Here

    }

    private Phase getPhase(String className)
            throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        if (className == null) {
            return new Phase();
        }
        Class phaseClass = Loader.loadClass(axisConfig.getSystemClassLoader(), className);
        return (Phase) phaseClass.newInstance();
    }
View Full Code Here

                // get the correct object-specific name
                String qnameAsString;

                if (obj instanceof Phase) {
                    Phase phaseObj = (Phase) obj;
                    qnameAsString = phaseObj.getName();

                    // add the list of handlers to the meta data
                    setupPhaseList(phaseObj, mdEntry);
                } else if (obj instanceof Handler) {
                    Handler handlerObj = (Handler) obj;
                    qnameAsString = handlerObj.getName();
                } else {
                    // TODO: will there be any other kinds of objects in the execution Chain?
                    qnameAsString = "NULL";
                }

                mdEntry.setQName(qnameAsString);

                // update the index for the entry in the chain

                if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                    log.trace(logCorrelationIDString +
                            ":writeExternal(): ***BEFORE OBJ WRITE*** executionChain entry class [" +
                            objClass + "] qname [" + qnameAsString + "]");
                }

                out.writeObject(mdEntry);

                // update the index so that the index
                // now indicates the next entry that
                // will be attempted
                nextIndex++;

                if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                    log.trace(logCorrelationIDString +
                            ":writeExternal(): ***AFTER OBJ WRITE*** executionChain entry class [" +
                            objClass + "] qname [" + qnameAsString + "]");
                }

            } // end while entries in execution chain

            // done with the entries in the execution chain
            // add the end-of-list marker
            MetaDataEntry lastEntry = new MetaDataEntry();
            lastEntry.setClassName(MetaDataEntry.END_OF_LIST);

            out.writeObject(lastEntry);
            nextIndex++;

            // nextIndex also gives us the number of entries
            // that were actually saved as opposed to the
            // number of entries in the executionChain
            out.writeInt(nextIndex);

        } else {
            // general case: handle "null" or "empty"
            out.writeBoolean(ExternalizeConstants.EMPTY_OBJECT);

            if (LoggingControl.debugLoggingAllowed && log.isTraceEnabled()) {
                log.trace(logCorrelationIDString + ":writeExternal(): executionChain is NULL");
            }
        }

        //---------------------------------------------------------
        // LinkedList executedPhases
        //---------------------------------------------------------
        // The strategy is to save some metadata about each
        // member of the list and the order of the list.
        // Then when the message context is re-constituted,
        // try to match up with phases and handlers on the
        // engine.
        //
        // Non-null list:
        //    UTF          - description string
        //    boolean      - active flag
        //    int          - expected number of entries in the list
        //    objects      - MetaDataEntry object per list entry
        //                        last entry will be empty MetaDataEntry
        //                        with MetaDataEntry.LAST_ENTRY marker
        //    int          - adjusted number of entries in the list
        //                        includes the last empty entry
        //
        // Empty list:
        //    UTF          - description string
        //    boolean      - empty flag
        //---------------------------------------------------------
        out.writeUTF("executedPhases");
        if (executedPhases != null && executedPhases.size() > 0) {
       
            // start writing data to the output stream
            out.writeBoolean(ExternalizeConstants.ACTIVE_OBJECT);
            out.writeInt(executedPhases.size());

            // put the metadata on each member of the list into a buffer

            int execNextIndex = 0;

            Iterator iterator = executedPhases.iterator();

            while (iterator.hasNext()) {
                Object obj = iterator.next();
                String objClass = obj.getClass().getName();
                // start the meta data entry for this object
                MetaDataEntry mdEntry = new MetaDataEntry();
                mdEntry.setClassName(objClass);

                // get the correct object-specific name
                String qnameAsString;

                if (obj instanceof Phase) {
                    Phase inPhaseObj = (Phase) obj;
                    qnameAsString = inPhaseObj.getName();

                    // add the list of handlers to the meta data
                    setupPhaseList(inPhaseObj, mdEntry);
                } else if (obj instanceof Handler) {
                    Handler inHandlerObj = (Handler) obj;
View Full Code Here

                // get the correct object-specific name
                String qnameAsString;

                if (obj instanceof Phase) {
                    // nested condition, the phase object contains another phase!
                    Phase phaseObj = (Phase) obj;
                    qnameAsString = phaseObj.getName();

                    // add the list of handlers to the meta data
                    setupPhaseList(phaseObj, mdEntry);
                } else if (obj instanceof Handler) {
                    Handler handlerObj = (Handler) obj;
View Full Code Here

TOP

Related Classes of org.apache.axis2.engine.Phase

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.