View Javadoc

1   /*******************************************************************************
2    *  Copyright (c) 2005, 2006, 2007 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   package it.imolinfo.jbi4cics.connection.jca.ims;
10  
11  import it.imolinfo.jbi4cics.connection.jca.JCACommareaBasedConnectionManager;
12  import it.imolinfo.jbi4cics.exception.ConnectionException;
13  import it.imolinfo.jbi4cics.service.ServiceContext;
14  
15  import javax.resource.cci.ConnectionSpec;
16  import javax.resource.cci.InteractionSpec;
17  import it.imolinfo.jbi4cics.Logger;
18  import it.imolinfo.jbi4cics.LoggerFactory;
19  
20  
21  
22  /**
23   * 
24   * @author raffaele, marcopiraccini
25   */
26  public class IMSConnectionManager extends JCACommareaBasedConnectionManager {
27  
28      /**
29       * The logger for this class and its instances.
30       */
31      private static final Logger LOG
32              = LoggerFactory.getLogger(IMSConnectionManager.class);
33      
34      public IMSConnectionManager() {
35          super();
36      }
37  
38      /* (non-Javadoc)
39       * @see it.imolinfo.jbi4cics.connection.jca.JCACommareaBasedConnectionManager#createInteractionSpec(it.imolinfo.jbi4cics.service.ServiceContext)
40       */
41      protected InteractionSpec createInteractionSpec(ServiceContext serviceContext) throws ConnectionException {
42  
43          InteractionSpec imsInteractionSpec = null;
44  
45          try {
46              imsInteractionSpec = (InteractionSpec)
47              this.getConnectorClassLoader().loadClass("com.ibm.connector2.ims.ico.IMSInteractionSpec").newInstance();
48          } catch (InstantiationException e) {
49              LOG.error("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);
50              throw new ConnectionException("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);                 
51          } catch (IllegalAccessException e) {
52              LOG.error("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);
53              throw new ConnectionException("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);                 
54          } catch (ClassNotFoundException e) {
55              LOG.error("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);
56              throw new ConnectionException("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);                 
57          }   
58  
59          /*
60           * property to set:
61           * username
62           * password
63           * see http://publib.boulder.ibm.com/infocenter/cicstg60/index.jsp 
64           */
65          if (imsInteractionSpec != null) {
66              //TODO sets the propety correctly
67              /*
68               * The settable properties are: 
69               * AsyncOutputAvailable
70               * CommitMode
71               * ConvEnded
72               * ExecutionTimeout
73               * IMSRequestType
74               * InteractionVerb
75               * LtermName
76               * MapName
77               * SocketTimeot
78               */    
79  
80          } else {      
81              LOG.error("CIC000501_InteractionSpec_not_retrieved");
82              throw new ConnectionException("CIC000501_InteractionSpec_not_retrieved");               
83          }
84          return imsInteractionSpec;
85  
86      }
87  
88      /* (non-Javadoc)
89       * @see it.imolinfo.jbi4cics.connection.jca.JCACommareaBasedConnectionManager#createConnectionSpec(it.imolinfo.jbi4cics.service.ServiceContext)
90       */
91      protected ConnectionSpec createConnectionSpec(ServiceContext serviceContext) throws ConnectionException {
92          ConnectionSpec imsConnectionSpec = null;
93  
94          try {
95              imsConnectionSpec = (ConnectionSpec)
96              this.getConnectorClassLoader().loadClass("com.ibm.connector2.ims.ico.IMSConnectionSpec").newInstance();
97          } catch (InstantiationException e) {
98              LOG.error("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);
99              throw new ConnectionException("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);                 
100         } catch (IllegalAccessException e) {
101             LOG.error("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);
102             throw new ConnectionException("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);                 
103         } catch (ClassNotFoundException e) {
104             LOG.error("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);
105             throw new ConnectionException("CIC000500_Error_istantiating_connection_spec", new Object[] {e.getMessage()}, e);                 
106         }   
107 
108         if (imsConnectionSpec != null) {
109             // TODO sets the property correclty
110             /*
111              * the properties that can be set from the interface are:
112              * user name
113              * password
114              * group name (a part of ims security)
115              * clientid (don't know what exactly is) 
116              * see http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp
117              */
118 
119             // imsConnectionSpec.setClientID(??);
120             // imsConnectionSpec.setGroupName(??);
121 
122         } else {      
123             LOG.error("CIC000502_ConnectionSpec_not_retrieved");
124             throw new ConnectionException("CIC000502_ConnectionSpec_not_retrieved");               
125         }
126 
127         return imsConnectionSpec;
128     }
129 
130 }