KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > deployment > config > ConfigSupportImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.deployment.config;
21
22 import java.beans.PropertyChangeEvent JavaDoc;
23 import java.beans.PropertyChangeListener JavaDoc;
24 import java.io.File JavaDoc;
25 import java.io.IOException JavaDoc;
26 import java.io.OutputStream JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.Collection JavaDoc;
29 import java.util.Collections JavaDoc;
30 import java.util.HashMap JavaDoc;
31 import java.util.Iterator JavaDoc;
32 import java.util.Map JavaDoc;
33 import java.util.Set JavaDoc;
34 import javax.enterprise.deploy.spi.exceptions.OperationUnsupportedException JavaDoc;
35 import org.netbeans.modules.j2ee.deployment.common.api.OriginalCMPMapping;
36 import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
37 import org.netbeans.modules.j2ee.deployment.impl.Server;
38 import javax.enterprise.deploy.spi.exceptions.ConfigurationException JavaDoc;
39 import javax.enterprise.deploy.model.*;
40 import javax.enterprise.deploy.shared.ModuleType JavaDoc;
41 import javax.enterprise.deploy.spi.*;
42 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException JavaDoc;
43 import javax.enterprise.deploy.spi.exceptions.InvalidModuleException JavaDoc;
44 import org.netbeans.modules.j2ee.deployment.devmodules.api.J2eeModule;
45 import org.netbeans.modules.j2ee.deployment.impl.ServerInstance;
46 import org.netbeans.modules.j2ee.deployment.impl.ServerRegistry;
47 import org.netbeans.modules.j2ee.deployment.plugins.api.ConfigurationSupport;
48 import org.netbeans.modules.j2ee.deployment.common.api.Datasource;
49 import org.netbeans.modules.j2ee.deployment.common.api.DatasourceAlreadyExistsException;
50 import org.openide.ErrorManager;
51 import org.openide.filesystems.FileLock;
52 import org.openide.filesystems.FileObject;
53 import org.openide.filesystems.FileUtil;
54 import org.openide.util.NbBundle;
55 import org.netbeans.api.project.FileOwnerQuery;
56 import org.netbeans.api.project.Project;
57 import org.netbeans.modules.j2ee.deployment.execution.DeploymentConfigurationProvider;
58
59 /**
60  * Each J2eeModuleProvider hold a reference to an instance of this config support.
61  * An instance of ConfigDataObject representing the current target configuration
62  * and it is cached for to avoid performance penalty of creating new one for every
63  * access to configuration.
64  *
65  * Whenenver target server of the module changes, a new config support is associate
66  * with the module providing access to the right configuration data object.
67  *
68  * @author nn136682
69  */

70 //PENDING: cleanup the usage of fakeserver, refresh. Instead, provide UI feedback for
71
// case when provider does not associate with any server.
72

