com.bigbross.bossa.resource
Class ResourceRegistry

java.lang.Object
  extended bycom.bigbross.bossa.resource.ResourceRegistry
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ResourceManager

public class ResourceRegistry
extends Object
implements Serializable

This class stores registered resources.

Author:
BigBross Team
See Also:
Serialized Form

Constructor Summary
ResourceRegistry(String id)
          Creates a new empty resource registry.
 
Method Summary
 Expression compile(String expression)
          Compiles a resource expression.
 Resource createResource(String id)
          Creates a new resource in this registry.
 Resource createResourceImpl(String id, boolean notify)
          Creates a new resource in this registry.
 String getId()
          Returns the id of this registry.
 Resource getResource(String id)
          Returns the resource with the given id.
 List getResources()
          Returns all registered resources.
 ResourceRegistry getSuperContext()
          Returns the super context of this registry.
 boolean registerSubContext(ResourceRegistry context)
          Registers another resource registry as a sub context of this resource registry.
 boolean removeResource(Resource resource)
          Removes a resource from this registry.
 boolean removeResourceImpl(Resource resource, boolean notify)
          Removes a resource from this registry.
 boolean removeSubContext(ResourceRegistry context)
          Remove the provided registry from the list of registered sub contexts of this registry.
 void setSuperContext(ResourceRegistry context)
          Sets a context as the super context of this registry.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceRegistry

public ResourceRegistry(String id)
Creates a new empty resource registry.

Parameters:
id - the id of this registry.
Method Detail

getId

public String getId()
Returns the id of this registry.

Returns:
the id of this registry.

setSuperContext

public void setSuperContext(ResourceRegistry context)
Sets a context as the super context of this registry.

Parameters:
context - the super context.

getSuperContext

public ResourceRegistry getSuperContext()
Returns the super context of this registry.

Returns:
the super context of this registry.

getResource

public Resource getResource(String id)
Returns the resource with the given id.

Parameters:
id - the resource id.
Returns:
the Resource object, null if there is no resource with this id.

getResources

public List getResources()
Returns all registered resources.

Returns:
a list of all resources registered.

createResource

public Resource createResource(String id)
                        throws BossaException
Creates a new resource in this registry.

Parameters:
id - the id of the resource to be created.
Returns:
the created Resource object, null if there is already a resource with this id.
Throws:
PersistenceException - if an error occours when making the execution of this method persistent.
BossaException

createResourceImpl

public Resource createResourceImpl(String id,
                                   boolean notify)
Creates a new resource in this registry.

This method does not create a transaction in the prevalent system. The execution of this method will not be persistent unless it is called inside an appropriate transaction.

Parameters:
id - the id of the resource to be created.
notify - if this operation should be notified.
Returns:
the created Resource object, null if there is already a resource with this id.

removeResource

public boolean removeResource(Resource resource)
                       throws BossaException
Removes a resource from this registry.

Parameters:
resource - the resource to be removed.
Returns:
true if the resource was removed, false if the resource was not found.
Throws:
PersistenceException - if an error occours when making the execution of this method persistent.
BossaException

removeResourceImpl

public boolean removeResourceImpl(Resource resource,
                                  boolean notify)
Removes a resource from this registry.

This method does not create a transaction in the prevalent system. The execution of this method will not be persistent unless it is called inside an appropriate transaction.

Parameters:
resource - the resource to be removed.
notify - if this operation should be notified.
Returns:
true if the resource was removed, false if the resource was not found.

registerSubContext

public boolean registerSubContext(ResourceRegistry context)
Registers another resource registry as a sub context of this resource registry. All entries in the sub context are expected to possibly depend on the entries of this registry, and are notified of resource removals.

Also, if this registry tree is rooted at a resource manager, the registry tree being registered is put in the global registry index.

Parameters:
context - the sub context.
Returns:
true if the sub context was added, false if the sub context was already present.

removeSubContext

public boolean removeSubContext(ResourceRegistry context)
Remove the provided registry from the list of registered sub contexts of this registry.

Also, if this registry tree is rooted at a resource manager, the registry tree being removed is removed from the global registry index.

Parameters:
context - the sub context.
Returns:
true if the sub context was removed, false if the sub context was not found.

compile

public Expression compile(String expression)
Compiles a resource expression.

It uses this ResourceManager to link the resources in the expression.

Parameters:
expression - the resource expression to be compiled.
Returns:
a Expression representing the compiled resource expression.


Copyright © 2003,2004 OpenBR Sistemas S/C Ltda.