Update of /cvsroot/larm/larm/src/java/larm/root
In directory sc8-pr-cvs1:/tmp/cvs-serv23925/src/java/larm/root
Added Files:
LARM.java
Log Message:
- Big bad update, reorganization, etc.
--- NEW FILE: LARM.java ---
package larm.root;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import larm.config.PropertyManager;
import larm.framework.Context;
import larm.framework.Contextualizable;
import larm.framework.Lifecycle;
import larm.framework.Startable;
import larm.framework.config.Configurable;
import larm.framework.config.Configuration;
import larm.pipes.PipelineManager;
import larm.sources.SourceManager;
import org.xml.sax.SAXException;
/**
* LARM
*
* @author
* @version $Id: LARM.java,v 1.1 2003/07/29 15:11:41 otis Exp $
*/
public final class LARM implements Configurable, Contextualizable, Startable
{
/**
* reads the properties section and puts them to the system properties
*/
PropertyManager propertyManager = new PropertyManager();
/**
* reads the pipes section and registers all pipelines
*/
PipelineManager pipelineManager = new PipelineManager();
/**
* reads the sources section and initializes and starts all sources
*/
SourceManager sourceManager = new SourceManager();
/**
* this context contains the above objects
*/
Context context = new Context();
/**
* @see larm.config.Configurable#configure(larm.config.Configuration)
*/
public void configure(Configuration conf)
{
Lifecycle.configure(propertyManager, conf.getSubConfig("properties"));
Lifecycle.configure(pipelineManager, conf.getSubConfig("pipes"));
Lifecycle.configure(sourceManager, conf.getSubConfig("sources"));
}
/**
* @see larm.framework.Contextualizable#contextualize(larm.framework.Context)
*/
public void contextualize(Context ctx)
{
context.set("propertyManager", propertyManager);
context.set("sourceManager", sourceManager);
context.set("pipelineManager", pipelineManager);
Lifecycle.contextualize(propertyManager, context);
Lifecycle.contextualize(pipelineManager, context);
Lifecycle.contextualize(sourceManager, context);
}
/**
* @see larm.framework.Startable#start()
*/
public void start()
{
// Lifecycle.start(propertyManager);
Lifecycle.start(pipelineManager);
Lifecycle.start(sourceManager);
}
public static void main(String[] args)
{
System.out.println("LARM");
if(args.length != 1)
{
System.out.println("Usage: java larm.root.LARM <configfile.xml>");
}
Logger log = Logger.getLogger("");
log.setLevel(Level.CONFIG);
try
{
LARM larm = new LARM();
Configuration config = new Configuration(new FileReader(args[0]));
log.info("Configuring...");
Lifecycle.configure(larm, config.getSubConfig("/larm"));
log.info("Contextualizing...");
Lifecycle.contextualize(larm, null);
log.info("Starting...");
Lifecycle.start(larm);
}
catch(FileNotFoundException e)
{
System.out.println("Could not find file: " + args[0]);
}
catch(IOException e)
{
System.out.println("I/O Error while reading file: " + args[0]);
}
catch(SAXException e)
{
System.out.println("Error while parsing " + args[0] + ": " + e.getMessage());
}
}
}
|