73 public final class ConfigSupportImpl implements J2eeModuleProvider.ConfigSupport,
74         DeploymentConfigurationProvider, PropertyChangeListener JavaDoc {
75     
76     private static final File JavaDoc[] EMPTY_FILE_LIST = new File JavaDoc[0];
77     private static final String JavaDoc GENERIC_EXTENSION = ".dpf"; // NOI18N
78

79     private String JavaDoc configurationPrimaryFileName = null;
80     private Map JavaDoc relativePaths = null;
81     private Map JavaDoc allRelativePaths = null;
82     
83     private final J2eeModuleProvider provider;
84     private final ModuleDeploymentSupport mds;
85     private DeploymentConfiguration deploymentConfiguration;
86     
87     private Server server;
88     private ServerInstance instance;
89     
90     /** Creates a new instance of ConfigSupportImpl */
91     public ConfigSupportImpl (J2eeModuleProvider provider) {
92         this.provider = provider;
93         mds = new ModuleDeploymentSupport(provider, true);
94         String JavaDoc serverInstanceId = provider.getServerInstanceID();
95         if (serverInstanceId != null) {
96             instance = ServerRegistry.getInstance().getServerInstance(serverInstanceId);
97             if (instance != null) {
98                 // project server instance exists
99
server = instance.getServer();
100             }
101         }
102         if (server == null) {
103             // project server instance is not set or does not exist
104
String JavaDoc serverID = provider.getServerID();
105             if (serverID != null) {
106                 // project server exists
107
server = ServerRegistry.getInstance().getServer(serverID);
108             }
109         }
110         // the module has no server set, do not listen to changes
111
if (server != null) {
112             provider.addPropertyChangeListener(this);
113         }
114     }
115     
116     /**
117      * This method save configurations in deployment plan in content directory
118      * and return the fileobject for the plan. Primary use is for remote deployment
119      * or standard jsr88 deployement.
120      */

121     public File JavaDoc getConfigurationFile() {
122         try {
123             return getDeploymentPlanFileForDistribution();
124         } catch (Exception JavaDoc ex) {
125             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
126         }
127         return null;
128     }
129     
130     /** Return an initiliazed deployment configuration */
131     public void createDeploymentConfiguration(Server server) {
132         if (server == this.server) {
133             createInitialConfiguration();
134         } else {
135             ModuleDeploymentSupport mds = new ModuleDeploymentSupport(provider, false);
136             DeployableObject dobj = mds.getDeployableObject();
137             try {
138                 DeploymentConfiguration deployConf = server.getDisconnectedDeploymentManager().createConfiguration(dobj);
139                 ConfigurationSupport serverConfig = server.getConfigurationSupport();
140                 File JavaDoc[] files = getDeploymentConfigurationFiles(getProvider(), server);
141                 serverConfig.initConfiguration(deployConf, files, getProvider().getEnterpriseResourceDirectory(), false);
142             } catch(InvalidModuleException JavaDoc ime) {
143                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ime);
144             } catch (ConfigurationException JavaDoc ce) {
145                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ce);
146             } catch (DeploymentManagerCreationException JavaDoc dmce) {
147                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, dmce);
148             }
149         }
150     }
151     
152     /**
153      * Return list of server specific configuration files.
154      */

155     public static File JavaDoc[] getDeploymentConfigurationFiles (J2eeModuleProvider provider, Server server) {
156         return getDeploymentConfigurationFiles(provider, server, false);
157     }
158     
159     public static FileObject[] getConfigurationFiles(J2eeModuleProvider jmp) {
160         Collection JavaDoc servers = ServerRegistry.getInstance().getServers();
161         ArrayList JavaDoc files = new ArrayList JavaDoc();
162         for (Iterator JavaDoc i=servers.iterator(); i.hasNext();) {
163             Server s = (Server) i.next();
164             File JavaDoc[] configs = getDeploymentConfigurationFiles(jmp, s, true);
165             for (int j=0; j<configs.length; j++) {
166                 files.add(FileUtil.toFileObject(configs[j]));
167             }
168         }
169         return (FileObject[]) files.toArray(new FileObject[files.size()]);
170     }
171     
172     public String JavaDoc getDeploymentName() {
173         try {
174             FileObject fo = getProvider().getJ2eeModule().getContentDirectory();
175             if (fo == null) {
176                 fo = findPrimaryConfigurationFO();
177             }
178             if (fo == null)
179                 return null;
180             Project owner = FileOwnerQuery.getOwner(fo);
181             if (owner != null)
182                 return owner.getProjectDirectory().getName();
183             
184         } catch (IOException JavaDoc ioe) {
185             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ioe);
186         }
187         return null;
188     }
189     
190     /** dispose all created deployment configurations */
191     public void dispose() {
192         if (server != null) {
193             provider.removePropertyChangeListener(this);
194             ConfigurationSupport serverConfig = server.getConfigurationSupport();
195             if (deploymentConfiguration != null && serverConfig != null) {
196                 serverConfig.disposeConfiguration(deploymentConfiguration);
197             }
198         }
199         if (mds != null) {
200             mds.cleanup();
201         }
202     }
203     
204     // J2eeModuleProvider.ConfigSupport ---------------------------------------
205

206     public boolean createInitialConfiguration() {
207         return getDeploymentConfiguration() != null;
208     }
209     
210     public boolean ensureConfigurationReady() {
211         return getDeploymentConfiguration() != null;
212     }
213      
214     /**
215      * Get context root (context path)
216      *
217      * @return string value, null if not set or not a WAR module
218      */

