Hi Geeks

Sometimes you really have to squeeze your brain to get a clear view. Now I
came up with this ideas on JMX Connectors:

- JMXConnector: defines a set of methods for both the client as well as the
  server side because both offer the same set of methods. This connector
  does not rely on a specific protocol.

- JMXClientConnector: add the client specific methods to initialize and shut
  down the connection (the server side must always be available otherwise
  the client cannot connect to (even when they are loaded or removed
  dynamically on the server side))

- ConnectorFactoryMBean: Convenience MBean to allow dynamic lookup and
  selection of a Server/Protocol or short a Connector.

- Protocol dependent implementation (whatever is necessary)

During the last days I was struggling with the design of the notification
listener
within this connector. I was not sure if the notification listener should 1)
use the
existing connector or if 2) it should be on its own and the connector only
allows
these listener to manage.
The 1) has the advantage to tunnel all the traffic through the connector and
can
be easy managed within the connector but on the other side it is only
available
as long as the connection is up and running.
2) has the advantage that the listener connection survives the connector,
that
it does not have to use the same protocol but it is harder to manage and
needs
a separate set of classes.
What do you think?

BTW, can someone give me a hint how the callback from the MBean listener
on the server side to the client side MBean listener works with RMI, thanx.

Here the java code it wrote up to now:

------------------------- JMXConnector Interface
-----------------------------------------------------

import javax.management.Attribute;
import javax.management.ObjectName;
import javax.management.QueryExp;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.InvalidAttributeValueException;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanException;
import javax.management.ReflectionException;

/**
* JMX Connector for a remote JMX maangement
*
* @author          Andreas "Mad" Schaefer ([EMAIL PROTECTED])
**/
public interface JMXConnector {

        // Constants -----------------------------------------------------
        
        // Static --------------------------------------------------------

        // Public --------------------------------------------------------
        /**
        * Invokes a method on the given MBean with the given parameters
        *
        * @param pName                    Object name of the target MBean
        * @param pActionName            Name of the action to be performed
        * @param pParams                        List of parameters of the
target method
        * @param pSignatures            List of parameter signatures to the
given
        *                                                  list of
parameters. This list has to have
        *                                                  the same number
of elements like pParams
        *                                                  and each element
should have a name of
        *                                                  a class (full
path) of the related parameter
        *
        * @return                                  Returned object or null
if the method is void
        *
        * @throws InstanceNotFoundException
        *                                                  Instance of the
MBean not found
        * @throws MBeanException        MBean excpetion
        * @throws ReflectionException
                                                                If the given
method with the given parameters
                                                                are not
found
        **/
        public Object invoke(
                ObjectName pName,
                String pActionName,
                Object[] pParams,
                String[] pSignatures
        ) throws InstanceNotFoundException,
                MBeanException,
                ReflectionException;

        /**
        * Query for a list of manageable beans (MBeans) accessible by
        * this connector and filtered by the given query expression
        *
        * @param pName                    ??
        * @param pQuery                  Query expression
        *
        * @return                                  A set of Object Names for
each
        *                                                  MBean found. It
always return
        *                                                  an object but it
can be empty.
        **/
        public Set queryMBeans(
                ObjectName pName,
                QueryExp pQuery
        );
        
        /**
        * Returns a collection of manageable bean infos accessible by
        * this connector
        *
        * @return                                  A collection of MBean
Infos. It is
        *                                                  always an object
returned by it can
        *                                                  be empty.
        **/
        public Collection getMBeanInfos();
        
        /**
        * Sets an attribute for the given manageable bean (MBean)
        *
        * @param pName                    Object name of the target MBean
        * @param pAttribute              Attribute object to be set
        *
        * @throws InstanceNotFoundException
        *                                                  Instance of the
MBean not found
        * @throws AttributeNotFoundException
        *                                                  Attribute not
found or is not writable
        * @throws InvalidAttributeValueException
        *                                                  Attribute
violates the attribute constraints
        * @throws MBeanException        MBean Exception (??)
        * @throws ReflectionException
        *                                                  General
Reflection Exception (??)
        **/
        public void setAttribute(
                ObjectName pName,
                Attribute pAttribute
        ) throws InstanceNotFoundException,
                AttributeNotFoundException,
                InvalidAttributeValueException,
                MBeanException,
                ReflectionException;
                                 
