1 19 20 23 24 package org.netbeans.modules.j2ee.sun.ws7.nodes; 25 26 import javax.enterprise.deploy.spi.DeploymentManager ; 27 import javax.enterprise.deploy.spi.TargetModuleID ; 28 import org.openide.nodes.Node; 29 import org.openide.nodes.Sheet; 30 import org.openide.nodes.PropertySupport; 31 import java.beans.PropertyEditor ; 32 import java.util.List ; 33 import java.lang.reflect.Method ; 34 35 39 public class WS70WebModule extends WS70ManagedObjectBase implements Node.Cookie { 40 41 private TargetModuleID moduleID; 42 private DeploymentManager manager; 43 private boolean enabled; 44 private String path; 45 46 public WS70WebModule(DeploymentManager manager, TargetModuleID moduleId){ 47 this.manager = manager; 48 this.moduleID = moduleId; 49 Class moduleClass = moduleID.getClass(); 50 try{ 51 Method method = moduleClass.getDeclaredMethod("isRunning", new Class []{}); 52 java.lang.Boolean retVal = (java.lang.Boolean )method.invoke(moduleID, new Object []{}); 53 enabled = retVal.booleanValue(); 54 method = moduleClass.getDeclaredMethod("getPath", new Class []{}); 55 path = (String )method.invoke(moduleID, new Object []{}); 56 }catch(Exception m){ 57 m.printStackTrace(); 58 } 59 60 } 61 public boolean isModuleEnabled(){ 62 return enabled; 63 } 64 public void setModuleEnabled(boolean enable) throws Exception { 65 try{ 66 if(enable){ 67 manager.start(new TargetModuleID []{this.moduleID}); 68 }else{ 69 manager.stop(new TargetModuleID []{this.moduleID}); 70 } 71 enabled = enable; 72 73 }catch(Exception ex){ 74 throw ex; 75 } 76 77 } 78 79 public String getName(){ 80 return moduleID.getModuleID(); 81 } 82 public String 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 attribute, Object value){ 105 return null; 106 } 107 public String getDisplayName(){ 108 return moduleID.getModuleID(); 109 } 110 public void undeploy() throws Exception { 111 try{ 112 manager.undeploy(new TargetModuleID []{moduleID}); 113 }catch(Exception ex){ 114 throw ex; 115 } 116 } 117 } 118 | Popular Tags |