org.apache.commons.clazz.reflect
Class ReflectedClazzLoader

java.lang.Object
  extended by org.apache.commons.clazz.ClazzLoader
      extended by org.apache.commons.clazz.reflect.ReflectedClazzLoader
Direct Known Subclasses:
ExtendedReflectedClazzLoader, StandardReflectedClazzLoader

public abstract class ReflectedClazzLoader
extends ClazzLoader

Version:
$Id: ReflectedClazzLoader.java 155436 2005-02-26 13:17:48Z dirkv $
Author:
Dmitri Plotnikov

Constructor Summary
ReflectedClazzLoader(ModelClazzLoader modelClazzLoader, ClassLoader classLoader)
           
 
Method Summary
protected abstract  Clazz createClazz(Class javaClass)
          Override this method to construct an Clazz for the given Class (javaClass).
 Clazz defineClazz(String name, Class clazzClass, Class instanceClass)
          Defines a new Clazz with the supplied name.
 Clazz getClazzForName(String name)
          Given a Clazz name, returns the corresponding Clazz.
 String getClazzName(Object instance)
          Returns the clazz name for the supplied instance.
 boolean isMember(Object instance)
          Returns true for all objects.
protected  boolean isSupportedClass(Class javaClass)
          Returns true for all classes supported by this specific clazz loader.
protected  Clazz lookupCustomClazz(Class javaClass)
          Try to find and allocate a custom Clazz for the specified Java class.
 
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
 

Constructor Detail

ReflectedClazzLoader

public ReflectedClazzLoader(ModelClazzLoader modelClazzLoader,
                            ClassLoader classLoader)
Method Detail

getClazzName

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

Specified by:
getClazzName in class ClazzLoader

getClazzForName

public Clazz getClazzForName(String name)
Description copied from class: ClazzLoader
Given a Clazz name, returns the corresponding Clazz. Does not cache clazzes, that's the job of CachingGroupClazzLoader. Return null if there is no Clazz for this name.

Note that we use canonical class names for primitive types and arrays, e.g. "byte", "byte[]", "boolean[][]", "java.lang.String[]".

Specified by:
getClazzForName in class ClazzLoader

lookupCustomClazz

protected Clazz lookupCustomClazz(Class javaClass)
Try to find and allocate a custom Clazz for the specified Java class. Build the name of the custom Clazz class out of the name of the Java class, followed by the model name, followed by the word "Clazz". For example, if the java class is called "my.Foo", and the model is "Standard", the corresponding Clazz class name is "my.FooStandardClazz".

Parameters:
javaClass -
Returns:
Clazz

isMember

public boolean isMember(Object instance)
Returns true for all objects.

Specified by:
isMember in class ClazzLoader
See Also:
ClazzLoader.isMember(Object)

isSupportedClass

protected boolean isSupportedClass(Class javaClass)
Returns true for all classes supported by this specific clazz loader.


createClazz

protected abstract Clazz createClazz(Class javaClass)
Override this method to construct an Clazz for the given Class (javaClass). Make sure that the new Clazz is initialized with the supplied clazzLoader representing the clazz loader group, not with this.


defineClazz

public Clazz defineClazz(String name,
                         Class clazzClass,
                         Class instanceClass)
Description copied from class: 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.

Specified by:
defineClazz in class ClazzLoader
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)


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.