1 19 package org.netbeans.modules.j2ee.sun.ide.controllers; 20 21 import java.util.Map ; 22 import java.util.List ; 23 import com.sun.appserv.management.client.AppserverConnectionSource; 24 import com.sun.appserv.management.config.DeployedItemRefConfig; 25 import com.sun.appserv.management.config.Enabled; 26 import com.sun.appserv.management.config.WebModuleConfig; 27 import com.sun.appserv.management.j2ee.J2EEDeployedObject; 28 import com.sun.appserv.management.j2ee.WebModule; 29 import com.sun.appserv.management.j2ee.Servlet; 30 31 import javax.enterprise.deploy.spi.DeploymentManager ; 32 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtControllerBase; 33 34 import org.netbeans.modules.j2ee.sun.util.NodeTypes; 35 36 37 45 public class WebModuleController extends AppserverMgmtControllerBase 46 implements DeployedItemsController, EnablerController { 47 48 private WebModule webModule; 49 private WebModuleConfig webConfig; 50 51 52 58 public WebModuleController(WebModule webModule, 59 AppserverConnectionSource connection) { 60 super(webModule, connection); 61 this.webModule = webModule; 62 } 63 64 65 71 public WebModuleController(final WebModule webModule, 72 final DeploymentManager dplmtMgr, 73 final AppserverConnectionSource connection) { 74 super(webModule, dplmtMgr, connection); 75 this.webModule = webModule; 76 } 77 78 public WebModuleController(final WebModule webModule, 79 final WebModuleConfig webConfig, 80 final DeploymentManager dplmtMgr, 81 final AppserverConnectionSource connection) { 82 super(webConfig, dplmtMgr, connection); 83 this.webModule = webModule; 84 this.webConfig = webConfig; 85 } 86 87 92 public String getDisplayName() { 93 if(webConfig != null) 94 return webConfig.getName(); 95 else 96 return webModule.getPath(); 97 } 98 99 105 public Map getProperties(List propsToIgnore) { 106 return getJ2EEAndConfigProperties(NodeTypes.WEB_MODULE, this.webModule, 107 this.webConfig, propsToIgnore); 108 } 109 110 118 public javax.management.Attribute setProperty(final String attrName, final Object value) { 119 120 testIfServerInDebug(); 121 122 return ControllerUtil.setAttributeValue(webModule, webConfig, attrName, value, 123 getMBeanServerConnection()); 124 } 125 126 130 private Servlet getServletByName(String servletName) { 131 132 testIfServerInDebug(); 133 134 return (Servlet) (getServletsAsMap().get(servletName)); 135 } 136 137 138 142 private Map getServletsAsMap() { 143 144 testIfServerInDebug(); 145 146 return webModule.getContaineeMap( 147 NodeTypes.getAMXJ2EETypeByNodeType(NodeTypes.SERVLET)); 148 } 149 150 151 155 public Map getServletProperties(final String servletName, 156 final List propsToIgnore) { 157 return getPropertiesFromBackend(NodeTypes.SERVLET, 158 getServletByName(servletName), propsToIgnore); 159 } 160 161 162 165 public javax.management.Attribute setServletProperties(final String servletName, 166 final String attrName, final Object value) { 167 168 testIfServerInDebug(); 169 170 return ControllerUtil.setAttributeValue( 171 getServletByName(servletName), attrName, value, 172 getMBeanServerConnection()); 173 } 174 175 176 180 public String [] getServlets() { 181 testIfServerInDebug(); 182 return ControllerUtil.getComponentNamesFromMap(getServletsAsMap()); 183 } 184 185 186 187 192 public boolean isEnabled() { 193 testIfServerInDebug(); 194 boolean configEnabled = ((Enabled)webConfig).getEnabled(); 195 return ControllerUtil.calculateIsEnabled(webConfig, configEnabled); 196 } 197 198 199 204 public void setEnabled(boolean enabled) { 205 testIfServerInDebug(); 206 DeployedItemRefConfig config = ControllerUtil.getDeployedItemRefConfig(webConfig); 207 if(config != null) 208 config.setEnabled(enabled); 209 } 210 211 public J2EEDeployedObject getJ2EEObject() { 212 return webModule; 213 } 214 } 215 | Popular Tags |