com.hammurapi.common

## Class SimpleMutableContext

- java.lang.Object
- - com.hammurapi.common.SimpleMutableContext

- All Implemented Interfaces:
    Context, MutableContext

      public class SimpleMutableContext
      extends Object
      implements MutableContext

  Simple context implementation.

- - ### Field Summary

    - ### Fields inherited from interface com.hammurapi.common.Context

      `INSTANCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SimpleMutableContext(Context... chain)`
    `SimpleMutableContext(Map<Class<?>,Collection<?>> services, Map<String,?> bindings, Context... chain)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `bind(String name, Object value)` Binds named object.
    `<T> T` | `lookup(Class<T> serviceClass, Predicate<T,Context>... selectors)` Looks up single object (service) by type.
    `Object` | `lookup(String name)` Looks up object by name.
    `<T> Iterator<T>` | `lookupAll(Class<T> serviceClass, Predicate<T,Context>... selectors)` Looks up all services of given type.
    `<T> void` | `register(Class<? super T> serviceType, T service)` Registers service.
    `Object` | `unbind(String name)` Unbinds named object.
    `<T> void` | `unregister(Class<? super T> serviceType, 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

    - #### SimpleMutableContext

          public SimpleMutableContext(Context... chain)

    - #### SimpleMutableContext

          public SimpleMutableContext(Map<Class<?>,Collection<?>> services,
                              Map<String,?> bindings,
                              Context... chain)

      Parameters:
        `classLoader` - ClassLoader for services. Can be null.
        `bindings` - Name bindings. Can be null.

  - ### Method Detail

    - #### bind

          public void bind(String name,
                  Object value)

      Description copied from interface: `MutableContext`
      Binds named object.
      Specified by:
        `bind` in interface `MutableContext`
      Parameters:
        `name` - Object name.
        `value` - Object reference. Cannot be null.

    - #### 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.

    - #### register

          public <T> void register(Class<? super T> serviceType,
                          T service)

      Description copied from interface: `MutableContext`
      Registers service.
      Specified by:
        `register` in interface `MutableContext`
      Type Parameters:
        `T` - Service implementation type.
      Parameters:
        `serviceType` - Service type.
        `service` - Service instance.

    - #### unregister

          public <T> void unregister(Class<? super T> serviceType,
                            T service)

      Description copied from interface: `MutableContext`
      Removes service registration.
      Specified by:
        `unregister` in interface `MutableContext`

    - #### 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.

    - #### lookup

          public <T> T lookup(Class<T> serviceClass,
                     Predicate<T,Context>... selectors)

      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.
        `selectors` - Optional service selectors. If more than one, selectors are combined with AND.
      Returns:
        Service instance or null.

    - #### lookupAll

          public <T> Iterator<T> lookupAll(Class<T> serviceClass,
                                  Predicate<T,Context>... selectors)

      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.
        `selectors` - Optional service selectors. If more than one, selectors are combined with AND.
      Returns:
        Iterator over services of requested type.