KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > config > ConfigurationStorage


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 package org.netbeans.modules.j2ee.sun.share.config;
20
21 import java.beans.PropertyChangeEvent JavaDoc;
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.beans.PropertyChangeSupport JavaDoc;
24 import java.io.*;
25 import java.util.*;
26 import javax.enterprise.deploy.model.*;
27 import javax.enterprise.deploy.spi.*;
28 import javax.enterprise.deploy.spi.exceptions.*;
29
30 import org.openide.*;
31 import org.openide.NotifyDescriptor.Confirmation;
32 import org.openide.filesystems.FileObject;
33 import org.openide.filesystems.FileUtil;
34 import org.openide.loaders.DataObject;
35 import org.openide.loaders.DataObjectNotFoundException;
36 import org.openide.nodes.*;
37 import org.openide.util.Mutex;
38 import org.openide.util.NbBundle;
39 import org.openide.util.RequestProcessor;
40 import org.openide.util.RequestProcessor.Task;
41 import org.openide.util.WeakListeners;
42
43 import org.xml.sax.SAXException JavaDoc;
44
45 import org.netbeans.modules.j2ee.deployment.devmodules.api.*;
46 import org.netbeans.modules.j2ee.deployment.devmodules.spi.*;
47 import org.netbeans.modules.j2ee.sun.share.config.ui.ConfigBeanTopComponent;
48 import org.netbeans.modules.j2ee.sun.share.configbean.SunONEDeploymentConfiguration;
49
50
51 /* ConfigurationStorage stores a DeploymentConfiguration. It is responsible
52  * for creating the DeployableObjects and the DConfigBeanRoots and tracking
53  * changes at the application level.
54  */

