JBoss Modular Service Kernel API 1.0.0.Beta4-SNAPSHOT

org.jboss.msc.value
Class InjectedValue<T>

java.lang.Object
  extended by org.jboss.msc.value.InjectedValue<T>
Type Parameters:
T - the value type
All Implemented Interfaces:
Injector<T>, Value<T>

public final class InjectedValue<T>
extends Object
implements Injector<T>, Value<T>

A value which is injected from another source. The value may only be read if the injector has populated it.

Author:
David M. Lloyd

Constructor Summary
InjectedValue()
          Construct a new instance.
 
Method Summary
 T getOptionalValue()
          Get the value if it was injected, or return null if it was not.
 T getValue()
          Get the actual value.
 void inject(T value)
          Inject the given value.
 void uninject()
          Uninject the given value (in other words, cancel or undo a previous injection).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InjectedValue

public InjectedValue()
Construct a new instance.

Method Detail

getValue

public T getValue()
           throws IllegalStateException
Get the actual value.

Specified by:
getValue in interface Value<T>
Returns:
the actual value
Throws:
IllegalStateException - if the value is time-sensitive and the current state does not allow retrieval.

inject

public void inject(T value)
            throws InjectionException
Inject the given value.

Specified by:
inject in interface Injector<T>
Parameters:
value - the value
Throws:
InjectionException - if the injection failed

uninject

public void uninject()
Uninject the given value (in other words, cancel or undo a previous injection). Only called after inject() has been called.

Specified by:
uninject in interface Injector<T>

getOptionalValue

public T getOptionalValue()
Get the value if it was injected, or return null if it was not.

Returns:
the value or null if it was not injected

JBoss Modular Service Kernel API 1.0.0.Beta4-SNAPSHOT

Copyright © 2010 JBoss, a division of Red Hat, Inc.