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.locator;
12  
13  import it.imolinfo.jbi4cics.exception.LocationException;
14  import it.imolinfo.jbi4cics.jbi.Messages;
15  
16  
17  /**
18   * @author raffaele
19   *
20   */
21  public class SimpleLocation implements ServiceLocation {
22    
23    public final static String DUMMY_TYPE="DUMMY";
24    public final static String CICS_TYPE="CICS";
25    public final static String IMS_TYPE="IMS";
26    public final static String JDBC_TYPE="JDBC";
27    /*public final static String JMS_TYPE="JMS";
28    public final static String MQ_TYPE="MQ";*/  
29    
30    /**
31     * The responsible to translate localized messages.
32     */
33    private static final Messages MESSAGES
34            = Messages.getMessages(SimpleLocation.class);
35    
36    String locationName;
37    int connectionType;
38    
39    
40    /**
41     * 
42     */
43    public SimpleLocation() {
44      super();
45      // TODO Auto-generated constructor stub
46    }
47  
48    /* (non-Javadoc)
49     * @see it.imolinfo.jbi4cics.locator.ServiceLocation#getJNDIName()
50     */
51    public String getLocationName() {
52      // TODO Auto-generated method stub
53      return locationName;
54    }
55    
56    public void setLocationName(String locationName) {
57      // TODO Auto-generated method stub
58      this.locationName=locationName;
59    }  
60  
61    /* (non-Javadoc)
62     * @see it.imolinfo.jbi4cics.locator.ServiceLocation#getConnectionType()
63     */
64    public int getConnectionType() {
65      // TODO Auto-generated method stub
66      return connectionType;
67    }
68    
69    public void setConnectionType(int connectionType) {
70      this.connectionType=connectionType;
71    }
72  
73    /**
74     * @return The connectionTypeName
75     * @throws LocationException The locsation Exception
76     */
77    public String getConnectionTypeName() throws LocationException {
78      switch (getConnectionType()) {
79        case ServiceLocation.DUMMY : return DUMMY_TYPE;
80        case ServiceLocation.CICS  : return CICS_TYPE;
81        case ServiceLocation.IMS   : return IMS_TYPE;
82        case ServiceLocation.JDBC  : return JDBC_TYPE;
83        /*case ServiceLocation.JMS   : return JMS_TYPE;
84        case ServiceLocation.MQ    : return MQ_TYPE;*/
85        default : throw new LocationException(MESSAGES.getString(
86                "CIC001500_Unknown_type", getConnectionType()));
87      }
88    }
89  
90    /**
91     * @param connectionTypeName The connectionTypeName to set
92     * @throws LocationException The location exception
93     */
94    public void setConnectionTypeName(String connectionTypeName) throws LocationException {
95      if (DUMMY_TYPE.equals(connectionTypeName)) {
96        setConnectionType(ServiceLocation.DUMMY);
97        return;
98      }
99      if (CICS_TYPE.equals(connectionTypeName)) {
100       setConnectionType(ServiceLocation.CICS);
101       return;
102     }
103     if (IMS_TYPE.equals(connectionTypeName)) {
104       setConnectionType(ServiceLocation.IMS);
105       return;
106     }
107     if (JDBC_TYPE.equals(connectionTypeName)) {
108       setConnectionType(ServiceLocation.JDBC);
109       return;
110     }
111     throw new LocationException(MESSAGES.getString("CIC001501_Invalid_type", connectionTypeName));
112   }
113 
114 }