KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > instance > BaseManager


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  * BaseManager.java
26  *
27  * Created on January 15, 2002, 5:00 PM
28  */

29
30 package com.sun.enterprise.instance;
31
32
33 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
34
35 import com.sun.enterprise.admin.AdminContext;
36 import com.sun.enterprise.admin.server.core.AdminService;
37 import com.sun.enterprise.config.ConfigBean;
38 import com.sun.enterprise.config.ConfigBeansFactory;
39 import com.sun.enterprise.config.ConfigContext;
40 import com.sun.enterprise.config.ConfigException;
41 import com.sun.enterprise.config.ConfigFactory;
42 import com.sun.enterprise.config.serverbeans.ApplicationRef;
43 import com.sun.enterprise.config.serverbeans.Applications;
44 import com.sun.enterprise.config.serverbeans.ConnectorModule;
45 import com.sun.enterprise.config.serverbeans.DasConfig;
46 import com.sun.enterprise.config.serverbeans.Domain;
47 import com.sun.enterprise.config.serverbeans.JavaConfig;
48 import com.sun.enterprise.config.serverbeans.Server;
49 import com.sun.enterprise.config.serverbeans.Server;
50 import com.sun.enterprise.config.serverbeans.ServerBeansFactory;
51 import com.sun.enterprise.config.serverbeans.ServerHelper;
52 import com.sun.enterprise.config.serverbeans.Servers;
53 import com.sun.enterprise.config.serverbeans.ServerXPathHelper;
54 import com.sun.enterprise.deployment.Application;
55 import com.sun.enterprise.deployment.BundleDescriptor;
56 import com.sun.enterprise.deployment.util.ModuleDescriptor;
57 import com.sun.enterprise.deployment.archivist.Archivist;
58 import com.sun.enterprise.deployment.archivist.ApplicationArchivist;
59 import com.sun.enterprise.deployment.archivist.EjbArchivist;
60 import com.sun.enterprise.deployment.archivist.WebArchivist;
61 import com.sun.enterprise.deployment.backend.DeployableObjectInfo;
62 import com.sun.enterprise.deployment.deploy.shared.FileArchive;
63 import com.sun.enterprise.util.io.FileUtils;
64 import com.sun.enterprise.util.StringUtils;
65 import com.sun.enterprise.util.RelativePathResolver;
66 import com.sun.logging.LogDomains;
67
68 import java.io.File JavaDoc;
69 import java.io.IOException JavaDoc;
70 import java.util.*;
71 import java.util.logging.Level JavaDoc;
72 import java.util.logging.Logger JavaDoc;
73
74 import org.xml.sax.SAXParseException JavaDoc;
75
76 /**
77  *
78  * @author sridatta
79  */

