org.oddjob.arooa.registry
Class ComponentRegistry

java.lang.Object
  extended byorg.oddjob.arooa.registry.ComponentRegistry
Direct Known Subclasses:
ForEachJob.PsudoRegistry

public class ComponentRegistry
extends java.lang.Object

Register components by id and look them up by path. A ComponentRegistry is a hierarchy with child registries. The path identifies in the hierarchy where the component resides.

Author:
Rob Gordon.

Constructor Summary
ComponentRegistry()
          Constructor for a local registry.
ComponentRegistry(ServerId serverId)
          Constructor for a registry that contains proxies for remote components on the give server.
 
Method Summary
 void addChild(ComponentRegistry child, java.lang.Object owner)
          Add a child ComponentRegistry to this one.
 Address addressForObject(java.lang.Object object)
          Get the possible addresses for a given component in this registry.
 int childCount()
          Get the number of child registries for this registry.
 java.lang.String getIdForComponent(java.lang.Object component)
          Find the id for the given component.
 ServerId getServerId()
          Get the serverId.
 boolean isOwner(java.lang.Object component)
          Is the give component a registry owner?
 java.lang.Object objectForAddress(Address address)
          Find the object from the possible addresses that could identify it.
 java.lang.Object objectForPath(Path path)
          Get an object for the given path.
 Path pathForObject(java.lang.Object component)
          Get the path to a given component that may or may not be in this registries hierarchy.
 void register(java.lang.String id, java.lang.Object component)
          Register an object.
 ComponentRegistry registryOwnedBy(java.lang.Object owner)
          Get the component registry owned by the component which will probably either be an Oddjob or client job.
 void remove(java.lang.Object component)
          Remove a component from the registry if it exists.
 void removeChild(java.lang.Object owner)
          Remove a child ComponentRegistry.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComponentRegistry

public ComponentRegistry()
Constructor for a local registry.


ComponentRegistry

public ComponentRegistry(ServerId serverId)
Constructor for a registry that contains proxies for remote components on the give server.

Parameters:
serverId - The ServerId.
Method Detail

getServerId

public ServerId getServerId()
Get the serverId.

Returns:
The serverId.

addChild

public void addChild(ComponentRegistry child,
                     java.lang.Object owner)
Add a child ComponentRegistry to this one.

Parameters:
child - The child component registry.
owner - The component in this registry which owns the child registry.

removeChild

public void removeChild(java.lang.Object owner)
Remove a child ComponentRegistry.

Parameters:
owner - The component in this registry which owns the child registry.

registryOwnedBy

public ComponentRegistry registryOwnedBy(java.lang.Object owner)
Get the component registry owned by the component which will probably either be an Oddjob or client job.

Parameters:
owner - The owner component.
Returns:
A ComponentRegistry or null if the compnent doesn't own a registry.

isOwner

public boolean isOwner(java.lang.Object component)
Is the give component a registry owner?

Parameters:
component - The component.
Returns:
true if it is, false otherwise.

register

public void register(java.lang.String id,
                     java.lang.Object component)
Register an object. The id should not contain reserved characters.

Parameters:
id - The id of the object.

getIdForComponent

public java.lang.String getIdForComponent(java.lang.Object component)
Find the id for the given component.

Parameters:
component - The component.
Returns:
The id or null if none can be found.

objectForPath

public java.lang.Object objectForPath(Path path)
Get an object for the given path.

Parameters:
path - The path.
Returns:
An object or null if it hasn't been registered.

objectForAddress

public java.lang.Object objectForAddress(Address address)
Find the object from the possible addresses that could identify it. If there are several paths to the object (which can happen if the original object is accessable via several servers), the object with the shortest path is returned.

Returns:
The componen or null if none of the addresses are accessable.

pathForObject

public Path pathForObject(java.lang.Object component)
Get the path to a given component that may or may not be in this registries hierarchy.

Parameters:
component - The component.
Returns:
The path or null if it can't be found.

addressForObject

public Address addressForObject(java.lang.Object object)
Get the possible addresses for a given component in this registry.

Parameters:
object - The component.
Returns:
The possible addresses or null if the object is not registered in this registry.

remove

public void remove(java.lang.Object component)
Remove a component from the registry if it exists.

Parameters:
component - The compnent.

childCount

public int childCount()
Get the number of child registries for this registry.

Returns:
The number of child registries.

toString

public java.lang.String toString()