org.jmx4odp.dynamicManagement
Class RemoteObjectFetcher

java.lang.Object
  extended by org.jmx4odp.dynamicManagement.RemoteObjectFetcher

public class RemoteObjectFetcher
extends java.lang.Object

This object retrieves remote objects from a registry. It can be used to either retreive the object stored in the registry, or the EJB created from the object if it is the HomeInterface.

Author:
Lucas McGregor

Constructor Summary
RemoteObjectFetcher()
          Creates a new instance of RemoteObjectFetcher
 
Method Summary
 java.lang.Class checkForEjb(java.lang.Object obj)
          Check the object to see if it's class name ends in "Home".
 java.lang.Object createEjb(java.lang.Object homeObject, java.lang.Class remoteInterface)
          Use the RemoteInterface to find the homeInterface (RemoteInterface.getName() + "Home") and then use the HomeInterface's class definition to invoke the create() method on the HomeObject to return the EJB remote interface.
 java.lang.Object createEjb(java.lang.Object homeObject, java.lang.Class remoteInterface, java.lang.Object[] args)
          Use the RemoteInterface to find the homeInterface (RemoteInterface.getName() + "Home") and then use the HomeInterface's class definition to invoke the create() method on the HomeObject to return the EJB remote interface.
 java.lang.Object createEjb(java.lang.Object homeObject, java.lang.String remoteInterface)
          Use the RemoteInterface to find the homeInterface (RemoteInterface.getName() + "Home") and then use the HomeInterface's class definition to invoke the create() method on the HomeObject to return the EJB remote interface.
 java.lang.Object fetchEjb(java.lang.String jndiName, java.lang.String url, java.lang.String remoteInterface)
          This is a shortcut method.
 javax.management.Descriptor[] fetchJndiTree()
          This method will use the InitialContext to locate a registry.
 javax.management.Descriptor[] fetchJndiTree(javax.naming.InitialContext initCtx)
          Use the supplied InitialContext to locate a registry.
 javax.management.Descriptor[] fetchJndiTree(java.lang.String providerUrl)
          This method will use the InitialContext updated with the supplied PROVIDER_URL to locate a registry.
 java.lang.Object fetchObject(java.lang.String jndiName)
          Use the InitialContext to lookup the object with the jndiName
 java.lang.Object fetchObject(java.lang.String jndiName, javax.naming.InitialContext ic)
          Use the following InitialContext and JndiName to lookup an object
 java.lang.Object fetchObject(java.lang.String jndiName, java.lang.String url)
          Update the InitialContext with the following url as the PROVIDER_URL and lookup the object with jndiName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemoteObjectFetcher

public RemoteObjectFetcher()
Creates a new instance of RemoteObjectFetcher

Method Detail

fetchObject

public java.lang.Object fetchObject(java.lang.String jndiName)
                             throws javax.naming.NamingException,
                                    javax.naming.NameNotFoundException,
                                    javax.naming.ServiceUnavailableException,
                                    java.rmi.RemoteException
Use the InitialContext to lookup the object with the jndiName

Throws:
javax.naming.NamingException
javax.naming.NameNotFoundException
javax.naming.ServiceUnavailableException
java.rmi.RemoteException

fetchObject

public java.lang.Object fetchObject(java.lang.String jndiName,
                                    java.lang.String url)
                             throws javax.naming.NamingException,
                                    javax.naming.NameNotFoundException,
                                    javax.naming.ServiceUnavailableException,
                                    java.rmi.RemoteException
Update the InitialContext with the following url as the PROVIDER_URL and lookup the object with jndiName.

Throws:
javax.naming.NamingException
javax.naming.NameNotFoundException
javax.naming.ServiceUnavailableException
java.rmi.RemoteException

fetchObject

public java.lang.Object fetchObject(java.lang.String jndiName,
                                    javax.naming.InitialContext ic)
                             throws javax.naming.NamingException,
                                    javax.naming.NameNotFoundException,
                                    javax.naming.ServiceUnavailableException,
                                    java.rmi.RemoteException
Use the following InitialContext and JndiName to lookup an object

Throws:
javax.naming.NamingException
javax.naming.NameNotFoundException
javax.naming.ServiceUnavailableException
java.rmi.RemoteException

createEjb

public java.lang.Object createEjb(java.lang.Object homeObject,
                                  java.lang.String remoteInterface)
                           throws java.lang.IllegalAccessException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.reflect.InvocationTargetException,
                                  java.lang.NoSuchMethodException,
                                  java.lang.SecurityException,
                                  java.lang.ClassNotFoundException
Use the RemoteInterface to find the homeInterface (RemoteInterface.getName() + "Home") and then use the HomeInterface's class definition to invoke the create() method on the HomeObject to return the EJB remote interface.

Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.ClassNotFoundException

createEjb

public java.lang.Object createEjb(java.lang.Object homeObject,
                                  java.lang.Class remoteInterface)
                           throws java.lang.IllegalAccessException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.reflect.InvocationTargetException,
                                  java.lang.NoSuchMethodException,
                                  java.lang.SecurityException,
                                  java.lang.ClassNotFoundException
