Package org.mule.api

Examples of org.mule.api.MuleSession


{
    protected transient Log logger = LogFactory.getLog(getClass());

    public MuleSession retrieveSessionInfoFromMessage(MuleMessage message) throws MuleException
    {
        MuleSession session = null;
        byte[] serializedSession = message.getInboundProperty(MuleProperties.MULE_SESSION_PROPERTY);

        if (serializedSession != null)
        {
            session = (MuleSession) SerializationUtils.deserialize(serializedSession, message.getMuleContext());
View Full Code Here


public class SerializeAndEncodeSessionHandler extends SerializeOnlySessionHandler
{
    @Override
    public MuleSession retrieveSessionInfoFromMessage(MuleMessage message) throws MuleException
    {
        MuleSession session = null;
        String serializedEncodedSession = message.getInboundProperty(MuleProperties.MULE_SESSION_PROPERTY);
       
        if (serializedEncodedSession != null)
        {
            byte[] serializedSession = Base64.decode(serializedEncodedSession);           
View Full Code Here

    private static Transformer encoder = new Base64Encoder();
    private static Transformer decoder = new Base64Decoder();

    public MuleSession retrieveSessionInfoFromMessage(MuleMessage message) throws MuleException
    {
         MuleSession session = new DefaultMuleSession(message.getMuleContext());

         String sessionId = message.getInboundProperty(MuleProperties.MULE_SESSION_ID_PROPERTY);
         Object sessionHeader = message.getInboundProperty(MuleProperties.MULE_SESSION_PROPERTY);

         if (sessionId != null)
         {
             throw new IllegalStateException(
                 "This session handler does not know how to look up session information for session id: "
                                 + sessionId);
         }
         if (sessionHeader != null)
         {
             String sessionString;
             try
             {
                 sessionString = new String((byte[]) decoder.transform(sessionHeader), message.getEncoding());
             }
             catch (UnsupportedEncodingException e)
             {
                 sessionString = new String((byte[]) decoder.transform(sessionHeader));
             }
             if (logger.isDebugEnabled())
             {
                 logger.debug("Parsing session header: " + sessionString);
             }
             String pair;
             String name;
             String value;
             for (StringTokenizer stringTokenizer = new StringTokenizer(sessionString, ";"); stringTokenizer.hasMoreTokens();)
             {
                 pair = stringTokenizer.nextToken();
                 int i = pair.indexOf("=");
                 if (i == -1)
                 {
                     throw new IllegalArgumentException(
                         CoreMessages.sessionValueIsMalformed(pair).toString());
                 }
                 name = pair.substring(0, i).trim();
                 value = pair.substring(i + 1).trim();
                 session.setProperty(name, value);
                 if (logger.isDebugEnabled())
                 {
                     logger.debug("Added MuleSession variable: " + pair);
                 }
             }
View Full Code Here

                    applicationEvent.getMuleEventContext().setStopFurtherProcessing(true);
                    applicationEvent.getMuleEventContext().dispatchEvent(message, endpoint);
                }
                else
                {
                    MuleSession session = new DefaultMuleSession(service, muleContext);
                    DefaultMuleEvent event = new DefaultMuleEvent(message, endpoint.getExchangePattern(),
                        session);
                    RequestContext.setEvent(event);
                    // transform if necessary
                    if (endpoint.getTransformers() != null)
View Full Code Here

    }

    public void testEventMetaDataPropagation() throws MuleException
    {
        Service service = muleContext.getRegistry().lookupService("component1");
        MuleSession session = new DefaultMuleSession(service, muleContext);
        MuleEvent event = new DefaultMuleEvent(new DefaultMuleMessage("Test MuleEvent", muleContext),
            ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoints().get(0), session);
        service.sendEvent(event);
    }
View Full Code Here

                }
               
                props.put(HttpConstants.HEADER_CONTENT_TYPE, contentType);
            }
            MuleMessage message = new DefaultMuleMessage(payload, props, muleContext);
            MuleSession session;

            if(event != null)
            {
                session = event.getSession();
            }
View Full Code Here

     * Packages a mule event for the current request
     */
    protected MuleEvent getEvent(MuleMessage message, OutboundEndpoint endpoint)
        throws MuleException
    {
        MuleSession session = new DefaultMuleSession(message, ((AbstractConnector)endpoint.getConnector()).getSessionHandler(), muleContext);

        if (credentials != null)
        {
            message.setOutboundProperty(MuleProperties.MULE_USER_PROPERTY, "Plain " + credentials.getToken());
        }
View Full Code Here

        setStartContext(true);
    }

    public void testMessageProcessor() throws Exception
    {
        MuleSession session = getTestSession(getTestService(), muleContext);
        Service testService = getTestService("test", Apple.class);
        assertNotNull(testService);

        SimpleCollectionAggregator router = new SimpleCollectionAggregator();
        router.setMuleContext(muleContext);
View Full Code Here

    protected MessageProcessor defaultRoute;

    public MuleEvent process(MuleEvent event) throws MuleException
    {
        MuleMessage message = event.getMessage();
        MuleSession session = event.getSession();
        MuleEvent result;
        boolean matchfound = false;

        for (Iterator iterator = matchableRoutes.iterator(); iterator.hasNext();)
        {
            MatchableMessageProcessor outboundRouter = (MatchableMessageProcessor) iterator.next();

            final MuleEvent eventToRoute;

            boolean copyEvent = false;
            // Create copy of message for router 1..n-1 if matchAll="true" or if
            // routers require copy because it may mutate payload before match is
            // chosen
            if (iterator.hasNext())
            {
                if (isMatchAll())
                {
                    copyEvent = true;
                }
                else if (outboundRouter instanceof TransformingMatchable)
                {
                    copyEvent = ((TransformingMatchable) outboundRouter).isTransformBeforeMatch();
                }
            }

            if (copyEvent)
            {
                if (((DefaultMuleMessage) message).isConsumable())
                {
                    throw new MessagingException(CoreMessages.cannotCopyStreamPayload(message.getPayload().getClass().getName()), event);
                }
                eventToRoute = OptimizedRequestContext.criticalSetEvent(event);
            }
            else
            {
                eventToRoute = event;
            }

            if (outboundRouter.isMatch(eventToRoute.getMessage()))
            {
                matchfound = true;
                result = outboundRouter.process(event);
                if (!isMatchAll())
                {
                    return result;
                }
            }
        }

        if (!matchfound && defaultRoute != null)
        {
            if (logger.isDebugEnabled())
            {
                logger.debug("Message did not match any routers on: " + session.getFlowConstruct().getName()
                             + " invoking catch all strategy");
            }
            return processDefaultRoute(event);
        }
        else if (!matchfound)
        {
            logger.warn("Message did not match any routers on: "
                        + session.getFlowConstruct().getName()
                        + " and there is no catch all strategy configured on this router.  Disposing message "
                        + message);
        }
        return event;
    }
View Full Code Here

        setStartContext(true);
    }

    public void testMessageResequencer() throws Exception
    {
        MuleSession session = getTestSession(getTestService(), muleContext);
        Service testService = getTestService("test", Apple.class);
        assertNotNull(testService);

        TestEventResequencer router = new TestEventResequencer(3);
        router.setMuleContext(muleContext);
View Full Code Here

TOP

Related Classes of org.mule.api.MuleSession

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.