KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > web > ServerConfigLookup


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  * ServerConfigLookup.java
26  *
27  * Created on June 7, 2002, 11:47 AM
28  */

29
30 package com.sun.enterprise.web;
31
32 import java.util.logging.Logger JavaDoc;
33 import java.util.logging.Level JavaDoc;
34 import com.sun.logging.LogDomains;
35 import com.sun.enterprise.config.ConfigContext;
36 import com.sun.enterprise.config.ConfigBean;
37 import com.sun.enterprise.config.ConfigException;
38 import com.sun.enterprise.server.ApplicationServer;
39 import com.sun.enterprise.server.ServerContext;
40 import com.sun.enterprise.web.session.PersistenceType;
41
42 import com.sun.enterprise.config.serverbeans.Applications;
43 import com.sun.enterprise.config.serverbeans.AvailabilityService;
44 import com.sun.enterprise.config.serverbeans.Cluster;
45 import com.sun.enterprise.config.serverbeans.ClusterHelper;
46 import com.sun.enterprise.config.serverbeans.Config;
47 import com.sun.enterprise.config.serverbeans.Domain;
48 import com.sun.enterprise.config.serverbeans.ElementProperty;
49 import com.sun.enterprise.config.serverbeans.J2eeApplication;
50 import com.sun.enterprise.config.serverbeans.JdbcResource;
51 import com.sun.enterprise.config.serverbeans.JdbcConnectionPool;
52 import com.sun.enterprise.config.serverbeans.ManagerProperties;
53 import com.sun.enterprise.config.serverbeans.Resources;
54 import com.sun.enterprise.config.serverbeans.Server;
55 import com.sun.enterprise.config.serverbeans.ServerHelper;
56 import com.sun.enterprise.config.serverbeans.ServerBeansFactory;
57 import com.sun.enterprise.config.serverbeans.SessionConfig;
58 import com.sun.enterprise.config.serverbeans.SessionManager;
59 import com.sun.enterprise.config.serverbeans.SessionProperties;
60 import com.sun.enterprise.config.serverbeans.StoreProperties;
61 import com.sun.enterprise.config.serverbeans.WebContainerAvailability;
62
63 import com.sun.enterprise.util.uuid.UuidGenerator;
64 import com.sun.enterprise.util.uuid.UuidGeneratorImpl;
65
66
67 public class ServerConfigLookup {
68         
69     
70     /**
71     * The prefix for the HADB connection url
72     */

73     protected final String JavaDoc HADB_CONNECTION_URL_PREFIX = "jdbc:sun:hadb:";
74   
75     /**
76     * The property name into domain.xml to obtain
77     * the cluster-id string
78     * Note: all instances in a cluster must have the same
79     * cluster-id defined at this location in server.xml
80     * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='cluster-id']";
81     */

82     protected final String JavaDoc CLUSTER_ID_PROPERTY_NAME =
83         "cluster-id";
84     
85     /**
86     * The property name into domain.xml to obtain
87     * the stale-session-checking-enabled string
88     */

89     protected final String JavaDoc STALE_SESSION_CHECKING_ENABLED_PROPERTY_NAME =
90         "stale-session-checking-enabled";
91     
92     /**
93     * The default cluster-id if none is defined in domain.xml
94     * Note: the default is ok if only one cluster is being serviced
95     * by an instance of HADB; if not then each cluster needs its
96     * own unique cluster-id and each instance must have it correctly
97     * defined in its server.xml
98     */

99     protected final String JavaDoc DEFAULT_CLUSTER_ID = "cluster1";
100     
101     /**
102     * The xpath expression into domain.xml to obtain
103     * the hadb-store-pool-jndi-name string
104     * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='store-pool-jndi-name']";
105     */

106     protected final String JavaDoc HADB_STORE_POOL_JNDI_NAME_PROPERTY_NAME =
107     "store-pool-jndi-name";
108     
109     /**
110     * The default store-pool-jndi-name (used by Web Container for
111     * HTTP Persistence to HADB
112     */

113     protected final String JavaDoc DEFAULT_STORE_POOL_JNDI_NAME = "jdbc/hastore";
114     
115     /**
116     * The xpath expression into server.xml to obtain
117     * the hadb-mgmt-env-path string
118     * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='hadb-mgmt-env-path']"
119     */

120     protected final String JavaDoc HADB_MGMT_ENV_PATH_PROPERTY_NAME =
121         "hadb-mgmt-env-path";
122     
123     /**
124     * The property name in domain.xml to obtain
125     * the hadb-database-name string
126     * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='hadb-database-name']";
127     */

128     protected final String JavaDoc HADB_DATABASE_NAME_PROPERTY_NAME =
129         "hadb-database-name";
130     
131     /**
132     * The property name into domain.xml to obtain
133     * the UuidGenerator impl class name
134     */

135     protected final String JavaDoc UUID_GENERATOR_CLASS_PROPERTY_NAME =
136         "uuid-impl-class";
137
138     /**
139     * The default UuidGenerator class (fully qualified name)
140     */

141     protected final String JavaDoc DEFAULT_UUID_GENERATOR_CLASS = "com.sun.enterprise.util.uuid.UuidGeneratorImpl";
142     
143     /**
144     * The property name in domain.xml to obtain
145     * the EE builder path - this property is not expected
146     * now to change and if it ever did, then the directory
147     * and package structure for the builder classes would
148     * have to change also
149     * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='ee-builder-path']"
150     */

151     protected final String JavaDoc EE_BUILDER_PATH_PROPERTY_NAME =
152         "ee-builder-path";
153   
154
155     /**
156     * The default path to the EE persistence strategy builders
157     */

158     protected final String JavaDoc DEFAULT_EE_BUILDER_PATH = "com.sun.enterprise.ee.web.initialization";
159
160     /**
161     * The property name in domain.xml to obtain
162     * the hadb-health-check string
163     * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='hadb-health-check-enabled']";
164     */

165     protected final String JavaDoc HADB_HEALTH_CHECK_ENABLED_PROPERTY_NAME =
166         "hadb-health-check-enabled";
167     
168     /**
169     * The default value of hadb-healthcheck-interval-in-seconds
170     */

171     protected final int DEFAULT_HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS = 5;
172
173     /**
174     * The property name in domain.xml to obtain
175     * the user name string in hadb jdbc-connection pool (for http session
176     * persistence)
177     */

178     protected final String JavaDoc USER_NAME = "User";
179     
180     /**
181     * The property name in domain.xml to obtain
182     * the password string in hadb jdbc-connection pool (for http session
183     * persistence)
184     */

185     protected final String JavaDoc PASSWORD = "Password";
186     
187     /**
188     * The property name in domain.xml to obtain
189     * the HADB agent password (used for connecting to HADB agent)
190     */

191     protected final String JavaDoc HADB_AGENT_PASSWORD = "ha-agent-password";
192     
193     /**
194     * The config context passed in via constructor
195     * used when a dynamic config context is needed
196     * rather than usual run-time config context e.g. deployment
197     */

198     protected ConfigContext _configContext = null;
199     
200     /** Creates a new instance of ServerConfigLookup */
201     public ServerConfigLookup() {
202         if (_logger == null) {
203             _logger = LogDomains.getLogger(LogDomains.WEB_LOGGER);
204         }
205     }
206         
207     /**
208     * Creates a new instance of ServerConfigLookup
209     * @param configContext
210     */

211     public ServerConfigLookup(ConfigContext configContext) {
212         this();
213         _configContext = configContext;
214     }
215     
216     //+++++++++++++++++++++++++START NEW METHODS++++++++++++++++++++++
217

218     /**
219     * Get the ServerContext for this server
220     * return null if not found
221     */

222     protected ServerContext getServerContext() {
223         return ApplicationServer.getServerContext();
224     }
225     
226     /**
227     * Get the ConfigContext for this server
228     * return null if not found
229     */

230     protected ConfigContext getConfigContextDynamic() {
231         if (_configContext != null) {
232             return _configContext;
233         } else {
234             return getConfigContext();
235         }
236     }
237
238     /**
239     * Get the ConfigContext for this server
240     * return null if not found
241     */

242     protected ConfigContext getConfigContext() {
243         ServerContext serverCtx = this.getServerContext();
244         if(serverCtx == null) {
245             return null;
246         }
247         return serverCtx.getConfigContext();
248     }
249
250     /**
251     * Get the server element from domain.xml.
252     * return null if not found
253     */

254     private Server getServerBean() {
255         Server serverBean = null;
256         /*
257         ServerContext serverCtx = ApplicationServer.getServerContext();
258         ConfigContext configCtx = serverCtx.getConfigContext();
259          */

260         ConfigContext configCtx = this.getConfigContext();
261         try {
262             serverBean = ServerBeansFactory.getServerBean(configCtx);
263         } catch (ConfigException ex) {}
264
265         return serverBean;
266     }
267
268     /**
269     * Get the server name from domain.xml.
270     * return null if not found
271     */

272     private String JavaDoc getServerName() {
273         String JavaDoc result = null;
274         Server serverBean = this.getServerBean();
275         if(serverBean != null) {
276             result = serverBean.getName();
277         }
278         return result;
279     }
280     
281     /**
282     * Get the cluster name from domain.xml for this server.
283     * return null if not found
284     */

285     public String JavaDoc getClusterName() {
286         String JavaDoc result = null;
287         /*
288         ServerContext serverCtx = ApplicationServer.getServerContext();
289         ConfigContext configCtx = serverCtx.getConfigContext();
290          */

291         ConfigContext configCtx = this.getConfigContext();
292         
293         String JavaDoc serverName = this.getServerName();
294         if(serverName == null) {
295             return result;
296         }
297         boolean isClustered = false;
298         try {
299             isClustered = ServerHelper.isServerClustered(configCtx, serverName);
300         } catch (ConfigException ex) {}
301         if(!isClustered) {
302             result = serverName + "_nc"; //non-clustered example: server1_nc
303
return result;
304         }
305         Cluster cluster = null;
306         try {
307             cluster = ClusterHelper.getClusterForInstance(configCtx, serverName);
308         } catch (ConfigException ex) {}
309         if(cluster != null) {
310             result = cluster.getName();
311         }
312         return result;
313     }
314     
315
316     /**
317     * Get the resources element from domain.xml.
318     * return null if not found
319     */

320     private Resources getResourcesBean() {
321         Resources resourcesBean = null;
322         Domain domainBean = null;
323         /*
324         ServerContext serverCtx = ApplicationServer.getServerContext();
325         ConfigContext configCtx = serverCtx.getConfigContext();
326          */

327         ConfigContext configCtx = this.getConfigContext();
328         try {
329             domainBean = ServerBeansFactory.getDomainBean(configCtx);
330             if(domainBean != null) {
331                 resourcesBean = domainBean.getResources();
332             }
333         } catch (ConfigException ex) {}
334
335         return resourcesBean;
336     }
337
338     /**
339     * Get the applications element from domain.xml.
340     * return null if not found
341     */

342     private Applications getApplicationsBean() {
343         Applications applicationsBean = null;
344         Domain domainBean = null;
345         /*
346         ServerContext serverCtx = ApplicationServer.getServerContext();
347         ConfigContext configCtx = serverCtx.getConfigContext();
348          */

349         ConfigContext configCtx = this.getConfigContext();
350         try {
351             domainBean = ServerBeansFactory.getDomainBean(configCtx);
352             if(domainBean != null) {
353                 applicationsBean = domainBean.getApplications();
354             }
355         } catch (ConfigException ex) {}
356
357         return applicationsBean;
358     }
359     
360     /**
361     * Get the applications element from domain.xml.
362     * return null if not found
363     */

364     private Applications getApplicationsBeanDynamic() {
365         Applications applicationsBean = null;
366         Domain domainBean = null;
367         /*
368         ServerContext serverCtx = ApplicationServer.getServerContext();
369         ConfigContext configCtx = serverCtx.getConfigContext();
370          */

371         ConfigContext configCtx = this.getConfigContextDynamic();
372         try {
373             domainBean = ServerBeansFactory.getDomainBean(configCtx);
374             if(domainBean != null) {
375                 applicationsBean = domainBean.getApplications();
376             }
377         } catch (ConfigException ex) {}
378         return applicationsBean;
379     }
380
381     /**
382     * Get the config element from domain.xml.
383     * return null if not found
384     */

385     private Config getConfigBean() {
386         Config configBean = null;
387         /*
388         ServerContext serverCtx = ApplicationServer.getServerContext();
389         ConfigContext configCtx = serverCtx.getConfigContext();
390          */

391         ConfigContext configCtx = this.getConfigContext();
392         try {
393             configBean = ServerBeansFactory.getConfigBean(configCtx);
394         } catch (ConfigException ex) {}
395
396         return configBean;
397     }
398     
399     /**
400     * Get the config element from domain.xml.
401     * return null if not found
402     */

403     private Config getConfigBeanDynamic() {
404         Config configBean = null;
405         ConfigContext configCtx = this.getConfigContextDynamic();
406         try {
407             configBean = ServerBeansFactory.getConfigBean(configCtx);
408         } catch (ConfigException ex) {}
409
410         return configBean;
411     }
412
413     /**
414     * Get the availability-service element from domain.xml.
415     * return null if not found
416     */

417     protected AvailabilityService getAvailabilityService() {
418         Config configBean = this.getConfigBean();
419         if(configBean == null) {
420             return null;
421         }
422         return configBean.getAvailabilityService();
423     }
424     
425     /**
426     * Get the availability-service element from domain.xml.
427     * return null if not found
428     */

429     protected AvailabilityService getAvailabilityServiceDynamic() {
430         Config configBean = this.getConfigBeanDynamic();
431         if(configBean == null) {
432             return null;
433         }
434         return configBean.getAvailabilityService();
435     }
436
437     /**
438     * Get the web-container-availability element from domain.xml.
439     * return null if not found
440     */

441     private WebContainerAvailability getWebContainerAvailability() {
442         AvailabilityService availabilityServiceBean = this.getAvailabilityService();
443         if(availabilityServiceBean == null) {
444             return null;
445         }
446         return availabilityServiceBean.getWebContainerAvailability();
447     }
448
449     /**
450     * Get the properties under the web-container-availability element
451     * from domain.xml.
452     * return array of single empty ElementProperty if not found
453     */

454     private ElementProperty[] getWebContainerAvailabilityProperties() {
455         WebContainerAvailability webContainerAvailabilityBean =
456             this.getWebContainerAvailability();
457         if(webContainerAvailabilityBean == null) {
458             return new ElementProperty[0];
459         }
460         return webContainerAvailabilityBean.getElementProperty();
461     }
462
463     /**
464     * Get the String value of the property under web-container-availability
465     * element from domain.xml whose name matches propName
466     * return null if not found
467     * @param propName
468     */

469     protected String JavaDoc getWebContainerAvailabilityPropertyString(String JavaDoc propName) {
470         String JavaDoc result = null;
471         WebContainerAvailability wcAvailabilityBean = this.getWebContainerAvailability();
472         if( (wcAvailabilityBean != null) && (wcAvailabilityBean.sizeElementProperty() > 0) ) {
473             ElementProperty[] props = wcAvailabilityBean.getElementProperty();
474             for (int i = 0; i < props.length; i++) {
475                 String JavaDoc name = props[i].getAttributeValue("name");
476                 String JavaDoc value = props[i].getAttributeValue("value");
477                 if (name.equalsIgnoreCase(propName)) {
478                     result = value;
479                 }
480             }
481         }
482         return result;
483     }
484
485     /**
486     * Get the String value of the property under web-container-availability
487     * element from domain.xml whose name matches propName
488     * return defaultValue if not found
489     * @param propName
490     */

491     protected String JavaDoc getWebContainerAvailabilityPropertyString(String JavaDoc propName, String JavaDoc defaultValue) {
492         String JavaDoc result = null;
493         WebContainerAvailability wcAvailabilityBean = this.getWebContainerAvailability();
494         if( (wcAvailabilityBean != null) && (wcAvailabilityBean.sizeElementProperty() > 0) ) {
495             ElementProperty[] props = wcAvailabilityBean.getElementProperty();
496             for (int i = 0; i < props.length; i++) {
497                 String JavaDoc name = props[i].getAttributeValue("name");
498                 String JavaDoc value = props[i].getAttributeValue("value");
499                 if (name.equalsIgnoreCase(propName)) {
500                     result = value;
501                 }
502             }
503         }
504         if(result == null) {
505             result = defaultValue;
506         }
507         return result;
508     }
509
510     /**
511     * Get the int value of the property under web-container-availability
512     * element from domain.xml whose name matches propName
513     * return defaultValue if not found
514     * @param propName
515     */

516     protected int getWebContainerAvailabilityPropertyInt(String JavaDoc propName, int defaultValue) {
517         int returnValue = defaultValue;
518         String JavaDoc returnValueString = null;
519         WebContainerAvailability wcAvailabilityBean = this.getWebContainerAvailability();
520         if( (wcAvailabilityBean != null) && (wcAvailabilityBean.sizeElementProperty() > 0) ) {
521             ElementProperty[] props = wcAvailabilityBean.getElementProperty();
522             for (int i = 0; i < props.length; i++) {
523                 String JavaDoc name = props[i].getAttributeValue("name");
524                 String JavaDoc value = props[i].getAttributeValue("value");
525                 if (name.equalsIgnoreCase(propName)) {
526                     returnValueString = value;
527                 }
528             }
529         }
530         if(returnValueString != null) {
531             try
532             {
533                 returnValue = (Integer.valueOf(returnValueString)).intValue();
534             } catch (NumberFormatException JavaDoc ex) {
535                 if(_logger.isLoggable(Level.FINEST)) {
536                     _logger.finest("Using Default Value = "
537                         + defaultValue);
538                 }
539             }
540         }
541         return returnValue;
542     }
543     
544     private com.sun.enterprise.config.serverbeans.WebModule getWebModuleByContextRoot(String JavaDoc contextRoot) {
545         com.sun.enterprise.config.serverbeans.WebModule result = null;
546         Applications applicationsBean = this.getApplicationsBeanDynamic();
547         if(applicationsBean == null) {
548             return null;
549         }
550         com.sun.enterprise.config.serverbeans.WebModule[] webModules =
551             applicationsBean.getWebModule();
552         for(int i=0; i<webModules.length; i++) {
553             com.sun.enterprise.config.serverbeans.WebModule nextWebModule =
554                 webModules[i];
555             String JavaDoc nextContextRoot = nextWebModule.getContextRoot();
556             if(nextContextRoot != null && nextContextRoot.equalsIgnoreCase(contextRoot)) {
557                 result = nextWebModule;
558             }
559         }
560         return result;
561     }
562
563     private boolean getWebModuleAvailability(String JavaDoc contextRoot, boolean inheritedValue) {
564         com.sun.enterprise.config.serverbeans.WebModule webModule =
565             this.getWebModuleByContextRoot(contextRoot);
566         if(webModule == null) {
567             //FIXME remove after testing
568
return false;
569             //return inheritedValue;
570
}
571         /*
572         String wmsString = webModule.getAvailabilityEnabled();
573         Boolean bool = this.toBoolean(wmsString);
574         
575         if(bool == null) {
576             return inheritedValue;
577         } else {
578             return bool.booleanValue();
579         }
580          */

581         return webModule.isAvailabilityEnabled();
582     }
583     
584     private J2eeApplication getJ2eeApplicationByName(String JavaDoc appName) {
585         J2eeApplication result = null;
586         Applications applicationsBean = this.getApplicationsBeanDynamic();
587         if(applicationsBean == null) {
588             return null;
589         }
590         return applicationsBean.getJ2eeApplicationByName(appName);
591     }
592     
593     private boolean getJ2eeApplicationAvailability(String JavaDoc appName, boolean inheritedValue) {
594         J2eeApplication j2eeApp =
595             this.getJ2eeApplicationByName(appName);
596         if(_logger.isLoggable(Level.FINEST)) {
597             _logger.finest("ServerConfigLookup>>getJ2eeApplicationAvailability j2eeApp = " + j2eeApp);
598         }
599         //System.out.println("ServerConfigLookup>>getJ2eeApplicationAvailability j2eeApp = " + j2eeApp);
600
if(j2eeApp == null) {
601             //FIXME remove after testing - protection if called in web module case
602
//return inheritedValue;
603
return false;
604         }
605         /*
606         String appString = j2eeApp.getAvailabilityEnabled();
607         Boolean bool = this.toBoolean(appString);
608         if(bool == null) {
609             return inheritedValue;
610         } else {
611             return bool.booleanValue();
612         }
613          */

614         return j2eeApp.isAvailabilityEnabled();
615     }
616     
617     //+++++++++++++++++++++++++END NEW METHODS++++++++++++++++++++++
618

619     /**
620     * Get the persistenceType from domain.xml.
621     * return null if not found
622     */

623     public PersistenceType getPersistenceTypeFromConfig() {
624         if(_logger.isLoggable(Level.FINEST)) {
625             _logger.finest("in ServerConfigLookup>>getPersistenceTypeFromConfig");
626         }
627         String JavaDoc persistenceTypeString = null;
628         PersistenceType persistenceType = null;
629
630         WebContainerAvailability webContainerAvailabilityBean =
631         this.getWebContainerAvailability();
632         if(webContainerAvailabilityBean == null) {
633             return null;
634         }
635         persistenceTypeString = webContainerAvailabilityBean.getPersistenceType();
636
637         //System.out.println("ServerConfigLookup>>getPersistenceTypeFromConfig:persistenceTypeString=" + persistenceTypeString);
638
if(persistenceTypeString != null) {
639             persistenceType = PersistenceType.parseType(persistenceTypeString);
640         }
641         if(persistenceType != null) {
642             if(_logger.isLoggable(Level.FINEST)) {
643                 _logger.finest("SERVER.XML persistenceType= " + persistenceType.getType());
644             }
645         } else {
646             if(_logger.isLoggable(Level.FINEST)) {
647                 _logger.finest("SERVER.XML persistenceType missing");
648             }
649         }
650         return persistenceType;
651     }
652     
653     /**
654     * Get the persistenceFrequency from domain.xml.
655     * return null if not found
656     * 7.0 xpath was "/server/web-container/session-config/session-manager/manager-properties/property[@name='persistenceFrequency']";
657     */

658     public String JavaDoc getPersistenceFrequencyFromConfig() {
659         if(_logger.isLoggable(Level.FINEST)) {
660             _logger.finest("in ServerConfigLookup>>getPersistenceFrequencyFromConfig");
661         }
662       
663         WebContainerAvailability webContainerAvailabilityBean =
664         this.getWebContainerAvailability();
665         if(webContainerAvailabilityBean == null) {
666             return null;
667         }
668         return webContainerAvailabilityBean.getPersistenceFrequency();
669     }
670     
671
672     /**
673     * Get the persistenceScope from domain.xml.
674     * return null if not found
675     * 7.0 xpath was "/server/web-container/session-config/session-manager/store-properties/property[@name='persistenceScope']";
676     */

677     public String JavaDoc getPersistenceScopeFromConfig() {
678         if(_logger.isLoggable(Level.FINEST)) {
679             _logger.finest("in ServerConfigLookup>>getPersistenceScopeFromConfig");
680         }
681         WebContainerAvailability webContainerAvailabilityBean =
682             this.getWebContainerAvailability();
683         if(webContainerAvailabilityBean == null) {
684             return null;
685         }
686         return webContainerAvailabilityBean.getPersistenceScope();
687     }
688   
689     /**
690     * Get the stale-session-checking-enabled from domain.xml.
691     * return false if not found
692     */

693     public boolean getStaleSessionCheckingFromConfig() {
694         if(_logger.isLoggable(Level.FINEST)) {
695             _logger.finest("in ServerConfigLookup>>getStaleSessionCheckingFromConfig");
696         }
697         String JavaDoc staleSessionCheckingEnabledString =
698             this.getWebContainerAvailabilityPropertyString(STALE_SESSION_CHECKING_ENABLED_PROPERTY_NAME, "false");
699         Boolean JavaDoc bool = this.toBoolean(staleSessionCheckingEnabledString);
700         if(bool == null) {
701             return false;
702         } else {
703             return bool.booleanValue();
704         }
705     }
706     
707     /**
708     * Get the cluster-id from domain.xml.
709     * return "cluster1" if not found
710     */

711     public String JavaDoc getClusterIdFromConfig() {
712         if(_logger.isLoggable(Level.FINEST)) {
713             _logger.finest("in ServerConfigLookup>>getClusterIdFromConfig");
714         }
715         return this.getWebContainerAvailabilityPropertyString(CLUSTER_ID_PROPERTY_NAME, DEFAULT_CLUSTER_ID);
716         //return this.getAvailServicePersistenceStorePropertyString(CLUSTER_ID_PROPERTY_NAME, DEFAULT_CLUSTER_ID);
717
}
718     
719     /**
720     * Get the availability-enabled from domain.xml.
721     * return false if not found
722     */

723     public boolean getAvailabilityEnabledFromConfig() {
724         if(_logger.isLoggable(Level.FINEST)) {
725             _logger.finest("in ServerConfigLookup>>getAvailabilityEnabledFromConfig");
726         }
727         AvailabilityService as = this.getAvailabilityService();
728         if(as == null) {
729             if(_logger.isLoggable(Level.FINEST)) {
730                 _logger.finest("AvailabilityService was not defined - check domain.xml");
731             }
732             return false;
733         }
734         return as.isAvailabilityEnabled();
735     }
736     
737     /**
738     * Get the availability-enabled from domain.xml.
739     * This takes into account:
740     * global
741     * web-container-availability
742     * web-module (if stand-alone)
743     * return false if not found
744     */

745     public boolean calculateWebAvailabilityEnabledFromConfig(String JavaDoc contextRoot, String JavaDoc j2eeAppName) {
746         if(_logger.isLoggable(Level.FINEST)) {
747             _logger.finest("in ServerConfigLookup>>calculateWebAvailabilityEnabledFromConfig");
748         }
749         //global availability from <availability-service> element
750
boolean globalAvailability =
751             this.getAvailabilityEnabledFromConfig();
752         if(_logger.isLoggable(Level.FINEST)) {
753             _logger.finest("globalAvailability = " + globalAvailability);
754         }
755         //System.out.println("globalAvailability = " + globalAvailability);
756
//web container availability from <web-container-availability> sub-element
757
boolean webContainerAvailability =
758             this.getWebContainerAvailabilityEnabledFromConfig(globalAvailability);
759         if(_logger.isLoggable(Level.FINEST)) {
760             _logger.finest("webContainerAvailability = " + webContainerAvailability);
761         }
762         //System.out.println("webContainerAvailability = " + webContainerAvailability);
763
//System.out.println("j2eeAppName=" + j2eeAppName);
764
if(j2eeAppName == null || "null".equals(j2eeAppName)) {
765             //the stand-alone web module case
766
boolean webModuleAvailability =
767                 this.getWebModuleAvailability(contextRoot, webContainerAvailability);
768             if(_logger.isLoggable(Level.FINEST)) {
769                 _logger.finest("webModuleAvailability = " + webModuleAvailability);
770             }
771             //System.out.println("webModuleAvailability = " + webModuleAvailability);
772
return globalAvailability
773                     && webContainerAvailability
774                     && webModuleAvailability;
775         } else {
776             //the j2ee application case
777
boolean j2eeApplicationAvailability =
778                 this.getJ2eeApplicationAvailability(j2eeAppName, webContainerAvailability);
779             if(_logger.isLoggable(Level.FINEST)) {
780                 _logger.finest("j2eeApplicationAvailability = " + j2eeApplicationAvailability);
781             }
782             //System.out.println("j2eeApplicationAvailability = " + j2eeApplicationAvailability);
783
return globalAvailability
784                     && webContainerAvailability
785                     && j2eeApplicationAvailability;
786         }
787     }
788     
789     /**
790     * Get the availability-enabled for the web container from domain.xml.
791     * return inherited global availability-enabled if not found
792     */

793     public boolean getWebContainerAvailabilityEnabledFromConfig() {
794         boolean globalAvailabilityEnabled = this.getAvailabilityEnabledFromConfig();
795         if(_logger.isLoggable(Level.FINEST)) {
796             _logger.finest("in ServerConfigLookup>>getWebContainerAvailabilityEnabledFromConfig");
797         }
798         WebContainerAvailability was = this.getWebContainerAvailability();
799         if(was == null) {
800             if(_logger.isLoggable(Level.FINEST)) {
801                 _logger.finest("WebContainerAvailability was not defined - check domain.xml");
802             }
803             return globalAvailabilityEnabled;
804         }
805         
806         String JavaDoc wasString = was.getAvailabilityEnabled();
807         Boolean JavaDoc bool = this.toBoolean(wasString);
808         if(bool == null) {
809             return globalAvailabilityEnabled;
810         } else {
811             return bool.booleanValue();
812         }
813     }
814     
815     /**
816     * Get the availability-enabled for the web container from domain.xml.
817     * return inherited global availability-enabled if not found
818     */

819     public boolean getWebContainerAvailabilityEnabledFromConfig(boolean inheritedValue) {
820         //boolean globalAvailabilityEnabled = this.getAvailabilityEnabledFromConfig();
821
if(_logger.isLoggable(Level.FINEST)) {
822             _logger.finest("in ServerConfigLookup>>getWebContainerAvailabilityEnabledFromConfig");
823         }
824         WebContainerAvailability was = this.getWebContainerAvailability();
825         if(was == null) {
826             if(_logger.isLoggable(Level.FINEST)) {
827                 _logger.finest("WebContainerAvailability was not defined - check domain.xml");
828             }
829             return inheritedValue;
830         }
831         
832         String JavaDoc wasString = was.getAvailabilityEnabled();
833         Boolean JavaDoc bool = this.toBoolean(wasString);
834         if(bool == null) {
835             return inheritedValue;
836         } else {
837             return bool.booleanValue();
838         }
839     }
840
841     /**
842     * convert the input value to the appropriate Boolean value
843     * if input value is null, return null
844     */

845     protected Boolean JavaDoc toBoolean(String JavaDoc value){
846         if(value == null) return null;
847         
848         if (value.equalsIgnoreCase("true"))
849             return Boolean.TRUE;
850         if (value.equalsIgnoreCase("yes"))
851             return Boolean.TRUE;
852         if (value.equalsIgnoreCase("on") )
853             return Boolean.TRUE;
854         if (value.equalsIgnoreCase("1"))
855             return Boolean.TRUE;
856     
857         return Boolean.FALSE;
858     }
859
860     /**
861     * Get the store-pool-jndi-name from domain.xml.
862     * This is the store-pool-name in <availability-service> element
863     * it represents the default for both web & ejb container
864     * return DEFAULT_STORE_POOL_JNDI_NAME if not found
865     */

866     public String JavaDoc getStorePoolJndiNameFromConfig() {
867         if(_logger.isLoggable(Level.FINEST)) {
868             _logger.finest("in ServerConfigLookup>>getStorePoolJndiNameFromConfig");
869         }
870         String JavaDoc result = DEFAULT_STORE_POOL_JNDI_NAME;
871         AvailabilityService as = this.getAvailabilityService();
872         if(as == null) {
873             return result;
874         }
875         String JavaDoc storePoolJndiName = as.getStorePoolName();
876         if(storePoolJndiName != null) {
877             result = storePoolJndiName;
878         }
879         return result;
880     }
881     
882     /**
883     * Get the store-pool-jndi-name from domain.xml.
884     * return value returned from getStorePoolJndiNameFromConfig if not found
885     */

886     public String JavaDoc getHaStorePoolJndiNameFromConfig() {
887         if(_logger.isLoggable(Level.FINEST)) {
888             _logger.finest("in ServerConfigLookup>>getHaStorePoolJndiNameFromConfig");
889         }
890         //String result = DEFAULT_STORE_POOL_JNDI_NAME;
891
String JavaDoc result = this.getStorePoolJndiNameFromConfig();
892         WebContainerAvailability webContainerAvailabilityBean =
893             this.getWebContainerAvailability();
894         if(webContainerAvailabilityBean == null) {
895             return result;
896         }
897         String JavaDoc result2 = webContainerAvailabilityBean.getHttpSessionStorePoolName();
898         if(result2 != null) {
899             result = result2;
900         }
901         return result;
902     }
903     
904     /**
905     * Get the hadb health check string from domain.xml.
906     *7.0 xpath was "/server/availability-service/persistence-store/property[@name='hadb-health-check-enabled']"
907     * returns the attribute ha-store-healthcheck-enabled in <availability-service>
908     */

909     public boolean getHadbHealthCheckFromConfig() {
910         AvailabilityService as = this.getAvailabilityService();
911         if(as == null) {
912             return false;
913         }
914         return as.isHaStoreHealthcheckEnabled();
915     }
916     
917     /**
918     * Get the hadb health check string from domain.xml.
919     *7.0 xpath was "/server/availability-service/persistence-store/property[@name='hadb-health-check-enabled']"
920     * returns the attribute ha-store-healthcheck-enabled in <availability-service>
921     */

922     public boolean getHadbHealthCheckFromConfigDynamic() {
923         AvailabilityService as = this.getAvailabilityServiceDynamic();
924         if(as == null) {
925             return false;
926         }
927         return as.isHaStoreHealthcheckEnabled();
928     }
929     
930     /**
931     * Get the sso-failover-enabled boolean from domain.xml.
932     */

933     public boolean getSsoFailoverEnabledFromConfig() {
934         WebContainerAvailability webContainerAvailabilityBean =
935         this.getWebContainerAvailability();
936         if(webContainerAvailabilityBean == null) {
937             return false;
938         }
939         return webContainerAvailabilityBean.isSsoFailoverEnabled();
940     }
941   
942     /**
943     * Get the hadb management environment path from domain.xml.
944     * this is the location of cladm
945     * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='hadb-mgmt-env-path']"
946     */

947     public String JavaDoc getHadbMgmtEnvPathFromConfig() {
948         return this.getWebContainerAvailabilityPropertyString(HADB_MGMT_ENV_PATH_PROPERTY_NAME, null);
949         //return this.getAvailServicePersistenceStorePropertyString(HADB_MGMT_ENV_PATH_PROPERTY_NAME, null);
950
}
951     
952     ///begin HADB Health Check Stuff
953
/**
954     * Get the String value of the property under availability-service
955     * element from domain.xml whose name matches propName
956     * return null if not found
957     * @param propName
958     */

959     protected String JavaDoc getAvailabilityServicePropertyString(String JavaDoc propName) {
960         String JavaDoc result = null;
961         AvailabilityService availabilityServiceBean = this.getAvailabilityService();
962         if( (availabilityServiceBean != null) && (availabilityServiceBean.sizeElementProperty() > 0) ) {
963             ElementProperty[] props = availabilityServiceBean.getElementProperty();
964             for (int i = 0; i < props.length; i++) {
965                 String JavaDoc name = props[i].getAttributeValue("name");
966                 String JavaDoc value = props[i].getAttributeValue("value");
967                 if (name.equalsIgnoreCase(propName)) {
968                     result = value;
969                 }
970             }
971         }
972         return result;
973     }
974
975     /**
976     * Get the String value of the ha-store-name attribute under availability-service
977     * element from domain.xml
978     * return null if not found
979     */

980     public String JavaDoc getHadbDatabaseNameFromConfig() {
981         AvailabilityService as = this.getAvailabilityService();
982         if(as == null) {
983             return null;
984         }
985         return as.getHaStoreName();
986     }
987     
988     /**
989     * Get the String value of the ha-store-name attribute under availability-service
990     * element from domain.xml
991     * return null if not found
992     */

993     public String JavaDoc getHadbDatabaseNameFromConfigDynamic() {
994         AvailabilityService as = this.getAvailabilityServiceDynamic();
995         if(as == null) {
996             return null;
997         }
998         return as.getHaStoreName();
999     }
1000
1001    /**
1002    * Get the String value of the ha-agent-password attribute under availability-service
1003    * element from domain.xml
1004    * return null if not found
1005    */

1006    public String JavaDoc getHadbAgentPasswordFromConfig() {
1007        AvailabilityService as = this.getAvailabilityService();
1008        if(as == null) {
1009            return null;
1010        }
1011        return as.getHaAgentPassword();
1012    }
1013    
1014    /**
1015    * Get the String value of the ha-agent-password property under availability-service
1016    * element from domain.xml
1017    * return null if not found
1018    */

1019    /* Old version based on property - remove after testing
1020    public String getHadbAgentPasswordFromConfig() {
1021        return this.getAvailabilityServicePropertyString(HADB_AGENT_PASSWORD);
1022    }
1023     */

1024
1025    /**
1026    * Get the String value of the ha-store-healthcheck-interval-in-seconds attribute under availability-service
1027    * element from domain.xml
1028    * return null if not found
1029    */

1030    public String JavaDoc getHaStoreHealthcheckIntervalInSecondsStringFromConfig() {
1031        AvailabilityService as = this.getAvailabilityService();
1032        if(as == null) {
1033            return null;
1034        }
1035        return as.getHaStoreHealthcheckIntervalInSeconds();
1036    }
1037    
1038    /**
1039    * Get the ha-store-healthcheck-interval-in-seconds from domain.xml.
1040    * returns the attribute ha-store-healthcheck-interval-in-seconds
1041    * in <availability-service>
1042    * if missing (or error) default to DEFAULT_HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS
1043    */

1044    public int getHaStoreHealthcheckIntervalInSecondsFromConfig() {
1045        int candidateReturnValue = -1;
1046        int returnValue
1047            = DEFAULT_HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS;
1048        String JavaDoc returnValueString =
1049            this.getHaStoreHealthcheckIntervalInSecondsStringFromConfig();
1050        if(returnValueString != null) {
1051            try
1052            {
1053                candidateReturnValue = (Integer.valueOf(returnValueString)).intValue();
1054            } catch (NumberFormatException JavaDoc ex) {
1055                if(_logger.isLoggable(Level.FINEST)) {
1056                    _logger.finest("Using Default Value = " + DEFAULT_HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS);
1057                }
1058            }
1059        }
1060        //avoid returning negative or zero values
1061
if(candidateReturnValue > 0) {
1062            returnValue = candidateReturnValue;
1063        }
1064        return returnValue;
1065    }
1066    
1067    /**
1068    * Get the String value of the ha-store-healthcheck-interval-in-seconds attribute under availability-service
1069    * element from domain.xml
1070    * return null if not found
1071    */

1072    public String JavaDoc getHaStoreHealthcheckIntervalInSecondsStringFromConfigDynamic() {
1073        AvailabilityService as = this.getAvailabilityServiceDynamic();
1074        if(as == null) {
1075            return null;
1076        }
1077        return as.getHaStoreHealthcheckIntervalInSeconds();
1078    }
1079    
1080    /**
1081    * Get the ha-store-healthcheck-interval-in-seconds from domain.xml.
1082    * returns the attribute ha-store-healthcheck-interval-in-seconds
1083    * in <availability-service>
1084    * if missing (or error) default to DEFAULT_HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS
1085    */

1086    public int getHaStoreHealthcheckIntervalInSecondsFromConfigDynamic() {
1087        int candidateReturnValue = -1;
1088        int returnValue
1089            = DEFAULT_HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS;
1090        String JavaDoc returnValueString =
1091            this.getHaStoreHealthcheckIntervalInSecondsStringFromConfigDynamic();
1092        if(returnValueString != null) {
1093            try
1094            {
1095                candidateReturnValue = (Integer.valueOf(returnValueString)).intValue();
1096            } catch (NumberFormatException JavaDoc ex) {
1097                if(_logger.isLoggable(Level.FINEST)) {
1098                    _logger.finest("Using Default Value = " + DEFAULT_HA_STORE_HEALTHCHECK_INTERVAL_IN_SECONDS);
1099                }
1100            }
1101        }
1102        //avoid returning negative or zero values
1103
if(candidateReturnValue > 0) {
1104            returnValue = candidateReturnValue;
1105        }
1106        return returnValue;
1107    }
1108 
1109    /**
1110    * Get the String value of the ha-agent-port attribute under availability-service
1111    * element from domain.xml
1112    * return null if not found
1113    */

1114    public String JavaDoc getHadbAgentPortFromConfig() {
1115        AvailabilityService as = this.getAvailabilityService();
1116        if(as == null) {
1117            return null;
1118        }
1119        return as.getHaAgentPort();
1120    }
1121    
1122    /**
1123    * Get the String value of the ha-agent-port attribute under availability-service
1124    * element from domain.xml
1125    * return null if not found
1126    */

1127    public String JavaDoc getHadbAgentPortFromConfigDynamic() {
1128        AvailabilityService as = this.getAvailabilityServiceDynamic();
1129        if(as == null) {
1130            return null;
1131        }
1132        return as.getHaAgentPort();
1133    }
1134    
1135    /**
1136     * Get the connectionURL for hadb agent(s) from domain.xml.
1137     */

1138    public String JavaDoc getHadbAgentConnectionURLFromConfig() {
1139        String JavaDoc url = null;
1140        StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
1141        String JavaDoc hostsString = this.getHadbAgentHostsFromConfig();
1142        String JavaDoc portString = this.getHadbAgentPortFromConfig();
1143        if(hostsString != null && portString != null) {
1144            sb.append(hostsString);
1145            sb.append(":");
1146            sb.append(portString);
1147            url = sb.toString();
1148        } else {
1149            url = null;
1150        }
1151        return url;
1152    }
1153    
1154    /**
1155     * Get the connectionURL for hadb agent(s) from domain.xml.
1156     */

1157    public String JavaDoc getHadbAgentConnectionURLFromConfigDynamic() {
1158        String JavaDoc url = null;
1159        StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
1160        String JavaDoc hostsString = this.getHadbAgentHostsFromConfigDynamic();
1161        String JavaDoc portString = this.getHadbAgentPortFromConfigDynamic();
1162        if(hostsString != null && portString != null) {
1163            sb.append(hostsString);
1164            sb.append(":");
1165            sb.append(portString);
1166            url = sb.toString();
1167        } else {
1168            url = null;
1169        }
1170        return url;
1171    }
1172
1173    /**
1174    * Get the String value of the ha-agent-hosts attribute under availability-service
1175    * element from domain.xml
1176    * return null if not found
1177    */

1178    public String JavaDoc getHadbAgentHostsFromConfig() {
1179        AvailabilityService as = this.getAvailabilityService();
1180        if(as == null) {
1181            return null;
1182        }
1183        return as.getHaAgentHosts();
1184    }
1185    
1186    /**
1187    * Get the String value of the ha-agent-hosts attribute under availability-service
1188    * element from domain.xml
1189    * return null if not found
1190    */

1191    public String JavaDoc getHadbAgentHostsFromConfigDynamic() {
1192        AvailabilityService as = this.getAvailabilityServiceDynamic();
1193        if(as == null) {
1194            return null;
1195        }
1196        return as.getHaAgentHosts();
1197    }
1198    
1199    ///end HADB Health Check Stuff
1200

1201    /**
1202    * Get the EE_BUILDER_PATH from server.xml.
1203    * this defaults to EE_BUILDER_PATH but can be modified
1204    * this is the fully qualified path to the EE builders
1205    * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='ee-builder-path']"
1206    */

1207    public String JavaDoc getEEBuilderPathFromConfig() {
1208        return this.getWebContainerAvailabilityPropertyString(EE_BUILDER_PATH_PROPERTY_NAME, DEFAULT_EE_BUILDER_PATH);
1209        //return this.getAvailServicePersistenceStorePropertyString(EE_BUILDER_PATH_PROPERTY_NAME, DEFAULT_EE_BUILDER_PATH);
1210
}
1211    
1212    /**
1213    * Get the UuidGenerator implementation class name from domain.xml.
1214    * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='uuid-impl-class']";
1215    */

1216    public String JavaDoc getUuidGeneratorImplClassFromConfig() {
1217        if(_logger.isLoggable(Level.FINEST)) {
1218            _logger.finest("in ServerConfigLookup>>getUuidGeneratorImplClassFromConfig");
1219        }
1220        return this.getWebContainerAvailabilityPropertyString(UUID_GENERATOR_CLASS_PROPERTY_NAME, DEFAULT_UUID_GENERATOR_CLASS);
1221        //return this.getAvailServicePersistenceStorePropertyString(UUID_GENERATOR_CLASS_PROPERTY_NAME, DEFAULT_UUID_GENERATOR_CLASS);
1222
}
1223  
1224    /**
1225    * Get the UuidGenerator implementation class from server.xml.
1226    * 7.0 xpath was "/server/availability-service/persistence-store/property[@name='uuid-impl-class']";
1227    */

1228    public UuidGenerator getUuidGeneratorFromConfig() {
1229      UuidGenerator generator = new UuidGeneratorImpl();
1230      String JavaDoc generatorImplClassName =
1231        this.getUuidGeneratorImplClassFromConfig();
1232      try {
1233          generator =
1234                (UuidGenerator) (Class.forName(generatorImplClassName)).newInstance();
1235      } catch (Exception JavaDoc ex) {
1236      }
1237      return generator;
1238    }
1239  
1240    /**
1241    * Get the value from server.xml for xpath
1242    * return defaultValue if not defined or other problem
1243    */

1244    public String JavaDoc getServerConfigValue(String JavaDoc xpath, String JavaDoc defaultValue ) {
1245        if(_logger.isLoggable(Level.FINEST)) {
1246            _logger.finest("in ServerConfigLookup>>getServerConfigValue:xpath=" + xpath
1247                + " defaultValue= " + defaultValue);
1248        }
1249
1250      ServerContext serverCtx = ApplicationServer.getServerContext();
1251      //this condition occurs during some unit tests
1252
if(serverCtx == null)
1253          return defaultValue;
1254      ConfigContext configCtx = serverCtx.getConfigContext();
1255      ConfigBean configBean = null;
1256      String JavaDoc returnValueString = null;
1257
1258      String JavaDoc returnValue = defaultValue;
1259      try {
1260          configBean =
1261              configCtx.exactLookup(xpath);
1262      } catch (ConfigException ex) {
1263      }
1264      if(configBean != null) {
1265          returnValueString = configBean.getAttributeValue("value");
1266      }
1267      if(returnValueString != null) {
1268          returnValue = returnValueString;
1269      }
1270      if(_logger.isLoggable(Level.FINEST)) {
1271          _logger.finest("RETURNED CONFIG VALUE FOR XPATH:" + xpath +
1272            " = " + returnValue);
1273      }
1274
1275      return returnValue;
1276    }
1277  
1278    /**
1279    * Get the value from server.xml for xpath
1280    * return defaultValue if not defined or other problem
1281    */

1282    public int getServerConfigValue(String JavaDoc xpath, int defaultValue ) {
1283        if(_logger.isLoggable(Level.FINEST)) {
1284            _logger.finest("in getServerConfigValue:xpath=" + xpath
1285                + " defaultValue= " + defaultValue);
1286        }
1287        /*
1288        ServerContext serverCtx = ApplicationServer.getServerContext();
1289        ConfigContext configCtx = serverCtx.getConfigContext();
1290        */

1291        ConfigContext configCtx = this.getConfigContext();
1292        ConfigBean configBean = null;
1293        String JavaDoc returnValueString = null;
1294
1295        int returnValue = defaultValue;
1296        try {
1297            configBean =
1298                configCtx.exactLookup(xpath);
1299        } catch (ConfigException ex) {
1300        }
1301        if(configBean != null) {
1302            returnValueString = configBean.getAttributeValue("value");
1303        }
1304        if(returnValueString != null) {
1305            try {
1306                returnValue = (Integer.valueOf(returnValueString)).intValue();
1307            } catch (NumberFormatException JavaDoc ex) {
1308                _logger.finest("Using Default Value = "
1309                    + defaultValue);
1310            }
1311        }
1312        if(_logger.isLoggable(Level.FINEST)) {
1313            _logger.finest("RETURNED CONFIG VALUE FOR XPATH:" + xpath +
1314                " = " + returnValue);
1315        }
1316
1317        return returnValue;
1318    }
1319
1320    /**
1321    * Get the session manager bean from domain.xml
1322    * return null if not defined or other problem
1323    * 7.0 xpath was "/server/web-container/session-config/session-manager";
1324    */

1325    public SessionManager getInstanceSessionManager() {
1326        Config configBean = this.getConfigBean();
1327        if(configBean == null) {
1328            return null;
1329        }
1330        
1331        com.sun.enterprise.config.serverbeans.WebContainer webContainerBean
1332            = configBean.getWebContainer();
1333        if(webContainerBean == null) {
1334            return null;
1335        }
1336        
1337        SessionConfig sessionConfigBean = webContainerBean.getSessionConfig();
1338        if(sessionConfigBean == null) {
1339            return null;
1340        }
1341        
1342        com.sun.enterprise.config.serverbeans.SessionManager smBean =
1343            sessionConfigBean.getSessionManager();
1344        return smBean;
1345    }
1346    
1347    /**
1348    * Get the manager properties bean from domain.xml
1349    * return null if not defined or other problem
1350    * 7.0 xpath was "/server/web-container/session-config/session-manager/manager-properties";
1351    */

1352    public ManagerProperties getInstanceSessionManagerManagerProperties() {
1353        
1354        SessionManager smBean = this.getInstanceSessionManager();
1355        if(smBean == null) {
1356            return null;
1357        }
1358        return smBean.getManagerProperties();
1359    }
1360    
1361    /**
1362    * Get the store properties bean from domain.xml
1363    * return null if not defined or other problem
1364    * 7.0 xpath was "/server/web-container/session-config/session-manager/store-properties";
1365    */

1366    public StoreProperties getInstanceSessionManagerStoreProperties() {
1367        
1368        SessionManager smBean = this.getInstanceSessionManager();
1369        if(smBean == null) {
1370            return null;
1371        }
1372        return smBean.getStoreProperties();
1373    }
1374
1375    /**
1376    * Get the session properties bean from server.xml
1377    * return null if not defined or other problem
1378    * 7.0 xpath was "/server/web-container/session-config/session-properties";
1379    */

1380    public SessionProperties getInstanceSessionProperties() {
1381        Config configBean = this.getConfigBean();
1382        if(configBean == null) {
1383            return null;
1384        }
1385        
1386        com.sun.enterprise.config.serverbeans.WebContainer webContainerBean
1387            = configBean.getWebContainer();
1388        if(webContainerBean == null) {
1389            return null;
1390        }
1391        
1392        SessionConfig sessionConfigBean = webContainerBean.getSessionConfig();
1393        if(sessionConfigBean == null) {
1394            return null;
1395        }
1396        
1397        com.sun.enterprise.config.serverbeans.SessionProperties spBean =
1398            sessionConfigBean.getSessionProperties();
1399        return spBean;
1400    }
1401     
1402    /**
1403    * Get the connectionUser from domain.xml.
1404    */

1405    public String JavaDoc getConnectionUserFromConfig() {
1406
1407        String JavaDoc user = null;
1408        JdbcConnectionPool pool = this.getHadbJdbcConnectionPoolFromConfig();
1409        if(pool == null) {
1410            return null;
1411        }
1412        if (pool.sizeElementProperty() > 0) {
1413            ElementProperty[] props = pool.getElementProperty();
1414            for (int i = 0; i < props.length; i++) {
1415                String JavaDoc name = props[i].getAttributeValue("name");
1416                String JavaDoc value = props[i].getAttributeValue("value");
1417                if (name.equalsIgnoreCase(USER_NAME)) {
1418                //if (name.equalsIgnoreCase("username")) {
1419
user = value;
1420                }
1421            }
1422        }
1423        if(_logger.isLoggable(Level.FINEST)) {
1424            _logger.finest("IN NEW getConnectionUserFromConfig: user=" + user);
1425        }
1426        return user;
1427    }
1428    
1429    /**
1430    * Get the connectionPassword from domain.xml.
1431    */

1432    public String JavaDoc getConnectionPasswordFromConfig() {
1433
1434        String JavaDoc password = null;
1435        JdbcConnectionPool pool = this.getHadbJdbcConnectionPoolFromConfig();
1436        if(pool == null)
1437            return null;
1438        if (pool.sizeElementProperty() > 0) {
1439            ElementProperty[] props = pool.getElementProperty();
1440            for (int i = 0; i < props.length; i++) {
1441                String JavaDoc name = props[i].getAttributeValue("name");
1442                String JavaDoc value = props[i].getAttributeValue("value");
1443                if (name.equalsIgnoreCase(PASSWORD)) {
1444                //if (name.equalsIgnoreCase("password")) {
1445
password = value;
1446                }
1447            }
1448        }
1449        if(_logger.isLoggable(Level.FINEST)) {
1450            _logger.finest("IN NEW getConnectionPasswordFromConfig: password=" + password);
1451        }
1452        return password;
1453    }
1454    
1455    /**
1456     * Get the connectionURL from domain.xml.
1457     */

1458    public String JavaDoc getConnectionURLFromConfig() {
1459        String JavaDoc url = null;
1460        StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
1461        JdbcConnectionPool pool = this.getHadbJdbcConnectionPoolFromConfig();
1462        if(pool == null)
1463            return null;
1464        if (pool.sizeElementProperty() > 0) {
1465            ElementProperty[] props = pool.getElementProperty();
1466            for (int i = 0; i < props.length; i++) {
1467                String JavaDoc name = props[i].getAttributeValue("name");
1468                String JavaDoc value = props[i].getAttributeValue("value");
1469                if (name.equalsIgnoreCase("serverList")) {
1470                    sb.append(HADB_CONNECTION_URL_PREFIX);
1471                    sb.append(value);
1472                    url = sb.toString();
1473                }
1474            }
1475        }
1476        if(_logger.isLoggable(Level.FINEST)) {
1477            _logger.finest("IN NEW getConnectionURLFromConfig: url=" + url);
1478        }
1479        return url;
1480    }
1481   
1482    /**
1483    * Get the JdbcConnectionPool for HADB from domain.xml.
1484    * return null if not found
1485    */

1486    public JdbcConnectionPool getHadbJdbcConnectionPoolFromConfig() {
1487        String JavaDoc storePoolJndiName = this.getHaStorePoolJndiNameFromConfig();
1488        if(storePoolJndiName == null)
1489            return null;
1490
1491        Resources resources = this.getResourcesBean();
1492        JdbcResource jdbcResource =
1493            resources.getJdbcResourceByJndiName(storePoolJndiName);
1494        if(jdbcResource == null) {
1495            return null;
1496        }
1497                
1498        String JavaDoc poolName = jdbcResource.getPoolName();
1499        JdbcConnectionPool pool =
1500            resources.getJdbcConnectionPoolByName(poolName);
1501        return pool;
1502    }
1503    
1504    
1505    /**
1506    * Get the JdbcConnectionPool name for HADB from domain.xml.
1507    */

1508    public String JavaDoc getHadbJdbcConnectionPoolNameFromConfig() {
1509
1510        String JavaDoc storePoolJndiName = this.getHaStorePoolJndiNameFromConfig();
1511        if(storePoolJndiName == null)
1512            return null;
1513
1514        Resources resources = this.getResourcesBean();
1515        JdbcResource jdbcResource =
1516            resources.getJdbcResourceByJndiName(storePoolJndiName);
1517        if(jdbcResource == null)
1518            return null;
1519        String JavaDoc poolName = jdbcResource.getPoolName();
1520        return poolName;
1521    }
1522    
1523    /**
1524     * The logger to use for logging ALL web container related messages.
1525     */

1526    private static Logger JavaDoc _logger = null;
1527    
1528}
1529
Popular Tags