Use the RemoteInterface to find the homeInterface (RemoteInterface.getName() + "Home") and then use the HomeInterface's class definition to invoke the create() method on the HomeObject to return the EJB remote interface.

Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.ClassNotFoundException

createEjb

public java.lang.Object createEjb(java.lang.Object homeObject,
                                  java.lang.Class remoteInterface,
                                  java.lang.Object[] args)
                           throws java.lang.IllegalAccessException,
                                  java.lang.IllegalArgumentException,
                                  java.lang.reflect.InvocationTargetException,
                                  java.lang.NoSuchMethodException,
                                  java.lang.SecurityException,
                                  java.lang.ClassNotFoundException
Use the RemoteInterface to find the homeInterface (RemoteInterface.getName() + "Home") and then use the HomeInterface's class definition to invoke the create() method on the HomeObject to return the EJB remote interface. If the args array is not null, then it will use these args as parameters for the create method. Else, it will assume that the create method takes no parameters.

Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.ClassNotFoundException

fetchJndiTree

public javax.management.Descriptor[] fetchJndiTree()
                                            throws java.lang.IllegalAccessException,
                                                   java.lang.IllegalArgumentException,
                                                   java.lang.reflect.InvocationTargetException,
                                                   java.lang.NoSuchMethodException,
                                                   java.lang.SecurityException,
                                                   java.lang.ClassNotFoundException,
                                                   javax.naming.NamingException,
                                                   javax.naming.NameNotFoundException,
                                                   javax.naming.ServiceUnavailableException,
                                                   java.rmi.RemoteException
This method will use the InitialContext to locate a registry. It will get each remote object from the regsirty result an array of Descriptor objects, one for each remote object in the registry. The Descriptor has the following fields:

Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.ClassNotFoundException
javax.naming.NamingException
javax.naming.NameNotFoundException
javax.naming.ServiceUnavailableException
java.rmi.RemoteException

fetchJndiTree

public javax.management.Descriptor[] fetchJndiTree(java.lang.String providerUrl)
                                            throws java.lang.IllegalAccessException,
                                                   java.lang.IllegalArgumentException,
                                                   java.lang.reflect.InvocationTargetException,
                                                   java.lang.NoSuchMethodException,
                                                   java.lang.SecurityException,
                                                   java.lang.ClassNotFoundException,
                                                   javax.naming.NamingException,
                                                   javax.naming.NameNotFoundException,
                                                   javax.naming.ServiceUnavailableException,
                                                   java.rmi.RemoteException
This method will use the InitialContext updated with the supplied PROVIDER_URL to locate a registry. It will get each remote object from the regsirty result an array of Descriptor objects, one for each remote object in the registry. The Descriptor has the following fields:

Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.ClassNotFoundException
javax.naming.NamingException
javax.naming.NameNotFoundException
javax.naming.ServiceUnavailableException
java.rmi.RemoteException

fetchJndiTree

public javax.management.Descriptor[] fetchJndiTree(javax.naming.InitialContext initCtx)
                                            throws java.lang.IllegalAccessException,
                                                   java.lang.IllegalArgumentException,
                                                   java.lang.reflect.InvocationTargetException,
                                                   java.lang.NoSuchMethodException,
                                                   java.lang.SecurityException,
                                                   java.lang.ClassNotFoundException,
                                                   javax.naming.NamingException,
                                                   javax.naming.NameNotFoundException,
                                                   javax.naming.ServiceUnavailableException,
                                                   java.rmi.RemoteException
Use the supplied InitialContext to locate a registry. It will get each remote object from the regsirty result an array of Descriptor objects, one for each remote object in the registry. The Descriptor has the following fields:

Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.ClassNotFoundException
javax.naming.NamingException
javax.naming.NameNotFoundException
javax.naming.ServiceUnavailableException
java.rmi.RemoteException

fetchEjb

public java.lang.Object fetchEjb(java.lang.String jndiName,
                                 java.lang.String url,
                                 java.lang.String remoteInterface)
                          throws java.lang.IllegalAccessException,
                                 java.lang.IllegalArgumentException,
                                 java.lang.reflect.InvocationTargetException,
                                 java.lang.NoSuchMethodException,
                                 java.lang.SecurityException,
                                 java.lang.ClassNotFoundException,
                                 javax.naming.NamingException,
                                 javax.naming.NameNotFoundException,
                                 javax.naming.ServiceUnavailableException,
                                 java.rmi.RemoteException
This is a shortcut method. It is the equivalent of calling:
createEjb(fetchObject(jndiName, url), remoteInterface)

Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException
java.lang.SecurityException
java.lang.ClassNotFoundException
javax.naming.NamingException
javax.naming.NameNotFoundException
javax.naming.ServiceUnavailableException
java.rmi.RemoteException

checkForEjb

public java.lang.Class checkForEjb(java.lang.Object obj)
Check the object to see if it's class name ends in "Home". If so check to see if the object has a create method that returns the RemoteInterface (class name - "Home"). If so, then invoke this method and return the RemoteObject, else return a null object.