User: andreas 
  Date: 00/11/23 23:51:44

  Modified:    examples/jboss.admin/src/org/jboss/jBossAdmin
                        RemoteAttribute.java RemoteFeature.java
                        RemoteResource.java RemoteServer.java
  Added:       examples/jboss.admin/src/org/jboss/jBossAdmin
                        RemoteNotification.java RemoteOperation.java
  Log:
  Added Operations and Notifications to the tree on the
  left hand side, assigned meaningful Icons to the tree.
  
  Revision  Changes    Path
  1.2       +2 -64     
ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteAttribute.java
  
  Index: RemoteAttribute.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteAttribute.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RemoteAttribute.java      2000/11/23 20:56:14     1.1
  +++ RemoteAttribute.java      2000/11/24 07:51:42     1.2
  @@ -15,6 +15,8 @@
   
   import javax.management.MBeanInfo;
   import javax.management.MBeanAttributeInfo;
  +import javax.management.MBeanFeatureInfo;
  +import javax.management.MBeanNotificationInfo;
   import javax.management.MBeanOperationInfo;
   import javax.management.ObjectInstance;
   import javax.management.ObjectName;
  @@ -35,7 +37,7 @@
   *   <description> 
   *      
   * @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad" Schaefer</A>
  -* @version $Revision: 1.1 $
  +* @version $Revision: 1.2 $
   **/
   public class RemoteAttribute
       extends RemoteFeature
  @@ -43,46 +45,13 @@
       // Constants -----------------------------------------------------
       
       // Attributes ----------------------------------------------------
  -     private JMXConnector mConnector;
  -    private ObjectInstance mService;
  -     private MBeanAttributeInfo mInfo;
       
  -    private Customizer c;
  -     private JComponent mViewer;
  -    
       // Static --------------------------------------------------------
       
       // Constructors --------------------------------------------------
       
       // Public --------------------------------------------------------
  -    public void setReference( JMXConnector pConnector, ObjectInstance pReference, 
MBeanAttributeInfo pInfo ) {
  -             mConnector = pConnector;
  -        mService = pReference;
  -             mInfo = pInfo;
  -    }
  -     
  -     public MBeanAttributeInfo getInfo() {
  -             return mInfo;
  -     }
  -
  -    public String toString() {
  -        return ( mInfo == null ? "" : mInfo.getName() );
  -    }
   
  -    public Iterator iterator() {
  -        return Util.sortByClass( super.iterator() );
  -    }
  -
  -    // BeanContextContainerProxy implementation -----------------
  -    public Component getComponent() {
  -             if( mViewer == null ) {
  -                     mViewer = new JScrollPane(
  -                             new Viewer()
  -                     );
  -             }
  -             return mViewer;
  -    }
  -    
        // Package protected ---------------------------------------------
        
        // Protected -----------------------------------------------------
  @@ -90,35 +59,4 @@
        // Private -------------------------------------------------------
        
        // Inner classes -------------------------------------------------
  -     public class Viewer
  -             extends JPanel
  -     {
  -             public Viewer() {
  -                     setLayout( new GridLayout( 0, 2 ) );
  -                     try {
  -                             add(
  -                                     new JLabel(
  -                                             mInfo.getName()
  -                                     )
  -                             );
  -                             add(
  -                                     new JLabel(
  -                                             mInfo.getDescription()
  -                                     )
  -                             );
  -                             add(
  -                                     new JLabel(
  -                                             mConnector.getAttribute(
  -                                                     mService.getObjectName(),
  -                                                     mInfo.getName()
  -                                             ) + ""
  -                                     )
  -                             );
  -                     }
  -                     catch( Exception e ) {
  -                             e.printStackTrace();
  -                     }
  -             }
  -     }
  -
   }
  
  
  
  1.2       +79 -2     
ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteFeature.java
  
  Index: RemoteFeature.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteFeature.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RemoteFeature.java        2000/11/23 20:56:14     1.1
  +++ RemoteFeature.java        2000/11/24 07:51:42     1.2
  @@ -13,34 +13,79 @@
   import java.util.*;
   import java.lang.reflect.*;
   
  +import javax.management.MBeanInfo;
  +import javax.management.MBeanAttributeInfo;
  +import javax.management.MBeanFeatureInfo;
  +import javax.management.MBeanNotificationInfo;
  +import javax.management.MBeanOperationInfo;
  +import javax.management.ObjectInstance;
  +import javax.management.ObjectName;
  +
  +import javax.swing.JComponent;
  +import javax.swing.JLabel;
  +import javax.swing.JPanel;
  +import javax.swing.JScrollPane;
  +import javax.swing.JTextField;
  +
   import com.dreambean.awt.BeanContextViewer;
   import com.dreambean.awt.GenericCustomizer;
  -
   import com.dreambean.ejx.Util;
   
  +import org.jboss.jmx.interfaces.JMXConnector;
  +
   /**
   *   <description> 
   *      
   * @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad" Schaefer</A>
  -* @version $Revision: 1.1 $
  +* @version $Revision: 1.2 $
   **/
  -public abstract class RemoteFeature
  +public class RemoteFeature
       extends BeanContextSupport
       implements BeanContextChildComponentProxy
   {
       // Constants -----------------------------------------------------
       
       // Attributes ----------------------------------------------------
  +     private JMXConnector mConnector;
  +    private ObjectInstance mService;
  +     private MBeanFeatureInfo mInfo;
  +    
  +    private Customizer c;
  +     private JComponent mViewer;
       
       // Static --------------------------------------------------------
       
       // Constructors --------------------------------------------------
       
       // Public --------------------------------------------------------
  +    public void setReference( JMXConnector pConnector, ObjectInstance pReference, 
MBeanFeatureInfo pInfo ) {
  +             mConnector = pConnector;
  +        mService = pReference;
  +             mInfo = pInfo;
  +    }
  +     
  +     public MBeanFeatureInfo getInfo() {
  +             return mInfo;
  +     }
  +
  +    public String toString() {
  +        return ( mInfo == null ? "" : mInfo.getName() );
  +    }
  +
       public Iterator iterator() {
           return Util.sortByClass( super.iterator() );
       }
   
  +    // BeanContextContainerProxy implementation -----------------
  +    public Component getComponent() {
  +             if( mViewer == null ) {
  +                     mViewer = new JScrollPane(
  +                             new Viewer()
  +                     );
  +             }
  +             return mViewer;
  +    }
  +    
        // Package protected ---------------------------------------------
        
        // Protected -----------------------------------------------------
  @@ -48,4 +93,36 @@
        // Private -------------------------------------------------------
        
        // Inner classes -------------------------------------------------
  +     public class Viewer
  +             extends JPanel
  +     {
  +             public Viewer() {
  +                     setLayout( new GridLayout( 0, 2 ) );
  +                     try {
  +                             add(
  +                                     new JLabel(
  +                                             mInfo.getName()
  +                                     )
  +                             );
  +                             add(
  +                                     new JLabel(
  +                                             mInfo.getDescription()
  +                                     )
  +                             );
  +                             if( mInfo instanceof MBeanAttributeInfo ) {
  +                                     add(
  +                                             new JLabel(
  +                                                     mConnector.getAttribute(
  +                                                             
mService.getObjectName(),
  +                                                             mInfo.getName()
  +                                                     ) + ""
  +                                             )
  +                                     );
  +                             }
  +                     }
  +                     catch( Exception e ) {
  +                             e.printStackTrace();
  +                     }
  +             }
  +     }
   }
  
  
  
  1.3       +89 -114   
ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteResource.java
  
  Index: RemoteResource.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteResource.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RemoteResource.java       2000/11/23 20:56:14     1.2
  +++ RemoteResource.java       2000/11/24 07:51:43     1.3
  @@ -15,6 +15,8 @@
   
   import javax.management.MBeanInfo;
   import javax.management.MBeanAttributeInfo;
  +import javax.management.MBeanFeatureInfo;
  +import javax.management.MBeanNotificationInfo;
   import javax.management.MBeanOperationInfo;
   import javax.management.ObjectInstance;
   import javax.management.ObjectName;
  @@ -35,7 +37,7 @@
   *   <description> 
   *      
   * @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad" Schaefer</A>
  -* @version $Revision: 1.2 $
  +* @version $Revision: 1.3 $
   **/
   public class RemoteResource
       extends BeanContextSupport
  @@ -49,6 +51,9 @@
       
       private Customizer c;
        private JComponent mViewer;
  +     
  +     private ObjectName mName;
  +     private String mDescription;
       
       // Static --------------------------------------------------------
       
  @@ -59,56 +64,70 @@
                mConnector = pConnector;
           mService = pReference;
                try {
  +                     mName = mService.getObjectName();
                        MBeanInfo lBean = mConnector.getMBeanInfo(
  -                             mService.getObjectName()
  +                             mName
                        );
  +                     mDescription = lBean.getDescription();
                        MBeanAttributeInfo[] lAttributes = lBean.getAttributes();
                        for( int i = 0; i < lAttributes.length; i++ ) {
  -                             createAttribute( lAttributes[ i ] );
  +                             createFeature( lAttributes[ i ] );
  +                     }
  +                     MBeanOperationInfo[] lOperations = lBean.getOperations();
  +                     for( int i = 0; i < lOperations.length; i++ ) {
  +                             createFeature( lOperations[ i ] );
                        }
  +                     MBeanNotificationInfo[] lNotifications = 
lBean.getNotifications();
  +                     for( int i = 0; i < lNotifications.length; i++ ) {
  +                             createFeature( lNotifications[ i ] );
  +                     }
                }
                catch( Exception e ) {
                        e.printStackTrace();
                }
       }
   
  +     public ObjectName getResourceName() {
  +             return mName;
  +     }
  +     
  +     public String getDescription() {
  +             return mDescription;
  +     }
  +     
       public String toString() {
  -        return ( mService == null ? "" : mService.getObjectName().toString() );
  +        return getResourceName() + "";
       }
       
  -    /* AS ??
  -    public EnterpriseBean getEjb(String name)
  -     {
  -             Iterator enum = super.iterator();
  -             while(enum.hasNext())
  -             {
  -                     EnterpriseBean ejb = (EnterpriseBean)enum.next();
  -                     if (ejb.getEjbName().equals(name))
  -                             return ejb;
  -             }
  -             throw new IllegalArgumentException("No such bean");
  -     }
  -*/
  -    
  -    public void createAttribute( MBeanAttributeInfo pFeature )
  +    public void createFeature( MBeanFeatureInfo pFeature )
           throws IOException, ClassNotFoundException
       {
           System.out.println( "Create new Feature: " + pFeature.getName() );
  -        addAttribute().setReference( mConnector, mService, pFeature );
  +             String lFeature = "org.jboss.jBossAdmin.RemoteFeature";
  +             if( pFeature instanceof MBeanAttributeInfo ) {
  +                             lFeature = "org.jboss.jBossAdmin.RemoteAttribute";
  +             }
  +             else if( pFeature instanceof MBeanOperationInfo ) {
  +                             lFeature = "org.jboss.jBossAdmin.RemoteOperation";
  +             }
  +             else if( pFeature instanceof MBeanNotificationInfo ) {
  +                             lFeature = "org.jboss.jBossAdmin.RemoteNotification";
  +             }
  +        addFeature( lFeature ).setReference( mConnector, mService, pFeature );
       }
   
  -    public RemoteAttribute addAttribute()
  +    public RemoteFeature addFeature( String pClass )
           throws IOException, ClassNotFoundException
       {
  -        return (RemoteAttribute) instantiateChild( 
"org.jboss.jBossAdmin.RemoteAttribute" );
  +        return (RemoteFeature) instantiateChild( pClass );
       }
   
       public Iterator iterator() {
           return Util.sortByClass( super.iterator() );
       }
       
  -    public Iterator getAttributes() {
  -        return Util.getChildrenByClass( super.iterator(), RemoteAttribute.class );
  +    public Iterator getFeatures() {
  +        return Util.getChildrenByClass( super.iterator(), RemoteFeature.class );
       }
       
      /**
  @@ -116,54 +135,6 @@
       *
       */
   /* AS ??
  -    public void findCMPFields(String idName)
  -   {
  -      Iterator entities = getEntities();
  -      while (entities.hasNext())
  -      {
  -         Entity entity = (Entity)entities.next();
  -         
  -         // Check if container-managed
  -         if (entity.getPersistenceType().equals("Bean"))
  -            continue;
  -         
  -         // Build comma-separated list of current fields prefixed with "," and 
suffixed with ","
  -         Iterator currentFields = entity.getCMPFields();
  -         String list = ",";
  -         while(currentFields.hasNext())
  -         {
  -            list += ((CMPField)currentFields.next()).getFieldName() + ",";
  -         }
  -         
  -         ClassLoader cl = 
((EjbResourceManager)getBeanContext().getBeanContext()).getClassLoader();
  -         try
  -         {
  -            Class clazz = cl.loadClass(entity.getEjbClass());
  -            Field[] fields = clazz.getFields();
  -            for (int i = 0; i < fields.length; i++)
  -            {
  -               String fieldName = fields[i].getName();
  -               
  -               // Check so that it doesn't exist yet - we don't want duplicates
  -               if (list.indexOf(","+fieldName+",") == -1)
  -                  entity.createCMPField(fieldName);
  -               
  -               // Check for id-field
  -               if (fieldName.equals(idName) && 
entity.getPrimaryKeyField().equals(""))
  -               {
  -                  entity.setPrimaryKeyField(idName);
  -                  entity.setPrimaryKeyClass(fields[i].getType().getName());
  -               }
  -            }
  -         } catch (Throwable e)
  -         {
  -            e.printStackTrace();
  -         }
  -         
  -      }
  -      
  -   }
  -   
      public void addEnvironmentEntry(String name, String type, String value)
         throws Exception
      {
  @@ -240,55 +211,59 @@
                public Viewer() {
                        setLayout( new GridLayout( 0, 2 ) );
                        try {
  -                             MBeanInfo lBean = mConnector.getMBeanInfo(
  -                                     mService.getObjectName()
  -                             );
  -                             Iterator k = getAttributes();
  +                             add( new JLabel( "Name" ) );
  +                             add( new JLabel( getResourceName() + "" ) );
  +                             add( new JLabel( "Description" ) );
  +                             add( new JLabel( getDescription() ) );
  +                             Iterator k = getFeatures();
                                while( k.hasNext() ) {
  -                                     MBeanAttributeInfo lAttribute = ( 
(RemoteAttribute) k.next() ).getInfo();
  -                                     add( new JLabel( lAttribute.getName() ) );
  -                                     if( lAttribute.isReadable() ) {
  -                                             if( lAttribute.isWritable() ) {
  -                                                     add(
  -                                                             new JTextField(
  -                                                                     
mConnector.getAttribute(
  -                                                                             
mService.getObjectName(),
  -                                                                             
lAttribute.getName()
  -                                                                     ) + ""
  -                                                             )
  -                                                     );
  +                                     MBeanFeatureInfo lFeature = ( (RemoteFeature) 
k.next() ).getInfo();
  +                                     if( lFeature instanceof MBeanAttributeInfo ) {
  +                                             MBeanAttributeInfo lAttribute = 
(MBeanAttributeInfo) lFeature;
  +                                             add( new JLabel( lAttribute.getName() 
) );
  +                                             if( lAttribute.isReadable() ) {
  +                                                     if( lAttribute.isWritable() ) {
  +                                                             add(
  +                                                                     new JTextField(
  +                                                                             
mConnector.getAttribute(
  +                                                                                    
 mService.getObjectName(),
  +                                                                                    
 lAttribute.getName()
  +                                                                             ) + ""
  +                                                                     )
  +                                                             );
  +                                                     }
  +                                                     else {
  +                                                             add(
  +                                                                     new JLabel(
  +                                                                             
mConnector.getAttribute(
  +                                                                                    
 mService.getObjectName(),
  +                                                                                    
 lAttribute.getName()
  +                                                                             ) + ""
  +                                                                     )
  +                                                             );
  +                                                     }
                                                }
                                                else {
  -                                                     add(
  -                                                             new JLabel(
  -                                                                     
mConnector.getAttribute(
  -                                                                             
mService.getObjectName(),
  -                                                                             
lAttribute.getName()
  -                                                                     ) + ""
  -                                                             )
  -                                                     );
  +                                                     if( lAttribute.isWritable() ) {
  +                                                             add(
  +                                                                     new 
JTextField( "" )
  +                                                             );
  +                                                     }
                                                }
                                        }
  -                                     else {
  -                                             if( lAttribute.isWritable() ) {
  -                                                     add(
  -                                                             new JTextField( "" )
  -                                                     );
  -                                             }
  +                                     else if( lFeature instanceof 
MBeanOperationInfo ) {
  +                                             MBeanOperationInfo lOperation = 
(MBeanOperationInfo) lFeature;
  +                                             add(
  +                                                     new JLabel(
  +                                                             lOperation.getName()
  +                                                     )
  +                                             );
  +                                             add(
  +                                                     new JLabel(
  +                                                             
lOperation.getDescription()
  +                                                     )
  +                                             );
                                        }
  -                             }
  -                             MBeanOperationInfo[] lOperations = 
lBean.getOperations();
  -                             for( int i = 0; i < lOperations.length; i++ ) {
  -                                     add(
  -                                             new JLabel(
  -                                                     lOperations[ i ].getName()
  -                                             )
  -                                     );
  -                                     add(
  -                                             new JLabel(
  -                                                     lOperations[ i 
].getDescription()
  -                                             )
  -                                     );
                                }
                        }
                        catch( Exception e ) {
  
  
  
  1.3       +0 -0      
ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteServer.java
  
  Index: RemoteServer.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteServer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RemoteServer.java 2000/11/23 20:56:14     1.2
  +++ RemoteServer.java 2000/11/24 07:51:43     1.3
  @@ -24,7 +24,7 @@
   *   <description> 
   *      
   * @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad" Schaefer</A>
  -* @version $Revision: 1.2 $
  +* @version $Revision: 1.3 $
   **/
   public class RemoteServer
       extends BeanContextSupport
  
  
  
  1.1                  
ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteNotification.java
  
  Index: RemoteNotification.java
  ===================================================================
  /*
   * jBoss, the OpenSource EJB server
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.jBossAdmin;
  
  import java.awt.*;
  import java.beans.*;
  import java.beans.beancontext.*;
  import java.io.*;
  import java.util.*;
  import java.lang.reflect.*;
  
  import javax.management.MBeanInfo;
  import javax.management.MBeanAttributeInfo;
  import javax.management.MBeanFeatureInfo;
  import javax.management.MBeanNotificationInfo;
  import javax.management.MBeanOperationInfo;
  import javax.management.ObjectInstance;
  import javax.management.ObjectName;
  
  import javax.swing.JComponent;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JTextField;
  
  import com.dreambean.awt.BeanContextViewer;
  import com.dreambean.awt.GenericCustomizer;
  import com.dreambean.ejx.Util;
  
  import org.jboss.jmx.interfaces.JMXConnector;
  
  /**
  *   <description> 
  *      
  * @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad" Schaefer</A>
  * @version $Revision: 1.1 $
  **/
  public class RemoteNotification
      extends RemoteFeature
  {
      // Constants -----------------------------------------------------
      
      // Attributes ----------------------------------------------------
      
      // Static --------------------------------------------------------
      
      // Constructors --------------------------------------------------
      
      // Public --------------------------------------------------------
  
        // Package protected ---------------------------------------------
        
        // Protected -----------------------------------------------------
        
        // Private -------------------------------------------------------
        
        // Inner classes -------------------------------------------------
  }
  
  
  
  1.1                  
ejx/examples/jboss.admin/src/org/jboss/jBossAdmin/RemoteOperation.java
  
  Index: RemoteOperation.java
  ===================================================================
  /*
   * jBoss, the OpenSource EJB server
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.jBossAdmin;
  
  import java.awt.*;
  import java.beans.*;
  import java.beans.beancontext.*;
  import java.io.*;
  import java.util.*;
  import java.lang.reflect.*;
  
  import javax.management.MBeanInfo;
  import javax.management.MBeanAttributeInfo;
  import javax.management.MBeanFeatureInfo;
  import javax.management.MBeanNotificationInfo;
  import javax.management.MBeanOperationInfo;
  import javax.management.ObjectInstance;
  import javax.management.ObjectName;
  
  import javax.swing.JComponent;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JTextField;
  
  import com.dreambean.awt.BeanContextViewer;
  import com.dreambean.awt.GenericCustomizer;
  import com.dreambean.ejx.Util;
  
  import org.jboss.jmx.interfaces.JMXConnector;
  
  /**
  *   <description> 
  *      
  * @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad" Schaefer</A>
  * @version $Revision: 1.1 $
  **/
  public class RemoteOperation
      extends RemoteFeature
  {
      // Constants -----------------------------------------------------
      
      // Attributes ----------------------------------------------------
      
      // Static --------------------------------------------------------
      
      // Constructors --------------------------------------------------
      
      // Public --------------------------------------------------------
  
        // Package protected ---------------------------------------------
        
        // Protected -----------------------------------------------------
        
        // Private -------------------------------------------------------
        
        // Inner classes -------------------------------------------------
  }
  
  
  

Reply via email to