219     public String JavaDoc getWebContextRoot() {
220         if (!getProvider().getJ2eeModule().getModuleType().equals(J2eeModule.WAR)) {
221             ErrorManager.getDefault().log("getWebContextRoot called on other module type then WAR"); //NOI18N
222
return null;
223         }
224         if (server == null) {
225             return null;
226         }
227         DeploymentConfiguration config = getDeploymentConfiguration();
228         if (config == null) {
229             return null;
230         }
231         ConfigurationSupport serverConfig = server.getConfigurationSupport();
232         if (serverConfig == null) {
233             return null;
234         }
235         try {
236             return serverConfig.getWebContextRoot(config, config.getDeployableObject());
237         } catch (ConfigurationException JavaDoc ce) {
238             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ce);
239             return null;
240         }
241     }
242     
243     /**
244      * Set context root (context path)
245      */

246     public void setWebContextRoot(String JavaDoc contextRoot) {
247         if (!getProvider().getJ2eeModule().getModuleType().equals(J2eeModule.WAR)) {
248             ErrorManager.getDefault().log("setWebContextRoot called on other module type then WAR"); //NOI18N
249
return;
250         }
251         if (server == null) {
252             return;
253         }
254         DeploymentConfiguration config = getDeploymentConfiguration();
255         if (config == null) {
256             return;
257         }
258         ConfigurationSupport serverConfig = server.getConfigurationSupport();
259         if (serverConfig == null) {
260             return;
261         }
262         try {
263             serverConfig.setWebContextRoot(config, config.getDeployableObject(), contextRoot);
264         } catch (ConfigurationException JavaDoc ce) {
265             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ce);
266         }
267     }
268         
269     public String JavaDoc[] getDeploymentConfigurationFileNames() {
270         if (server == null) {
271             return new String JavaDoc[]{};
272         }
273         if (hasCustomSupport()) {
274             return (String JavaDoc[]) getRelativePaths().keySet().toArray(new String JavaDoc[relativePaths.size()]);
275         }
276         return new String JavaDoc[] { getStandardDeploymentPlanName() };
277     }
278     
279     public String JavaDoc getContentRelativePath(String JavaDoc configName) {
280         if (! hasCustomSupport()) {
281             return configName; //just return the name so that the .dpf file is writen at the root of dist directory.
282
}
283         return (String JavaDoc) getAllRelativePaths().get(configName);
284     }
285     
286     public void setCMPMappingInfo(final OriginalCMPMapping[] mappings) {
287         if (server == null) {
288             // the module has no target server
289
return;
290         }
291         DeploymentConfiguration config = getDeploymentConfiguration();
292         ConfigurationSupport serverConfig = server.getConfigurationSupport();
293         serverConfig.setMappingInfo(config, mappings);
294     }
295     
296     public void ensureResourceDefinedForEjb(final String JavaDoc ejbname, final String JavaDoc ejbtype) {
297         if (ejbname == null) {
298             throw new NullPointerException JavaDoc("EJB name cannot be null"); // NOI18N
299
}
300         if (ejbtype == null) {
301             throw new NullPointerException JavaDoc("EJB type cannot be null"); // NOI18N
302
}
303         if (server == null) {
304             // the module has no target server
305
return;
306         }
307         DDBean ejbBean = findDDBean(ejbname, ejbtype);
308         if (ejbBean != null) {
309             DeploymentConfiguration config = getDeploymentConfiguration();
310             ConfigurationSupport serverConfig = server.getConfigurationSupport();
311             serverConfig.ensureResourceDefined(config, ejbBean);
312         }
313     }
314     
315     public void ensureResourceDefinedForEjb(String JavaDoc ejbname, String JavaDoc ejbtype, String JavaDoc jndiName) {
316         if (ejbname == null) {
317             throw new NullPointerException JavaDoc("EJB name cannot be null"); // NOI18N
318
}
319         if (ejbtype == null) {
320             throw new NullPointerException JavaDoc("EJB type cannot be null"); // NOI18N
321
}
322         if (jndiName == null) {
323             throw new NullPointerException JavaDoc("JNDI name cannot be null"); // NOI18N
324
}
325         if (server == null) {
326             // the module has no target server
327
return;
328         }
329         DDBean ejbBean = findDDBean(ejbname, ejbtype);
330         if (ejbBean != null) {
331             DeploymentConfiguration config = getDeploymentConfiguration();
332             ConfigurationSupport serverConfig = server.getConfigurationSupport();
333             serverConfig.ensureResourceDefined(config, ejbBean, jndiName);
334         }
335     }
336     
337     /*
338      * @return DD bean of the specified EJB type with the specified EJB name in ejb-jar.xml
339      * or null if no such DD bean exists.
340      */

