com.hammurapi.util
Class CompositeContext

java.lang.Object
  extended by com.hammurapi.util.CompositeContext
All Implemented Interfaces:
Context, MutableContext

public class CompositeContext
extends Object
implements MutableContext

Context delegating to other contexts "parts".

Author:
Pavel Vlasov

Field Summary
 
Fields inherited from interface com.hammurapi.util.Context
INSTANCE
 
Constructor Summary
CompositeContext()
           
CompositeContext(Context... parts)
           
 
Method Summary
 void bind(String name, Object obj)
          Binds named object.
<T> T
lookup(Class<T> serviceClass)
          Looks up single object (service) by type.
 Object lookup(String name)
          Looks up object by name.
<T> Iterator<T>
lookupAll(Class<T> serviceClass)
          Looks up all services of given type.
<T> void
register(Class<? super T> type, T service)
          Registers service.
 void setParts(Context... parts)
           
 Object unbind(String name)
          Unbinds named object.
<T> void
unregister(Class<? super T> type, T service)
          Removes service registration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeContext

public CompositeContext()

CompositeContext

public CompositeContext(Context... parts)
Method Detail

setParts

public void setParts(Context... parts)

lookupAll

public <T> Iterator<T> lookupAll(Class<T> serviceClass)
Description copied from interface: Context
Looks up all services of given type.

Specified by:
lookupAll in interface Context
Type Parameters:
T - Service type.
Parameters:
serviceClass - Requested service type.
Returns:
Iterator over services of requested type.

lookup

public <T> T lookup(Class<T> serviceClass)
Description copied from interface: Context
Looks up single object (service) by type.

Specified by:
lookup in interface Context
Type Parameters:
T - Service type.
Parameters:
serviceClass - Requested service type.
Returns:
Service instance or null.

lookup

public Object lookup(String name)
Description copied from interface: Context
Looks up object by name.

Specified by:
lookup in interface Context
Parameters:
name - Object name.
Returns:
named object or null.

bind

public void bind(String name,
                 Object obj)
Description copied from interface: MutableContext
Binds named object.

Specified by:
bind in interface MutableContext
Parameters:
name - Object name.
obj - Object reference. Cannot be null.

register

public <T> void register(Class<? super T> type,
                         T service)
Description copied from interface: MutableContext
Registers service.

Specified by:
register in interface MutableContext
Type Parameters:
T - Service implementation type.
Parameters:
type - Service type.
service - Service instance.

unbind

public Object unbind(String name)
Description copied from interface: MutableContext
Unbinds named object.

Specified by:
unbind in interface MutableContext
Returns:
Object previously bound to given name.

unregister

public <T> void unregister(Class<? super T> type,
                           T service)
Description copied from interface: MutableContext
Removes service registration.

Specified by:
unregister in interface MutableContext