electric.registry
Class Registry

java.lang.Object
  extended byelectric.registry.Registry

public final class Registry
extends java.lang.Object

Registry is a class that exposes static methods for publishing, binding and invoking services. It manages a collection of underlying IRegistries, and iterates through each registry to satisfy a particular operation. Registry is created with a single default IRegistry whose name is "root" and type is DirectoryRegistry. When an object that does not implement IService is published, it is automatically wrapped in a service whose default class is "electric.service.object.ObjectService".

Author:
webMethods

Constructor Summary
Registry()
           
 
Method Summary
static IRegistryListener addListener(java.lang.String name, IRegistryListener listener)
          Add the specified listener to the collection of listeners.
static void addRegistry(java.lang.String name, IRegistry registry)
          Add the specified registry to the collection of registries with the default priority of 5.
static void addRegistry(java.lang.String name, IRegistry registry, float priority)
          Add the specified registry to the collection of registries.
static java.lang.Object bind(java.lang.Class type)
          Return a proxy to a service that implements the specified interface.
static java.lang.Object bind(java.lang.Class[] types)
          Return a proxy to a service that implements the specified interfaces.
static java.lang.Object bind(java.lang.Class[] types, Context context)
          Return a proxy to a service that implements the specified interfaces.
static java.lang.Object bind(java.lang.Class type, Context context)
          Return a proxy to a service that implements the specified interface.
static IProxy bind(java.lang.String path)
          Return an IProxy to the service with the specified path.
static java.lang.Object bind(java.lang.String path, java.lang.Class type)
          Return a proxy to the service at the specified path.
static java.lang.Object bind(java.lang.String path, java.lang.Class[] types)
          Return a proxy to the service at the specified path.
static java.lang.Object bind(java.lang.String path, java.lang.Class[] types, Context context)
          Return a proxy to the service at the specified path.
static java.lang.Object bind(java.lang.String path, java.lang.Class type, Context context)
          Return a proxy to the service at the specified path.
static IProxy bind(java.lang.String path, Context context)
          Return an IProxy to the service with the specified path.
static java.lang.Object get(java.lang.String path)
          Return the object with the specified path in the root registry, or null if not found.
static java.lang.String[] getAllPaths(java.lang.Object object)
           
static CompoundRegistry getCompoundRegistry()
          Return my underlying compound registry.
static IDirectory getDirectory(java.lang.String path)
          Return the subdirectory of the root registry with the specified path.
static IRegistryListener getListener(java.lang.String name)
          Return the specified listener from the collection of listeners, or null if not found.
static java.lang.String getPath(IServer server, java.lang.Object object)
           
static java.lang.String getPath(java.lang.Object object)
           
static java.lang.String getPath(java.lang.String name, java.lang.Object object)
          Return the path of the specified object relative to a named server or directory.
static IReference getReference(java.lang.String path, java.lang.Class[] interfaces, Context context)
          Return an IReference to the service at the specified path.
static IReference getReference(java.lang.String path, java.lang.Class type, Context context)
          Return an IReference to the service at the specified path.
static IRegistry getRegistry(java.lang.String name)
          Return the specified registry from the collection of registries, or null if not found.
static java.lang.String getRegistryPath(java.lang.Object object)
           
static java.lang.String[] getRegistryPaths(java.lang.Object object)
          Return the path to the object in the registry.
static IService getService(java.lang.String path)
          Return the service with the specified path in the root registry, or null if not found.
static IServiceFactory getServiceFactory()
          Return the service factory.
static java.lang.Object newProxy(Proxy proxy, java.lang.Class[] types)
          Return a dynamic proxy that implements the specified interfaces.
static void publish(java.lang.String path, java.lang.Object object)
          Publish the object to the specified path.
static void publish(java.lang.String path, java.lang.Object object, java.lang.Class type)
          Publish the object to the specified path.
static void publish(java.lang.String path, java.lang.Object object, java.lang.Class[] types)
          Publish the object to the specified path.
static void publish(java.lang.String path, java.lang.Object object, java.lang.Class[] types, Context context)
          Publish the object to the specified path.
static void publish(java.lang.String path, java.lang.Object object, java.lang.Class type, Context context)
          Publish the object to the specified path.
static void publish(java.lang.String path, java.lang.Object object, Context context)
          Publish the object to the specified path.
static IRegistryListener removeListener(java.lang.String name)
          Remove and return the specified listener from the collection of listeners, or do nothing if not found.
static IRegistry removeRegistry(java.lang.String name)
          Remove and return the specified registry from the collection of registries, or do nothing if not found.
static void setDirectory(java.lang.String path, IDirectory directory)
          Set a subdirectory of the root registry to the specified directory.
static void setServiceFactory(IServiceFactory serviceFactory)
          Set the service factory.
static void startup()
          Called by the platform startup.
static void unpublish(java.lang.String path)
          Unpublish the object from the specified path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Registry

public Registry()
Method Detail

startup

