1 19 20 25 26 package org.netbeans.modules.j2ee.sun.share.management; 27 28 import java.io.IOException ; 29 import javax.management.MBeanException ; 30 import javax.management.ReflectionException ; 31 import javax.management.IntrospectionException ; 32 import javax.management.InstanceNotFoundException ; 33 import javax.management.AttributeNotFoundException ; 34 import javax.management.InvalidAttributeValueException ; 35 import javax.management.MBeanServerConnection ; 36 import javax.management.ObjectName ; 37 import javax.management.AttributeList ; 38 import java.rmi.RemoteException ; 39 import java.rmi.ServerException ; 40 import java.util.ResourceBundle ; 41 42 import javax.enterprise.deploy.spi.DeploymentManager ; 43 import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface; 44 45 import org.netbeans.modules.j2ee.sun.api.ServerInterface; 46 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtController; 47 import org.netbeans.modules.j2ee.sun.ide.controllers.ControllerUtil; 48 49 50 51 55 public class ServerMEJB implements ServerInterface { 56 57 58 private UtilMEJB ut = null; 59 60 private DeploymentManager currentDM = null; 61 static final ResourceBundle bundle = ResourceBundle.getBundle("org.netbeans.modules.j2ee.sun.share.management.Bundle"); 63 public ServerMEJB( ) { 64 65 } 66 public ServerMEJB(DeploymentManager dm) { 67 setDeploymentManager (dm); 68 } 69 public void setDeploymentManager(DeploymentManager dm){ 70 this.currentDM = dm; 71 72 } 73 public Object getAttribute(ObjectName name, String attribute) throws MBeanException , 74 AttributeNotFoundException , InstanceNotFoundException , ReflectionException , RemoteException { 75 return this.getUT().updateGetAttribute(name, attribute); 76 } 77 78 public AttributeList getAttributes(ObjectName name, String [] attributes) throws 79 ReflectionException , InstanceNotFoundException , RemoteException { 80 return this.getUT().updateGetAttributes(name, attributes); 81 } 82 83 public javax.management.MBeanInfo getMBeanInfo(ObjectName name) throws IntrospectionException , InstanceNotFoundException , 84 ReflectionException , RemoteException { 85 return this.getUT().updateMBeanInfo(name); 86 } 87 88 public Object invoke(ObjectName name, String operationName, Object [] params, String [] signature) throws InstanceNotFoundException , 89 MBeanException , ReflectionException , RemoteException { 90 return this.getUT().updateInvoke(name, operationName, params, signature); 91 } 92 93 public void setAttribute(ObjectName name, javax.management.Attribute attribute) throws InstanceNotFoundException , 94 AttributeNotFoundException , InvalidAttributeValueException , MBeanException , ReflectionException , RemoteException { 95 this.getUT().updateSetAttribute(name, attribute); 96 } 97 98 public DeploymentManager getDeploymentManager(){ 99 return this.currentDM; 100 } 101 102 public MBeanServerConnection getMBeanServerConnection() throws RemoteException , ServerException { 103 return this.getUT().getConnection(); 104 } 105 106 public Object getManagement(){ 107 return this; 108 } 109 110 private UtilMEJB getUT() throws RemoteException , ServerException { 111 SunDeploymentManagerInterface sdmi = (SunDeploymentManagerInterface)currentDM; 112 if (sdmi.isSuspended()){ 113 throw new RemoteException (bundle.getString("MSG_ServerInDebug")) ; 115 } 116 if (this.ut!=null){ 117 118 return this.ut; 119 } 120 SunDeploymentManagerInterface dm=(SunDeploymentManagerInterface)currentDM; 121 try{ 122 123 ut = new UtilMEJB(dm); 124 ut.getConnection().getDefaultDomain(); 126 127 } 128 catch (IOException e){ 129 if(e.getMessage().contains ("500")){ this.ut =null; 131 } 132 } 133 catch (java.lang.NoClassDefFoundError ncf){ throw new RemoteException (bundle.getString("MSG_WrongInstallDir")) ; 135 } 136 return this.ut; 137 } 138 139 public String getWebModuleName(String contextRoot) { 140 String name = null; 141 SunDeploymentManagerInterface sunDm = (SunDeploymentManagerInterface)currentDM; 142 if (sunDm.isSuspended()) { 143 return null; 144 } 145 if (sunDm.isRunning(false)) { 146 if (sunDm.grabInnerDM(true)) { 147 try { 148 AppserverMgmtController controller = getController(); 149 if(controller != null) { 150 name = controller.getWebModuleName(contextRoot); 151 } 152 } finally { 153 sunDm.releaseInnerDM(); 154 } 155 } 156 } 157 return name; 158 } 159 160 private AppserverMgmtController getController(){ 161 AppserverMgmtController controller = null; 162 SunDeploymentManagerInterface sunDm = (SunDeploymentManagerInterface)currentDM; 163 controller = ControllerUtil.getAppserverMgmtControllerFromDeployMgr(currentDM); 164 return controller; 165 } 166 167 171 public void checkCredentials() throws IOException { 172 SunDeploymentManagerInterface sdmi = (SunDeploymentManagerInterface)currentDM; 173 if (sdmi.isSuspended()){ 174 throw new RemoteException (bundle.getString("MSG_ServerInDebug")) ; 175 } 176 SunDeploymentManagerInterface dm=(SunDeploymentManagerInterface)currentDM; 177 getUT().getConnection().getDefaultDomain(); 179 return; 180 } 181 182 } 183 | Popular Tags |