341     private DDBean findDDBean(String JavaDoc ejbname, String JavaDoc ejbtype) {
342         if (!J2eeModule.EJB.equals(provider.getJ2eeModule().getModuleType())) {
343             throw new IllegalArgumentException JavaDoc("Trying to get config bean for ejb on non ejb module!"); //NONI18N
344
}
345         DDBean ejbBean = null;
346         DDRoot ddroot = mds.getDDBeanRoot(J2eeModule.EJBJAR_XML);
347         StandardDDImpl[] ddbeans = (StandardDDImpl[]) ddroot.getChildBean(
348                 "/enterprise-beans/" + ejbtype); //NOI18N
349
for (int i=0; i<ddbeans.length; i++) {
350             String JavaDoc ejbName = (String JavaDoc) ddbeans[i].proxy.bean.getValue("EjbName"); //NOI18N
351
if (ejbname.equals(ejbName)) {
352                 ejbBean = ddbeans[i];
353                 break;
354             }
355         }
356         if (ejbBean == null) {
357             if (ddbeans != null) {
358                 for (int i=0; i<ddbeans.length; i++) {
359                     String JavaDoc msg = ddbeans[i].proxy.bean.dumpBeanNode();
360                     ErrorManager.getDefault().log(ErrorManager.ERROR, msg);
361                 }
362             }
363             Exception JavaDoc e = new Exception JavaDoc("Failed to lookup: "+ejbname+" type "+ejbtype);
364             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
365             return null;
366         }
367         
368         return ejbBean;
369     }
370     
371     public Set JavaDoc<Datasource> getDatasources() {
372         
373         Set JavaDoc<Datasource> projectDS = Collections.<Datasource>emptySet();
374         
375         if (server != null) {
376             ConfigurationSupport configSupport = server.getConfigurationSupport();
377             if (configSupport != null) {
378                 DeploymentConfiguration config = getDeploymentConfiguration();
379                 if (config != null) {
380                     projectDS = configSupport.getDatasources(config);
381                 }
382             }
383         }
384
385         return projectDS;
386     }
387
388     public boolean isDatasourceCreationSupported() {
389         if (server == null) {
390             // the module has no target server
391
return false;
392         }
393         ConfigurationSupport configSupport = server.getConfigurationSupport();
394         
395         if (configSupport == null)
396             return false;
397         
398         return configSupport.isDatasourceCreationSupported();
399     }
400     
401     public Datasource createDatasource(String JavaDoc jndiName, String JavaDoc url, String JavaDoc username, String JavaDoc password, String JavaDoc driver)
402     throws OperationUnsupportedException JavaDoc, DatasourceAlreadyExistsException {
403         Datasource ds = null;
404         if (server != null) {
405             ConfigurationSupport configSupport = server.getConfigurationSupport();
406             if (configSupport != null) {
407                 DeploymentConfiguration config = getDeploymentConfiguration();
408                 if (config != null) {
409                     try {
410                         ds = configSupport.createDatasource(config, jndiName, url, username, password, driver);
411                     } catch (ConfigurationException JavaDoc ce) {
412                         ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ce);
413                     }
414                 }
415             }
416         }
417         return ds;
418     }
419     
420     // DeploymentConfigurationProvider implementation -------------------------
421

422     /**
423      * Create and cache deployment configuration for the current server.
424      */

