org.webmacro.util
Class ComponentMap

java.lang.Object
  |
  +--org.webmacro.util.ComponentMap

public class ComponentMap
extends java.lang.Object

A ComponentMap takes a list of component names and builds a Map of instance objects. You can include a filename in a list of components and the contents of that file will be inserted into the list. The format of the component list is a series of name=class entries separated by whitespace, commas, newlines, or semicolons. If the "name=" portion is omitted then the base classname of the component will be used as its name instead.

Here is an example:

 
       Freddy=org.webmacro.examples.Freddy
       /examples/COMPONENTS Critter=com.semiotek.creature.Mongrel
       org.webmacro.servlet.FormTool

 
The above component list defines Freddy, implemented by the class org.webmacro.examples.Freddy. Also, the contents of the file /examples/COMPONENTS will be read from the CLASSPTH and inserted into this component list. The last entry in the example above is a component with no explicit name: org.webmacro.servlet.FormTool. The base class name will be used as the name for this component: FormTool.

A component must have one of the following three constructors. They will be searched for in this order:

  1. public Component(String name, org.webmacro.util.Settings config)
  2. public Component(String name)
  3. public Component()
It is an error if a component does not even have the no-argument constructor. If you declare one of the constructors with an argument then your component will have some extra information available with which to configure itself when it is instantiated by the ComponentMap.


Constructor Summary
ComponentMap()
          Create a new ComponentMap for the supplied list of names separated on whitespace, commas, newlines, colons, and semicolons.
ComponentMap(Settings initProps)
          Create a new ComponentMap for the supplied list of names using the supplied Settings for initialization, if any initialization can be done.
 
Method Summary
protected  void add(java.lang.String component, java.lang.String suffix)
           
 java.lang.Object get(java.lang.Object name)
           
 java.util.Iterator keys()
          Get an iterator that walks throught he keys installed into this ComponentMap
 void load(java.lang.String namelist)
          Load the component map from the supplied namelist.
 void load(java.lang.String[] namelist)
          Load the component map from the supplied name list.
 void load(java.lang.String[] namelist, java.lang.String suffix)
          Load the component map from the supplied name list.
 void load(java.lang.String namelist, java.lang.String suffix)
          Load the component map from the supplied namelist.
static void main(java.lang.String[] arg)
           
 java.util.Iterator values()
          Get an iterator that walkst hrough the values installed into this ComponentMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentMap

public ComponentMap()
Create a new ComponentMap for the supplied list of names separated on whitespace, commas, newlines, colons, and semicolons.

ComponentMap

public ComponentMap(Settings initProps)
Create a new ComponentMap for the supplied list of names using the supplied Settings for initialization, if any initialization can be done. The name list will be separated on whitespace, commas, newlines, colons, and semicolons.
Method Detail

get

public java.lang.Object get(java.lang.Object name)

keys

public java.util.Iterator keys()
Get an iterator that walks throught he keys installed into this ComponentMap

values

public java.util.Iterator values()
Get an iterator that walkst hrough the values installed into this ComponentMap

load

public void load(java.lang.String namelist)
Load the component map from the supplied namelist. The string will be separated by spaces, tabs, newlines, commas, and semicolons, the load(String[]) will be called.

load

public void load(java.lang.String namelist,
                 java.lang.String suffix)
Load the component map from the supplied namelist. The string will be separated by spaces, tabs, newlines, commas, and semicolons, the load(String[]) will be called. The suffic will be dropped from the end of component names as they are registered, if they do not have an explicit name.

load

public void load(java.lang.String[] namelist)
Load the component map from the supplied name list.

load

public void load(java.lang.String[] namelist,
                 java.lang.String suffix)
Load the component map from the supplied name list. If key names are derived from class names then the supplied suffix will be dropped from the name.

add

protected void add(java.lang.String component,
                   java.lang.String suffix)

main

public static void main(java.lang.String[] arg)