org.ungoverned.moduleloader.search
Class SelfContainedSearchPolicy

java.lang.Object
  extended byorg.ungoverned.moduleloader.search.SelfContainedSearchPolicy
All Implemented Interfaces:
SearchPolicy

public class SelfContainedSearchPolicy
extends java.lang.Object
implements SearchPolicy

This class implements a ModuleLoader search policy that assumes that all modules are self-contained. In other words, when loading a class or resource for a particular module, only that particular module's resource sources are search. No classes or resources are shared among modules.

See Also:
SearchPolicy, Module, ModuleClassLoader, ModuleManager

Constructor Summary
SelfContainedSearchPolicy()
           
 
Method Summary
 java.lang.Class findClass(Module module, java.lang.String name)
          Simply returns null which forces the module class loader to only search the target module's resource sources for the specified class.
 java.net.URL findResource(Module module, java.lang.String name)
          Simply returns null which forces the module class loader to only search the target module's resource sources for the specified resource.
 void setModuleManager(ModuleManager mgr)
          This method is part of the SearchPolicy interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SelfContainedSearchPolicy

public SelfContainedSearchPolicy()
Method Detail

setModuleManager

public void setModuleManager(ModuleManager mgr)
                      throws java.lang.IllegalStateException
This method is part of the SearchPolicy interface. This method is called by the ModuleManager once to give the search policy instance a reference to its associated module manager. This method should be implemented such that it cannot be called twice; calling this method a second time should produce an illegal state exception.

Specified by:
setModuleManager in interface SearchPolicy
Parameters:
mgr - the module manager associated with this search policy.
Throws:
java.lang.IllegalStateException - if the method is called more than once.

findClass

public java.lang.Class findClass(Module module,
                                 java.lang.String name)
Simply returns null which forces the module class loader to only search the target module's resource sources for the specified class.

Specified by:
findClass in interface SearchPolicy
Parameters:
module - the target module that is loading the class.
name - the name of the class being loaded.
Returns:
null.

findResource

public java.net.URL findResource(Module module,
                                 java.lang.String name)
Simply returns null which forces the module class loader to only search the target module's resource sources for the specified resource.

Specified by:
findResource in interface SearchPolicy
Parameters:
module - the target module that is loading the class.
name - the name of the resource being loaded.
Returns:
null.