org.jvnet.hk2.component
Interface Factory


public interface Factory

Hook to create/obtain an instance of a component from somewhere, instead of letting the auto-depends create it via the constructor.

Factory is by itself a component, so the factory implementation could have everything it needs injected.

Author:
Kohsuke Kawaguchi
See Also:
Service

Method Summary
 java.lang.Object getObject()
          The system calls this method to obtain a reference to the component.
 

Method Detail

getObject

java.lang.Object getObject()
                           throws ComponentException
The system calls this method to obtain a reference to the component.

Returns:
null is a valid return value. This is useful when a factory primarily does a look-up and it fails to find the specified component, yet you don't want that by itself to be an error. If the injection wants a non-null value (i.e., @Inject(optional=false)).
Throws:
ComponentException - If the factory failed to get/create an instance and would like to propagate the error to the caller.


Copyright © 2011 Oracle Corporation. All Rights Reserved.