55 public class ConfigurationStorage implements PropertyChangeListener JavaDoc, Node.Cookie {
56     
57     public static final String JavaDoc ROOT = "/"; // NOI18N
58
private SunONEDeploymentConfiguration config;
59     
60     // Dataobject support -- ref to dataobject, property change listener
61
// that deletes the reference and detaches itself when dataobject is made invalid.
62
private ConfigDataObject configDataObject = null;
63     private Object JavaDoc dobjMonitor = new Object JavaDoc();
64     private PropertyChangeListener JavaDoc weakPropListener = null;
65     
66     // Map of url -> ModuleDeploymentSupport
67
Map moduleMap = new HashMap();
68     final Map versionListeners = new HashMap();
69     private boolean needsSave = false;
70     final J2eeModuleProvider module;
71     boolean loaded = false;
72     private Task autoSaveTask;
73     private int saveInProgress;
74     private int cleanInProgress;
75     private boolean saveFailedDialogDisplayed;
76     
77     // PropertyChangeSupport instance to let us forward dataobject cookie changes
78
// to any listeners (ie. ConfigBeanNode).
79
private PropertyChangeSupport JavaDoc dobjCookieChangeSupport;
80     
81     public ConfigurationStorage(J2eeModuleProvider module, SunONEDeploymentConfiguration config) throws ConfigurationException, InvalidModuleException, IOException, SAXException JavaDoc {
82         this.module = module;
83         this.config = config;
84         this.saveInProgress = 0;
85         this.cleanInProgress = 0;
86         this.dobjCookieChangeSupport = new PropertyChangeSupport JavaDoc(this);
87         
88         load(); // calls init(), below.
89
createVersionListeners();
90     }
91     
92     private void init() throws ConfigurationException, InvalidModuleException, IOException {
93         // do the clean up first
94
try {
95             cleanInProgress++;
96             for (Iterator i = moduleMap.values().iterator(); i.hasNext();) {
97                 ((ModuleDDSupport)i.next()).cleanup();
98             }
99             moduleMap.clear();
100         } finally {
101             cleanInProgress--;
102         }
103         
104         // create all MDS/ADS classes here. MDS's should be GC'ed if the DC changes.
105
ModuleDDSupport mds = new ModuleDDSupport(module, config);
106         moduleMap.put(ROOT,mds);
107         /*if(module.getJ2eeModule().getModuleType().equals(J2eeModule.EAR)) {
108             J2eeAppProvider appProvider = (J2eeAppProvider) module;
109             J2eeModuleContainer container = (J2eeModuleContainer) module.getJ2eeModule();
110             dobj = new ApplImpl(mds,moduleMap);
111             J2eeModuleProvider[] modules = appProvider.getChildModuleProviders();
112             container.addModuleListener(this);
113             for(int i = 0; i < modules.length; i++) {
114                 moduleMap.put(modules[i].getJ2eeModule().getUrl(),new ModuleDeploymentSupport(modules[i]));
115             }
116         }*/

117     }
118
119     /** Normalizes a DDBeanRoot from j2eeserver module into the matching DDRoot
120      * that is managed by our ModuleDDSupport.
121      */

122     public DDBeanRoot normalizeDDBeanRoot(DDBeanRoot ddBeanRoot) {
123         DDBeanRoot ddNew = ddBeanRoot;
124
125         // !PW FIXME enhance this algorithm to handle multiple modules if this class does.
126
// Until then, there is only one entry in the table, under ROOT key.
127
ModuleDDSupport mds = (ModuleDDSupport) moduleMap.get(ROOT);
128         if(mds != null) {
129             DDBeanRoot newRoot = mds.getDDBeanRoot();
130             if(newRoot != ddBeanRoot && newRoot != null) {
131                 ddNew = newRoot;
132
133                 // Not sure if we need to handle ddbeanroot for webservices.xml, but in case
134
// someone passes that one in, it will cause this assert here.
135
assert ddBeanRoot.getXpath().equals(ddNew.getXpath()) : "Mismatched xpaths in normalizeDDBeanRoot for " + ddBeanRoot;
136             }
137         }
138         
139         return ddNew;
140     }
141     
142     public DDBean normalizeEjbDDBean(DDBean ejbDDBean) {
143         DDBean result = null;
144         String JavaDoc theEjbName = Utils.getField(ejbDDBean, "ejb-name"); // NOI18N
145
ModuleDDSupport mds = (ModuleDDSupport) moduleMap.get(ROOT);
146         DDRoot ddRoot = mds.getDDBeanRoot(J2eeModule.EJBJAR_XML);
147         StandardDDImpl[] ddBeans = (StandardDDImpl[]) ddRoot.getChildBean(ejbDDBean.getXpath());
148
149         for(int i = 0; i < ddBeans.length; i++) {
150             String JavaDoc ejbName = (String JavaDoc) ddBeans[i].proxy.bean.getValue("EjbName"); // NOI18N
151
if (theEjbName.equals(ejbName)) {
152                 result = ddBeans[i];
153                 break;
154             }
155         }
156         
157         if(result == null) {
158             if (ddBeans != null) {
159                 for (int i = 0; i < ddBeans.length; i++) {
160                     String JavaDoc msg = ddBeans[i].proxy.bean.dumpBeanNode();
161                     ErrorManager.getDefault().log(ErrorManager.ERROR, msg);
162                 }
163             }
164             Exception JavaDoc ex = new Exception JavaDoc("Failed to lookup: " + theEjbName + ", type " + ejbDDBean.getXpath()); // NOI18N
165
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
166         }
167
168         return result;
169     }
170
171     private boolean ensureLoaded() {
172         if(loaded) {
173             return true;
174         }
175         
176         try {
177             load();
178             return true;
179         } catch (Exception JavaDoc e) {
180             ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
181             return false;
182         }
183     }
184     
185     public ConfigDataObject getPrimaryDataObject() {
186         ConfigDataObject configDO;
187         
188         synchronized (dobjMonitor) {
189             if(configDataObject == null) {
190                 FileObject configFO = FileUtil.toFileObject(config.getConfigFiles()[0]);
191                 if(configFO != null) {
192                     try {
193                         DataObject dObj = DataObject.find(configFO);
194                         if(dObj instanceof ConfigDataObject) {
195                             configDataObject = (ConfigDataObject) dObj;
196                             weakPropListener = WeakListeners.propertyChange(this, configDataObject);
197                             configDataObject.addPropertyChangeListener(weakPropListener);
198 // System.out.println("CS: Lookup & cached dataobject for " + configDataObject.getName());
199
}
200                     } catch (DataObjectNotFoundException ex) {
201                         // return null if not found.
202
}
203                 }
204             }
205             configDO = configDataObject;
206         }
207         return configDO;
208     }
209     
210     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
211         // if dataobject is being made invalid, remove listener and null our reference.
212
// System.out.println("CS.DataObject.propchange: " + evt.getPropertyName() + ", old = " + evt.getOldValue() + ", new = " + evt.getNewValue());
213
if(DataObject.PROP_VALID.equals(evt.getPropertyName())) {
214             if(Boolean.FALSE.equals(evt.getNewValue())) {
215                 synchronized (dobjMonitor) {
216 // System.out.println("CS: Removing invalid dataobject reference to " + configDataObject.getName());
217
configDataObject.removePropertyChangeListener(weakPropListener);
218                     configDataObject = null;
219                     weakPropListener = null;
220                 }
221             }
222         }
223         // Forward cookie changes to anyone listening to us (see ConfigBeanNode.java)
224
else if(DataObject.PROP_COOKIE.equals(evt.getPropertyName())) {
225             dobjCookieChangeSupport.firePropertyChange(evt);
226         }
227     }
228     
229     public void addPropertyChangeListener(PropertyChangeListener JavaDoc pCL) {
230         dobjCookieChangeSupport.addPropertyChangeListener(pCL);
231     }
232
233     public void removePropertyChangeListener(PropertyChangeListener JavaDoc pCL) {
234         dobjCookieChangeSupport.removePropertyChangeListener(pCL);
235     }
236     
237     
238     /**
239      * Return comma separeted list of files.
240      */

