jfun.yan.xml
Interface NutEnvironment


public interface NutEnvironment

The environment that a Nut object is running in.

Author:
Ben Yu Nov 11, 2005 1:21:55 PM

Method Summary
 Component cast(java.lang.Class target_type, Component c, Location loc)
          Transform a Component so that the instantiated instance is converted to the target type.
 java.lang.Object convert(java.lang.Class target_type, java.lang.Object val, Location loc)
          Convert an object to a target type.
 java.lang.Object deserialize(java.lang.Class type, java.lang.String text)
          Convert a string literal to an object of a certain type.
 java.lang.Object findService(java.lang.Object key)
          To find an optional service provided by the system.
 java.io.File getBaseDir()
          Get the base directory setting of the system.
 java.lang.ClassLoader getComponentClassLoader()
          Get the class loader used to load the component classes.
 DefaultLifecycleManager getLifecycleManager()
          Get the lifecycle manager.
 java.lang.ClassLoader getNutClassLoader()
          Get the class loader used to load the Nut tags.
 ParameterBinder getParameterWiringMode(java.lang.String mode_name, Location loc)
          Get the auto wiring mode specified by the mode name.
 PropertyBinder getPropertyWiringMode(java.lang.String mode_name, Location loc)
          Get the auto wiring mode specified by the mode name.
 ResourceLoader getResourceLoader()
          Get the ResourceLoader object for loading resources.
 boolean isDeserializable(java.lang.Class type)
          To determine if string literal can be converted to the target type.
 boolean isEagerlyInstantiating()
          Do we by default eagerly instantiate components?
 void registerDeserializer(java.lang.Class type, Deserializer deserializer, boolean overriding, boolean mandatory)
          To register a Deserializer.
 void registerDynamic(java.lang.Object key, java.lang.Object val, boolean overridable, boolean overriding, Location loc)
          Dynamically register an object.
 void registerEagerInstantiation(int seq, java.lang.Object key, Component c)
          Add a Component to the list to be eagerly instantiated.
 

Method Detail

getResourceLoader

ResourceLoader getResourceLoader()
Get the ResourceLoader object for loading resources.


getNutClassLoader

java.lang.ClassLoader getNutClassLoader()
Get the class loader used to load the Nut tags.


getComponentClassLoader

java.lang.ClassLoader getComponentClassLoader()
Get the class loader used to load the component classes.


convert

java.lang.Object convert(java.lang.Class target_type,
                         java.lang.Object val,
                         Location loc)
Convert an object to a target type.

Parameters:
target_type - the target type.
val - the object to be converted.
loc - the location within the source that does the conversion.
Returns:
the object of the target type.

cast

Component cast(java.lang.Class target_type,
               Component c,
               Location loc)
Transform a Component so that the instantiated instance is converted to the target type.

Parameters:
target_type - the target type.
c - the Component to transform.
loc - the location within the source that does the casting.
Returns:
the Component that instantiates object of the target type.

getBaseDir

java.io.File getBaseDir()
Get the base directory setting of the system. It may be different from new File(".").


getPropertyWiringMode

PropertyBinder getPropertyWiringMode(java.lang.String mode_name,
                                     Location loc)
                                     throws ConfigurationException
Get the auto wiring mode specified by the mode name.

Parameters:
mode_name - the mode name.
loc - the Location within the source file.
Returns:
the PropertyBinder object encapsulating the auto wiring mode, or null if this is manual wiring.
Throws:
ConfigurationException - if the mode name is not recognized.

getParameterWiringMode

ParameterBinder getParameterWiringMode(java.lang.String mode_name,
                                       Location loc)
                                       throws ConfigurationException
Get the auto wiring mode specified by the mode name.

Parameters:
mode_name - the mode name.
loc - the location within the source file.
Returns:
the ParameterBinder object encapsulating the auto wiring mode, or null if this is manual wiring.
Throws:
ConfigurationException - if the mode name is not recognized.

isEagerlyInstantiating

boolean isEagerlyInstantiating()
Do we by default eagerly instantiate components?


findService

java.lang.Object findService(java.lang.Object key)
To find an optional service provided by the system.

Parameters:
key - the key to the service.
Returns:
the service object. Null is returned if the key is not found.

getLifecycleManager

DefaultLifecycleManager getLifecycleManager()
Get the lifecycle manager.


registerEagerInstantiation

void registerEagerInstantiation(int seq,
                                java.lang.Object key,
                                Component c)
Add a Component to the list to be eagerly instantiated.

Parameters:
seq - the sequence number of the component within the enclosing scope. This number is important to figure out the evaluation order of the components.
key - the key of the component.
c - the component.

registerDynamic

void registerDynamic(java.lang.Object key,
                     java.lang.Object val,
                     boolean overridable,
                     boolean overriding,
                     Location loc)
Dynamically register an object.

Parameters:
key - the key of the object.
val - the object.
overridable - whether this registration is overridable.
overriding - do we override when the same key is already used by another dynamically registered entry.
loc - the location of the entry.

deserialize

java.lang.Object deserialize(java.lang.Class type,
                             java.lang.String text)
                             throws java.lang.Throwable
Convert a string literal to an object of a certain type.

Parameters:
type - the target type.
text - the string literal.
Returns:
the object of the target type.
Throws:
java.lang.Throwable - when any error happens.

registerDeserializer

void registerDeserializer(java.lang.Class type,
                          Deserializer deserializer,
                          boolean overriding,
                          boolean mandatory)
To register a Deserializer.

Parameters:
type - the type that uses the Deserializer to convert literal string to objects of this type.
deserializer - the Deserializer object.
overriding - whether override the existent Deserializer if any. and an Deserializer object is already registered for the target type.
mandatory - true if this registration has to go through.
Throws:
java.lang.IllegalArgumentException - if not overriding and an Deserializer object is already registered for the target type.

isDeserializable

boolean isDeserializable(java.lang.Class type)
To determine if string literal can be converted to the target type.

Parameters:
type - the target type.
Returns:
true if convertible.