net.dpml.lang
Class SimpleServiceRegistry

java.lang.Object
  extended by net.dpml.lang.SimpleServiceRegistry
All Implemented Interfaces:
ServiceRegistry

public class SimpleServiceRegistry
extends Object
implements ServiceRegistry

Simple service registry implementation that selects the first service that is type assignable from the list of service instance supplied to the registry constructor.

Version:
2.1.0
Author:
Digital Product Management Library

Constructor Summary
SimpleServiceRegistry(Object... args)
          Creation of a new service registry with no parent.
SimpleServiceRegistry(ServiceRegistry parent, Object... args)
          Creation of a new service registry with no parent.
 
Method Summary
<T> T
lookup(Class<T> type)
          Matches a service in the registry with the supplied type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleServiceRegistry

public SimpleServiceRegistry(Object... args)
Creation of a new service registry with no parent.

Parameters:
args - an ordered sequence of thread-safe services

SimpleServiceRegistry

public SimpleServiceRegistry(ServiceRegistry parent,
                             Object... args)
Creation of a new service registry with no parent.

Parameters:
parent - an optional fallback registry
args - an ordered sequence of thread-safe services
Method Detail

lookup

public <T> T lookup(Class<T> type)
Matches a service in the registry with the supplied type. If no match is found and a parent registry has been delclared, the lookup request is passed onto the parent registry, otherwise null is returned.

Specified by:
lookup in interface ServiceRegistry
Parameters:
type - the service type
Returns:
an instance of the type or null if the type could not be resolved