425     public DeploymentConfiguration getDeploymentConfiguration() {
426         if (deploymentConfiguration == null) {
427             DeployableObject dobj = mds.getDeployableObject();
428             try {
429                 if (instance != null) {
430                     deploymentConfiguration = instance.getDeploymentManagerForConfiguration().createConfiguration(dobj);
431                 } else if (server != null) {
432                     deploymentConfiguration = server.getDisconnectedDeploymentManager().createConfiguration(dobj);
433                 } else {
434                     // the module has no target server, there is nothing else to return
435
return null;
436                 }
437                 ConfigurationSupport serverConfig = server.getConfigurationSupport();
438                 File JavaDoc[] files = getDeploymentConfigurationFiles(getProvider(), server);
439                 serverConfig.initConfiguration(deploymentConfiguration, files,
440                         getProvider().getEnterpriseResourceDirectory(), true);
441             } catch(InvalidModuleException JavaDoc ime) {
442                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ime);
443                 return null;
444             } catch (ConfigurationException JavaDoc ce) {
445                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ce);
446                 return null;
447             } catch (DeploymentManagerCreationException JavaDoc dmce) {
448                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, dmce);
449                 return null;
450             }
451         }
452         return deploymentConfiguration;
453     }
454         
455     public DeployableObject getDeployableObject(String JavaDoc moduleUri) {
456         DeployableObject deplObj = mds.getDeployableObject();
457         if (deplObj instanceof J2eeApplicationObject) {
458             return ((J2eeApplicationObject)deplObj).getDeployableObject(moduleUri);
459         }
460         return mds.getDeployableObject();
461     }
462     
463     // private helpers --------------------------------------------------------
464

465     /**
466      * Return list of server specific configuration files.
467      */

468     private static File JavaDoc[] getDeploymentConfigurationFiles (J2eeModuleProvider provider, Server server, boolean existingOnly) {
469         if (provider == null || server == null)
470             return new File JavaDoc[0];
471         
472         ModuleType JavaDoc type = (ModuleType JavaDoc) provider.getJ2eeModule().getModuleType();
473         String JavaDoc[] fnames;
474         if (hasCustomSupport(server, type)) {
475             fnames = server.getDeploymentPlanFiles(type);
476         } else if (server.supportsModuleType(type)) {
477             fnames = new String JavaDoc[] { getStandardDeploymentPlanName(server) };
478         } else {
479             return EMPTY_FILE_LIST;
480         }
481         
482         ArrayList JavaDoc files = new ArrayList JavaDoc();
483         for (int i = 0; i < fnames.length; i++) {
484             File JavaDoc path = new File JavaDoc(fnames[i]);
485             String JavaDoc fname = path.getName();
486             File JavaDoc file = null;
487             if (existingOnly) {
488                 FileObject fo = provider.findDeploymentConfigurationFile(fname);
489                 if (fo != null) {
490                     file = FileUtil.toFile(fo);
491                 }
492             } else {
493                 file = provider.getDeploymentConfigurationFile(fname);
494             }
495             
496             if (file != null) {
497                 files.add(file);
498             }
499         }
500         return (File JavaDoc[])files.toArray(new File JavaDoc[files.size()]);
501     }
502     
503     /**
504      * Creates and returns the JSR-88 deployment plan file for the current
505      * deployment configuration.
506      *
507      * @return deployment plan file.
508      */

