View Javadoc

1   /*
2    * $Id: ReusableSessionWrapperFactory.java 23154 2011-10-12 06:00:08Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.jms;
12  
13  import javax.jms.QueueSession;
14  import javax.jms.Session;
15  import javax.jms.TopicSession;
16  
17  public class ReusableSessionWrapperFactory
18  {
19      public static Session createWrapper(Session session)
20      {
21          if (session instanceof TopicSession)
22          {
23              return new ReusableTopicSessionWrapper((TopicSession) session);
24          }
25          else if (session instanceof QueueSession)
26          {
27              return new ReusableQueueSessionWrapper((javax.jms.QueueSession) session);
28          }
29          else if (session instanceof Session)
30          {
31              return new ReusableSessionWrapper(session);
32          }
33          else
34          {
35              throw new IllegalArgumentException("session type " + session.getClass() + " no supported as reusable");
36          }
37      }
38  
39  }