KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > nodes > WS70WebModule


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 /*
21  * WS70WebModule.java
22  */

23
24 package org.netbeans.modules.j2ee.sun.ws7.nodes;
25
26 import javax.enterprise.deploy.spi.DeploymentManager JavaDoc;
27 import javax.enterprise.deploy.spi.TargetModuleID JavaDoc;
28 import org.openide.nodes.Node;
29 import org.openide.nodes.Sheet;
30 import org.openide.nodes.PropertySupport;
31 import java.beans.PropertyEditor JavaDoc;
32 import java.util.List JavaDoc;
33 import java.lang.reflect.Method JavaDoc;
34
35 /**
36  *
37  * @author Administrator
38  */

39 public class WS70WebModule extends WS70ManagedObjectBase implements Node.Cookie {
40
41     private TargetModuleID JavaDoc moduleID;
42     private DeploymentManager JavaDoc manager;
43     private boolean enabled;
44     private String JavaDoc path;
45     /** Creates a new instance of WS70WebModule */
46     public WS70WebModule(DeploymentManager JavaDoc manager, TargetModuleID JavaDoc moduleId){
47         this.manager = manager;
48         this.moduleID = moduleId;
49         Class JavaDoc moduleClass = moduleID.getClass();
50         try{
51             Method JavaDoc method = moduleClass.getDeclaredMethod("isRunning", new Class JavaDoc[]{});
52             java.lang.Boolean JavaDoc retVal = (java.lang.Boolean JavaDoc)method.invoke(moduleID, new Object JavaDoc[]{});
53             enabled = retVal.booleanValue();
54             method = moduleClass.getDeclaredMethod("getPath", new Class JavaDoc[]{});
55             path = (String JavaDoc)method.invoke(moduleID, new Object JavaDoc[]{});
56         }catch(Exception JavaDoc m){
57             m.printStackTrace();
58         }
59         
60     }
61     public boolean isModuleEnabled(){
62         return enabled;
63     }
64     public void setModuleEnabled(boolean enable) throws Exception JavaDoc{
65         try{
66             if(enable){
67                 manager.start(new TargetModuleID JavaDoc[]{this.moduleID});
68             }else{
69                 manager.stop(new TargetModuleID JavaDoc[]{this.moduleID});
70             }
71             enabled = enable;
72             
73         }catch(Exception JavaDoc ex){
74             throw ex;
75         }
76         
77     }
78     
79     public String JavaDoc getName(){
80         return moduleID.getModuleID();
81     }
82     public String JavaDoc getPath(){
83         return path;
84     }
85     public Sheet updateSheet(Sheet sheet) {
86         Sheet.Set ps = sheet.get(Sheet.PROPERTIES);
87         Attribute attr = null;
88         AttributeInfo attrInfo = null;
89         attr = new Attribute("Module ID", moduleID.getModuleID());
90         attrInfo = new AttributeInfo("Module ID", "java.lang.String", null,
91                                                    true, false, false);
92         ps.put(createReadOnlyProperty(attr, attrInfo, "shortDescription"));
93         attr = new Attribute("Web URL", moduleID.getWebURL());
94         attrInfo = new AttributeInfo("Web URL", "java.lang.String", null,
95                                                    true, false, false);
96         ps.put(createReadOnlyProperty(attr, attrInfo, "shortDescription"));
97         attr = new Attribute("Path", path);
98         attrInfo = new AttributeInfo("Path", "java.lang.String", null,
99                                                    true, false, false);
100         ps.put(createReadOnlyProperty(attr, attrInfo, "shortDescription"));
101         
102         return sheet;
103     }
104     public Attribute setAttribute(String JavaDoc attribute, Object JavaDoc value){
105         return null;
106     }
107     public String JavaDoc getDisplayName(){
108         return moduleID.getModuleID();
109     }
110     public void undeploy() throws Exception JavaDoc{
111         try{
112             manager.undeploy(new TargetModuleID JavaDoc[]{moduleID});
113         }catch(Exception JavaDoc ex){
114             throw ex;
115         }
116     }
117 }
118
Popular Tags