509     private File JavaDoc getDeploymentPlanFileForDistribution() throws IOException JavaDoc, ConfigurationException JavaDoc {
510         if (server == null) {
511             String JavaDoc msg = NbBundle.getMessage(ConfigSupportImpl.class, "MSG_NoTargetSelected");
512             throw new ConfigurationException JavaDoc(msg);
513         }
514         
515         FileLock lock = null;
516         OutputStream JavaDoc out = null;
517         try {
518             FileObject dist = getProvider().getJ2eeModule().getContentDirectory();
519             String JavaDoc planName = getStandardDeploymentPlanName();
520             FileObject plan = null;
521             if (dist != null) {
522                 plan = dist.getFileObject(planName);
523                 if (plan == null) {
524                     plan = dist.createData(planName);
525                 }
526             } else {
527                 return null;
528             }
529             lock = plan.lock();
530             out = plan.getOutputStream(lock);
531             DeploymentConfiguration conf = getDeploymentConfiguration();
532             if (conf != null) {
533                 conf.save(out);
534                 return FileUtil.toFile(plan);
535             }
536             return null;
537         } finally {
538             if (lock != null) lock.releaseLock();
539             try {
540                 if (out != null) out.close();
541             } catch(IOException JavaDoc ioe) {
542                 ErrorManager.getDefault().log(ioe.toString());
543             }
544         }
545     }
546     
547     private String JavaDoc getPrimaryConfigurationFileName() {
548         getRelativePaths();
549         
550         if (configurationPrimaryFileName == null)
551             return getStandardDeploymentPlanName();
552         else
553             return configurationPrimaryFileName;
554     }
555
556     private String JavaDoc getStandardDeploymentPlanName() {
557         return getStandardDeploymentPlanName(server);
558
559     }
560     
561     private static String JavaDoc getStandardDeploymentPlanName(Server server) {
562         return server.getShortName() + GENERIC_EXTENSION;
563     }
564
565     private FileObject findPrimaryConfigurationFO() throws IOException JavaDoc {
566         String JavaDoc configFileName = getPrimaryConfigurationFileName();
567         return getProvider().findDeploymentConfigurationFile(configFileName);
568     }
569
570     private ModuleType JavaDoc getModuleType() {
571         return (ModuleType JavaDoc) getProvider().getJ2eeModule().getModuleType();
572     }
573     
574     private boolean hasCustomSupport() {
575         return hasCustomSupport(server, getModuleType());
576     }
577     
578     private static boolean hasCustomSupport(Server server, ModuleType JavaDoc type) {
579         if (server == null || server.getConfigurationSupport() == null) {
580             return false;
581         }
582         return server.getDeploymentPlanFiles(type) != null;
583     }
584
585     private J2eeModuleProvider getProvider () {
586         return provider;
587     }
588     
589     private Map JavaDoc getRelativePaths() {
590         if (relativePaths != null)
591             return relativePaths;
592         
593         relativePaths = new HashMap JavaDoc();
594         if (hasCustomSupport()) {
595             String JavaDoc [] paths = server.getDeploymentPlanFiles(getModuleType());
596             configurationPrimaryFileName = paths[0].substring(paths[0].lastIndexOf("/")+1);
597         
598             collectData(server, relativePaths);
599         }
600         
601         return relativePaths;
602     }
603     
604     private void collectData(Server server, Map JavaDoc map) {
605         if (! this.hasCustomSupport(server, getModuleType()))
606             return;
607         
608         String JavaDoc [] paths = server.getDeploymentPlanFiles(getModuleType());
609         paths = (paths == null) ? new String JavaDoc[0] : paths;
610         for (int i=0; i<paths.length; i++) {
611             String JavaDoc name = paths[i].substring(paths[i].lastIndexOf("/")+1);
612             map.put(name, paths[i]);
613         }
614     }
615     
616     private Map JavaDoc getAllRelativePaths() {
617         if (allRelativePaths != null)
618             return allRelativePaths;
619         
620         allRelativePaths = new HashMap JavaDoc();
621         Collection JavaDoc servers = ServerRegistry.getInstance().getServers();
622         for (Iterator JavaDoc i=servers.iterator(); i.hasNext();) {
623             Server server = (Server) i.next();
624             collectData(server, allRelativePaths);
625         }
626         return allRelativePaths;
627     }
628
629     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
630         if (J2eeModuleProvider.PROP_ENTERPRISE_RESOURCE_DIRECTORY.equals(evt.getPropertyName())) {
631             DeploymentConfiguration config = getDeploymentConfiguration();
632             ConfigurationSupport serverConfig = server.getConfigurationSupport();
633             Object JavaDoc newValue = evt.getNewValue();
634             if (newValue != null && !(newValue instanceof File JavaDoc)) {
635                 throw new IllegalArgumentException JavaDoc("Enterprise resource directory property value is not a File"); // NIO18N
636
}
637             serverConfig.updateResourceDir(config, (File JavaDoc)newValue);
638         }
639     }
640 }
641
Popular Tags