Java 8 LogicalMessageContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 LogicalMessageContext class.

This code example shows how to use the following methods:get, getMessage
      return true; 
   } 
 
   @Override 
   public boolean handleMessage(LogicalMessageContext mc) {
      HandlerUtils.printMessageContext("Service LogicalHandler", mc);
      if (Boolean.FALSE.equals(mc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY))) {
         try { 
            LogicalMessage msg = mc.getMessage();
            JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
            Object payload = msg.getPayload(jaxbContext);
            if (payload instanceof DoubleIt) { 
               DoubleIt req = (DoubleIt) payload;
               if (req.getNumberToDouble() == 30) {
                  throw new ProtocolException(
                        "Doubling 30 is not allowed by the web service provider."); 
               } 
            } 
         } catch (JAXBException ex) {
            throw new ProtocolException(ex);
6
CodeRank
This code example shows how to use the following methods:get, getMessage
 
    public final boolean handleMessage(LogicalMessageContext messageContext) {
        System.out.println("LogicalMessageHandler handleMessage called");
 
        try { 
            boolean outbound = (Boolean)messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
 
            if (outbound) {
                // get the LogicalMessage from our context 
                // 
                LogicalMessage msg = messageContext.getMessage();
 
                // check the payload, if its an AddNumbers request, we'll intervene 
                // 
                JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
                Object payload = msg.getPayload(jaxbContext);
                if (payload instanceof JAXBElement) {
                    payload = ((JAXBElement)payload).getValue();
                } 
 
5
CodeRank
This code example shows how to use the following methods:get, getMessage
     
    public final boolean handleMessage(LogicalMessageContext messageContext) {
        //System.out.println("LogicalMessageHandler handleMessage called"); 
 
        try { 
            boolean outbound = (Boolean)messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
 
            if (outbound) {
                // get the LogicalMessage from our context 
                LogicalMessage msg = messageContext.getMessage();
 
                // check the payload, if its an AddNumbers request, we'll intervene 
                JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
                Object payload = msg.getPayload(jaxbContext);
                if (payload instanceof JAXBElement) {
                    payload = ((JAXBElement<?>)payload).getValue();
                } 
 
                if (payload instanceof AddNumbers) { 
                    AddNumbers req = (AddNumbers)payload;
5
CodeRank
This code example shows how to use the following methods:get, put, setScope
    * @param smc SOAPMessageContext 
    * @return boolean  
    */ 
	public boolean handleMessage(LogicalMessageContext smc) {
		Boolean outboundProperty = (Boolean) smc
				.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); 
		if (outboundProperty.booleanValue()) { 
			startTime = new Date();
			smc.put(HandlerName + "StartTime", startTime);
		} else {  
			try { 
				startTime = (Date) smc.get(HandlerName + "StartTime");
				endTime = new Date();
				long elapsedTime = endTime.getTime() - startTime.getTime();
				 
				smc.put("ELAPSED_TIME", elapsedTime);
				smc.setScope("ELAPSED_TIME", MessageContext.Scope.APPLICATION); 
				logger.info("Elapsed time in handler " + HandlerName + " is " 
						+ elapsedTime); 
			} catch (Exception x) {

5
CodeRank
This code example shows how to use the following methods:get, getMessage
 
    @Resource(name="greeting") 
    private String greeting;
 
    public boolean handleMessage(LogicalMessageContext context) {
        System.out.println(this + " HandleMessage: " + context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY) + " " + greeting);
        System.out.println(context.getMessage().getPayload());
        return true; 
    } 
 
    @PostConstruct 
    public void init() { 
        System.out.println(this + " init " + context);
    } 
 
    @PreDestroy 
    public void destroy() { 
        System.out.println(this + " destroy");
    } 
     
5
CodeRank
This code example shows how to use the following methods:getMessage
 
 
public class TestLogicalHandler implements LogicalHandler<LogicalMessageContext> {
    public boolean handleMessage(LogicalMessageContext ctx) {
        try { 
            LogicalMessage msg = ctx.getMessage();
            Source payload = msg.getPayload();
            String request = getSourceAsString(payload);
            // System.out.println(getSourceAsString(payload)); 
 
            // Make sure SOAP handler has changed the value successfully. 
            if (request.indexOf("ServerSOAPHandler") >= 0) {
                InputStream greetMeInputStream = getClass()
                    .getResourceAsStream("resources/GreetMeRpcLiteralReqLogical.xml");
                StreamSource source = new StreamSource();
                source.setInputStream(greetMeInputStream);
                msg.setPayload(source);
            } else if (request.indexOf("TestGreetMeResponse") >= 0) {
                InputStream greetMeInputStream = getClass()
                    .getResourceAsStream("resources/GreetMeRpcLiteralRespLogical.xml");
4
CodeRank
This code example shows how to use the following methods:getMessage
    public final boolean handleMessage(LogicalMessageContext messageContext) {
        //System.out.println("LogicalMessageHandler handleMessage called"); 
 
        try { 
            // get the LogicalMessage from our context 
            LogicalMessage msg = messageContext.getMessage();
 
            // check the payload, if its an AddNumbers request, we'll intervene 
            JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
            Object payload = msg.getPayload(jaxbContext);
            Object value = payload; 
            if (payload instanceof JAXBElement) {
                value = ((JAXBElement<?>)payload).getValue();
            } 
 
            if (value instanceof AddNumbers) { 
                AddNumbers req = (AddNumbers)value;
 
                int a = req.getArg0();
                req.setArg0(a * 10);
4
CodeRank
This code example shows how to use the following methods:getMessage
     * @throws Exception 
     */ 
    public void testGetPayloadAsSource() throws Exception {
        LogicalMessageContext lmc = createSampleContext();
         
        LogicalMessage msg = lmc.getMessage();
        assertTrue("The returned LogicalMessage was null", msg != null);
         
        Source payload = msg.getPayload();
        assertTrue("The returned payload (Source) was null", payload != null);
         
        String resultContent = _getStringFromSource(payload);
        assertTrue("The content returned was null", resultContent != null);
        assertTrue("The content returned was incomplete, unexpected element", resultContent.indexOf("echoString") > -1);
        assertTrue("The content returned was incomplete, unexpected content", resultContent.indexOf(INPUT) > -1);
    } 
     
    /** 
     * Tests the setting of the payload and make sure we don't cache improperly. 
     * @throws Exception 
4
CodeRank
This code example shows how to use the following methods:put
See Code Examples for Java 8 LogicalMessageContext Methods: