当前位置: 首页>>代码示例>>Java>>正文


Java Handler类代码示例

本文整理汇总了Java中org.apache.axis2.engine.Handler的典型用法代码示例。如果您正苦于以下问题:Java Handler类的具体用法?Java Handler怎么用?Java Handler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Handler类属于org.apache.axis2.engine包,在下文中一共展示了Handler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doProcessing

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
@Test
public void doProcessing() throws Exception {
    // Creating SOAP envelope
    SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);

    MessageContext mc = new MessageContext();

    try {
        mc.setEnvelope(env);
    } catch (AxisFault axisFault) {
        fail(axisFault.getMessage());
    }

    assertFalse(headerBlock.isProcessed());

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    assertTrue(headerBlock.isProcessed());
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:27,代码来源:ReportHeaderProcessedTest.java

示例2: testDoProcessingForResponder

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
@Test
public void testDoProcessingForResponder() throws Exception {
    System.out.println("[testDoProcessingForResponder]");
    MessageContext mc = new MessageContext();
    mc.setFLOW(MessageContext.OUT_FLOW);
    mc.setServerSide(true);

    AxisHttpResponse response = mock(AxisHttpResponse.class);
    mc.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO, response);

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertNotNull(invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    verify(response).setHeader("Server", HTTP_HDR_VALUE);
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:19,代码来源:HTTPProductIdentifierTest.java

示例3: testDoProcessingOfErrors

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
@Test
public void testDoProcessingOfErrors() throws Exception {
    // Initialising Errors
    ErrorMessage error = new ErrorMessage();
    error.setMessageId("some_message_id");
    error.setTimestamp(new Date());
    ArrayList<IEbmsError> errors = new ArrayList<>();
    errors.add(new EbmsError());
    error.setErrors(errors);

    MessageContext mc = new MessageContext();

    // Setting input Receipt property
    StorageManager updateManager = core.getStorageManager();

    IErrorMessageEntity errorMessageEntity =
            updateManager.storeIncomingMessageUnit(error);
    System.out.println("errors: " + errorMessageEntity.getErrors());
    ArrayList<IErrorMessageEntity> errorMessageEntities = new ArrayList<>();
    errorMessageEntities.add(errorMessageEntity);
    mc.setProperty(MessageContextProperties.IN_ERRORS,
            errorMessageEntities);

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    // Checking log messages to make sure handler validated
    // the pull request successfully
    verify(mockAppender, atLeastOnce())
            .doAppend(captorLoggingEvent.capture());
    List<LoggingEvent> events = captorLoggingEvent.getAllValues();
    String msg = "Received Error satisfies basic validations";
    assertTrue(eventContainsMsg(events, Level.DEBUG, msg));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:39,代码来源:BasicHeaderValidationTest.java

示例4: copyPhase

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
/**
 * To copy phase information from one to another
 *
 * @param phase
 */
private Phase copyPhase(Phase phase) throws DeploymentException {
    Phase newPhase = new Phase(phase.getPhaseName());
    Iterator<Handler> handlers = phase.getHandlers().iterator();

    while (handlers.hasNext()) {
        try {
            Handler handlerDescription = (Handler) handlers.next();

            newPhase.addHandler(handlerDescription.getHandlerDesc());
        } catch (PhaseException e) {
            throw new DeploymentException(e);
        }
    }

    return newPhase;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:22,代码来源:PhasesInfo.java

示例5: testDynamicPhase

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
public void testDynamicPhase() {
    List inFlow = axisConfig.getInFlowPhases();
    for (int i = 0; i < inFlow.size(); i++) {
        Phase phase = (Phase) inFlow.get(i);
        if (phase.getName().equals("NewPhase")) {
            assertEquals("Wrong index for NewPhase!", 3, i);
            assertEquals("Wrong # of handlers in NewPhase", 3, phase.getHandlerCount());
            Handler h6 = (Handler)phase.getHandlers().get(0);
            assertTrue("Wrong type for handler", h6 instanceof Handler3);
        }
    }

    inFlow = axisConfig.getInFaultFlowPhases();
    assertTrue("NewPhase wasn't found in InFaultFlow", isPhaseInFlow(inFlow, "NewPhase"));

    List outFlow = axisConfig.getInFaultFlowPhases();
    assertTrue("NewPhase wasn't found in OutFlow", isPhaseInFlow(outFlow, "NewPhase"));        
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:19,代码来源:DeploymentTotalTest.java

示例6: getPhaseData

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
private PhaseData getPhaseData(Phase phase, boolean isGlobalPhase, boolean invert) {
    PhaseData phaseData = new PhaseData(phase.getPhaseName());
    phaseData.setIsGlobalPhase(isGlobalPhase);
    HandlerData[] handlers = new HandlerData[phase.getHandlerCount()];

    // populate the phase handlers
    Handler handler;
    if (invert) {
        for (int i = phase.getHandlers().size() - 1, j = 0; i >= 0; i--, j++) {
            handler = phase.getHandlers().get(i);
            handlers[j] = getHandlerData(handler);
        }
    } else {
        for (int i = 0; i < phase.getHandlers().size(); i++) {
            handler = phase.getHandlers().get(i);
            handlers[i] = getHandlerData(handler);
        }
    }

    phaseData.setHandlers(handlers);
    log.debug("Setting phase ==> " + phaseData.getName());
    return phaseData;
}
 
开发者ID:wso2,项目名称:carbon-commons,代码行数:24,代码来源:AxisConfigAdminService.java

示例7: testDoProcessingForInitiator

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
@Test
public void testDoProcessingForInitiator() throws Exception {
    System.out.println("[testDoProcessingForInitiator]");
    MessageContext mc = new MessageContext();
    mc.setFLOW(MessageContext.OUT_FLOW);
    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertNotNull(invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    Options options = mc.getOptions();
    assertNotNull(options.getProperty(HTTPConstants.USER_AGENT));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:15,代码来源:HTTPProductIdentifierTest.java

示例8: testDoProcessing

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
@Test
public void testDoProcessing() throws Exception {
    MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
    // Creating SOAP envelope
    SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);
    // Adding UserMessage from mmd
    OMElement umElement = UserMessageElement.createElement(headerBlock, mmd);

    MessageContext mc = new MessageContext();

    UserMessage userMessage
            = UserMessageElement.readElement(umElement);
    String msgId = userMessage.getMessageId();
    StorageManager updateManager = core.getStorageManager();
    IUserMessageEntity userMessageEntity =
            updateManager.storeIncomingMessageUnit(userMessage);
    mc.setProperty(MessageContextProperties.IN_USER_MESSAGE,
            userMessageEntity);

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    verify(mockAppender, atLeastOnce()).doAppend(captorLoggingEvent.capture());
    LoggingEvent loggingEvent = captorLoggingEvent.getValue();
    //Check log level
    assertThat(loggingEvent.getLevel(), is(Level.WARN));
    //Check the message being logged
    assertThat(loggingEvent.getRenderedMessage(),
            is("User message [msgId= " + msgId + "] is ready for processing"));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:37,代码来源:StartProcessingUsrMessageTest.java

示例9: testProcessing

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
/**
 * Test construction of the user message to be successfully consumed by
 * {@link org.holodeckb2b.ebms3.handlers.inflow.ReadUserMessage ReadUserMessage} handler
 */
@Test
public void testProcessing() {
    MessageMetaData mmd = TestUtils.getMMD("handlers/full_mmd.xml", this);
    // Creating SOAP envelope
    SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);
    // Adding UserMessage from mmd
    UserMessageElement.createElement(headerBlock, mmd);

    MessageContext mc = new MessageContext();
    try {
        mc.setEnvelope(env);
    } catch (AxisFault axisFault) {
        fail(axisFault.getMessage());
    }

    assertNull(mc.getProperty(MessageContextProperties.IN_USER_MESSAGE));

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }

    assertNotNull(mc.getProperty(MessageContextProperties.IN_USER_MESSAGE));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:33,代码来源:ReadUserMessageTest.java

示例10: testInFlows

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
@Test
public void testInFlows() throws Exception {
    // Creating SOAP envelope
    SOAPEnvelope env = SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);

    MessageContext mc = new MessageContext();
    mc.setFLOW(MessageContext.IN_FLOW);

    try {
        mc.setEnvelope(env);
    } catch (AxisFault axisFault) {
        fail(axisFault.getMessage());
    }

    PullRequest pullRequest = new PullRequest();
    pullRequest.setMessageId("some_pull_request_id_01");

    PullRequestElement.createElement(headerBlock, pullRequest);

    assertNull(mc.getProperty(MessageContextProperties.IN_PULL_REQUEST));
    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertEquals(Handler.InvocationResponse.CONTINUE, invokeResp);
    } catch (Exception e) {
        fail(e.getMessage());
    }
    assertNotNull(mc.getProperty(MessageContextProperties.IN_PULL_REQUEST));
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:31,代码来源:ReadPullRequestTest.java

示例11: testMessageReceivedFromICloud

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
@Test
public void testMessageReceivedFromICloud() throws PersistenceException {
    MessageMetaData mmd = TestUtils.getMMD("multihop/icloud/full_mmd.xml", this);
    // Creating SOAP envelope
    SOAPEnvelope env =
            SOAPEnv.createEnvelope(SOAPEnv.SOAPVersion.SOAP_12);
    // Adding header
    SOAPHeaderBlock headerBlock = Messaging.createElement(env);
    // Adding UserMessage from mmd
    OMElement userMessage = UserMessageElement.createElement(headerBlock, mmd);

    IUserMessageEntity userMessageEntity =
            HolodeckB2BCore.getStorageManager().storeIncomingMessageUnit(
                            UserMessageElement.readElement(userMessage));

    MessageContext mc = new MessageContext();

    // Setting input message property
    mc.setProperty(MessageContextProperties.IN_USER_MESSAGE, userMessageEntity);
    try {
        mc.setEnvelope(env);
    } catch (AxisFault axisFault) {
        fail(axisFault.getMessage());
    }

    SOAPHeaderBlock messaging = Messaging.getElement(mc.getEnvelope());
    // Setting Role, as stated in paragraph 4.3 of AS4 profile
    messaging.setRole(MultiHopConstants.NEXT_MSH_TARGET);

    assertNotNull(MessageContextUtils.getReceivedMessageUnits(mc));

    try {
        Handler.InvocationResponse invokeResp = handler.invoke(mc);
        assertEquals("InvocationResponse.CONTINUE", invokeResp.toString());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
 
开发者ID:holodeck-b2b,项目名称:Holodeck-B2B,代码行数:39,代码来源:CheckFromICloudTest.java

示例12: findHandler

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
/**
 * Find the Handler object that matches the criteria
 * 
 * @param existingHandlers The list of existing handlers and phases
 * @param handlerClassName the class name string for the target object
 *                   (could be a derived class)
 * @return the Handler object that matches the criteria
 */
public static Object findHandler(List<Handler> existingHandlers, MetaDataEntry metaDataEntry) //String handlerClassName)
{

    String title = "ObjectStateUtils:findHandler(): ";

    String handlerClassName = metaDataEntry.getClassName();
    String qNameAsString = metaDataEntry.getQNameAsString();

    for (int i = 0; i < existingHandlers.size(); i++) {
        if (existingHandlers.get(i) != null) {
            String tmpClassName = existingHandlers.get(i).getClass().getName();
            String tmpName = ((Handler) existingHandlers.get(i)).getName().toString();

            if ((tmpClassName.equals(handlerClassName)) && (tmpName.equals(qNameAsString))) {
                // trace point
                if (log.isTraceEnabled()) {
                    log.trace(title + " [" + handlerClassName + "]  name [" + qNameAsString
                            + "]  returned");
                }

                return (Handler) (existingHandlers.get(i));
            }
        }
    }

    // trace point
    if (log.isTraceEnabled()) {
        log.trace(title + " [" + handlerClassName + "]  name [" + qNameAsString
                + "] was not found in the existingHandlers list");
    }

    return null;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:42,代码来源:ActivateUtils.java

示例13: addExecutedPhase

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
/**
 * Add a Phase to the collection of executed phases for the path.
 * Phases will be inserted in a LIFO data structure.
 *
 * @param phase The phase to add to the list.
 */
public void addExecutedPhase(Handler phase) {
    if (executedPhases == null) {
        executedPhases = new LinkedList<Handler>();
    }
    executedPhases.addFirst(phase);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:13,代码来源:MessageContext.java

示例14: getExecutedPhases

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
/**
 * Get an iterator over the executed phase list.
 *
 * @return An Iterator over the LIFO data structure.
 */
public Iterator<Handler> getExecutedPhases() {
    if (DEBUG_ENABLED) {
        checkActivateWarning("getExecutedPhases");
    }
    if (executedPhases == null) {
        executedPhases = new LinkedList<Handler>();
    }
    return executedPhases.iterator();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:15,代码来源:MessageContext.java

示例15: flattenHandlerList

import org.apache.axis2.engine.Handler; //导入依赖的package包/类
/**
 * Flatten the handler list into just unique handler instances
 * including phase instances.
 *
 * @param list the list of handlers/phases
 * @param map  users should pass null as this is just a holder for the recursion
 * @return a list of unigue object instances
 */
private ArrayList<Handler> flattenHandlerList(List<Handler> list, LinkedHashMap<String, Handler> map) {

    if (map == null) {
        map = new LinkedHashMap<String, Handler>();
    }

    Iterator<Handler> it = list.iterator();
    while (it.hasNext()) {
        Handler handler = (Handler) it.next();

        String key = null;
        if (handler != null) {
            key = handler.getClass().getName() + "@" + handler.hashCode();
        }

        if (handler instanceof Phase) {
            // put the phase in the list
            map.put(key, handler);

            // add its handlers to the list
            flattenHandlerList(((Phase) handler).getHandlers(), map);
        } else {
            // if the same object is already in the list,
            // then it won't be in the list multiple times
            map.put(key, handler);
        }
    }

    return new ArrayList<Handler>(map.values());
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:39,代码来源:MessageContext.java


注:本文中的org.apache.axis2.engine.Handler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。