things.thinger.kernel.basic
Class KernelBasic_Loader

java.lang.Object
  extended by things.thinger.kernel.basic.KernelBasic_Loader
All Implemented Interfaces:
Verbose, Loader

public class KernelBasic_Loader
extends java.lang.Object
implements Loader, Verbose

A THINGS loader implementation for KernelBasic. This one will always take the cached version, even if it is aged.

It also load modules, but we do not allow the loader to compile new versions. The modules need to be in the classpath. I'll add the dynamic loading later it if it becomes desirable.

There is a lot of extra stuff here for more dynamic class management and caching. Of course, java isn't a big fan of multiple versions of the same named class, so I don't know if I'll ever get around to playing with it.

To be honest, this never really worked right. The library compiler and command line compiler named the inner classes differently, causing mayhem when encountered with a mix-match of dependent classes with inner classes. It is all fixable, but it just wasn't important at the time. I don't know anyone that actually used the dynamic loading anyway. (Too bad, because that was part of the reason for building a new kernel in the first place.

Trying to mesh the library compiler with the abstract universe was a gigantic pain in the ass. Thus was born the 'makeLocal' methods, which was a very unfortunate compromise. To a large degree, this one class alone might lead me to abandon Java for future personal projects.

Version:
1.0

Version History

EPG - Initial - 8 JUL 07
 
Author:
Erich P. Gatejen

Constructor Summary
KernelBasic_Loader()
          Constructor.
 
Method Summary
 void addSource(Universe sourceUniverse, java.lang.String sourceRoot)
          Add a source universe.
 void init(Universe cacheUniverse, java.lang.String cacheRoot)
          Initialize the loader.
 boolean isVerbose()
          Is it set to verbose?
 java.lang.Class<MODULE> loadModule(java.lang.String name)
          Load a MODULE class.
 java.lang.Class<THING> loadThing(java.lang.String name)
          Load a THING class.
 void purge()
          Purge the loader.
 void purgeThing(java.lang.String path)
          Purge a specific thing from the loader.
 void screech(java.lang.String message)
          Post a verbose message if verbose mode is on.
 void verboseOff()
          Turn off the verbose mode.
 void verboseOn(StringPoster poster)
          Turn on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KernelBasic_Loader

public KernelBasic_Loader()
                   throws SystemException
Constructor.

Throws:
SystemException
Method Detail

init

public void init(Universe cacheUniverse,
                 java.lang.String cacheRoot)
          throws SystemException
Initialize the loader. It will clear out any previous configuration, including the added sources. It should be harmless to do this whenever.

Specified by:
init in interface Loader
Parameters:
cacheUniverse - The universe in which to cache.
cacheRoot - The root for cached items.
Throws:
SystemException

addSource

public void addSource(Universe sourceUniverse,
                      java.lang.String sourceRoot)
               throws SystemException
Add a source universe.

Specified by:
addSource in interface Loader
Parameters:
sourceUniverse - The universe from where to load items.
sourceRoot - The root within the universe.
Throws:
SystemException

purge

public void purge()
           throws SystemException
Purge the loader. Any cached things will be dumped. This affects the internal cache only. The compiled cache in the system universe is left alone.

Specified by:
purge in interface Loader
Throws:
SystemException

purgeThing

public void purgeThing(java.lang.String path)
                throws SystemException
Purge a specific thing from the loader. If cached, it will be cleared. This affects the internal cache only. The compiled cache in the system universe is left alone. This will never cause an error, unless there is an init() problem.

Specified by:
purgeThing in interface Loader
Parameters:
path - the path to the item to purge.
Throws:
SystemException

loadThing

public java.lang.Class<THING> loadThing(java.lang.String name)
                                 throws SystemException
Load a THING class. It will take the cached version first.

Specified by:
loadThing in interface Loader
Parameters:
name - to the THING.
Returns:
A class for that thing. This is the binary name and it should reside in one of the registered
Throws:
SystemException
See Also:
THING

loadModule

public java.lang.Class<MODULE> loadModule(java.lang.String name)
                                   throws SystemException
Load a MODULE class.

Specified by:
loadModule in interface Loader
Parameters:
name - the name/path to the MODULE. Depends on the loader being used, but typically it's a classpath.
Returns:
A class for that module.
Throws:
SystemException
See Also:
MODULE

verboseOn

public void verboseOn(StringPoster poster)
               throws ThingsException
Turn on. It will test the poster and will throw a ThingsException if it has a problem.

Specified by:
verboseOn in interface Verbose
Parameters:
poster - StringPoster where to put the debug info
Throws:
ThingsException

verboseOff

public void verboseOff()
Turn off the verbose mode.

Specified by:
verboseOff in interface Verbose

screech

public void screech(java.lang.String message)
Post a verbose message if verbose mode is on. It will never throw an exception. The implementation may find a way to report exceptions.

Specified by:
screech in interface Verbose
Parameters:
message - The message.

isVerbose

public boolean isVerbose()
Is it set to verbose?

Specified by:
isVerbose in interface Verbose
Returns:
true if it is verbose, otherwise false.


Things.