org.jvnet.hk2.component
Interface Creator<T>

All Superinterfaces:
Holder<T>, Inhabitant<T>
All Known Implementing Classes:
AbstractCreatorImpl, ConstructorCreator, ConstructorWomb, FactoryCreator

public interface Creator<T>
extends Inhabitant<T>

Encapsulates how to create an object.

Signature-wise it's the same as Inhabitant but it carries an additional meaning.

Author:
Kohsuke Kawaguchi
See Also:
Creators

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.sun.hk2.component.Holder
Holder.Impl<T>
 
Method Summary
 T create(Inhabitant onBehalfOf)
          Creates a new instance.
 T get()
          Short cut for
 void initialize(T t, Inhabitant onBehalfOf)
          Performs initialization of object, such as dependency injection.
 
Methods inherited from interface org.jvnet.hk2.component.Inhabitant
companions, get, getSerializedMetadata, getSerializedMetadata, isInstantiated, lead, metadata, release, setCompanions, type, typeName
 

Method Detail

get

T get()
      throws ComponentException
Short cut for
 T o = create();
 initialize(o);
 return o;
 

Specified by:
get in interface Holder<T>
Specified by:
get in interface Inhabitant<T>
Throws:
ComponentException

create

T create(Inhabitant onBehalfOf)
         throws ComponentException
Creates a new instance. The caller is supposed to call the initialize(Object, Inhabitant) right away. This 2-phase initialization allows us to handle cycle references correctly.

Parameters:
onBehalfOf -
Throws:
ComponentException

initialize

void initialize(T t,
                Inhabitant onBehalfOf)
                throws ComponentException
Performs initialization of object, such as dependency injection.

Throws:
ComponentException


Copyright © 2011 Oracle Corporation. All Rights Reserved.