KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > server > ResourceDeployerFactory


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * @(#) ResourceDeployerFactory.java
26  *
27  * Copyright 2000-2001 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  *
31  * This software is the confidential and proprietary information
32  * of iPlanet/Sun Microsystems, Inc. ("Confidential Information").
33  * You shall not disclose such Confidential Information and shall
34  * use it only in accordance with the terms of the license
35  * agreement you entered into with iPlanet/Sun Microsystems.
36  */

37 package com.sun.enterprise.server;
38
39
40 import com.sun.enterprise.resource.AdminObjectResourceDeployer;
41 import com.sun.enterprise.resource.ConnectorConnectionPoolDeployer;
42 import com.sun.enterprise.resource.ConnectorResourceDeployer;
43 import com.sun.enterprise.resource.ResourceAdapterConfigDeployer;
44 import com.sun.enterprise.resource.JdbcResourceDeployer;
45 import com.sun.enterprise.resource.PersistenceManagerFactoryResourceDeployer;
46 import com.sun.enterprise.resource.CustomResourceDeployer;
47 import com.sun.enterprise.resource.ExternalJndiResourceDeployer;
48 import com.sun.enterprise.resource.MailResourceDeployer;
49 import com.sun.enterprise.resource.JdbcConnectionPoolDeployer;
50 import com.sun.enterprise.config.serverbeans.Resources;
51 import com.sun.enterprise.admin.event.ResourceDeployEvent;
52 import com.sun.enterprise.util.i18n.StringManager;
53
54 import java.util.logging.Logger JavaDoc;
55 import java.util.logging.Level JavaDoc;
56 import com.sun.logging.LogDomains;
57
58 /**
59  * Deployer factory for different resource types.
60  */

61 class ResourceDeployerFactory {
62
63     /** Admin object resource deployer */
64     private ResourceDeployer resourceAdapterConfigDeployer_ = null;
65
66     /** Admin object resource deployer */
67     private ResourceDeployer adminObjectResourceDeployer_ = null;
68
69     /** Connector Resource deployer */
70     private ResourceDeployer connectorResourceDeployer_ = null;
71
72     /** Connector Connection pool */
73     private ResourceDeployer connectorConnectionPoolDeployer_ = null;
74
75     /** jdbc resource deployer */
76     private ResourceDeployer jdbcResourceDeployer_ = null;
77
78     /** pmf resource deployer */
79     private ResourceDeployer pmfResourceDeployer_ = null;
80
81     /** custom resource deployer */
82     private ResourceDeployer customResourceDeployer_ = null;
83
84     /** external jndi resource deployer */
85     private ResourceDeployer externalJndiResourceDeployer_ = null;
86
87     /** java mail resource deployer */
88     private ResourceDeployer mailResourceDeployer_ = null;
89     
90     // start 4650787
91
// JdbcConnectionPoolDeployer_ was added to support dynamic connection pool - bug # 4650787
92
/** jdbc connection pool deployer */
93     private ResourceDeployer JdbcConnectionPoolDeployer_ = null;
94     // end 4650787
95

96     /** logger to log core messages */
97     static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.CORE_LOGGER);
98     
99     private static StringManager localStrings =
100         StringManager.getManager("com.sun.enterprise.server");
101     
102     /**
103      * Initializes the resource deployers.
104      */

105     ResourceDeployerFactory() {
106         this.resourceAdapterConfigDeployer_ =
107                  new ResourceAdapterConfigDeployer();
108         this.adminObjectResourceDeployer_ = new AdminObjectResourceDeployer();
109         this.connectorResourceDeployer_ = new ConnectorResourceDeployer();
110         this.connectorConnectionPoolDeployer_ = new ConnectorConnectionPoolDeployer();
111         this.jdbcResourceDeployer_ = new JdbcResourceDeployer();
112         this.pmfResourceDeployer_ =
113                             new PersistenceManagerFactoryResourceDeployer();
114         this.customResourceDeployer_ = new CustomResourceDeployer();
115         this.externalJndiResourceDeployer_ = new ExternalJndiResourceDeployer();
116         this.mailResourceDeployer_ = new MailResourceDeployer();
117     // start 4650787
118
// new JdbcConnectionPoolDeployer instance was created to support
119
// dynamic connection pool - bug # 4650787
120
/** jdbc connection pool deployer */
121         this.JdbcConnectionPoolDeployer_ = new JdbcConnectionPoolDeployer();
122     // end 4650787
123
}
124
125     /**
126      * Returns a resource deployer for the given resource type.
127      *
128      * @param type resource type
129      *
130      * @throws Exception if unknown resource type
131      */

132     ResourceDeployer getResourceDeployer(String JavaDoc type) throws Exception JavaDoc {
133
134     ResourceDeployer deployer = null;
135
136     if (type.equals(ResourceDeployEvent.RES_TYPE_JDBC)) {
137
138             deployer = this.jdbcResourceDeployer_;
139
140         } else if (type.equals(ResourceDeployEvent.RES_TYPE_PMF)) {
141
142             deployer = this.pmfResourceDeployer_;
143
144     } else if (type.equals(ResourceDeployEvent.RES_TYPE_CUSTOM)) {
145
146             deployer = this.customResourceDeployer_;
147
148     } else if (type.equals(ResourceDeployEvent.RES_TYPE_EXTERNAL_JNDI)) {
149
150             deployer = this.externalJndiResourceDeployer_;
151
152         } else if (type.equals(ResourceDeployEvent.RES_TYPE_MAIL)) {
153
154             deployer = this.mailResourceDeployer_;
155
156         } else if (type.equals(ResourceDeployEvent.RES_TYPE_AOR)) {
157
158             deployer = this.adminObjectResourceDeployer_;
159
160         } else if (type.equals(ResourceDeployEvent.RES_TYPE_CR)) {
161
162             deployer = this.connectorResourceDeployer_;
163
164         } else if (type.equals(ResourceDeployEvent.RES_TYPE_CCP)) {
165
166             deployer = this.connectorConnectionPoolDeployer_;
167
168         } else if (type.equals(ResourceDeployEvent.RES_TYPE_RAC)) {
169
170             deployer = this.resourceAdapterConfigDeployer_;
171
172     } else if (type.equals(ResourceDeployEvent.RES_TYPE_JCP)) {
173     // start 4650787
174
// type check was created to support
175
// dynamic connection pool - bug # 4650787
176
deployer = this.JdbcConnectionPoolDeployer_;
177     // end 4650787
178

179         } else {
180         String JavaDoc msg = localStrings.getString(
181                 "resource.deployment.resource_type_not_implemented" ,type);
182         throw new Exception JavaDoc(msg);
183         }
184
185         return deployer;
186     }
187
188     /**
189      * Convenience method. It delegates the call to the deployer with the
190      * config resource beands. The deployer returns the implementation
191      * specific object that it wants.
192      *
193      * @param type type of resource
194      * @param name jndi name of the resource
195      * @param rbeans config resource beans
196      */

197     Object JavaDoc getResource(String JavaDoc type, String JavaDoc name, Resources rbeans)
198             throws Exception JavaDoc {
199
200         return getResourceDeployer(type).getResource(name, rbeans);
201     }
202 }
203
Popular Tags