Package org.mule.session

Examples of org.mule.session.DefaultMuleSession


    /** @see EE-1705/MULE-4567 */
    public void testSessionProperties() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler handler = new SerializeAndEncodeSessionHandler();
        MuleSession session = new DefaultMuleSession(muleContext);
       
        String string = "bar";
        session.setProperty("fooString", string);

        Date date = new Date(0);
        session.setProperty("fooDate", date);
       
        List<String> list = createList();
        session.setProperty("fooList", list);
       
        handler.storeSessionInfoToMessage(session, message);
        // store save session to outbound, move it to the inbound
        // for retrieve to deserialize
        Object s = message.removeProperty(MuleProperties.MULE_SESSION_PROPERTY);
        message.setInboundProperty(MuleProperties.MULE_SESSION_PROPERTY, s);
        session = handler.retrieveSessionInfoFromMessage(message);
       
        Object obj = session.getProperty("fooString");
        assertTrue(obj instanceof String);
        assertEquals(string, obj);
       
        obj = session.getProperty("fooDate");
        assertTrue("Object should be a Date but is " + obj.getClass().getName(), obj instanceof Date);
        assertEquals(date, obj);

        obj = session.getProperty("fooList");
        assertTrue("Object should be a List but is " + obj.getClass().getName(), obj instanceof List);
        assertEquals(list, obj);
    }
View Full Code Here


    /** @see EE-1774 */
    public void testNonSerializableSessionProperties() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        MuleSession session = new DefaultMuleSession(muleContext);
        SessionHandler handler = new SerializeAndEncodeSessionHandler();
       
        NotSerializableClass clazz = new NotSerializableClass();
        session.setProperty("foo", clazz);
        handler.storeSessionInfoToMessage(session, message);
        // store save session to outbound, move it to the inbound
        // for retrieve to deserialize
        Object s = message.removeProperty(MuleProperties.MULE_SESSION_PROPERTY);
        message.setInboundProperty(MuleProperties.MULE_SESSION_PROPERTY, s);
        session = handler.retrieveSessionInfoFromMessage(message);
        // Property was removed because it could not be serialized
        assertNull(session.getProperty("foo"));
    }   
View Full Code Here

    /** @see EE-1820 */
    public void testBackwardsCompatibility() throws Exception
    {
        MuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler legacyHandler = new LegacySessionHandler();
        MuleSession session = new DefaultMuleSession(muleContext);
       
        String string = "bar";
        session.setProperty("fooString", string);

        Date date = new Date(0);
        session.setProperty("fooDate", date);
       
        List<String> list = createList();
        session.setProperty("fooList", list);
       
        legacyHandler.storeSessionInfoToMessage(session, message);
        try
        {
            // Try to deserialize legacy format with new session handler
View Full Code Here

    /** @see EE-1820 */
    public void testSessionPropertiesLegacyFormat() throws Exception
    {
        DefaultMuleMessage message = new DefaultMuleMessage("Test Message", muleContext);
        SessionHandler handler = new LegacySessionHandler();
        MuleSession session = new DefaultMuleSession(muleContext);
       
        String string = "bar";
        session.setProperty("fooString", string);

        Date date = new Date(0);
        session.setProperty("fooDate", date);
       
        List<String> list = createList();
        session.setProperty("fooList", list);

        handler.storeSessionInfoToMessage(session, message);
        // store save session to outbound, move it to the inbound
        // for retrieve to deserialize
        Object s = message.removeProperty(MuleProperties.MULE_SESSION_PROPERTY);
        message.setInboundProperty(MuleProperties.MULE_SESSION_PROPERTY, s);
        session = handler.retrieveSessionInfoFromMessage(message);
       
        Object obj = session.getProperty("fooString");
        assertTrue(obj instanceof String);
        assertEquals(string, obj);
       
        obj = session.getProperty("fooDate");
        // MULE-4567 / EE-1705
        assertTrue(obj instanceof String);

        obj = session.getProperty("fooList");
        // MULE-4567 / EE-1705
        assertTrue(obj instanceof String);
    }   
View Full Code Here

        EndpointBuilder endpointBuilder = muleContext.getEndpointFactory().getEndpointBuilder(endpoint);
        endpointBuilder.setExchangePattern(exchangePattern);
        OutboundEndpoint ep = endpointBuilder.buildOutboundEndpoint();
      
        DefaultMuleEvent event = new DefaultMuleEvent(message, ep.getExchangePattern(),
            new DefaultMuleSession(flowConstruct, muleContext));

        RequestContext.setEvent(event);
        MuleEvent resultEvent = ep.process(event);
       
        MuleMessage response = null;
View Full Code Here

        return asyncReplyMessageProcessor;
    }
   
    public MuleEvent process(MuleEvent event) throws MuleException
    {
        MuleSession calledSession = new DefaultMuleSession(event.getSession(), this);
        MuleEvent newEvent = new DefaultMuleEvent(event.getMessage(), event.getEndpoint(), event, calledSession);
        RequestContext.setEvent(newEvent);
        try
        {
            return messageProcessorChain.process(newEvent);
View Full Code Here

    public final MuleEvent routeMessage(MuleMessage message,
                                          Transaction trans,
                                          OutputStream outputStream) throws MuleException
    {
        return routeMessage(message, new DefaultMuleSession(connector.getMuleContext()), trans,
            outputStream);
    }
View Full Code Here

        {
            session.setFlowConstruct(flowConstruct);
        }
        else
        {
            session = new DefaultMuleSession(flowConstruct, connector.getMuleContext());
        }
        return new DefaultMuleEvent(message, getEndpoint(), session, ros);
    }
View Full Code Here

        message.addProperties(messageProperties, PropertyScope.INVOCATION);

        // Use an endpoint cache to prevent memory leaks (see MULE-5422)
        OutboundEndpoint ep = endpointCache.getOutboundEndpoint(endpoint, exchangePattern, null);
        DefaultMuleEvent event = new DefaultMuleEvent(message, ep.getExchangePattern(),
            new DefaultMuleSession(flowConstruct, muleContext));
        RequestContext.setEvent(event);

        // Set correlation properties in SESSION scope so that they get propagated to response messages.
        if (messageProperties.get(PROPERTY_PROCESS_TYPE) != null)
        {
View Full Code Here

//        }
      

        MuleEvent replyEvent = null;
        MuleMessage reply;
        MuleSession session = new DefaultMuleSession(flow, muleContext);

        try
        {
            replyEvent = router.process(new DefaultMuleEvent(message, router.getEndpoint()
                .getExchangePattern(), session));
View Full Code Here

TOP

Related Classes of org.mule.session.DefaultMuleSession

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.