|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjfun.yan.xml.NutsProcessor
public class NutsProcessor
The main class that parses an xml config file and populates container and lifecycle manager with the information stored in the config file.
| Constructor Summary | |
|---|---|
NutsProcessor()
Create a NutsProcessor object. |
|
NutsProcessor(java.lang.ClassLoader classloader)
Create an NutsProcessor object. |
|
NutsProcessor(java.lang.ClassLoader cloader,
Container yan)
Create an NutsProcessor object. |
|
NutsProcessor(java.lang.ClassLoader cloader,
Container yan,
DefaultLifecycleManager manager,
java.io.File basedir)
Create an NutsProcessor object. |
|
NutsProcessor(java.lang.ClassLoader classloader,
ResourceLoader rloader)
Create an NutsProcessor object. |
|
NutsProcessor(java.lang.ClassLoader cloader,
ResourceLoader rloader,
Container yan)
Create an NutsProcessor object. |
|
NutsProcessor(java.lang.ClassLoader cloader,
ResourceLoader rloader,
Container yan,
DefaultLifecycleManager manager,
java.io.File basedir)
Create an NutsProcessor object. |
|
| Method Summary | |
|---|---|
NutsProcessor |
createMetaInterpreter()
Create an NutsProcessor object that's gonna be used to load meta configuration of Nut classes. |
NutsProcessor |
createMetaProcessor(java.lang.ClassLoader loader)
Create an NutsProcessor object that's gonna be used to load meta configuration of Nut classes. |
NutsProcessor |
createMetaProcessor(java.lang.ClassLoader loader,
ResourceLoader rloader)
Create an NutsProcessor object that's gonna be used to load meta configuration of Nut classes. |
java.lang.Object |
deserialize(java.lang.Class type,
java.lang.String v)
Convert a string literal to an object of a certain type. |
NutDescriptor |
findNut(java.lang.String key)
Get a NutDescriptor registered by putNut(). |
java.lang.Object |
findService(java.lang.Object key)
To find the service object registered using registerService(Object, Object). |
java.io.File |
getBaseDir()
To get the base directory used by the processor. |
java.lang.ClassLoader |
getClassLoader()
To get the ClassLoader used to load component classes. |
Container |
getContainer()
To get the container used by this processor. |
DefaultLifecycleManager |
getLifecycleManager()
To get the lifecycle manager used by this processor. |
java.util.Set |
getNutKeys()
Get the set of keys of Nut descriptors. |
ParameterBinder |
getParameterWiring()
Get the default parameter auto wiring mode. |
PropertyBinder |
getPropertyWiring()
Get the default property auto-wiring mode. |
ResourceLoader |
getResourceLoader()
To get the ResourceLoader used to load resources. |
java.util.Set |
getServiceKeys()
Get the set of the keys of the service objects. |
SingletonMode |
getSingletonMode()
Get the default singleton mode. |
java.lang.Object |
getVariable(java.lang.String key)
To get a variable value. |
boolean |
hasVariable(java.lang.String key)
Checks whether a variable name exists. |
boolean |
isDeserializable(java.lang.Class type)
To determine if string literal can be converted to the target type. |
void |
loadNutsFromContainer(Container nuts)
Load descriptors of the nut classes registered in a Container. |
void |
loadNutsMetaData(java.lang.Object id,
java.lang.ClassLoader loader,
ResourceLoader rloader,
java.io.InputStream in)
Load configuration information from an InputStream and wires Nut classes. |
void |
loadNutsMetaData(java.lang.Object id,
java.io.InputStream in)
Load configuration information from an InputStream and wires Nut classes. |
void |
loadNutsMetaFile(java.lang.ClassLoader loader,
ResourceLoader rloader,
java.lang.String filename)
Load a configuration file that wires Nut classes. |
void |
loadNutsMetaFile(java.lang.String filename)
Load a configuration file that wires Nut classes. |
void |
loadNutsMetaResource(java.lang.String resourcename)
Load configuration information from a resource loaded by the component class loader. |
java.util.Map |
preInstantiate()
Pre-initialize eagerly instantiated components. |
java.util.Map |
preInstantiate(Container container)
Pre-initialize eagerly instantiated components. |
java.util.Map |
preInstantiate(Container container,
java.util.Map store)
Pre-initialize eagerly instantiated components. |
java.util.Map |
preInstantiate(java.util.Map store)
Pre-initialize eagerly instantiated components. |
java.lang.String[] |
process(java.lang.Object id,
java.io.InputStream in)
Process bytes read from an InputStream. |
java.lang.String[] |
processFile(java.io.File file)
Process a config file. |
java.lang.String[] |
processFile(java.lang.String filename)
Process a config file. |
java.lang.String[] |
processResource(java.lang.String resourcename)
Process a resource from the component class loader as an xml configuration. |
void |
registerAutoWiring(java.lang.String mode_name,
ParameterBinder mode)
Register a parameter autowiring mode. |
void |
registerAutoWiring(java.lang.String mode_name,
PropertyBinder mode)
Register a property autowiring mode. |
void |
registerDeserializer(java.lang.Class type,
Deserializer deserializer,
boolean overriding,
boolean mandatory)
To register a Deserializer. |
void |
registerNut(java.lang.String key,
NutDescriptor desc)
Add an external nut descriptor for the processor to use. |
void |
registerService(java.lang.Object key,
java.lang.Object service)
To register a service object that can be read by customized Nuts classes through the call of NutEnvironment.findService(Object). |
void |
registerVariable(java.lang.String key,
java.lang.Object val)
Register a variable that can be referenced in the xml file using "$varname" syntax. |
void |
removeNut(java.lang.String key)
Unregister a NutDescriptor. |
void |
removeVariable(java.lang.String key)
To remove a registration of a variable. |
void |
setParameterWiring(ParameterBinder param_wiring)
Set the default parameter auto-wiring mode. |
void |
setPropertyWiring(PropertyBinder prop_wiring)
Set the default property auto-wiring mode. |
void |
setSingletonMode(SingletonMode singleton_mode)
Set the default singleton mode. |
void |
unregisterService(java.lang.Object key)
To unregister a service object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NutsProcessor()
The ClassLoader object that loads this class is used to load the nut classes and the component classes.
public NutsProcessor(java.lang.ClassLoader classloader)
classloader - the ClassLoader object to load component classes and resources.
public NutsProcessor(java.lang.ClassLoader classloader,
ResourceLoader rloader)
classloader - the ClassLoader object to load component classes.rloader - the ResourceLoader object to load resources.
public NutsProcessor(java.lang.ClassLoader cloader,
Container yan,
DefaultLifecycleManager manager,
java.io.File basedir)
cloader - the ClassLoader object to load component classes and resources.yan - the container that registers the components.manager - the life cycle manager.basedir - the base directory against which relative paths
found in the config file can be resolved.
public NutsProcessor(java.lang.ClassLoader cloader,
ResourceLoader rloader,
Container yan,
DefaultLifecycleManager manager,
java.io.File basedir)
cloader - the ClassLoader object to load component classes.rloader - the ResourceLoader object to load resources.yan - the container that registers the components.manager - the life cycle manager.basedir - the base directory against which relative paths
found in the config file can be resolved.
public NutsProcessor(java.lang.ClassLoader cloader,
Container yan)
cloader - the ClassLoader to load the component classes and resources.yan - the container that registeres the components.
public NutsProcessor(java.lang.ClassLoader cloader,
ResourceLoader rloader,
Container yan)
cloader - the ClassLoader to load the component classes.rloader - the ResourceLoader to load resources.yan - the container that registeres the components.| Method Detail |
|---|
public java.lang.Object deserialize(java.lang.Class type,
java.lang.String v)
throws java.lang.Throwable
type - the target type.v - the string literal.
java.lang.Throwable - when any error happens.public boolean isDeserializable(java.lang.Class type)
type - the target type.
public java.lang.String[] processResource(java.lang.String resourcename)
throws java.io.IOException
resourcename - the resource name.
java.io.IOException - when resource reading fails.
public java.lang.String[] processFile(java.lang.String filename)
throws java.io.IOException
filename - the configuration file name.
java.io.IOException - if file reading fails.
public java.lang.String[] processFile(java.io.File file)
throws java.io.IOException
file - the configuration file.
java.io.IOException - if file reading fails.
public java.lang.String[] process(java.lang.Object id,
java.io.InputStream in)
throws java.io.IOException
id - the module id.in - the InputStream object.
java.io.IOException - any io error.
public java.util.Map preInstantiate(Container container,
java.util.Map store)
container - the container to resolve dependency for these components.store - the Map object to collect the instantiated results.
The map key is UID, which is a combination of the module id and the component id.
public java.util.Map preInstantiate(Container container)
container - the container to resolve dependency for these components.
UID, which is a combination of the module id and the component id.public java.util.Map preInstantiate(java.util.Map store)
store - the Map object to collect the instantiated results.
The map key is UID, which is a combination of the module id and the component id.
public java.util.Map preInstantiate()
UID, which is a combination of the module id and the component id.public DefaultLifecycleManager getLifecycleManager()
public Container getContainer()
public java.io.File getBaseDir()
public java.lang.ClassLoader getClassLoader()
public ResourceLoader getResourceLoader()
public void registerAutoWiring(java.lang.String mode_name,
PropertyBinder mode)
mode_name - the mode name.mode - the PropertyBinder object encapsulating the autowiring logic.
public void registerAutoWiring(java.lang.String mode_name,
ParameterBinder mode)
mode_name - the mode name.mode - the ParameterBinder object encapsulating the autowiring logic.
public void registerDeserializer(java.lang.Class type,
Deserializer deserializer,
boolean overriding,
boolean mandatory)
throws java.lang.IllegalArgumentException
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.mandatory - true if this registration has to go through.
java.lang.IllegalArgumentException - if the registration is mandatory but not overriding
and an Deserializer object is already registered for the target type.public java.lang.Object findService(java.lang.Object key)
registerService(Object, Object).
key - the key to the service object.
public void registerService(java.lang.Object key,
java.lang.Object service)
NutEnvironment.findService(Object).
register and unregister are thread safe.
key - the service key.service - the service object.public void unregisterService(java.lang.Object key)
key - the key of the service object.public java.util.Set getServiceKeys()
public void registerNut(java.lang.String key,
NutDescriptor desc)
key - the key of the nut.desc - the descriptor.public NutDescriptor findNut(java.lang.String key)
key - the key of the NutDescriptor.
public void removeNut(java.lang.String key)
key - the key of the NutDescriptor.
public void registerVariable(java.lang.String key,
java.lang.Object val)
key - the variable name.val - the variable value.public java.lang.Object getVariable(java.lang.String key)
key - the variable name.
public boolean hasVariable(java.lang.String key)
key - the variable name.public void removeVariable(java.lang.String key)
key - the variable name.public java.util.Set getNutKeys()
public ParameterBinder getParameterWiring()
public void setParameterWiring(ParameterBinder param_wiring)
param_wiring - the wiring mode. Null if auto-wiring is disabled.public PropertyBinder getPropertyWiring()
public void setPropertyWiring(PropertyBinder prop_wiring)
prop_wiring - the wiring mode.
Null if auto-wiring is disabled.public SingletonMode getSingletonMode()
public void setSingletonMode(SingletonMode singleton_mode)
singleton_mode - the singleton mode.
Null if prototype is used.
public NutsProcessor createMetaProcessor(java.lang.ClassLoader loader,
ResourceLoader rloader)
The default singleton mode is "off" and the default parameter auto-wiring mode is "bytype".
All the service objects and externally registered nuts descriptors will be copied to this new NutsProcessor object.
It is fine to create an NutsProcessor object by calling the constructor directly. Any NutsProcessor object can be used to interpret meta configuration.
This method just makes it more convenient to set the default settings and copy the existing service objects and externally registered nut descriptors.
loader - The class loader to load classes.rloader - the ResourceLoader to load resources.
public NutsProcessor createMetaProcessor(java.lang.ClassLoader loader)
The default singleton mode is "off" and the default parameter auto-wiring mode is "bytype".
All the service objects and externally registered nuts descriptors will be copied to this new NutsProcessor object.
It is fine to create an NutsProcessor object by calling the constructor directly. Any NutsProcessor object can be used to interpret meta configuration.
This method just makes it more convenient to set the default settings and copy the existing service objects and externally registered nut descriptors.
loader - The class loader to load classes and resources.
public NutsProcessor createMetaInterpreter()
The component classloader is used to load classes.
The default singleton mode is "off" and the default parameter auto-wiring mode is "bytype".
All the service objects and externally registered nuts descriptors will be copied to this new NutsProcessor object.
It is fine to create an NutsProcessor object by calling the constructor directly. Any NutsProcessor object can be used to interpret meta configuration.
This method just makes it more convenient to set the default settings and copy the existing service objects and externally registered nut descriptors.
public void loadNutsFromContainer(Container nuts)
nuts - the container containing nut components.
public void loadNutsMetaFile(java.lang.ClassLoader loader,
ResourceLoader rloader,
java.lang.String filename)
throws java.io.IOException
By default, singleton mode in a nuts meta file is disabled.
loader - the class loader to load classes during interpretation.rloader - thefilename - the config file containing the nuts class wiring.
java.io.IOException - when file reading fails.
public void loadNutsMetaData(java.lang.Object id,
java.lang.ClassLoader loader,
ResourceLoader rloader,
java.io.InputStream in)
throws java.io.IOException
By default, singleton mode is disabled.
loader - the class loader to load classes during interpretation.rloader - the ResourceLoader to load resources during interpretation.in - the stream containing meta configuration information.
java.io.IOException - when file reading fails.
public void loadNutsMetaFile(java.lang.String filename)
throws java.io.IOException
By default, singleton mode in a nuts meta file is disabled.
The component classloader is used to load these nuts classes.
filename - the config file containing the nuts class wiring.
java.io.IOException - when file reading fails.
public void loadNutsMetaData(java.lang.Object id,
java.io.InputStream in)
throws java.io.IOException
By default, singleton mode is disabled.
The component classloader is used to load these nuts classes.
in - the stream containing meta configuration information.
java.io.IOException - when file reading fails.
public void loadNutsMetaResource(java.lang.String resourcename)
throws java.io.IOException
The Nut descriptors and their ids loaded from this InputStream will be used during interpretation of regular configuration files for components.
By default, singleton mode is disabled.
The component classloader is used to load these nuts classes.
resourcename - the name of the resource containing meta configuration
information.
java.io.IOException - when file reading fails.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||