com.myarch.reloader
Class ClassCollectionController

java.lang.Object
  |
  +--com.myarch.reloader.ClassCollectionController
All Implemented Interfaces:
LoadController
Direct Known Subclasses:
ExceptionCollectionController

public class ClassCollectionController
extends java.lang.Object
implements LoadController

Allows for loading the classes listed with ClassCollectionController. Only the specified classes will be re-loaded.

Author:
Alexander Ananiev

Constructor Summary
ClassCollectionController()
          Constructs a new ClassCollectionController with the empty class list.
ClassCollectionController(java.util.Collection classes)
          Constructs a new ClassCollectionController with the specified collection of classes.
ClassCollectionController(java.lang.String pClass)
          Constructs a new ClassCollectionController with the class list containing a single class.
 
Method Summary
 void addClass(java.lang.String pClass)
          Adds a reloadable class to the class list.
 java.util.Collection getClasses()
          Returns the reloadable class list.
protected  boolean isClassFound(java.lang.String pClass)
          Returns true if class is found in the list of reloadable classes.
 boolean isLoadByParentAllowed(java.lang.String className, java.lang.String mainClassName, java.lang.ClassLoader loader)
          Prohibits using parent loader for loadable classes.
 boolean isReloadAllowed(java.lang.String className, java.lang.String mainClassName, java.lang.ClassLoader loader)
          Returns true if a class belongs to the list of reloadable classes and can be reloaded.
 void setClasses(java.util.Collection classes)
          Sets the collection of classes that can be reloaded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassCollectionController

public ClassCollectionController()
Constructs a new ClassCollectionController with the empty class list.

ClassCollectionController

public ClassCollectionController(java.util.Collection classes)
Constructs a new ClassCollectionController with the specified collection of classes.
Parameters:
classes - collection of reloadable classes

ClassCollectionController

public ClassCollectionController(java.lang.String pClass)
Constructs a new ClassCollectionController with the class list containing a single class.
Parameters:
pClass - class name
Method Detail

setClasses

public void setClasses(java.util.Collection classes)
Sets the collection of classes that can be reloaded.
Parameters:
classes - collection of reloadable classes

getClasses

public java.util.Collection getClasses()
Returns the reloadable class list.
Returns:
collection of reloadable classes

addClass

public void addClass(java.lang.String pClass)
Adds a reloadable class to the class list.
Parameters:
pClass - class name

isClassFound

protected boolean isClassFound(java.lang.String pClass)
Returns true if class is found in the list of reloadable classes.
Parameters:
pClass - class to look for
Returns:
true if a class belongs to the list

isReloadAllowed

public boolean isReloadAllowed(java.lang.String className,
                               java.lang.String mainClassName,
                               java.lang.ClassLoader loader)
Returns true if a class belongs to the list of reloadable classes and can be reloaded.
Specified by:
isReloadAllowed in interface LoadController
Parameters:
className - class name to load
mainClassName - name of the "main" class. Main class is a class passed as a parameter to Reloader.reload() method.
loader - the actual class loader used to load a class.
Returns:
true if class className is allowed to be loaded.

isLoadByParentAllowed

public boolean isLoadByParentAllowed(java.lang.String className,
                                     java.lang.String mainClassName,
                                     java.lang.ClassLoader loader)
Prohibits using parent loader for loadable classes. This ensures that the class is either loaded by the Reloader or ClassNotFoundException is thrown.
Specified by:
isLoadByParentAllowed in interface LoadController
Parameters:
className - class name to load
mainClassName - name of the "main" class. Main class is a class passed as a parameter to Reloader.reload() method.
loader - the actual class loader used to load a class (parent loader).
Returns:
false all the time to prohibit using the parent loader.


Copyright © 2001 Alexander Ananiev & MyArch.com. All Rights Reserved.