241     private String JavaDoc filesToString(File[] files) {
242         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
243         if (files.length > 0) {
244             sb.append(files[0].getPath());
245         }
246         for (int i = 1; i < files.length; i++) {
247             sb.append(", "); // NOI18N
248
sb.append(files[i].getPath());
249         }
250         return sb.toString();
251     }
252
253     /**
254      * Save configuration only if the graphical config editor is not opened, mark as
255      * modified otherwise.
256      */

257     public void autoSave() {
258 // System.out.println("autosave... [" + System.currentTimeMillis() + "]");
259
if (autoSaveTask == null) {
260 // System.out.println("creating autosaver... [" + System.currentTimeMillis() + "]");
261
autoSaveTask = RequestProcessor.getDefault().post(new Runnable JavaDoc() {
262                 private boolean dialogIsDisplayed;
263                 public void run() {
264                     // TODO should be rewritten - currently needs to be run in
265
// the event dispatch thread since we are accessing window api,
266
// see also ConfigDataObject.fileChanged
267
// System.out.println("running autosaver... [" + System.currentTimeMillis() + "]");
268
Mutex.EVENT.readAccess(new Runnable JavaDoc() {
269                         public void run() {
270 // System.out.println("running nested autosaver... [" + System.currentTimeMillis() + "]");
271
if(dialogIsDisplayed) {
272 // System.out.println("editor save query active, no autosave... [" + System.currentTimeMillis() + "]");
273
return; // Reentrancy not supported nor needed.
274
}
275                             
276                             ConfigDataObject configDO = getPrimaryDataObject();
277                             if (configDO == null) {
278 // System.out.println("no saver/dataobject... [" + System.currentTimeMillis() + "]");
279
// no dataobject -- if primary file does not exist, save configuration
280
FileObject configFO = FileUtil.toFileObject(config.getConfigFiles()[0]);
281                                 if(configFO == null) {
282                                     try {
283 // System.out.println("no file object, saving new configuration... [" + System.currentTimeMillis() + "]");
284
save();
285 // System.out.println("configuration saved... [" + System.currentTimeMillis() + "]");
286
} catch (Exception JavaDoc ex) {
287                                         ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
288                                     }
289                                 }
290                                 
291                                 // return because we've either just saved or there was no saver (and thus nothing to save).
292
return;
293                             }
294                             
295                             // proceed in auto save only if graphical config editor is not opened
296
if (!configDO.isConfigEditorOpened()) {
297 // System.out.println("editor is closed, saving... [" + System.currentTimeMillis() + "]");
298
try {
299                                     // if config files are modified, ask whether to rewrite them
300
if (configDO.areModified()) {
301                                         File files[] = ConfigurationStorage.this.config.getConfigFiles();
302                                         String JavaDoc serverName = ConfigurationStorage.this.config.getAppServerVersion().toString();
303                                         String JavaDoc msg = NbBundle.getMessage(ConfigurationStorage.class,
304                                                 "MSG_SaveGeneratedChanges", // NOI18N
305
serverName,
306                                                 filesToString(files));
307                                         Confirmation cf = new Confirmation(msg, NotifyDescriptor.YES_NO_OPTION);
308                                         dialogIsDisplayed = true;
309                                         DialogDisplayer.getDefault().notify(cf);
310                                         if (!NotifyDescriptor.YES_OPTION.equals(cf.getValue())) {
311                                             return;
312                                         }
313                                     }
314                                     save();
315 // System.out.println("configuration saved... [" + System.currentTimeMillis() + "]");
316
} catch (Exception JavaDoc ex) {
317                                     // ignore it
318
ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
319                                 } finally {
320                                     dialogIsDisplayed = false;
321                                 }
322                             } else {
323 // System.out.println("editor is open, marking dirty... [" + System.currentTimeMillis() + "]");
324
configDO.setChanged();
325                             }
326                         }
327                     });
328                 }
329             }, 100);
330         } else {
331 // System.out.println("scheduling autosave... [" + System.currentTimeMillis() + "]");
332
autoSaveTask.schedule(100);
333         }
334     }
335     
336     public void setChanged() {
337         if(cleanInProgress == 0) {
338             needsSave = true;
339             autoSave();
340         }
341     }
342     
343     public void updateDDRoot(FileObject dd) {
344         if("webservices".equals(dd.getName())) {
345             ModuleDDSupport mds = (ModuleDDSupport) moduleMap.get(ROOT);
346             if(mds != null) {
347                 mds.getDDBeanRoot(ModuleDDSupport.filenameToPath(dd.getNameExt(), mds.getType()));
348             }
349         }
350     }
351     
352     public DeploymentConfiguration getDeploymentConfiguration() {
353         return config;
354     }
355     
356     public static J2eeModuleProvider getChildModuleProvider(J2eeModuleProvider jmp, String JavaDoc uri) {
357         if (uri == null) {
358             return null;
359         }
360         J2eeModuleProvider child = null;
361         if (jmp instanceof J2eeAppProvider) {
362             J2eeAppProvider jap = (J2eeAppProvider) jmp;
363             child = jap.getChildModuleProvider(uri);
364             if (child == null) {
365                 if (uri.startsWith(ROOT)) {
366                     uri = uri.substring(1);
367                 } else {
368                     uri = ROOT + uri;
369                 }
370                 child = jap.getChildModuleProvider(uri);
371             }
372         }
373         return child;
374     }
375     
376     // J2eeModule.ModuleListener methods
377
/*public void addModule(J2eeModule child) {
378         if (child == null || ! ensureLoaded())
379             return;
380         
381         // more tolerant to multiple firing
382         if (moduleMap.get(child.getUrl()) != null)
383             return;
384         
385         J2eeModuleProvider jmp = getChildModuleProvider(module, child.getUrl());
386         assert (jmp != null);
387         ModuleDeploymentSupport mds = new ModuleDeploymentSupport(jmp);
388         moduleMap.put(child.getUrl(), mds);
389         createVersionListener(child);
390         try {
391             createDConfigBean(mds);
392         } catch (ConfigurationException ce) {
393             ErrorManager.getDefault().notify(ErrorManager.EXCEPTION,ce);
394             // PENDING what do I do with this error? need to somehow
395             // abort configuration
396         }
397     }
398     
399     public void removeModule(J2eeModule child) {
400         if (! ensureLoaded())
401             return;
402
403         ModuleDeploymentSupport mds = (ModuleDeploymentSupport) moduleMap.get(child.getUrl());
404         moduleMap.remove(child.getUrl());
405         mds.dispose(config);
406         removeVersionListener(child);
407     }*/

