diff options
Diffstat (limited to 'component/src/main/java/com/yahoo/component/AbstractComponent.java')
-rw-r--r-- | component/src/main/java/com/yahoo/component/AbstractComponent.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/component/src/main/java/com/yahoo/component/AbstractComponent.java b/component/src/main/java/com/yahoo/component/AbstractComponent.java index 41d4c0dc6e9..7fc828becb5 100644 --- a/component/src/main/java/com/yahoo/component/AbstractComponent.java +++ b/component/src/main/java/com/yahoo/component/AbstractComponent.java @@ -6,8 +6,8 @@ import com.yahoo.collections.MethodCache; import java.lang.reflect.Method; /** - * Superclass of components. You must use this instead of subclassing Component if your component - * needs to be called on destruction. + * Superclass of destructible components. Container components to be created via dependency injection + * do not have to extend this class unless they need to implement {@link #deconstruct}. * * @author bratseth */ @@ -24,7 +24,17 @@ public class AbstractComponent implements Component { protected final boolean isDeconstructable; /** + * Creates a new component which is invalid until {@link #initId} is called on it. + * The dependency injection framework (DI) will always set the id, so components to be created + * via DI do not have to implement other constructors, and should not set the id themselves. + */ + protected AbstractComponent() { + isDeconstructable = setIsDeconstructable(); + } + + /** * Creates a new component with an id. + * Only for testing and components that are not created via dependency injection. * * @throws NullPointerException if the given id is null */ @@ -33,11 +43,6 @@ public class AbstractComponent implements Component { isDeconstructable = setIsDeconstructable(); } - /** Creates a new component which is invalid until {@link #initId} is called on it. */ - protected AbstractComponent() { - isDeconstructable = setIsDeconstructable(); - } - /** Initializes this. Always called from a constructor or the framework. Do not call. */ public final void initId(ComponentId id) { if (this.id != null && !this.id.equals(id)) |