1 package org.netbeans.modules.j2ee.sun.ide.controllers; 2 20 import com.sun.appserv.management.j2ee.J2EEDeployedObject; 21 import java.util.Iterator ; 22 import java.util.List ; 23 import com.sun.appserv.management.base.Util; 24 import com.sun.appserv.management.util.jmx.JMXUtil; 25 import com.sun.appserv.management.config.Enabled; 26 import com.sun.appserv.management.client.AppserverConnectionSource; 27 import com.sun.appserv.management.config.DeployedItemRefConfig; 28 import com.sun.appserv.management.config.J2EEApplicationConfig; 29 import com.sun.appserv.management.j2ee.J2EEApplication; 30 import com.sun.appserv.management.j2ee.EJBModule; 31 import com.sun.appserv.management.j2ee.WebModule; 32 import com.sun.appserv.management.j2ee.AppClientModule; 33 import com.sun.appserv.management.j2ee.ResourceAdapterModule; 34 import javax.enterprise.deploy.spi.DeploymentManager ; 35 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtControllerBase; 36 37 import org.netbeans.modules.j2ee.sun.util.NodeTypes; 38 39 48 public class J2EEApplicationMgmtController extends AppserverMgmtControllerBase 49 implements DeployedItemsController, EnablerController { 50 51 private J2EEApplication application; 52 private J2EEApplicationConfig appConfig; 53 54 60 public J2EEApplicationMgmtController(final J2EEApplication application, 61 final DeploymentManager dplmtMgr, 62 final AppserverConnectionSource connection) { 63 super(application, dplmtMgr, connection); 64 this.application = application; 65 } 66 67 public J2EEApplicationMgmtController(final J2EEApplication application, 68 final J2EEApplicationConfig appConfig, 69 final DeploymentManager dplmtMgr, 70 final AppserverConnectionSource connection) { 71 super(appConfig, dplmtMgr, connection); 72 this.application = application; 73 this.appConfig = appConfig; 74 } 75 81 public java.util.Map getProperties(List propsToIgnore) { 82 return getJ2EEAndConfigProperties(NodeTypes.ENTERPRISE_APPLICATION, 83 this.application, this.appConfig, propsToIgnore); 84 } 85 86 87 95 public javax.management.Attribute setProperty(final String attrName, final Object value) { 96 97 testIfServerInDebug(); 98 99 return ControllerUtil.setAttributeValue(application, appConfig, attrName, value, 100 getMBeanServerConnection()); 101 } 102 103 107 public EJBModuleController[] getEJBModules() { 108 109 testIfServerInDebug(); 110 111 java.util.Map apps = application.getContaineeMap(EJBModule.J2EE_TYPE); 112 java.util.Vector controllers = new java.util.Vector (); 113 for(Iterator itr = apps.values().iterator(); itr.hasNext(); ) { 114 controllers.add(new EJBModuleController( 115 (EJBModule)itr.next(), getDeploymentManager(), 116 appMgmtConnection)); 117 } 118 EJBModuleController[] result = 119 new EJBModuleController[controllers.size()]; 120 return (EJBModuleController[]) controllers.toArray(result); 121 } 122 123 124 128 public AppClientModuleController[] getAppClientModules() { 129 130 testIfServerInDebug(); 131 132 java.util.Map apps = application.getContaineeMap(AppClientModule.J2EE_TYPE); 133 java.util.Vector controllers = new java.util.Vector (); 134 for(Iterator itr = apps.values().iterator(); itr.hasNext(); ) { 135 controllers.add(new AppClientModuleController( 136 (AppClientModule)itr.next(), getDeploymentManager(), 137 appMgmtConnection)); 138 } 139 AppClientModuleController[] result = 140 new AppClientModuleController[controllers.size()]; 141 return (AppClientModuleController[]) controllers.toArray(result); 142 } 143 144 145 149 public ConnectorModuleController[] getConnectorModules() { 150 151 testIfServerInDebug(); 152 153 String resJ2EETypeProp = 154 Util.makeJ2EETypeProp(ResourceAdapterModule.J2EE_TYPE); 155 String appProperty = 156 JMXUtil.makeProp(J2EEApplication.J2EE_TYPE, getName()); 157 String props = Util.concatenateProps(resJ2EETypeProp, appProperty); 158 java.util.Set embeddedRars = getQueryMgr().queryPropsSet(props); 159 java.util.Vector resAdaptorModules = new java.util.Vector (); 160 for(Iterator itr = embeddedRars.iterator(); itr.hasNext(); ) { 161 resAdaptorModules.add(new ConnectorModuleController( 162 (ResourceAdapterModule)itr.next(), getDeploymentManager(), 163 appMgmtConnection)); 164 } 165 ConnectorModuleController[] result = 166 new ConnectorModuleController[resAdaptorModules.size()]; 167 return (ConnectorModuleController[]) resAdaptorModules.toArray(result); 168 } 169 170 171 175 public WebModuleController[] getWebModules() { 176 177 testIfServerInDebug(); 178 java.util.Map apps = ControllerUtil.stripOutSystemApps( 179 application.getContaineeMap(WebModule.J2EE_TYPE)); 180 181 java.util.Vector controllers = new java.util.Vector (); 182 for(Iterator itr = apps.values().iterator(); itr.hasNext(); ) { 183 controllers.add(new WebModuleController( 184 (WebModule)itr.next(), getDeploymentManager(), 185 appMgmtConnection)); 186 } 187 WebModuleController[] result = 188 new WebModuleController[controllers.size()]; 189 return (WebModuleController[]) controllers.toArray(result); 190 } 191 192 198 public String [] getEmbeddedModulesByType(String nodeType) { 199 200 testIfServerInDebug(); 201 202 return ControllerUtil.getComponentNamesFromMap( 203 application.getContaineeMap( 204 NodeTypes.getAMXJ2EETypeByNodeType(nodeType))); 205 } 206 207 208 211 public String [] getEjbsByType(String nodeType, String ejbModuleName, 212 String ejbName) { 213 214 testIfServerInDebug(); 215 216 return ControllerUtil.getComponentNamesFromMap( 217 application.getContaineeMap( 218 NodeTypes.getAMXJ2EETypeByNodeType(nodeType))); 219 } 220 221 222 228 public EJBModule getEJBModuleByName(String ejbModuleName) { 229 230 testIfServerInDebug(); 231 232 java.util.Map modules = application.getContaineeMap(EJBModule.J2EE_TYPE); 233 return (EJBModule) modules.get(ejbModuleName); 234 } 235 236 237 242 public boolean isEnabled() { 243 testIfServerInDebug(); 244 boolean configEnabled = ((Enabled)appConfig).getEnabled(); 245 return ControllerUtil.calculateIsEnabled(appConfig, configEnabled); 246 } 247 248 249 254 public void setEnabled(boolean enabled) { 255 testIfServerInDebug(); 256 DeployedItemRefConfig config = ControllerUtil.getDeployedItemRefConfig(appConfig); 257 if(config != null) 258 config.setEnabled(enabled); 259 } 260 261 public J2EEDeployedObject getJ2EEObject() { 262 return application; 263 } 264 265 } 266 267 268 269 | Popular Tags |