Overview | Package | Class | Tree | Deprecated | Index | Help
| Compoze Software, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.compoze.util
Class ServiceRegistry

    java.lang.Object
      com.compoze.util.ServiceRegistry

All Implemented Interfaces:
  java.io.Serializable

public class ServiceRegistry
extends java.lang.Object
implements java.io.Serializable

This class is a generic registry of interfaces that are used to provide services. It maps interfaces to the classes that implement them. By switching the implementing class of a given interface in the registry the runtime behavior of the code may be customized. It can be used to allow for "pluggable" implementations of an interface, configurable at runtime by a passed in Properties object.

See Also:
  Serialized Form

Constructor Summary
`ServiceRegistry(java.util.Properties props)` Constructor.

Method Summary
`java.lang.Class` | `get(java.lang.Class interfaceClass)` Get the implementing class of the specified interface.
`java.lang.Class` | `get(java.lang.Class interfaceClass, java.lang.ClassLoader classLoader)` Get the implementing class of the specified interface.
`java.lang.Object` | `getInstance(java.lang.Class interfaceClass)` Create an instance of the implementor of the specified interface using its default constructor.
`java.lang.Object` | `getInstance(java.lang.Class interfaceClass, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs)` Create an instance of the implementor of the specified interface using the specified constructor.
`java.lang.Object` | `getInstance(java.lang.Class interfaceClass, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs, java.lang.ClassLoader classLoader)` Create an instance of the implementor of the specified interface using the specified constructor.
`java.lang.Object` | `getInstance(java.lang.Class interfaceClass, java.lang.ClassLoader classLoader)` Create an instance of the implementor of the specified interface using its default constructor.
`java.lang.Object` | `getMappedInstance(java.lang.Class interfaceClass, java.lang.Object keyObject)` Create an instance of the implementor of the specified interface using its default constructor.
`java.lang.Object` | `getMappedInstance(java.lang.Class interfaceClass, java.lang.Object keyObject, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs)` Create an instance of the implementor of the specified interface using the specified constructor.
`java.lang.Object` | `getMappedInstance(java.lang.Class interfaceClass, java.lang.Object keyObject, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs, java.lang.ClassLoader classLoader)` Create an instance of the implementor of the specified interface using the specified constructor.
`java.lang.Object` | `getMappedInstance(java.lang.Class interfaceClass, java.lang.Object keyObject, java.lang.ClassLoader classLoader)` Create an instance of the implementor of the specified interface using its default constructor.
`java.lang.Class` | `getService(java.lang.Class interfaceClass)` Get a service from an interface class.
`java.lang.Class` | `getService(java.lang.Class interfaceClass, java.lang.ClassLoader classLoader)` Get a service from an interface class.
`java.lang.Object` | `getSingletonInstance(java.lang.Class interfaceClass)` Create an instance of the implementor of the specified interface using its default constructor.
`java.lang.Object` | `getSingletonInstance(java.lang.Class interfaceClass, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs)` Create an instance of the implementor of the specified interface using the specified constructor.
`java.lang.Object` | `getSingletonInstance(java.lang.Class interfaceClass, java.lang.Class[] constructorArgTypes, java.lang.Object[] constructorArgs, java.lang.ClassLoader classLoader)` Create an instance of the implementor of the specified interface using the specified constructor.
`java.lang.Object` | `getSingletonInstance(java.lang.Class interfaceClass, java.lang.ClassLoader classLoader)` Create an instance of the implementor of the specified interface using its default constructor.
`static void` | `main(java.lang.String[] args)` Exerciser.
`void` | `set(java.lang.Class interfaceClass, java.lang.Class implementingClass)` Set the implementor of the specified interface.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ServiceRegistry

    public ServiceRegistry(java.util.Properties props)

  Constructor. Once the Properties object is initially read in this constructor it is not referenced again.

Parameters:
  `props` - the properties to read the services from

Method Detail

### get

    public java.lang.Class get(java.lang.Class interfaceClass)

  Get the implementing class of the specified interface.

  Parameters:
    `interfaceClass` - the class of the interface
  Returns:
    the class that implements the interface, or null if not found

### get

    public java.lang.Class get(java.lang.Class interfaceClass,
                               java.lang.ClassLoader classLoader)

  Get the implementing class of the specified interface.

  Parameters:
    `interfaceClass` - the class of the interface
    `classLoader` - the class loader to look for class in
  Returns:
    the class that implements the interface, or null if not found

