Enhydra 3.1.1b1 API

org.enhydra.xml.xmlc.reloading
Class XMLCReloadingFactory

java.lang.Object
  |
  +--org.enhydra.xml.xmlc.reloading.XMLCReloadingFactory

public class XMLCReloadingFactory
extends java.lang.Object
implements XMLCFactory

Factory class to create instances of XMLC-generated class with automatic recompilation if the class is out-of-date relative to a source file.

This class can create objects from classes derived from XMLC objects. It uses a constructor that takes a boolean argument which delays the creation of the DOM until the delegate can be set. If the derived class requires another constructor, this can be approached in two ways. Either deriving a factory that creates objects through the derived constructor or used this factory object inside of the derived class constructor, obtain the delegate with getUpdatedClass(). Such a constructor would contain:

    super(false);
    setDelegate(factory.getUpdatedClassInstance());
    buildDocument();
 
If a log channel is supplied, logging maybe performed. The following log levels are used:

See Also:
StandardRecompilationHandler, ResourceLoader, ResourceLoaderFactory

Constructor Summary
XMLCReloadingFactory(RecompilationHandler recompiler, java.lang.ClassLoader classLoader, XMLCLogger logger)
          Constructor.
XMLCReloadingFactory(RecompilationHandler recompiler, ResourceLoader resourceLoader, XMLCLogger logger)
          Constructor.
 
Method Summary
 XMLObject create(java.lang.Class xmlcBasedClass)
          Create an instance of a XMLC-generated class or a class derived from one, given either a class or an interface object.
 XMLObject create(java.lang.String xmlcClassName)
          Create an instance of a XMLC-generated class or a class derived from one, given the name of the class.
 XMLCLogger getLogger()
          Get the logger.
 int getRecompileCount()
          Get the count of the number of recompilations that have occured.
 int getReloadCount()
          Get the count of the number of reloads that have occured.
 ResourceLoader getResourceLoader()
          Get the ResourceLoader associate this this factory
 XMLObject getUpdatedClassInstance(java.lang.Class xmlcBasedClass)
          If a XMLC class has been updated, get a new instance of it.
 java.lang.Class loadUpdatedClass(java.lang.Class xmlcBasedClass)
          Given a class that is either a XMLC-generate class or a class derived from one, determine if the generate class is out-of-date; if so recompile and return the new class as the delegate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLCReloadingFactory

public XMLCReloadingFactory(RecompilationHandler recompiler,
                            ResourceLoader resourceLoader,
                            XMLCLogger logger)
Constructor.
Parameters:
recompiler - Recompilation handler used to recompile objects. If null, classes will not be recompiled.
resourceLoader - ResourceLoader used to load classes and locate the source file. This is a wrapper around a class loader that implements functionality missing in the standard classloader interface.
logger - XMLC logger or null for no logging.

XMLCReloadingFactory

public XMLCReloadingFactory(RecompilationHandler recompiler,
                            java.lang.ClassLoader classLoader,
                            XMLCLogger logger)
Constructor.
Parameters:
recompiler - Recompilation handler used to recompile objects. If null, classes will not be recompiled.
classLoader - Classloader used to load classes when a class name is specified. This must be one of the class loaders that we have built-in knowledge of. The currently supported classloaders are:
  • com.lutris.classloader.MultiClassLoader
  • org.apache.tomcat.util.NetworkClassLoader
logger - XMLC logger or null for no logging.
Method Detail

loadUpdatedClass

public java.lang.Class loadUpdatedClass(java.lang.Class xmlcBasedClass)
Given a class that is either a XMLC-generate class or a class derived from one, determine if the generate class is out-of-date; if so recompile and return the new class as the delegate. This method is useful when building derived factory classes.
Parameters:
xmlcBasedClass - The XMLC-generate class or a subclass.
Returns:
The new version of the generated class, or null if the class is not out of date.
Throws:
XMLCReloadingException - If an error occurs obtaining the class.

getUpdatedClassInstance

public XMLObject getUpdatedClassInstance(java.lang.Class xmlcBasedClass)
If a XMLC class has been updated, get a new instance of it. Don't build the DOM at this time.
Parameters:
xmlcBasedClass - The XMLC-generate class or a subclass.
Returns:
A new instance of the XMLC-generate class (not the subclass, sutiable for use as a delegate. If the class is not out of date, null is returned.
Throws:
XMLCReloadingException - If an error occurs obtaining the class.

create

public XMLObject create(java.lang.String xmlcClassName)
Create an instance of a XMLC-generated class or a class derived from one, given the name of the class.

The class must have a constructor that takes a single boolean argument that will disable the immediate build of the DOM if false. XMLC creates such a constructor in the classes it generates.

Specified by:
create in interface XMLCFactory
Parameters:
xmlcClassName - The name of the XMLC class or derived class.
Returns:
The new object.
Throws:
XMLCReloadingException - If an error occurs creating the object.
See Also:
create(Class)

create

public XMLObject create(java.lang.Class xmlcBasedClass)
Create an instance of a XMLC-generated class or a class derived from one, given either a class or an interface object.

If a class is given, then it should be either the XMLC generated class or a class derived from it.

If an interface is given, it is converted to the implementation name by appending "Impl" to the name. In this case, the implementation must be in the same package.

The class must have a constructor that takes a single boolean argument that will disable the immediate build of the DOM if false. XMLC creates such a constructor in the classes it generates.

Specified by:
create in interface XMLCFactory
Parameters:
xmlcBasedClass - The Class object for the class or interface.
Returns:
The new object.
Throws:
XMLCReloadingException - If an error occurs creating the object.

getResourceLoader

public ResourceLoader getResourceLoader()
Get the ResourceLoader associate this this factory

getLogger

public XMLCLogger getLogger()
Get the logger.

getReloadCount

public int getReloadCount()
Get the count of the number of reloads that have occured.

getRecompileCount

public int getRecompileCount()
Get the count of the number of recompilations that have occured.

Enhydra 3.1.1b1 API