Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.picocontainer.gems.behaviors
Class Assimilated<T>

    java.lang.Object
      org.picocontainer.behaviors.AbstractBehavior<T>
          org.picocontainer.gems.behaviors.Assimilated<T>

All Implemented Interfaces:
  Serializable, org.picocontainer.Behavior<T>, org.picocontainer.ComponentAdapter<T>, org.picocontainer.ComponentLifecycle<T>, org.picocontainer.ComponentMonitorStrategy, org.picocontainer.LifecycleStrategy

    public final class Assimilated<T>

extends org.picocontainer.behaviors.AbstractBehavior<T>

ComponentAdapter that assimilates a component for a specific type.

Allows the instance of another `ComponentAdapter` to be converted into interface `type`, that the instance is not assignable from. In other words the instance of the delegated adapter does NOT necessarily implement the `type` interface.

For Example:

`

     public interface Foo {
         int size();
     }

     public class Bar {
         public int size() {
             return 1;
         }
     }

     new Assimilated(Foo.class, new InstanceAdapter(new Bar()));

`

Notice how Bar does not implement the interface Foo. But Bar does have an identical `size()` method.

Author:
  Jörg Schaible, Michael Ward
See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter
`org.picocontainer.ComponentAdapter.NOTHING`

Field Summary

Fields inherited from class org.picocontainer.behaviors.AbstractBehavior
`delegate`

Constructor Summary
`Assimilated(Class<T> type, org.picocontainer.ComponentAdapter delegate)` Construct an Assimilated.
`Assimilated(Class<T> type, org.picocontainer.ComponentAdapter delegate, ProxyFactory proxyFactory)` Construct an Assimilated.

Method Summary
`Class<T>` | `getComponentImplementation()` Return the type of the component.
`T` | `getComponentInstance(org.picocontainer.PicoContainer container, Type into)` Create and return a component instance.
`Object` | `getComponentKey()` Return the key of the component.
`String` | `getDescriptor()`

Methods inherited from class org.picocontainer.behaviors.AbstractBehavior
`accept, changeMonitor, componentHasLifecycle, currentMonitor, dispose, dispose, findAdapterOfType, getComponentInstance, getDelegate, hasLifecycle, isStarted, start, start, stop, stop, toString, verify`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Assimilated

    public Assimilated(Class<T> type,
                       org.picocontainer.ComponentAdapter delegate,
                       ProxyFactory proxyFactory)
                throws org.picocontainer.PicoCompositionException

  Construct an Assimilated. The `type` may not implement the type of the component instance. If the component instance does implement the interface, no proxy is used though.

  Parameters:
    `type` - The class type used as key.
    `delegate` - The delegated `ComponentAdapter`.
    `proxyFactory` - The `ProxyFactory` to use.
  Throws:
    `org.picocontainer.PicoCompositionException` - Thrown if the `type` is not compatible and cannot be proxied.

### Assimilated

    public Assimilated(Class<T> type,
                       org.picocontainer.ComponentAdapter delegate)

  Construct an Assimilated. The `type` may not implement the type of the component instance. The implementation will use JDK `Proxy` instances. If the component instant does implement the interface, no proxy is used anyway.

  Parameters:
    `type` - The class type used as key.
    `delegate` - The delegated `ComponentAdapter`.

Method Detail

### getComponentInstance

    public T getComponentInstance(org.picocontainer.PicoContainer container,
                                  Type into)
                           throws org.picocontainer.PicoCompositionException

  Create and return a component instance. If the component instance and the type to assimilate is not compatible, a proxy for the instance is generated, that implements the assimilated type.

  Specified by:
    `getComponentInstance` in interface `org.picocontainer.ComponentAdapter<T>`
  Overrides:
    `getComponentInstance` in class `org.picocontainer.behaviors.AbstractBehavior<T>`
  Throws:
    `org.picocontainer.PicoCompositionException`
  See Also:
    `AbstractBehavior#getComponentInstance(org.picocontainer.PicoContainer, java.lang.Class into)`

### getDescriptor

    public String getDescriptor()

### getComponentImplementation

    public Class<T> getComponentImplementation()

  Return the type of the component. If the component type is not compatible with the type to assimilate, the assimilated type is returned.

  Specified by:
    `getComponentImplementation` in interface `org.picocontainer.ComponentAdapter<T>`
  Overrides:
    `getComponentImplementation` in class `org.picocontainer.behaviors.AbstractBehavior<T>`
  See Also:
    `AbstractBehavior.getComponentImplementation()`

### getComponentKey

    public Object getComponentKey()

  Return the key of the component. If the key of the delegated component is a type, that is not compatible with the type to assimilate, then the assimilated type replaces the original type.

  Specified by:
    `getComponentKey` in interface `org.picocontainer.ComponentAdapter<T>`
  Overrides:
    `getComponentKey` in class `org.picocontainer.behaviors.AbstractBehavior<T>`
  See Also:
    `AbstractBehavior.getComponentKey()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2009 Codehaus. All Rights Reserved.