### getInstance

    public java.lang.Object getInstance(java.lang.Class interfaceClass)
                                 throws java.lang.IllegalAccessException,
                                        java.lang.InstantiationException,
                                        java.lang.NoSuchMethodException,
                                        java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using its default constructor.

  Parameters:
    `interfaceClass` - the class of the interface
  Returns:
    an instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getInstance

    public java.lang.Object getInstance(java.lang.Class interfaceClass,
                                        java.lang.ClassLoader classLoader)
                                 throws java.lang.IllegalAccessException,
                                        java.lang.InstantiationException,
                                        java.lang.NoSuchMethodException,
                                        java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using its default constructor.

  Parameters:
    `interfaceClass` - the class of the interface
    `classLoader` - the class loader to look for class in
  Returns:
    an instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getInstance

    public java.lang.Object getInstance(java.lang.Class interfaceClass,
                                        java.lang.Class[] constructorArgTypes,
                                        java.lang.Object[] constructorArgs)
                                 throws java.lang.IllegalAccessException,
                                        java.lang.InstantiationException,
                                        java.lang.NoSuchMethodException,
                                        java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using the specified constructor.

  Parameters:
    `interfaceClass` - the class of the interface
    `constructorArgTypes` - argument types of the desired constructor
    `constructorArgs` - arguments for the desired constructor
  Returns:
    an instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getInstance

    public java.lang.Object getInstance(java.lang.Class interfaceClass,
                                        java.lang.Class[] constructorArgTypes,
                                        java.lang.Object[] constructorArgs,
                                        java.lang.ClassLoader classLoader)
                                 throws java.lang.IllegalAccessException,
                                        java.lang.InstantiationException,
                                        java.lang.NoSuchMethodException,
                                        java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using the specified constructor.

  Parameters:
    `interfaceClass` - the class of the interface
    `constructorArgTypes` - argument types of the desired constructor
    `constructorArgs` - arguments for the desired constructor
    `classLoader` - the class loader to look for class in
  Returns:
    an instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getMappedInstance

    public java.lang.Object getMappedInstance(java.lang.Class interfaceClass,
                                              java.lang.Object keyObject)
                                       throws java.lang.IllegalAccessException,
                                              java.lang.InstantiationException,
                                              java.lang.NoSuchMethodException,
                                              java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using its default constructor. On subsequent calls previously created instances whose key objects match the specified key object will be returned.

  Parameters:
    `interfaceClass` - the class of the interface
    `keyObject` - the key object in the map
  Returns:
    the mapped instance of the implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getMappedInstance

    public java.lang.Object getMappedInstance(java.lang.Class interfaceClass,
                                              java.lang.Object keyObject,
                                              java.lang.ClassLoader classLoader)
                                       throws java.lang.IllegalAccessException,
                                              java.lang.InstantiationException,
                                              java.lang.NoSuchMethodException,
                                              java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using its default constructor. On subsequent calls previously created instances whose key objects match the specified key object will be returned.

  Parameters:
    `interfaceClass` - the class of the interface
    `keyObject` - the key object in the map
    `classLoader` - the class loader to look for class in
  Returns:
    the mapped instance of the implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getMappedInstance

    public java.lang.Object getMappedInstance(java.lang.Class interfaceClass,
                                              java.lang.Object keyObject,
                                              java.lang.Class[] constructorArgTypes,
                                              java.lang.Object[] constructorArgs)
                                       throws java.lang.IllegalAccessException,
                                              java.lang.InstantiationException,
                                              java.lang.NoSuchMethodException,
                                              java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using the specified constructor. Only one of the specified class will be created. On subsequent calls the one that is already created will be returned.

  Parameters:
    `interfaceClass` - the class of the interface
    `keyObject` - the key object in the map
    `constructorArgTypes` - argument types of the desired constructor
    `constructorArgs` - arguments for the desired constructor
  Returns:
    the singleton instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getMappedInstance

    public java.lang.Object getMappedInstance(java.lang.Class interfaceClass,
                                              java.lang.Object keyObject,
                                              java.lang.Class[] constructorArgTypes,
                                              java.lang.Object[] constructorArgs,
                                              java.lang.ClassLoader classLoader)
                                       throws java.lang.IllegalAccessException,
                                              java.lang.InstantiationException,
                                              java.lang.NoSuchMethodException,
                                              java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using the specified constructor. Only one of the specified class will be created. On subsequent calls the one that is already created will be returned.

  Parameters:
    `interfaceClass` - the class of the interface
    `keyObject` - the key object in the map
    `constructorArgTypes` - argument types of the desired constructor
    `constructorArgs` - arguments for the desired constructor
    `classLoader` - the class loader to look for class in
  Returns:
    the singleton instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getSingletonInstance

    public java.lang.Object getSingletonInstance(java.lang.Class interfaceClass)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.InstantiationException,
                                                 java.lang.NoSuchMethodException,
                                                 java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using its default constructor. Only one of the specified class will be created. On subsequent calls the one that is already created will be returned.

  Parameters:
    `interfaceClass` - the class of the interface
  Returns:
    the singleton instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getSingletonInstance

    public java.lang.Object getSingletonInstance(java.lang.Class interfaceClass,
                                                 java.lang.ClassLoader classLoader)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.InstantiationException,
                                                 java.lang.NoSuchMethodException,
                                                 java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using its default constructor. Only one of the specified class will be created. On subsequent calls the one that is already created will be returned.

  Parameters:
    `interfaceClass` - the class of the interface
    `classLoader` - the class loader to look for class in
  Returns:
    the singleton instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getSingletonInstance

    public java.lang.Object getSingletonInstance(java.lang.Class interfaceClass,
                                                 java.lang.Class[] constructorArgTypes,
                                                 java.lang.Object[] constructorArgs)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.InstantiationException,
                                                 java.lang.NoSuchMethodException,
                                                 java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using the specified constructor. Only one of the specified class will be created. On subsequent calls the one that is already created will be returned.

  Parameters:
    `interfaceClass` - the class of the interface
    `constructorArgTypes` - argument types of the desired constructor
    `constructorArgs` - arguments for the desired constructor
  Returns:
    the singleton instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### getSingletonInstance

    public java.lang.Object getSingletonInstance(java.lang.Class interfaceClass,
                                                 java.lang.Class[] constructorArgTypes,
                                                 java.lang.Object[] constructorArgs,
                                                 java.lang.ClassLoader classLoader)
                                          throws java.lang.IllegalAccessException,
                                                 java.lang.InstantiationException,
                                                 java.lang.NoSuchMethodException,
                                                 java.lang.reflect.InvocationTargetException

  Create an instance of the implementor of the specified interface using the specified constructor. Only one of the specified class will be created. On subsequent calls the one that is already created will be returned.

  Parameters:
    `interfaceClass` - the class of the interface
    `constructorArgTypes` - argument types of the desired constructor
    `constructorArgs` - arguments for the desired constructor
    `classLoader` - the class loader to look for class in
  Returns:
    the singleton instance of the new implementing class
  Throws:
    `java.lang.IllegalAccessException` - if the implementing class could not be accessed
    `java.lang.InstantiationException` - if the implementing class could not be instantiated
    `java.lang.NoSuchMethodException` - if the specified constructor does not exist
    `java.lang.reflect.InvocationTargetException` - if the specified constructor could not be invoked

### set

    public void set(java.lang.Class interfaceClass,
                    java.lang.Class implementingClass)

  Set the implementor of the specified interface.

  Parameters:
    `interfaceClass` - the class of the interface
    `implementingClass` - the class that implements the interface

### getService

    public java.lang.Class getService(java.lang.Class interfaceClass)

  Get a service from an interface class.

  Parameters:
    `interfaceClass` -
  Returns:
    the service class

### getService

    public java.lang.Class getService(java.lang.Class interfaceClass,
                                      java.lang.ClassLoader classLoader)

  Get a service from an interface class.

  Parameters:
    `interfaceClass` -
    `classLoader` - the class loader to look for class in
  Returns:
    the service class

### main

    public static void main(java.lang.String[] args)

  Exerciser.

  Parameters:
    `args` - arguments (first is name of properties file)

Overview | Package | Class | Tree | Deprecated | Index | Help
| Compoze Software, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright ©1999-2003 Compoze Software, Inc. All rights reserved.