80 public abstract class BaseManager {
81     
82     protected ConfigContext configContext;
83     protected ConfigBean configBean;
84     private DasConfig appConfig;
85     protected InstanceEnvironment instanceEnvironment;
86     protected boolean useBackupServerXml = true;
87     protected static final String JavaDoc SYSTEM_PREFIX = "system-";
88     protected static final String JavaDoc SYSTEM_ADMIN_PREFIX = "system-admin";
89     protected static Logger JavaDoc _logger=LogDomains.getLogger(LogDomains.CORE_LOGGER);
90     private static Map registeredDescriptors;
91
92     /** javac debug option */
93     private static final String JavaDoc DEBUG_OPTION = "-g";
94
95     /** javac optimize option */
96     private static final String JavaDoc OPTIMIZE_OPTION = "-O";
97     
98     public BaseManager(InstanceEnvironment env, boolean useBackupServerXml)
99             throws ConfigException {
100
101         instanceEnvironment = env;
102         try {
103             this.useBackupServerXml = useBackupServerXml;
104                 //_logger.log(Level.FINE,"core.serverxml_usage",((useBackupServerXml)?"back":"hot"));
105

106             String JavaDoc fileUrl;
107             if(useBackupServerXml) {
108                 fileUrl = instanceEnvironment.getBackupConfigFilePath();
109             } else {
110                 fileUrl = instanceEnvironment.getConfigFilePath();
111             }
112             
113             if (useBackupServerXml) {
114                 AdminService as = AdminService.getAdminService();
115                 if (as != null) {
116                     AdminContext ac = as.getAdminContext();
117                     if (ac != null) {
118                         configContext = ac.getAdminConfigContext();
119                     }
120                 }
121             }
122             if (configContext == null) {
123                 configContext = ConfigFactory.createConfigContext(fileUrl);
124             }
125             configBean = ConfigBeansFactory.getConfigBeanByXPath(this.configContext,
126                                         ServerXPathHelper.XPATH_APPLICATIONS);
127             //RAMAKANTH
128
if (configBean == null) {
129                 configBean = new Applications();
130             }
131
132             //ROB: config changes
133
appConfig = ServerBeansFactory.getDasConfigBean(configContext);
134
135             //RAMAKANTH
136
//Why?? what does this mean??
137
if (appConfig == null) {
138                 appConfig = new DasConfig();
139             }
140
141         }
142         catch(Exception JavaDoc e) {
143             throw new ConfigException(Localizer.getValue(ExceptionType.MISSING_SERVER_NODE), e);
144         }
145     }
146     
147     /**
148      * @return the module type this class is managing
149      */

150     public abstract ModuleType JavaDoc getModuleType();
151     
152     /**
153      * @author bnevins
154      * 9-23-03 for S1AS 8.0PE
155      * The namespace has been flattened for 8.0
156      * This method is called to see if a name is registered for a different
157      * type of J2EE Deployable Object. Deployment Backend itself will check the
158      * Manager for the same type of object to see if it is a re-deploy. If that
159      * check is negative, it will call here to check all the other types. If a different
160      * type is registered with the same name, Deployment will fail the deployment
161      * instead of wiping out the other app/module with the same name.
162      * @return A String with the name of the deployable object type -- if the name is registered,
163      * otherwise null.
164      */

165     
166     public static String JavaDoc isRegisteredAnywhere(InstanceEnvironment ienv, String JavaDoc id)
167     {
168         try {
169             BaseManager[] mans = new BaseManager[]{
170                 new WebModulesManager(ienv),
171                 new EjbModulesManager(ienv),
172                 new AppclientModulesManager(ienv),
173                 new ConnectorModulesManager(ienv),
174                 new AppsManager(ienv)
175             };
176
177             String JavaDoc[] errors = new String JavaDoc[] {"Web Module", "EJB Module", "App Client Module", "Connector Module", "Application"};
178
179             for(int i = 0; i < mans.length; i++){
180                 if(mans[i].listIds().contains(id)) {
181                     return errors[i];
182                 }
183             }
184         }
185         catch(Exception JavaDoc e){
186         }
187         return null;
188     }
189         
190     /**
191      * Returns a virtual application for standalone module or a fully
192      * initialized application object from the deployment descriptors
193      *
194      * @param modId web module id
195      *
196      * @return the deployment descriptor object for this web module
197      *
198      * @throws ConfigException if unable to load the deployment descriptor
199      */

200     public Application getDescriptor(String JavaDoc modId, ClassLoader JavaDoc cl,
201         boolean validateXML) throws ConfigException {
202     
203     return getDescriptor(modId, cl, getLocation(modId), validateXML);
204     }
205     
206     /**
207      * Returns a virtual application for standalone module or a fully
208      * initialized application object from the deployment descriptors
209      *
210      * @param modId web module id
211      *
212      * @return the deployment descriptor object for this web module
213      *
214      * @throws ConfigException if unable to load the deployment descriptor
215      */

216     public abstract Application getDescriptor(String JavaDoc modId, ClassLoader JavaDoc cl, String JavaDoc loc, boolean validateXML)
217         throws ConfigException;
218     
219         
220     /**
221      * This method only returns from cache. Call it only when you are
222      * are sure the application should be in the instance managers.
223      */

224     public Application getDescriptor(String JavaDoc appID)
225             throws ConfigException {
226         return getRegisteredDescriptor(appID);
227     }
228     
229     // START OF IASRI 4709374
230
/**
231      * Returns a boolean indicating whether or not bytecode preprocessing is
232      * enabled. The bytecode preprocessor is deemed to be enabled if if a
233      * value for bytecode-preprocessors is set in the java config.
234      * @throws ConfigException - enabled via server.xml
235      * @return - true if enabled, otherwise false.
236      */

237       public boolean isByteCodePreprocessingEnabled()
238         throws ConfigException {
239         boolean result = false;
240         //ROB: config changes
241
JavaConfig jc = ServerBeansFactory.getJavaConfigBean(configContext);
242         if (jc != null) {
243             if (jc.getBytecodePreprocessors() != null) {
244                 result = true;
245             }
246         }
247         return result;
248     }
249     
250     /**
251      * Returns an array of bytecode preprocessor class name(s) as set in
252      * server.xml.
253      * @throws ConfigException
254      * @return - an array of preprocessor class names.
255      */

256     public String JavaDoc[] getBytecodeProcessorClassNames()
257         throws ConfigException {
258         String JavaDoc result[] = null;
259         //ROB: config changes - use of domain.xml
260
JavaConfig jc = ServerBeansFactory.getJavaConfigBean(configContext);
261         if (jc != null) {
262            String JavaDoc value = jc.getBytecodePreprocessors();
263            _logger.log(Level.INFO,
264               "core.preprocessor_class_name", value);
265            // Split the comma delimited list of bytecode preprocessor
266
// class names into the result array
267
result = value.split(",");
268         }
269
270         return result;
271     }
272     // END OF IASRI 4709374
273

274     /**
275      * Returns true if dynamic reloading is enabled.
276      *
277      * @return true if dynamic reloading is enabled
278      */

279     public boolean isDynamicReloadEnabled() {
280         //ROB: config changes
281
//return ((Applications)this.configBean).isDynamicReloadEnabled();
282
return appConfig.isDynamicReloadEnabled();
283     }
284
285     /**
286      * Returns the reload polling interval in milli-seconds.
287      *
288      * @return reload polling interval in milli-seconds
289      */

290     public long getReloadPollIntervalInMillis() {
291
292         // pool interval from server configuration in seconds
293
String JavaDoc intv = appConfig.getDynamicReloadPollIntervalInSeconds();
294
295
296         long pollIntv;
297
298         try {
299             pollIntv = Long.parseLong(intv) * 1000;
300         } catch (NumberFormatException JavaDoc nme) {
301
302             // use the default interval
303
intv = appConfig.getDefaultDynamicReloadPollIntervalInSeconds();
304
305             try {
306                 pollIntv = Long.parseLong(intv) * 1000;
307             } catch (NumberFormatException JavaDoc ne) {
308                 // this should never happen
309
pollIntv = 2000l;
310             }
311         }
312
313         return pollIntv;
314     }
315
316     /**
317      * Returns the java class path for this server instance.
318      * It includes the "classpath-prefix" and "classpath-suffix".
319      * This method is called during deployment to construct the
320      * class loader. Deployment assumes that server class path will
321      * not differ between admin instance and a regular instance.
322      * So, only prefix and suffix are added to the class path.
323      *
324      * @return the system class path that includes only prefix & suffix
325      *
326      * @throws ConfigException if an error while reading the server.xml
327      */

328     public List getSystemCPathPrefixNSuffix() throws ConfigException {
329
330         List classPath = new ArrayList();
331
332         // bean that represents the java configuration
333
JavaConfig jconfig = (JavaConfig) ConfigBeansFactory.
334                                     getConfigBeanByXPath(this.configContext,
335                                         ServerXPathHelper.XPATH_JAVACONFIG);
336
337         // add the class path prefix first
338
String JavaDoc prefix = jconfig.getClasspathPrefix();
339         if (prefix != null) {
340             StringTokenizer st = new StringTokenizer(prefix,File.pathSeparator);
341             while (st.hasMoreTokens()) {
342                 classPath.add(st.nextToken());
343             }
344         }
345
346         // adds the class path suffix to the list
347
String JavaDoc suffix = jconfig.getClasspathSuffix();
348         if (suffix != null) {
349             StringTokenizer st = new StringTokenizer(suffix,File.pathSeparator);
350             while (st.hasMoreTokens()) {
351                 classPath.add(st.nextToken());
352             }
353         }
354
355         return classPath;
356
357     }
358
359     /**
360      * Returns the system class path for this server instance.
361      * It includes the "classpath-prefix", "classpath" and "classpath-suffix".
362      *
363      * @return the system class path
364      *
365      * @throws ConfigException if an error while reading the server.xml
366      */

367
368     public List getSystemClasspath() throws ConfigException {
369     if(!Boolean.getBoolean(com.sun.enterprise.server.PELaunch.USE_NEW_CLASSLOADER_PROPERTY)){
370         List classPath = new ArrayList();
371
372         // bean that represents the java configuration
373
JavaConfig jconfig = (JavaConfig) ConfigBeansFactory.
374                                     getConfigBeanByXPath(this.configContext,
375                                         ServerXPathHelper.XPATH_JAVACONFIG);
376
377         // add the class path prefix first
378
String JavaDoc prefix = jconfig.getClasspathPrefix();
379         if (prefix != null) {
380             StringTokenizer st = new StringTokenizer(prefix,File.pathSeparator);
381             while (st.hasMoreTokens()) {
382                 classPath.add(st.nextToken());
383             }
384         }
385
386         // adds the server classpath to the list
387
String JavaDoc serverClasspath = jconfig.getServerClasspath();
388         if (serverClasspath != null) {
389             StringTokenizer st =
390                 new StringTokenizer(serverClasspath,File.pathSeparator);
391             while (st.hasMoreTokens()) {
392                 classPath.add(st.nextToken());
393             }
394         }
395
396         // adds the class path suffix to the list
397
String JavaDoc suffix = jconfig.getClasspathSuffix();
398         if (suffix != null) {
399             StringTokenizer st = new StringTokenizer(suffix,File.pathSeparator);
400             while (st.hasMoreTokens()) {
401                 classPath.add(st.nextToken());
402             }
403         }
404
405         return classPath;
406     } else {
407         return com.sun.enterprise.server.PELaunch.getServerClasspath();
408     }
409     }
410
411     /**
412      * Per the platform specification, connector classes are to be availble
413      * to all applications, i.e. a connector deployed to target foo should
414      * be available to apps deployed on foo (and not target bar). During
415      * deployment process on DAS, we don't really need to load any
416      * connector classes EXCEPT when the verifier is turned on. In that
417      * case, we will need to figure out all connector module deployed to
418      * the target on which the application is deployed. Resolving the
419      * classpath accordlingly. If verifier is not on, we bypass this logic
420      * to save some time.
421      *
422      * @param resolveOnDAS Whether to resolve connector classpath or not.
423      * This should only be true when running on DAS.
424      * @param target The target on which the application is to be deployed
425      */

426     public List getSharedClasspath(boolean resolveOnDAS, String JavaDoc target)
427         throws ConfigException {
428         List classpath = new ArrayList();
429
430         ConnectorModule[] mods = null;
431         if (resolveOnDAS && (target != null)) {
432             mods = ServerHelper.getAssociatedConnectorModules(
433                         configContext, target);
434         } else {
435             mods = ((Applications)this.configBean).getConnectorModule();
436         }
437
438         if (mods != null) {
439             for (int i=0; i<mods.length; i++) {
440                 if (resolveOnDAS) {
441                     classpath.add(RelativePathResolver.resolvePath(
442                         mods[i].getLocation()));
443                 } else {
444                     classpath.add(mods[i].getLocation());
445                 }
446             }
447         }
448         
449         return classpath;
450         
451     }
452     
453
454     /**
455      * Returns the rmic options for deployment.
456      *
457      * @return rmic options as of type java.lang.String
458      * @throws ConfigException if an error while reading server.xml
459      */

460     public List getRmicOptions() throws ConfigException {
461         
462         List rmicOptions = new ArrayList();
463
464         // bean that represents the java configuration
465
JavaConfig jconfig = (JavaConfig) ConfigBeansFactory.
466                                     getConfigBeanByXPath(this.configContext,
467                                         ServerXPathHelper.XPATH_JAVACONFIG);
468         String JavaDoc options = jconfig.getRmicOptions();
469         if (options == null) {
470             options = jconfig.getDefaultRmicOptions();
471         }
472         StringTokenizer st = new StringTokenizer(options, " ");
473         while (st.hasMoreTokens()) {
474             String JavaDoc op = (String JavaDoc) st.nextToken();
475             rmicOptions.add(op);
476             _logger.log(Level.FINE, "Detected Rmic option: " + op);
477         }
478         
479         return rmicOptions;
480     }
481
482     /**
483      * Returns the javac options for deployment. The options can be anything
484      * except "-d", "-classpath" and "-cp".
485      * It tokenizes the options by blank space between them. It does
486      * not to detect options like "-g -g -g" since javac handles it.
487      *
488      * @return javac options as of type java.lang.String
489      * @throws ConfigException if an error while reading server.xml
490      */

491     public List getJavacOptions() throws ConfigException {
492         
493         List javacOptions = new ArrayList();
494
495         // bean that represents the java configuration
496
JavaConfig jconfig = (JavaConfig) ConfigBeansFactory.
497                                     getConfigBeanByXPath(this.configContext,
498                                         ServerXPathHelper.XPATH_JAVACONFIG);
499         String JavaDoc options = jconfig.getJavacOptions();
500         if (options == null) {
501             options = jconfig.getDefaultJavacOptions();
502         }
503         StringTokenizer st = new StringTokenizer(options, " ");
504         while (st.hasMoreTokens()) {
505             String JavaDoc op = (String JavaDoc) st.nextToken();
506             if ( !(op.startsWith("-d")
507                 || op.startsWith("-cp") || op.startsWith("-classpath")) ) {
508                 javacOptions.add(op);
509             } else {
510                 _logger.log(Level.WARNING, "core.unsupported_javac_option", op);
511             }
512         }
513         
514         return javacOptions;
515     }
516
517     /**
518      * Returns true if environment class path ignore flag is turned on.
519      *
520      * @return true if environment class path ignore flag is turned on
521      * @throws ConfigException if an error while reading the server.xml
522      */

523     public boolean isEnvClasspathIgnored() throws ConfigException {
524
525         // bean that represents the java configuration
526
JavaConfig jconfig = (JavaConfig) ConfigBeansFactory.
527                                     getConfigBeanByXPath(this.configContext,
528                                        ServerXPathHelper.XPATH_JAVACONFIG);
529
530         return jconfig.isEnvClasspathIgnored();
531     }
532
533     public final boolean isIASOwned(String JavaDoc id)
534     {
535         // WBN 2/7/2002 -- I don't think this bit of info is ever going
536
// to be persisted. Here is a M^2 technology way of doing it.
537

538         assert instanceEnvironment != null;
539
540         try
541         {
542             return instanceEnvironment.isIASOwned(getLocation(id));
543         }
544         catch(Exception JavaDoc e)
545         {
546             return false;
547         }
548     }
549     
550     /**
551      * Refreshes config context using the given context. This method is called
552      * during dynamic deploy/undeploy of applications and stand alone modules.
553      *
554      * @param ctx new config context (from the event)
555      * @throws ConfigException if null config context or an error while
556      * retrieving the config bean
557      */

558     public void refreshConfigContext(ConfigContext ctx) throws ConfigException {
559
560         this.configContext = ctx;
561         this.configBean = ConfigBeansFactory.
562                 getConfigBeanByXPath(this.configContext,
563                                     ServerXPathHelper.XPATH_APPLICATIONS);
564     }
565     
566     public void refreshConfigContext() throws ConfigException {
567         configContext.refresh(true);
568         configBean = ConfigBeansFactory.getConfigBeanByXPath(this.configContext,
569                                     ServerXPathHelper.XPATH_APPLICATIONS);
570     }
571     
572
573     public InstanceEnvironment getInstanceEnvironment() {
574         return this.instanceEnvironment;
575     }
576     
577     public boolean isShared(String JavaDoc id) throws ConfigException {
578         throw new UnsupportedOperationException JavaDoc(
579             Localizer.getValue(ExceptionType.UNSUPPORTED, "isShared()"));
580     }
581     public void setShared(String JavaDoc modId, boolean shared) throws ConfigException {
582         throw new UnsupportedOperationException JavaDoc(Localizer.getValue(
583                 ExceptionType.UNSUPPORTED, "setShared()"));
584     }
585     
586     public String JavaDoc getStubLocation(String JavaDoc id) {
587         throw new UnsupportedOperationException JavaDoc(Localizer.getValue(
588                 ExceptionType.UNSUPPORTED, "getStubLocation()"));
589     }
590     
591     public boolean isRegistered(String JavaDoc id) {
592         return isRegistered(id, this.configBean);
593     }
594      
595     public void saveConfigContext() throws ConfigException {
596
597         if(!this.useBackupServerXml) {
598             throw new ConfigException(Localizer.getValue(ExceptionType.CANT_APPLY));
599         }
600             
601         this.configContext.flush();
602     }
603     
604     public void applyServerXmlChanges() throws ConfigException {
605         if(!this.useBackupServerXml) {
606             throw new ConfigException(Localizer.getValue(ExceptionType.CANT_APPLY));
607         }
608         this.configContext.flush();
609         instanceEnvironment.applyServerXmlChanges(false);
610     }
611         
612     public void setVirtualServers(String JavaDoc modId, String JavaDoc value)
613             throws ConfigException {
614     }
615         
616     /**
617      *override for Web Modules
618      */

619     public String JavaDoc getContextRoot(String JavaDoc id) throws ConfigException {
620         throw new UnsupportedOperationException JavaDoc(Localizer.getValue(
621                 ExceptionType.UNSUPPORTED, "getContextRoot()"));
622     }
623
624     /**
625      *override for Web Modules
626      */

627     public void setContextRoot(String JavaDoc id, String JavaDoc value) throws ConfigException {
628         throw new UnsupportedOperationException JavaDoc(Localizer.getValue(
629                 ExceptionType.UNSUPPORTED, "setContextRoot()"));
630     }
631     
632     /**
633      * @return the registered descriptors map
634      */

635     public abstract Map getRegisteredDescriptors();
636     
637     /**
638      * register an new application descriptor in the map
639      *
640      * @param registrationName is the registration name for the descriptor
641      * @param descriptor the new application to register
642      */

643     public void registerDescriptor(String JavaDoc registrationName, Application descriptor) {
644         
645         Map map = getRegisteredDescriptors();
646         if (map==null) {
647             return;
648         }
649         map.put(registrationName, descriptor);
650     }
651          
652     /**
653      * @return a registered application descriptor if exists
654      * @param the registration name for the application descriptor
655      */

656     public Application getRegisteredDescriptor(String JavaDoc registrationName) {
657         Map map = getRegisteredDescriptors();
658         if (map==null) {
659             return null;
660         }
661         return (Application) map.get(registrationName);
662     }
663     
664     /**
665      * @return a registered application descriptor if exists
666      * @param the registration name for the application descriptor
667      */

668     public void unregisterDescriptor(String JavaDoc registrationName) {
669         Map map = getRegisteredDescriptors();
670         if (map==null) {
671             return;
672         }
673         map.remove(registrationName);
674     }
675
676     // Stores the application descriptor object into the application DD.
677
public void saveAppDescriptor(String JavaDoc appId, Application appDes,
678             String JavaDoc appDir, String JavaDoc generatedAppDir, boolean isVirtual)
679         throws ConfigException {
680         try {
681             if (isVirtual) {
682                 appDes.setVirtual(true);
683             }
684             FileArchive archive = new FileArchive();
685             archive.open(generatedAppDir);
686
687             FileArchive archive2 = new FileArchive();
688             archive2.open(appDir);
689
690             DescriptorArchivist archivist = new DescriptorArchivist();
691             archivist.write(appDes, archive2, archive);
692
693             // copy the additional webservice elements etc
694
Archivist.copyExtraElements(archive2, archive);
695         } catch (Throwable JavaDoc t) {
696                         throw new ConfigException(
697                 Localizer.getValue(ExceptionType.FAIL_DD_SAVE, appId), t);
698         }
699     }
700
701     // Begin EE: 4927099 - load only associated applications
702

703     /**
704      * Returns true if the given application is referenced by this
705      * server instance.
706      *
707      * @param appId application id
708      * @return true if the named application is used/referred by this server
709      *
710      * @throws ConfigException if an error while paring domain.xml
711      */

712     boolean isReferenced(String JavaDoc appId)
713     {
714         try {
715             return ServerHelper.serverReferencesApplication(this.configContext,
716                 instanceEnvironment.getName(), appId);
717         } catch (ConfigException ex) {
718             //This represents an unexpected exception. Log and return false
719
_logger.log(Level.WARNING, "isReferenced.unexpectedException", ex);
720             return false;
721         }
722     }
723
724     // End EE: 4927099 - load only associated applications
725

726     /**
727      * Returns the config context associated with this manager.
728      *
729      * @return config context associated with this manager
730      */

731     public ConfigContext getConfigContext() {
732         return this.configContext;
733     }
734
735     public abstract String JavaDoc getLocation(String JavaDoc id) throws ConfigException;
736     public abstract void setLocation(String JavaDoc id, String JavaDoc location) throws ConfigException;
737     public abstract String JavaDoc getGeneratedXMLLocation(String JavaDoc id);
738     public abstract boolean isEnabled(String JavaDoc id) throws ConfigException;
739     public abstract void setEnable(String JavaDoc id, boolean enabled) throws ConfigException;
740     public abstract boolean isSystem(String JavaDoc id) throws ConfigException;
741     public abstract boolean isSystemAdmin(String JavaDoc id) throws ConfigException;
742     public abstract void setOptionalAttributes(String JavaDoc id, Properties optionalAttributes) throws ConfigException;
743     public abstract String JavaDoc getDescription(String JavaDoc id) throws ConfigException;
744     public abstract void setDescription(String JavaDoc id, String JavaDoc desc) throws ConfigException;
745     protected abstract boolean isRegistered(String JavaDoc id, ConfigBean bean);
746     public abstract void remove(String JavaDoc name) throws ConfigException;
747     public abstract List listIds() throws ConfigException;
748
749     /**
750      * This method is needed because we need to read persistence descriptors
751      * from the original app exploded dir as opposed to generated dir
752      * because generated XML do not contain any information about PUs.
753      * One way to avoid this would be to write out PU details in
754      * sun-application.xml, but we have not done that yet.
755      * @param appDir directory where application was exploded (this is not same
756      * as the directory where generated XML files are written).
757      * @param application the application object whose persistence units
758      * will be read. This method will read all the persistence units
759      * recurssively and register at appropriate level.
760      * @throws IOException
761      * @throws SAXParseException
762      */

763     protected void readPersistenceDeploymentDescriptors(
764             String JavaDoc appDir, Application application)
765             throws IOException JavaDoc, SAXParseException JavaDoc {
766         FileArchive archive = new FileArchive();
767         archive.open(appDir);
768         try {
769             ApplicationArchivist.readPersistenceDeploymentDescriptorsRecursively(
770                     archive, application);
771         } finally {
772             archive.close();
773         }
774     }
775 }
776
Popular Tags