1 19 package org.netbeans.modules.j2ee.sun.ide.controllers; 20 21 import java.util.Map ; 22 import java.util.List ; 23 24 import javax.management.Attribute ; 25 26 import com.sun.appserv.management.base.AMX; 27 import com.sun.appserv.management.client.AppserverConnectionSource; 28 import com.sun.appserv.management.config.DeployedItemRefConfig; 29 import com.sun.appserv.management.config.EJBModuleConfig; 30 import com.sun.appserv.management.config.Enabled; 31 import com.sun.appserv.management.j2ee.EJBModule; 32 import com.sun.appserv.management.j2ee.J2EEDeployedObject; 33 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 40 48 public class EJBModuleController extends AppserverMgmtControllerBase 49 implements DeployedItemsController, EnablerController { 50 51 private EJBModule ejbModule; 52 private EJBModuleConfig ejbConfig; 53 54 60 public EJBModuleController(EJBModule ejbModule, 61 AppserverConnectionSource connection) { 62 super(ejbModule, connection); 63 this.ejbModule = ejbModule; 64 } 65 66 67 73 public EJBModuleController(final EJBModule ejbModule, 74 final DeploymentManager dplmtMgr, 75 final AppserverConnectionSource connection) { 76 super(ejbModule, dplmtMgr, connection); 77 this.ejbModule = ejbModule; 78 } 79 80 public EJBModuleController(final EJBModule ejbModule, 81 final EJBModuleConfig ejbConfig, 82 final DeploymentManager dplmtMgr, 83 final AppserverConnectionSource connection) { 84 super(ejbConfig, dplmtMgr, connection); 85 this.ejbModule = ejbModule; 86 this.ejbConfig = ejbConfig; 87 } 88 89 95 public Map getProperties(List propsToIgnore) { 96 return getJ2EEAndConfigProperties(NodeTypes.EJB_MODULE, this.ejbModule, 97 this.ejbConfig, propsToIgnore); 98 } 99 100 101 109 public Attribute setProperty(final String attrName, final Object value) { 110 111 testIfServerInDebug(); 112 113 return ControllerUtil.setAttributeValue(ejbModule, ejbConfig, attrName, value, 114 getMBeanServerConnection()); 115 } 116 117 121 public String [] getStatelessSessionBeans() { 122 return getEjbsByType(NodeTypes.STATELESS_SESSION_BEAN); 123 } 124 125 126 129 public String [] getStatefulSessionBeans() { 130 return getEjbsByType(NodeTypes.STATEFUL_SESSION_BEAN); 131 } 132 133 134 137 public String [] getMessageDrivenBeans() { 138 return getEjbsByType(NodeTypes.MESSAGE_DRIVEN_BEAN); 139 } 140 141 142 146 public String [] getEntityBeans() { 147 return getEjbsByType(NodeTypes.ENTITY_BEAN); 148 } 149 150 151 154 public Map getStatelessEJBProperties(final String ejbName, 155 final List propsToIgnore) { 156 return getPropertiesFromBackend(NodeTypes.STATELESS_SESSION_BEAN, 157 getEjb(NodeTypes.STATELESS_SESSION_BEAN, ejbName), propsToIgnore); 158 } 159 160 163 public Attribute setStatelessEJBProperties(final String ejbName, 164 final String attrName, final Object value) { 165 166 testIfServerInDebug(); 167 168 return ControllerUtil.setAttributeValue( 169 getEjb(NodeTypes.STATELESS_SESSION_BEAN, ejbName), attrName, value, 170 getMBeanServerConnection()); 171 } 172 173 174 177 public Map getStatefulEJBProperties(final String ejbName, 178 final List propsToIgnore) { 179 return getPropertiesFromBackend(NodeTypes.STATEFUL_SESSION_BEAN, 180 getEjb(NodeTypes.STATEFUL_SESSION_BEAN, ejbName), propsToIgnore); 181 } 182 183 186 public Attribute setStatefulEJBProperties(final String ejbName, 187 final String attrName, final Object value) { 188 189 testIfServerInDebug(); 190 191 return ControllerUtil.setAttributeValue( 192 getEjb(NodeTypes.STATEFUL_SESSION_BEAN, ejbName), attrName, value, 193 getMBeanServerConnection()); 194 } 195 196 199 public Map getEntityEJBProperties(final String ejbName, 200 final List propsToIgnore) { 201 return getPropertiesFromBackend(NodeTypes.ENTITY_BEAN, 202 getEjb(NodeTypes.ENTITY_BEAN, ejbName), propsToIgnore); 203 } 204 205 208 public Attribute setEntityEJBProperties(final String ejbName, 209 final String attrName, final Object value) { 210 211 testIfServerInDebugAndLogException(); 212 213 return ControllerUtil.setAttributeValue( 214 getEjb(NodeTypes.ENTITY_BEAN, ejbName), attrName, value, 215 getMBeanServerConnection()); 216 } 217 218 221 public Map getMessageDrivenEJBProperties(final String ejbName, 222 final List propsToIgnore) { 223 return getPropertiesFromBackend(NodeTypes.MESSAGE_DRIVEN_BEAN, 224 getEjb(NodeTypes.MESSAGE_DRIVEN_BEAN, ejbName), propsToIgnore); 225 } 226 227 230 public Attribute setMessageDrivenEJBProperties(final String ejbName, 231 final String attrName, final Object value) { 232 233 testIfServerInDebug(); 234 235 return ControllerUtil.setAttributeValue( 236 getEjb(NodeTypes.ENTITY_BEAN, ejbName), attrName, value, 237 getMBeanServerConnection()); 238 } 239 240 243 public AMX getEjb(final String nodeType, final String ejbName) { 244 testIfServerInDebug(); 245 return ejbModule.getContainee( 246 NodeTypes.getAMXJ2EETypeByNodeType(nodeType), ejbName); 247 } 248 249 250 253 public String [] getEjbsByType(String nodeType) { 254 testIfServerInDebug(); 255 return ControllerUtil.getComponentNamesFromMap( 256 ejbModule.getContaineeMap( 257 NodeTypes.getAMXJ2EETypeByNodeType(nodeType))); 258 } 259 260 261 266 public boolean isEnabled() { 267 testIfServerInDebug(); 268 boolean configEnabled = ((Enabled)ejbConfig).getEnabled(); 269 return ControllerUtil.calculateIsEnabled(ejbConfig, configEnabled); 270 } 271 272 273 278 public void setEnabled(boolean enabled) { 279 testIfServerInDebug(); 280 DeployedItemRefConfig config = ControllerUtil.getDeployedItemRefConfig(ejbConfig); 281 if(config != null) 282 config.setEnabled(enabled); 283 } 284 285 public J2EEDeployedObject getJ2EEObject() { 286 return ejbModule; 287 } 288 } 289 | Popular Tags |