com.ebmwebsourcing.easycommons.registry
Class ResourceRegistry<T>

java.lang.Object
  extended by com.ebmwebsourcing.easycommons.registry.ResourceRegistry<T>

public class ResourceRegistry<T>
extends Object

This is a generic implementation of a resource registry. All methods that alter registry state are thread safe.

Author:
ofabre

Constructor Summary
ResourceRegistry()
           
 
Method Summary
 T lookup(String key)
           
 void register(String key, T resource)
           
 void unregister(String key)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceRegistry

public ResourceRegistry()
Method Detail

register

public void register(String key,
                     T resource)
Parameters:
key - cannot be null
resource - cannot be null
Throws:
KeyAlreadyBoundException - if the provided key is already bound to a registered object

unregister

public void unregister(String key)
Parameters:
key - cannot be null
Throws:
KeyNotFoundException - if the provided key isn't found in registry

lookup

public T lookup(String key)
Parameters:
key - cannot be null
Returns:
the resource bound to this key or null if not found


Copyright © 2012 Petals Link. All Rights Reserved.