        /**
        * Returns the attribute of the given manageable bean (MBean) and
        * the given attribute name
        *
        * @param pName                    Object name of the target MBean
        * @param pAttributeName  Name of the attribute
        *
        * @return                                  Object value of the given
attribute
        *
        * @throws InstanceNotFoundException
        *                                                  Instance of the
MBean not found
        * @throws AttributeNotFoundException
        *                                                  Attribute not
found or is not writable
        * @throws InvalidAttributeValueException
        *                                                  Attribute
violates the attribute constraints
        * @throws MBeanException        MBean Exception (??)
        * @throws ReflectionException
        *                                                  General
Reflection Exception (??)
        **/
        public Object getAttribute(
                ObjectName pName,
                String pAttributeName
        ) throws MBeanException,
                AttributeNotFoundException,
                InstanceNotFoundException,
                ReflectionException;
        
        /* AS 8/ 8/00
        * Also the methods set/getAttributes() where instead of the
Attribute
        * we have an array of Attributes or a an array of Attribute names
        */
        
        /**
        * Register the given notification listener at the given manageable
        * bean (MBean)
        *
        * @param pName                    Object name of the target MBean
        * @param pListener                Notification listener to be added
        
        * @throws InstanceNotFoundException
        *                                                  Instance of the
MBean not found
        * @throws InvalidArgumentException
        *                                                  Given listener is
null
        */
        public void addNoficationListener (
                ObjectName  pName,
                NotificationListener pListener
        ) throws InstanceNotFoundException,
                IllegalArgumentException;

        /**
        * Unregister the given notification listener at the given manageable
        * bean (MBean)
        *
        * @param pName                    Object name of the target MBean
        * @param pListener                Notification listener to be added
        
        * @throws InstanceNotFoundException
        *                                                  Instance of the
MBean not found
        * @throws ListenerNotFoundException
        *                                                  Given listener is
not found
        */
        public void removeNoficationListener (
                ObjectName  pName,
                NotificationListener pListener
        ) throws InstanceNotFoundException,
                ListenerNotFoundException;
}
------------------------- End of JMXConnector Interface
-----------------------------------------------------

------------------------- JMXClientConnector Interface
-----------------------------------------------------
/**
* Client Side JMX Connector to be used in conjunction with
* a server/protocol selector
*
* @author          Andreas "Mad" Schaefer ([EMAIL PROTECTED])
**/
public interface JMXClientConnector extends JMXConnector {

        // Constants -----------------------------------------------------

        // Static --------------------------------------------------------

        // Public --------------------------------------------------------
        /**
        * Initialize the client connector to a given server side JMX
        * Connector
        *
        * @param pServer                                        Server
indentification (because
        *
I do not know the necessary type
        *
for a general server ident. I
        *
choose Object)
        *
        * @throws IllegalArgumentException      If the given server is not
valid
        *
or not recognized by the connector
        *
implementation
        */
        public void start(
                Object pServer
        ) throws IllegalArgumentException;
        /**
        * Stops the client connector, remove the remote connection and frees
        * the resources.
        */
        public void stop();
        /**
        * Indicates if the connection is alive and ready to serve
        *
        * @return                                                       True
if the connection is alive
        */
        public boolean isAlive();
}
------------------------- End of JMXClientConnector Interface
-----------------------------------------------------

------------------------- ConnectorFactoryMBean Class
-----------------------------------------------------
import javax.management.DynamicMBean;

/**
* Factory delivering a list of servers and its available protocol connectors
* and after selected to initiate the connection
*
* This is just the (incomplete) interface of it
*
* @author          Andreas "Mad" Schaefer ([EMAIL PROTECTED])
**/
public class ConnectorFactoryMBean exends DynamicMBean {

        // Constants -----------------------------------------------------
        
        // Static --------------------------------------------------------

        // Public --------------------------------------------------------
        /**
        * Returns a list of available servers
        *
        * @param pServerQuery           Query instance to filter the list of
servers
        *
        * @return                                       A collection of
available servers
        *
names/identifications (String)
        */
        public Collection getServers(
                ServerQuery pServerQuery
        );
        
        /**
        * Returns a list of available protocols (connectors)
        *
        * @param pServer                        Server name/identification
to look up
        *
        * @return                                       A collection of
available protocols (String)
        */
        public Collection getProtocols(
                String pServer
        );

        /**
        * Initiate a connection to the given server with the given
        * protocol
        *
        * @param pServer                        Server name/identification
to connect to
        * @param pProtocol                      Protocol to use
        */
        public void createConnection(
                String pServer,
                String pProtocol
        );
        
        /**
        * Removes the given connection and frees the resources
        *
        * @param pSever                         Server name/identification
of the connectino
        * @param pProtocol                      Protocol used
        */
        public void removeConnection(
                String pServer,
                String pProtocol
        );
}
------------------------- End of ConnectorFactoryMBean Class
-----------------------------------------------------

Have fun
Mad Andy

Reply via email to