KickJava   Java API By Example, From Geeks To Geeks.

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


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 package com.sun.enterprise.server;
25
26 import com.sun.enterprise.config.*;
27 import com.sun.enterprise.config.ConfigException;
28 import java.util.logging.Level JavaDoc;
29 import java.util.logging.Logger JavaDoc;
30 import java.util.*;
31
32 import com.sun.logging.LogDomains;
33 import com.sun.enterprise.connectors.*;
34 import com.sun.enterprise.deployment.*;
35 import com.sun.enterprise.util.io.FileUtils;
36
37 /**
38   *
39   * @author Srikanth P
40   * @version
41  */

42
43 public class ConnectorResourcesLoader extends ResourcesLoader{
44
45     static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.CORE_LOGGER);
46     
47     /** context of the server instance runtime */
48
49
50     public ConnectorResourcesLoader(ServerContext sc) throws ConfigException{
51         super(sc);
52     }
53
54
55
56     public void load() {
57         ConfigBean[][] cb = null;
58         try {
59             cb = resourceUtil.getConnectorResources();
60             if(cb != null)
61                 load(cb);
62         }
63         catch(ConfigException ce) {
64             _logger.log(Level.SEVERE,"core.connectorresource_read_error" );
65             _logger.log(Level.SEVERE,"" ,ce);
66         }
67     }
68
69     public void load(boolean standAloneRarsOnly) {
70         ConfigBean[][] cb = null;
71         try {
72             if(standAloneRarsOnly) {
73                 cb = resourceUtil.getStandAloneNonSystemRarConnectorResources();
74             } else {
75                 cb = resourceUtil.getConnectorResources(standAloneRarsOnly);
76             }
77             if(cb != null)
78                 load(cb);
79         }
80         catch(ConfigException ce) {
81             _logger.log(Level.SEVERE,"core.connectorresource_read_error" );
82             _logger.log(Level.SEVERE,"" ,ce);
83         }
84     }
85
86     public void loadRAConfigs() {
87         ConfigBean[][] cb = new ConfigBean[1][];;
88         try {
89             ConfigBean[] raConfBeans = resourceUtil.getResourceAdapterConfigs();
90             if(raConfBeans != null) {
91                 cb[0] = raConfBeans;
92                 load(cb);
93             }
94         }
95         catch(ConfigException ce) {
96             _logger.log(Level.SEVERE,"core.connectorresource_read_error" );
97             _logger.log(Level.SEVERE,"" ,ce);
98         }
99     }
100
101     public void load(String JavaDoc rarName) {
102
103         ConfigBean[][] cb = null;
104         try {
105             cb = resourceUtil.getConnectorResources(rarName);
106             if(cb != null)
107                 load(cb);
108         }
109         catch(ConfigException ce) {
110             _logger.log(Level.SEVERE,"core.connectorresource_read_error" );
111             _logger.log(Level.SEVERE,"" ,ce);
112
113         }
114     }
115     public void loadRAConfigs(String JavaDoc rarName) {
116         ConfigBean[][] cb = new ConfigBean[1][];;
117         try {
118             ConfigBean[] raConfBeans = resourceUtil.getResourceAdapterConfigs(rarName);
119             if(raConfBeans != null) {
120                 cb[0] = raConfBeans;
121                 load(cb);
122             }
123         }
124         catch(ConfigException ce) {
125             _logger.log(Level.SEVERE,"core.connectorresource_read_error" );
126             _logger.log(Level.SEVERE,"" ,ce);
127         }
128     }
129
130     public void loadEmbeddedRarRAConfigs(String JavaDoc appName) {
131         ConfigBean[][] cb = new ConfigBean[1][];;
132         try {
133             ConfigBean[] raConfBeans =
134                     resourceUtil.getEmbeddedRarResourceAdapterConfigs(appName);
135             if(raConfBeans != null) {
136                 cb[0] = raConfBeans;
137                 load(cb);
138             }
139         }
140         catch(ConfigException ce) {
141             _logger.log(Level.SEVERE,"core.connectorresource_read_error" );
142             _logger.log(Level.SEVERE,"" ,ce);
143         }
144     }
145
146     public void loadEmbeddedRarResources(String JavaDoc appName, Application appDesc) {
147
148         Set rars = appDesc.getRarDescriptors();
149
150         for (Iterator itr = rars.iterator(); itr.hasNext();) {
151             ConnectorDescriptor cd = (ConnectorDescriptor) itr.next();
152             String JavaDoc rarName = cd.getDeployName();
153             String JavaDoc embeddedRarName = appName+
154                        ConnectorConstants.EMBEDDEDRAR_NAME_DELIMITER+
155                        FileUtils.makeFriendlyFilenameNoExtension(rarName);
156             load(embeddedRarName);
157         }
158     }
159     
160     public void stopActiveResourceAdapters(){
161         ConnectorRuntime.stopAllActiveResourceAdapters();
162     }
163     
164 }
Popular Tags