408     
409     public Node getMainNode() {
410         Node[] nodes = getMainNodes();
411         return nodes.length > 0 ? nodes[0] : null;
412     }
413     
414     public Node[] getMainNodes() {
415         if (! ensureLoaded()) {
416             return new Node[0];
417         }
418         
419         ModuleDDSupport mds = (ModuleDDSupport) moduleMap.get(ROOT);
420         return mds == null? new Node[0] : mds.getNodes();
421     }
422     
423     public Node[] getNodes(J2eeModule mod) {
424         if (! ensureLoaded()) {
425             return new Node[0];
426         }
427         
428         ModuleDDSupport mds = (ModuleDDSupport) moduleMap.get(mod.getUrl());
429         /*if (mds == null) {
430             addModule(mod);
431             mds = (ModuleDeploymentSupport) moduleMap.get(mod.getUrl());
432         }*/

433         if (mds == null) {
434             return new Node[0];
435         } else {
436             return mds.getNodes();
437         }
438     }
439     
440     private void createDConfigBean(ModuleDDSupport mod) throws ConfigurationException {
441         mod.createConfigs(this);
442     }
443     
444     public void saveOnDemand() throws IOException {
445         if (needsSave) {
446             save();
447         }
448     }
449     
450     public void save() throws IOException {
451         // If there is an exception during the save operation (either a ConfigurationException
452
// for some bizarre non-I/O related reason or a true IOException), display an appropriate
453
// message to the user. Then rethrow the exception (wrapping as an IOException if required)
454
// so that the caller can handle it intelligently. For example, this is the only way that
455
// ExitDialog can be notified that the file didn't save properly (and prevents the IDE from
456
// shutting down prematurely and throwing away the user's still unsaved data).
457
try {
458             saveInProgress++;
459             
460             if(config != null) {
461                 config.writeDeploymentPlanFiles(this);
462                 needsSave = false;
463                 ConfigDataObject configDO = getPrimaryDataObject();
464                 if(configDO != null) {
465                     configDO.resetChanged();
466                 }
467             } else {
468                 throw new IllegalStateException JavaDoc("Attempted to save configuration when DeploymentConfiguration is null.");
469             }
470         } catch (ConfigurationException ce) {
471             reportExceptionDuringSave(ce);
472             
473             // 1. Must throw IOException here, otherwise, if caller is IDE's exit dialog
474
// this dataobject will be removed from the queue of savable objects.
475
// 2. IOException constructor in JDK 1.4.2 cannot chain exceptions.
476
IOException ioe = new IOException(ce.getLocalizedMessage());
477             ioe.initCause(ce);
478             throw ioe;
479         } catch(IOException ioe) {
480             reportExceptionDuringSave(ioe);
481             throw ioe;
482         } finally {
483             saveInProgress--;
484         }
485     }
486     
487     private void reportExceptionDuringSave(Exception JavaDoc ex) {
488         if(!saveFailedDialogDisplayed) { // do not display multiple instances
489
try {
490                 // Why is there a separate flag here instead of reusing saveInProgress?
491
saveFailedDialogDisplayed = true;
492
493                 // Try to do a nice message box if this exception comes with a reason for the failure.
494
String JavaDoc errorMsg;
495                 String JavaDoc exceptionMsg = ex.getLocalizedMessage();
496                 String JavaDoc appServerVersion = config.getAppServerVersion().toString();
497                 String JavaDoc fileList = filesToString(config.getConfigFiles());
498
499                 if(exceptionMsg != null && exceptionMsg.length() > 0) {
500                     if(ex instanceof IOException) {
501                         // For IOExceptions, if there is message, just display that. This eliminates
502
// redundancy of the filename, e.g. "[filename]: Access denied" is the message if the file
503
// is read-only.
504
errorMsg = exceptionMsg;
505                     } else {
506                         // For all other exceptions, prefix the application server and affected file to the message.
507
errorMsg = NbBundle.getMessage(ConfigurationStorage.class, "MSG_ConfigurationSaveFailedHasMessage",
508                                 appServerVersion, fileList, exceptionMsg);
509                     }
510                 } else {
511                     // If there is no message, simply indicate there was a problem saving the affected files.
512
errorMsg = NbBundle.getMessage(ConfigurationStorage.class, "MSG_ConfigurationSaveFailed",
513                             appServerVersion, fileList);
514                 }
515
516                 DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(errorMsg));
517             } finally {
518                 saveFailedDialogDisplayed = false;
519             }
520         }
521     }
522     
523     public void load() throws IOException, InvalidModuleException, ConfigurationException {
524         if(saveInProgress > 0) { // internal change - do not reload
525
return;
526         }
527
528         init();
529         
530         /*if(module.getJ2eeModule().getModuleType().equals(J2eeModule.EAR)) {
531             J2eeAppProvider appProvider = (J2eeAppProvider) module;
532             J2eeModuleProvider[] modules = appProvider.getChildModuleProviders();
533             for(int i = 0; i < modules.length; i++) {
534                 ModuleDeploymentSupport mds = (ModuleDeploymentSupport) moduleMap.get(modules[i].getJ2eeModule().getUrl());
535                 dps.readDeploymentPlanFiles(config, mds.getDeployableObject(), getSaveFiles(modules[i],serverString.getServer()));
536             }
537         }*/

538
539         if(config instanceof SunONEDeploymentConfiguration) {
540             SunONEDeploymentConfiguration s1dc = (SunONEDeploymentConfiguration) config;
541             ModuleDDSupport rootSupport = (ModuleDDSupport) moduleMap.get(ROOT);
542             s1dc.readDeploymentPlanFiles(this, rootSupport.getDDBeanRoot());
543             createDConfigBean(rootSupport);
544             loaded = true;
545         } else {
546             throw new IllegalArgumentException JavaDoc("Invalid DeploymentConfiguration: " + config);
547         }
548     }
549     
550     public void cleanup() {
551         // This is called by the ModuleVersion listener to rebuild the tree if
552
// the DD version changes since that forces creation of a new DDBean graph.
553
// However, that means we should never clear 'config' here, since in that
554
// case, the configuration is still valid and necessary.
555
for(Iterator i = moduleMap.values().iterator();i.hasNext();) {
556             ModuleDDSupport mds = (ModuleDDSupport) i.next();
557             removeVersionListener(mds.getProvider().getJ2eeModule());
558             mds.cleanup();
559         }
560         moduleMap = new HashMap();
561         /*if (dobj instanceof J2eeModuleContainer) {
562             J2eeModuleContainer jmc = (J2eeModuleContainer) dobj;
563             jmc.removeModuleListener(this);
564         }*/

565     }
566
567     private String JavaDoc getKey(J2eeModule mod) {
568         String JavaDoc key = mod.getUrl();
569         if (key == null || key.trim().equals("")) { //NOI18N
570
key = ROOT;
571         }
572         return key;
573     }
574     
575     private void createVersionListener(J2eeModule mod) {
576         String JavaDoc key = getKey(mod);
577         J2eeModule.VersionListener listener = new ModuleVersionListener(key);
578         mod.addVersionListener(listener);
579         versionListeners.put(key, listener);
580     }
581     
582     private void removeVersionListener(J2eeModule mod) {
583         J2eeModule.VersionListener vl = (J2eeModule.VersionListener) versionListeners.remove(getKey(mod));
584         if (vl != null) {
585             mod.removeVersionListener(vl);
586         }
587     }
588     
589     private void createVersionListeners() {
590         createVersionListener(module.getJ2eeModule());
591         /*if(module.getJ2eeModule().getModuleType().equals(J2eeModule.EAR)) {
592             J2eeModuleContainer appProvider = (J2eeModuleContainer) module;
593             J2eeModule[] modules = appProvider.getModules(this);
594             for(int i = 0; i < modules.length; i++) {
595                 createVersionListener(modules[i]);
596             }
597         }*/

598     }
599
600     boolean saveInProgress() {
601         return (saveInProgress > 0);
602     }
603
604     private class ModuleVersionListener implements J2eeModule.VersionListener {
605         private String JavaDoc moduleUri;
606         ModuleVersionListener(String JavaDoc moduleUri) {
607             this.moduleUri = moduleUri;
608         }
609         public void versionChanged(String JavaDoc oldVersion, String JavaDoc newVersion) {
610             try {
611                 saveOnDemand();
612                 cleanup();
613                 init();
614             } catch(java.util.NoSuchElementException JavaDoc e) {
615                 String JavaDoc msg = NbBundle.getMessage(
616                 ConfigurationStorage.class, "MSG_DescriptorError", "TBD", e.getMessage());
617                 NotifyDescriptor nd = new NotifyDescriptor.Message(msg, NotifyDescriptor.ERROR_MESSAGE);
618                 DialogDisplayer.getDefault().notify(nd);
619                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
620             } catch(IOException ex) {
621                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
622             } catch (Exception JavaDoc e2) {
623                 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e2);
624             }
625             
626             ConfigBeanTopComponent tc = ConfigBeanTopComponent.findByConfigStorage(ConfigurationStorage.this);
627             if (tc != null) {
628                 tc.refresh();
629             }
630         }
631     }
632 }
633
Popular Tags