org.apache.commons.clazz.common
Class GroupClazzLoader

java.lang.Object
  extended byorg.apache.commons.clazz.ClazzLoader
      extended byorg.apache.commons.clazz.common.GroupClazzLoader
Direct Known Subclasses:
BeanGroupClazzLoader, ReflectedGroupClazzLoader

public class GroupClazzLoader
extends org.apache.commons.clazz.ClazzLoader

Aggregates multiple ClazzLoaders, which are invoked one after another according to the ChainOfResponsibility pattern. Note that member clazz loaders are invoked in the order reverse to the order they were added.

Version:
$Id: GroupClazzLoader.java,v 1.6 2004/02/19 23:58:40 scolebourne Exp $
Author:
Dmitri Plotnikov

Field Summary
protected  ArrayList loaders
          List of member loaders.
 
Constructor Summary
GroupClazzLoader(org.apache.commons.clazz.ModelClazzLoader modelClazzLoader)
           
 
Method Summary
 void addClazzLoader(org.apache.commons.clazz.ClazzLoader loader)
          Adds a ClazzLoader to the group.
 boolean canAddClazzLoader(org.apache.commons.clazz.ClazzLoader loader)
          Returns true if the supplied loader "belongs" in the group and can be added to it.
 org.apache.commons.clazz.Clazz defineClazz(String name, Class clazzClass, Class instanceClass)
          Defines a new Clazz with the supplied name.
 org.apache.commons.clazz.Clazz getClazzForName(String name)
          Given a Clazz name, produces the corresponding Clazz by invoking member loaders one by one until the clazz is found.
 List getClazzLoaders()
          Returns all clazz loaders registered with this group, in the order of priority
 String getClazzName(Object instance)
          Returns the clazz name for the supplied instance.
 boolean isMember(Object instance)
          Returns true iff this group has a member loader that has or can construct a Clazz for the supplied instance.
 
Methods inherited from class org.apache.commons.clazz.ClazzLoader
enableLogging, getClazz, getModel, getModelClazzLoader, isLoggingEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loaders

protected ArrayList loaders
List of member loaders. Note that the list is always iterated in the reverse direction, so the loaded add last is the one invoked first.

Constructor Detail

GroupClazzLoader

public GroupClazzLoader(org.apache.commons.clazz.ModelClazzLoader modelClazzLoader)
Method Detail

canAddClazzLoader

public boolean canAddClazzLoader(org.apache.commons.clazz.ClazzLoader loader)
Returns true if the supplied loader "belongs" in the group and can be added to it. The default implementation returns true.


addClazzLoader

public void addClazzLoader(org.apache.commons.clazz.ClazzLoader loader)
Adds a ClazzLoader to the group. ClazzLoaders added last are invoked first. Before the group adds the loader to itself, it checks if any of its members are groups themselves and, if so, tries to add the new loader to those subgroups.


isMember

public boolean isMember(Object instance)
Returns true iff this group has a member loader that has or can construct a Clazz for the supplied instance.


getClazzName

public String getClazzName(Object instance)
Description copied from class: org.apache.commons.clazz.ClazzLoader
Returns the clazz name for the supplied instance. Returns null if it cannot produce a clazz name for the instance.


getClazzForName

public org.apache.commons.clazz.Clazz getClazzForName(String name)
Given a Clazz name, produces the corresponding Clazz by invoking member loaders one by one until the clazz is found.


defineClazz

public org.apache.commons.clazz.Clazz defineClazz(String name,
                                                  Class clazzClass,
                                                  Class instanceClass)
Description copied from class: org.apache.commons.clazz.ClazzLoader
Defines a new Clazz with the supplied name. If it cannot define a clazz of the supplied type or if it cannot define clazzes at all, returns null.

Parameters:
name - the name of the clazz, should be unique within the scope of the top-level ClazzLoader
clazzClass - the Class of the Clazz that this method needs to produce.
instanceClass - the Class of the instances the new Clazz will be able to create using the newInstance() method.
Returns:
Clazz
See Also:
ClazzLoader.defineClazz(String, Class, Class)

getClazzLoaders

public List getClazzLoaders()
Returns all clazz loaders registered with this group, in the order of priority



Copyright © 2002-2005 The Apache Software Foundation. All Rights Reserved.