public static void startup()
Called by the platform startup. This method is not intended for general use.


setDirectory

public static void setDirectory(java.lang.String path,
                                IDirectory directory)
                         throws DirectoryException
Set a subdirectory of the root registry to the specified directory.

Parameters:
path - The path within the root registry.
directory - The directory.
Throws:
DirectoryException - If the root registry throws an exception.

getDirectory

public static IDirectory getDirectory(java.lang.String path)
                               throws DirectoryException
Return the subdirectory of the root registry with the specified path.

Parameters:
path - The path within the root registry.
Throws:
DirectoryException - If the root registry throws an exception.

addRegistry

public static void addRegistry(java.lang.String name,
                               IRegistry registry)
Add the specified registry to the collection of registries with the default priority of 5.

Parameters:
name - The name of the registry.
registry - The registry to add.

addRegistry

public static void addRegistry(java.lang.String name,
                               IRegistry registry,
                               float priority)
Add the specified registry to the collection of registries.

Parameters:
name - The name of the registry.
registry - The registry to add.
priority - The priority, 1=highest, tried first

getRegistry

public static IRegistry getRegistry(java.lang.String name)
Return the specified registry from the collection of registries, or null if not found.

Parameters:
name - The name of the registry.

removeRegistry

public static IRegistry removeRegistry(java.lang.String name)
Remove and return the specified registry from the collection of registries, or do nothing if not found.

Parameters:
name - The name of the registry.

getCompoundRegistry

public static CompoundRegistry getCompoundRegistry()
Return my underlying compound registry.


bind

public static java.lang.Object bind(java.lang.String path,
                                    java.lang.Class type)
                             throws RegistryException
Return a proxy to the service at the specified path.

Parameters:
path - The path of the service.
type - The interface that the proxy should implement.
Throws:
RegistryException - If any of the registries throws an exception.

bind

public static java.lang.Object bind(java.lang.String path,
                                    java.lang.Class[] types)
                             throws RegistryException
Return a proxy to the service at the specified path.

Parameters:
path - The path of the service.
types - The interfaces that the proxy should implement.
Throws:
RegistryException - If any of the registries throws an exception.

bind

public static java.lang.Object bind(java.lang.String path,
                                    java.lang.Class type,
                                    Context context)
                             throws RegistryException
Return a proxy to the service at the specified path.

Parameters:
path - The path of the service.
type - The interface that the proxy should implement.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

bind

public static java.lang.Object bind(java.lang.String path,
                                    java.lang.Class[] types,
                                    Context context)
                             throws RegistryException
Return a proxy to the service at the specified path.

Parameters:
path - The path of the service.
types - The interfaces that the proxy should implement.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

bind

public static java.lang.Object bind(java.lang.Class type)
                             throws RegistryException
Return a proxy to a service that implements the specified interface.

Parameters:
type - The interface that the proxy should implement.
Throws:
RegistryException - If any of the registries throws an exception.

bind

public static java.lang.Object bind(java.lang.Class type,
                                    Context context)
                             throws RegistryException
Return a proxy to a service that implements the specified interface.

Parameters:
type - The interface that the proxy should implement.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

bind

public static java.lang.Object bind(java.lang.Class[] types)
                             throws RegistryException
Return a proxy to a service that implements the specified interfaces.

Parameters:
types - The interfaces that the proxy should implement.
Throws:
RegistryException - If any of the registries throws an exception.

bind

public static java.lang.Object bind(java.lang.Class[] types,
                                    Context context)
                             throws RegistryException
Return a proxy to a service that implements the specified interfaces.

Parameters:
types - The interfaces that the proxy should implement.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

bind

public static IProxy bind(java.lang.String path)
                   throws RegistryException
Return an IProxy to the service with the specified path.

Parameters:
path - The path of the service.
Throws:
RegistryException - If any of the registries throws an exception.

bind

public static IProxy bind(java.lang.String path,
                          Context context)
                   throws RegistryException
Return an IProxy to the service with the specified path.

Parameters:
path - The path of the service.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

getReference

public static IReference getReference(java.lang.String path,
                                      java.lang.Class type,
                                      Context context)
                               throws RegistryException
Return an IReference to the service at the specified path.

Parameters:
path - The path of the service.
type - The interface.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

getReference

public static IReference getReference(java.lang.String path,
                                      java.lang.Class[] interfaces,
                                      Context context)
                               throws RegistryException
Return an IReference to the service at the specified path.

Parameters:
path - The path of the service.
interfaces - The interfaces.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

newProxy

public static java.lang.Object newProxy(Proxy proxy,
                                        java.lang.Class[] types)
Return a dynamic proxy that implements the specified interfaces.

Parameters:
proxy - The underlying proxy.
types - The interfaces to implement.

publish

public static void publish(java.lang.String path,
                           java.lang.Object object)
                    throws RegistryException
Publish the object to the specified path. By default, all of the object's public static and instance methods are exposed. If the object does not implement IService, it is wrapped in the default service type. An object can be published to more than one path.

