01: /**
02: * $Id: IWAYConnectionFactory.java,v 1.3 2005/09/27 07:22:07 dh112019 Exp $
03: * Copyright 2005 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.iwayutil.connection;
14:
15: import java.util.Properties;
16: import com.sun.portal.iwayutil.config.IWAYConfiguration;
17: import com.sun.portal.iwayutil.connection.jca.*;
18: import com.sun.portal.iwayutil.logger.*;
19:
20: /**
21: * This is a factory class for obtaining {@link IWayConnection}
22: * instances. Either a JCA or a WebServices connection is obtained
23: * depending on the "iway.connectType" config property
24: * @author nk137934
25: */
26: public class IWAYConnectionFactory {
27:
28: public static final String CONNECTION_TYPE_JCA = "JCA";
29: public static final String CONNECTION_TYPE_WEBSERVICES = "WS";
30:
31: /** Private Constructor */
32: private IWAYConnectionFactory() {
33: }
34:
35: // Instantiate the appropriate iway connection object
36: private static IWAYConnection getIWAYConnection(
37: String connectionType) {
38: if (connectionType.equals(CONNECTION_TYPE_JCA)) {
39: return new IWAYJCAConnection();
40: } else {
41: //return new IWAYWebServiceConnection();
42: return null;
43: }
44: }
45:
46: /**
47: * This static method returns an IWayConnection object based on the
48: * "iway.connectType" property.
49: * @return The iway connection object
50: * @throws Exception When there is a failure in obtaining a connection
51: * object.
52: */
53: public static IWAYConnection getIWAYConnection() throws Exception {
54: debug("getIWAYConnection", "Getting iWay Connection");
55: String connectionType = IWAYConfiguration
56: .getIWAYConnectionType();
57: debug("getIWAYConnection", "connectionType " + connectionType);
58: return getIWAYConnection(connectionType);
59: }
60:
61: public static IWAYConnection getIWAYConnection(Properties props)
62: throws Exception {
63: debug("getIWAYConnectionProps", "Getting iWay Connection");
64: return new IWAYJCAPropsConnection(props);
65: }
66:
67: private static void debug(String methodName, String msg) {
68: EAILogger
69: .logMessage("com.sun.portal.iwayutil.connection.IWAYConnectionFactory :"
70: + methodName + ":" + msg);
71: }
72: }
|