View Javadoc

1   /*******************************************************************************
2    *  Copyright (c) 2005, 2006 Imola Informatica.
3    *  All rights reserved. This program and the accompanying materials
4    *  are made available under the terms of the LGPL License v2.1
5    *  which accompanies this distribution, and is available at
6    *  http://www.gnu.org/licenses/lgpl.html
7    *******************************************************************************/
8   /**
9    * 
10   */
11  package it.imolinfo.jbi4cics.connection;
12  
13  import it.imolinfo.jbi4cics.connection.jca.cics.CICSConnectionManager;
14  import it.imolinfo.jbi4cics.connection.jca.ims.IMSConnectionManager;
15  import it.imolinfo.jbi4cics.connection.jdbc.JdbcConnectionManager;
16  import it.imolinfo.jbi4cics.locator.ServiceLocation;
17  import it.imolinfo.jbi4cics.service.ServiceContext;
18  import it.imolinfo.jbi4cics.Logger;
19  import it.imolinfo.jbi4cics.LoggerFactory;
20  
21  /**
22   * @author raffaele
23   *
24   */
25  public class ConnectionManagerFactory {
26  	/**
27       * The logger for this class and its instances.
28       */
29      private static final Logger LOG
30              = LoggerFactory.getLogger(ConnectionManagerFactory.class);
31  	
32      private static CICSConnectionManager cicsConnectionManager=new CICSConnectionManager();
33      private static IMSConnectionManager imsConnectionManager=new IMSConnectionManager();
34      private static JdbcConnectionManager jdbcConnectionManager=new JdbcConnectionManager();
35      private static EchoConnectionManager echoConnectionManager=new EchoConnectionManager();
36  	
37      /**
38  	 * void constructor.
39  	 */
40  	  public ConnectionManagerFactory(){
41  		  super();
42  	  }
43  
44      
45      public static ConnectionManager createConnectionManager(ServiceContext serviceContext){
46          
47          LOG.debug("Using service location: {0}", serviceContext.getServiceLocation());       
48          LOG.debug("Using connection type: {0}", serviceContext.getServiceLocation().getConnectionType());
49          switch (serviceContext.getServiceLocation().getConnectionType()){
50          case ServiceLocation.CICS : return cicsConnectionManager;
51          case ServiceLocation.IMS  : return imsConnectionManager;
52          case ServiceLocation.JDBC  : return jdbcConnectionManager;
53          default : return echoConnectionManager;
54          }
55      }
56  }