Parameters:
path - The path.
object - The object.
Throws:
RegistryException - If any of the registries throws an exception.

publish

public static void publish(java.lang.String path,
                           java.lang.Object object,
                           Context context)
                    throws RegistryException
Publish the object to the specified path. By default, all of the object's public static and instance methods are exposed. If the object does not implement IService, it is wrapped in the default service type. An object can be published to more than one path.

Parameters:
path - The path.
object - The object.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

publish

public static void publish(java.lang.String path,
                           java.lang.Object object,
                           java.lang.Class type)
                    throws RegistryException
Publish the object to the specified path. By default, all of the object's public static and instance methods are exposed. If the object does not implement IService, it is wrapped in the default service type. An object can be published to more than one path.

Parameters:
path - The path.
object - The object.
type - The interface to expose.
Throws:
RegistryException - If any of the registries throws an exception.

publish

public static void publish(java.lang.String path,
                           java.lang.Object object,
                           java.lang.Class type,
                           Context context)
                    throws RegistryException
Publish the object to the specified path. By default, all of the object's public static and instance methods are exposed. If the object does not implement IService, it is wrapped in the default service type. An object can be published to more than one path.

Parameters:
path - The path.
object - The object.
type - The interface to expose.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

publish

public static void publish(java.lang.String path,
                           java.lang.Object object,
                           java.lang.Class[] types)
                    throws RegistryException
Publish the object to the specified path. By default, all of the object's public static and instance methods are exposed. If the object does not implement IService, it is wrapped in the default service type. An object can be published to more than one path.

Parameters:
path - The path.
object - The object.
types - The interfaces to expose.
Throws:
RegistryException - If any of the registries throws an exception.

publish

public static void publish(java.lang.String path,
                           java.lang.Object object,
                           java.lang.Class[] types,
                           Context context)
                    throws RegistryException
Publish the object to the specified path. By default, all of the object's public static and instance methods are exposed. If the object does not implement IService, it is wrapped in the default service type. An object can be published to more than one path.

Parameters:
path - The path.
object - The object.
types - The interfaces to expose.
context - The context.
Throws:
RegistryException - If any of the registries throws an exception.

unpublish

public static void unpublish(java.lang.String path)
                      throws RegistryException
Unpublish the object from the specified path.

Parameters:
path - The path.
Throws:
RegistryException - If any of the registries throws an exception or if an object was not found.

getServiceFactory

public static IServiceFactory getServiceFactory()
Return the service factory.


setServiceFactory

public static void setServiceFactory(IServiceFactory serviceFactory)
Set the service factory.

Parameters:
serviceFactory - The new value.

get

public static java.lang.Object get(java.lang.String path)
                            throws RegistryException
Return the object with the specified path in the root registry, or null if not found.

Parameters:
path - The path.
Throws:
RegistryException - If the root registry threw an exception.

getService

public static IService getService(java.lang.String path)
                           throws RegistryException
Return the service with the specified path in the root registry, or null if not found. The path can be a local path like "foo" or "/foo/bar", or relative to any of the currently active servers, like "http://localhost:8004/glue/exchange".

Parameters:
path - The path.
Throws:
RegistryException - If the root registry threw an exception.

addListener

public static IRegistryListener addListener(java.lang.String name,
                                            IRegistryListener listener)
Add the specified listener to the collection of listeners.

Parameters:
name - The name of the listener.
listener - The listener to add.

getListener

public static IRegistryListener getListener(java.lang.String name)
Return the specified listener from the collection of listeners, or null if not found.

Parameters:
name - The name of the listener.

removeListener

public static IRegistryListener removeListener(java.lang.String name)
Remove and return the specified listener from the collection of listeners, or do nothing if not found.

Parameters:
name - The name of the listener.

getPath

public static java.lang.String getPath(java.lang.String name,
                                       java.lang.Object object)
Return the path of the specified object relative to a named server or directory. If the name starts with a "/", return the path relative to the that subdirectory in the root registry, otherwise return the path relative to the server with that name. If the object is not found or an underlying exception occurs, return null.

Parameters:
name - The name of a server or path within the root registry.
object - The object.

getPath

public static java.lang.String getPath(IServer server,
                                       java.lang.Object object)
Parameters:
server -
object -

getPath

public static java.lang.String getPath(java.lang.Object object)
Parameters:
object -

getAllPaths

public static java.lang.String[] getAllPaths(java.lang.Object object)
Parameters:
object -

getRegistryPath

public static java.lang.String getRegistryPath(java.lang.Object object)
                                        throws RegistryException
Parameters:
object -
Returns:
Throws:
RegistryException

getRegistryPaths

public static java.lang.String[] getRegistryPaths(java.lang.Object object)
                                           throws RegistryException
Return the path to the object in the registry.

Parameters:
object - The object that was published into the registry.
Throws:
RegistryException


copyright© 2001-2004 by webMethods All Rights Reserved.