geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject cvs commit: incubator-geronimo/sandbox/explorer/src/java/org/apache/geronimo/explorer Explorer.groovy ExplorerMain.java MBeanNode.java MBeanServerNode.java MBeanTreeModel.java ViewManager.java
Date Fri, 23 Jan 2004 03:47:02 GMT
dblevins    2004/01/22 19:47:02

  Added:       sandbox/explorer .cvsignore LICENSE.txt TODO.txt maven.xml
                        project.properties project.xml
               sandbox/explorer/src/java/org/apache/geronimo/explorer
                        Explorer.groovy ExplorerMain.java MBeanNode.java
                        MBeanServerNode.java MBeanTreeModel.java
                        ViewManager.java
  Removed:     modules/explorer .cvsignore LICENSE.txt TODO.txt maven.xml
                        project.properties project.xml
               modules/explorer/src/java/org/apache/geronimo/explorer
                        Explorer.groovy ExplorerMain.java MBeanNode.java
                        MBeanServerNode.java MBeanTreeModel.java
                        ViewManager.java
  Log:
  Moving the explorer package to the sandbox
  
  Revision  Changes    Path
  1.1                  incubator-geronimo/sandbox/explorer/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  target
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/LICENSE.txt
  
  Index: LICENSE.txt
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/TODO.txt
  
  Index: TODO.txt
  ===================================================================
  * use JavaBean customizers for attributes?
  	otherwise use a factory for editors per property type & name & ObjectName
  
  * allow attributes to be changed
  
  * nicer layout of forms
  
  * use JSR 160 to connect
  	
  * deployment UI stuff
  
  * combine twiddle commands with explorer
  	
  
  
  1.1                  incubator-geronimo/sandbox/explorer/maven.xml
  
  Index: maven.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!-- $Revision: 1.1 $ $Date: 2004/01/23 03:47:02 $ -->
  
  <project default="default"
    xmlns:j="jelly:core"
    xmlns:ant="jelly:ant">
    
    <goal name="setclasspath">
  	<path id="test.classpath">
  	    <pathelement path="${maven.build.dest}"/>
  	    <pathelement path="target/classes"/>
  	    <pathelement path="target/test-classes"/>
  	    <path refid="maven.dependency.classpath"/>
  	</path>
    </goal>
  
    <postGoal name="java:compile">
      <attainGoal name="groovy:compile"/>
    </postGoal>
    
    <!-- this will move into the groovy plugin soon -->
    <goal name="groovy:compile" prereqs="setclasspath"
    		description="Compiles the Groovy source files">
      <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="test.classpath"/>

      <groovyc destdir="${basedir}/target/classes" srcdir="${basedir}/src/java" listfiles="false">
        <classpath refid="test.classpath"/>
      </groovyc>
    </goal>
    
    <goal name="run" prereqs="test:compile"
  		description="Runs the JMX explorer">
      <java classname="org.apache.geronimo.explorer.ExplorerMain" fork="yes">
        <classpath refid="test.classpath"/>
      </java>
    </goal>
    
  </project>
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/project.properties
  
  Index: project.properties
  ===================================================================
  ##
  ## $Revision: 1.1 $ $Date: 2004/01/23 03:47:02 $
  ##
  
  # required for Groovy unit test cases
  maven.test.search.classdir = true
  
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <!-- $Revision: 1.1 $ $Date: 2004/01/23 03:47:02 $ -->
  
  <project>
    <pomVersion>3</pomVersion>
    <extend>${basedir}/../../etc/project.xml</extend>
    
    <!-- ===================== -->
    <!-- Module Identification -->
    <!-- ===================== -->
    
    <name>Geronimo :: Explorer</name>
    <id>geronimo-explorer</id>
    <shortDescription></shortDescription>
    <description></description>
    <siteDirectory></siteDirectory>
    <distributionDirectory></distributionDirectory>
    
    <package>org.apache.geronimo.explorer</package>
    <currentVersion>DEV</currentVersion>
    
    
    <!-- ============ -->
    <!-- Dependencies -->
    <!-- ============ -->
    
    <dependencies>
    
      <!-- Module Dependencies -->
      
      <dependency>
        <groupId>geronimo</groupId>
        <artifactId>geronimo-common</artifactId>
        <version>DEV</version>
        <properties>
          <module>true</module>
          <runtime>true</runtime>
        </properties>
      </dependency>
  
      <dependency>
        <groupId>geronimo</groupId>
        <artifactId>geronimo-core</artifactId>
        <version>DEV</version>
        <properties>
          <module>true</module>
          <runtime>true</runtime>
        </properties>
      </dependency>
  
  
      <dependency>
        <groupId>geronimo</groupId>
        <artifactId>geronimo-remoting</artifactId>
        <version>DEV</version>
        <properties>
          <module>true</module>
          <runtime>true</runtime>
        </properties>
      </dependency>
  
      <!-- Thirdparty Dependencies -->
      
      <dependency>
        <id>mx4j</id>
        <version>SNAPSHOT</version>
        <properties>
            <bootstrap>true</bootstrap>
        </properties>
      </dependency>
  
      <dependency>
        <id>groovy</id>
        <version>1.0-alpha-1</version>
        <url>http://groovy.codehaus.org</url>
        <properties>
          <runtime>true</runtime>
        </properties>
      </dependency>
  
      <dependency>
        <id>commons-logging</id>
        <version>1.0.3</version>
        <url>http://jakarta.apache.org/commons/logging</url>
        <properties>
          <runtime>true</runtime>
        </properties>
      </dependency>
  
      <dependency>
        <id>asm</id>
        <version>1.3.4</version>
      </dependency>   
      
  	<!-- temp hack - won't need this soon -->
      <dependency>
        <id>asm+util</id>
        <version>1.3.4</version>
        <url>http://asm.objectweb.org/</url>
      </dependency>
  
      <!-- Runtime dependencies due to remoting -->
      <dependency>
         <id>commons-lang</id>
         <version>SNAPSHOT</version>
         <url>http://jakarta.apache.org/commons/lang</url>
         <properties>
           <runtime>false</runtime>
         </properties>
      </dependency>
  
      <dependency>
         <id>concurrent</id>
         <version>1.3.2</version>
         <properties>
            <runtime>true</runtime>
         </properties>
      </dependency>    
      
  
    </dependencies>
    
    
    <!-- =================== -->
    <!-- Build Specification -->
    <!-- =================== -->
    
    <build>
      <unitTest>
        <!-- For some reason this is not pulled from the global project -->
        <includes>
          <include>**/*Test.java</include>
        </includes>
        <excludes>
          <exclude>**/Abstract*.java</exclude>
        </excludes>
        
        <resources>
          <resource>
            <directory>${basedir}/src/test</directory>
            <includes>
              <include>**/*.xml</include>
            </includes>
          </resource>
        </resources>
      </unitTest>
    </build>
  
  </project>
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/src/java/org/apache/geronimo/explorer/Explorer.groovy
  
  Index: Explorer.groovy
  ===================================================================
  package org.apache.geronimo.explorer
  
  import groovy.swing.SwingBuilder
  
  import java.awt.BorderLayout
  import javax.management.MBeanServer;
  import javax.management.MBeanServerFactory;
  import javax.management.ObjectName;
  import javax.swing.BorderFactory
  
  class Explorer {
  
      property frame
      property swing
      property treeModel
      property viewManager
      property objectName
      
      static void main(args) { 
  	    explorer = new Explorer()
  	    explorer.run()   
  	}
  	
      void run() {
          swing = new SwingBuilder()
          viewManager = new ViewManager(this)
          
          frame = swing.frame(title:'Geronimo Explorer', location:[200,200], size:[800,400])
{
              menuBar {
  		        menu(text:'Help') {
  		            menuItem() {
  		                action(name:'About', closure:{ showAbout() })
  		            }
  		        }
  		    }
  			split = splitPane() {
                  scrollPane() {
  					tree(model:owner.getTreeModel(), valueChanged:{event| onTreeSelection(event)})
                  }
                  p = panel()
                  owner.viewManager.setPanel(p)
  		    }
  		    split.dividerLocation = 0.5
  		}        
  		frame.show()
      }
      
      createMBeanView(name) {
  		objectName = name
          return swing.scrollPane(constraints:BorderLayout.CENTER) {
              vbox() {
                  panel(border:BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(),
'MBean Properties')) {
                      name = owner.getObjectName()
                      label(text:'domain')
                      textField(text:name.domain, editable:false)
                      
                      for (e in name.keyPropertyList) {
                          valueText = ""
                          if (e.value != null) {
                              valueText = e.value.toString()
                          }
  
                          label(text:e.key)
                          textField(text:valueText, editable:false)                    
                      }
                  }
                  panel(border:BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(),
'MBean Attributes')) {
                      name = owner.getObjectName()
                      server = owner.getMBeanServer()
                      beanInfo = owner.getMBeanInfo()
                      attributes = beanInfo.attributes
                      list = []
                      for (attrInfo in attributes) {
                          attrName = attrInfo.getName()
                          description = attrInfo.getDescription()
                          value = server.getAttribute(name, attrName)
      
                          valueText = ""
                          if (value != null) {
                              valueText = value.toString()
                          }
                          label(text:attrName)
                          textField(text:valueText)                    
                      }
                  }
                  panel(border:BorderFactory.createTitledBorder(BorderFactory.createLoweredBevelBorder(),
'MBean Operations')) {
                      beanInfo = owner.getMBeanInfo()
                      operations = beanInfo.operations
                      list = []
                      for (opInfo in operations) {
                          opName = opInfo.getName()
                          description = opInfo.getDescription()
  
                          label(text:opName)
                          
                          /** @todo this will only work when local variables are passed into
closures */
                          //button(text:'Call', actionListener:{ owner.callMBeanOperation(opName)
})                    
                          button(text:'Call')                    
                      }
                  }
              }
          }
      }
      
  	onTreeSelection(event) {
  	    path = event.path
  	    System.out.println("Selected: " + path)
  	    
  	    node = path.lastPathComponent
  	    
          System.out.println("node: " + node)
  
  		viewManager.setSelectedTreeNode(node)
  	}
  	
  	getMBeanServer() {
  	    return getTreeModel().getMBeanServer()
  	}
  	
  	getMBeanInfo() {
          server = getMBeanServer()
          return server.getMBeanInfo(objectName)
  	}
  
      showAbout() {
   		pane = swing.optionPane(message:'This program is a Swing user interface for introspecting
Geronimo servers')
   		dialog = pane.createDialog(frame, 'About Geronimo Explorer')
   		dialog.show()
      }
  }
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/src/java/org/apache/geronimo/explorer/ExplorerMain.java
  
  Index: ExplorerMain.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.explorer;
  
  import groovy.lang.GroovyObject;
  
  import java.net.URISyntaxException;
  
  import javax.management.MBeanServer;
  
  import org.apache.geronimo.remoting.jmx.RemoteMBeanServerFactory;
  import org.codehaus.groovy.runtime.InvokerHelper;
  
  /**
   * A temporary bootstap mechanism for the Groovy script until
   * Groovy reaches beta-1 and can support static main(String[]) methods
   * 
   * @version <code>$Revision: 1.1 $ $Date: 2004/01/23 03:47:02 $</code>
   */
  public class ExplorerMain {
      public static void main(String[] args) {
          
          String host="localhost";
          if( args.length > 0 )
              host = args[0];
          
          try {
              GroovyObject explorer = (GroovyObject) ExplorerMain.class.getClassLoader().loadClass("org.apache.geronimo.explorer.Explorer").newInstance();
              InvokerHelper.setProperty(explorer, "treeModel", getMBeanTreeModel(host));
              explorer.invokeMethod("run", null);
          }
          catch (Exception e) {
              System.out.println("Caught: " + e);
              e.printStackTrace();
          }
      }
  
      public static MBeanTreeModel getMBeanTreeModel(String host)
          throws Exception {
          return new MBeanTreeModel(getMBeanServer(host));
      }
      
      public static MBeanServer getMBeanServer(String host) throws URISyntaxException {
          return RemoteMBeanServerFactory.create(host);
          //return MBeanServerFactory.createMBeanServer();
      }
  }
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/src/java/org/apache/geronimo/explorer/MBeanNode.java
  
  Index: MBeanNode.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.explorer;
  
  import javax.management.ObjectName;
  import javax.swing.tree.DefaultMutableTreeNode;
  
  /**
   * Tree model for MBeans
   *
   * @version <code>$Revision: 1.1 $ $Date: 2004/01/23 03:47:02 $</code>
   */
  public class MBeanNode extends DefaultMutableTreeNode {
  
      public MBeanNode(ObjectName name) {
          super(name);
      }
  
      public ObjectName getObjectName() {
          return (ObjectName) getUserObject();
      }    
  
      public String toString() {
          return getObjectName().getKeyPropertyListString();
      }
  
  }
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/src/java/org/apache/geronimo/explorer/MBeanServerNode.java
  
  Index: MBeanServerNode.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.explorer;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Set;
  
  import javax.management.MBeanServer;
  import javax.management.MBeanServerFactory;
  import javax.management.ObjectName;
  import javax.swing.tree.DefaultMutableTreeNode;
  
  /**
   * Tree model for MBeans
   *
   * @version <code>$Revision: 1.1 $ $Date: 2004/01/23 03:47:02 $</code>
   */
  public class MBeanServerNode extends DefaultMutableTreeNode {
  
      private MBeanServer server;
      private Map domains = new HashMap();
  
      public MBeanServerNode() {
          this(MBeanServerFactory.createMBeanServer());
      }
  
      public MBeanServerNode(MBeanServer server) {
          super("Server");
          this.server = server;
          createDomains();
      }
      
      public MBeanServer getMBeanServer() {
          return server;
      }
      
      protected void createDomains() {
          Set names = server.queryNames(null, null);
          for (Iterator iter = names.iterator(); iter.hasNext();) {
              ObjectName name = (ObjectName) iter.next();
              String domain = name.getDomain();
              DefaultMutableTreeNode domainNode = (DefaultMutableTreeNode) domains.get(domain);
              if (domainNode == null) {
                  domainNode = new DefaultMutableTreeNode(domain);
                  domains.put(domain, domainNode);
                  add(domainNode);
              }
              domainNode.add(new MBeanNode(name));
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/src/java/org/apache/geronimo/explorer/MBeanTreeModel.java
  
  Index: MBeanTreeModel.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.explorer;
  
  import javax.management.MBeanServer;
  import javax.management.MBeanServerFactory;
  import javax.swing.tree.DefaultTreeModel;
  
  /**
   * Tree model for MBeans
   *
   * @version <code>$Revision: 1.1 $ $Date: 2004/01/23 03:47:02 $</code>
   */
  public class MBeanTreeModel extends DefaultTreeModel {
  
      public MBeanTreeModel() {
          this(MBeanServerFactory.createMBeanServer());
      }
  
      public MBeanTreeModel(MBeanServer server) {
          super(new MBeanServerNode(server));
      }
  
      public MBeanServer getMBeanServer() {
          return getRootNode().getMBeanServer();
      }
      
      public MBeanServerNode getRootNode() {
          return (MBeanServerNode) getRoot();
      }
  }
  
  
  
  1.1                  incubator-geronimo/sandbox/explorer/src/java/org/apache/geronimo/explorer/ViewManager.java
  
  Index: ViewManager.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.explorer;
  
  import java.awt.BorderLayout;
  import java.awt.Component;
  
  import javax.management.MBeanServer;
  import javax.management.ObjectName;
  import javax.swing.JPanel;
  
  import org.codehaus.groovy.runtime.InvokerHelper;
  
  /**
   * Manages views of selected tree nodes
   *
   * @version <code>$Revision: 1.1 $ $Date: 2004/01/23 03:47:02 $</code>
   */
  public class ViewManager {
  
      private JPanel panel;
      private Object explorer;
      private MBeanServer server;
  
      public ViewManager(Object explorer) {
          this.explorer = explorer;
          this.server = (MBeanServer) InvokerHelper.getProperty(explorer, "MBeanServer");
      }
  
      public void setSelectedTreeNode(Object node) {
          if (node instanceof MBeanNode) {
              MBeanNode mbeanNode = (MBeanNode) node;
  
              // lets make the mbean view
              ObjectName name = mbeanNode.getObjectName();
              System.out.println("About to call method: createMBeanView");
              
              Component component = (Component) InvokerHelper.invokeMethod(explorer, "createMBeanView",
name);
              setViewComponent(component);
          }
          else {
              setViewComponent(null);
          }
      }
  
      public JPanel getPanel() {
          return panel;
      }
  
      public void setPanel(JPanel panel) {
          this.panel = panel;
          panel.setLayout(new BorderLayout());
      }
  
      protected void setViewComponent(Component component) {
          panel.removeAll();
          if (component != null) {
              panel.add(component, BorderLayout.CENTER);
          }
          panel.invalidate();
          panel.revalidate();
          panel.repaint();
      }
  }
  
  
  

Mime
View raw message