1 19 package org.netbeans.modules.j2ee.sun.ide.runtime.nodes; 20 21 import java.beans.PropertyChangeEvent ; 22 import java.beans.PropertyChangeListener ; 23 import java.util.Iterator ; 24 import javax.swing.Action ; 25 import javax.management.Attribute ; 26 import javax.management.MBeanAttributeInfo ; 27 import org.netbeans.modules.j2ee.sun.api.SunDeploymentManagerInterface; 28 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtContainerNode; 29 import org.netbeans.modules.j2ee.sun.bridge.apis.AppserverMgmtController; 30 import org.openide.util.RequestProcessor; 31 import org.openide.util.actions.SystemAction; 32 33 import org.netbeans.modules.j2ee.sun.util.NodeTypes; 34 import org.netbeans.modules.j2ee.sun.ide.controllers.ControllerUtil; 35 36 import javax.enterprise.deploy.spi.DeploymentManager ; 37 import org.netbeans.modules.j2ee.sun.util.PropertySupportFactory; 38 import org.openide.nodes.PropertySupport; 39 import org.openide.nodes.Sheet; 40 41 43 public class DomainRootNode extends AppserverMgmtContainerNode implements PropertyChangeListener , Runnable { 44 45 private static final String NODE_TYPE = NodeTypes.DOMAIN; 46 private PropertySupportFactory propSupportFactory = 47 PropertySupportFactory.getInstance(); 48 private DeploymentManager deployMgr; 49 50 51 54 public DomainRootNode(final DeploymentManager dm) { 55 super(null, NODE_TYPE); 56 deployMgr =dm; 57 SunDeploymentManagerInterface sdm=(SunDeploymentManagerInterface)deployMgr; 58 sdm.addPropertyChangeListener(this); 59 63 javax.swing.SwingUtilities.invokeLater(new Runnable () { 64 public void run() { 65 refresh(); 66 } 67 }); 68 69 shutOffJMXAndAMXLogging(); 70 } 71 72 public void refresh(){ 73 RequestProcessor.getDefault().post(this); 74 } 75 76 public void run() { 77 SunDeploymentManagerInterface sdm=(SunDeploymentManagerInterface)deployMgr; 78 if (sdm.isSuspended()) { 79 return; 80 } 81 if (sdm.grabInnerDM(true)) { 82 try { 83 AppserverMgmtController a= ControllerUtil.getAppserverMgmtControllerFromDeployMgr( deployMgr); 84 setAppserverMgmtController(a); 85 super.refresh(); 86 } finally { 87 sdm.releaseInnerDM(); 88 } 89 } else { 90 javax.swing.SwingUtilities.invokeLater(new Runnable () { 91 public void run() { 92 refresh(); 93 } 94 }); 95 } 96 } 97 106 public Action [] getActions(boolean flag) { 107 return new SystemAction[] {}; 108 } 109 110 116 protected Sheet createSheet() { 117 Sheet sheet = Sheet.createDefault(); 118 ClassLoader origClassLoader=Thread.currentThread().getContextClassLoader(); 119 try { 120 Thread.currentThread().setContextClassLoader( 121 this.getClass().getClassLoader()); 122 Sheet.Set props = sheet.get(Sheet.PROPERTIES); 123 props.put(createPropertySupportArray(getSheetProperties())); 124 return sheet; 125 } catch(RuntimeException rex) { 126 return sheet; 127 } finally { 128 Thread.currentThread().setContextClassLoader(origClassLoader); 129 } 130 } 131 132 138 private PropertySupport[] createPropertySupportArray(final java.util.Map attrMap) { 139 PropertySupport[] supports = new PropertySupport[attrMap.size()]; 140 int i = 0; 141 for(Iterator itr = attrMap.keySet().iterator(); itr.hasNext(); ) { 142 Attribute attr = (Attribute ) itr.next(); 143 MBeanAttributeInfo info = (MBeanAttributeInfo ) attrMap.get(attr); 144 supports[i] = 145 propSupportFactory.createLogLevelProperty(this, attr, info); 146 i++; 147 } 148 return supports; 149 } 150 151 156 private java.util.Map getSheetProperties() { 157 return getAppserverMgmtController().getLogProperties("server"); } 159 160 171 public javax.management.Attribute setSheetProperty(String attrName, Object value) { 172 try { 173 return getAppserverMgmtController().setLogProperties("server", attrName, value); } catch (RuntimeException rex) { 175 return null; 176 } 177 } 178 179 183 private void shutOffJMXAndAMXLogging() { 184 186 java.util.logging.Logger.getLogger( 187 "org.netbeans.modules.j2ee.sun"). 188 setLevel(java.util.logging.Level.OFF); 189 190 java.util.logging.Logger.getLogger( 192 "javax.enterprise.system.tools.admin"). 193 setLevel(java.util.logging.Level.OFF); 194 java.util.logging.Logger.getLogger( 195 "javax.enterprise.system.tools.admin.client"). 196 setLevel(java.util.logging.Level.OFF); 197 java.util.logging.Logger.getLogger( 198 "javax.enterprise.system.tools.admin.server"). 199 setLevel(java.util.logging.Level.OFF); 200 java.util.logging.Logger.getLogger( 201 "javax.enterprise.system.tools.admin.server.mbeans"). 202 setLevel(java.util.logging.Level.OFF); 203 204 java.util.logging.Logger.getLogger( 206 "javax.management.remote"). 207 setLevel(java.util.logging.Level.OFF); 208 } 209 210 public void propertyChange(PropertyChangeEvent evt) { 211 212 213 javax.swing.SwingUtilities.invokeLater(new Runnable () { 215 public void run() { 216 refresh(); 217 } 218 }); 219 } 220 221 222 223 } 224 | Popular Tags |