org.melati.app
Class AbstractConfigApp

Package class diagram package AbstractConfigApp
java.lang.Object
  extended by org.melati.app.AbstractConfigApp
All Implemented Interfaces:
App
Direct Known Subclasses:
AbstractPoemApp, ConfigApp

public abstract class AbstractConfigApp
extends Object
implements App

ConfigApp is the simplest way to use Melati. All a ConfigApp does is to configure a Melati. Importantly it does not establish a Poem session leaving you to do this for yourself. If you want a POEM session established, please extend AbstractPoemApp. ConfigApp does set up a basic PoemContext with the Method set, but not the POEM logicaldatabase, table or troid. The arguments are expected to end with a freeform string telling your application what it is meant to do. This is automatically made available in templates as $melati.Method. You can change the way these things are determined by overriding poemContext(org.melati.Melati).


Field Summary
protected static MelatiConfig melatiConfig
           
protected  PrintStream output
           
 
Constructor Summary
AbstractConfigApp()
           
 
Method Summary
protected  String[] applyNamedArguments(String[] arguments)
           
protected abstract  void doConfiguredRequest(Melati melati)
          Instantiate this method to build up your own output.
 String getSysAdminEmail()
          This method SHOULD be overidden.
 String getSysAdminName()
          This method SHOULD be overidden.
 Melati init(String[] args)
          Initialise.
protected  MelatiConfig melatiConfig()
          Set application properties from the default properties file.
protected  PoemContext poemContext(Melati melati)
          Set up the (@link PoemContext}, but only the Method.
 void run(String[] args)
          Do our thing.
 void setOutput(PrintStream out)
          Set output.
 void term(Melati melati)
          Clean up at end of run.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

melatiConfig

protected static MelatiConfig melatiConfig

output

protected PrintStream output
Constructor Detail

AbstractConfigApp

public AbstractConfigApp()
Method Detail

init

public Melati init(String[] args)
            throws MelatiException
Initialise.

Parameters:
args - the command line arguments
Returns:
a newly created Melati
Throws:
MelatiException - if something goes wrong during initialisation

term

public void term(Melati melati)
          throws IOException
Clean up at end of run. Overridden in PoemApp.

Parameters:
melati - the melati
Throws:
IOException - if there is an io problem

melatiConfig

protected MelatiConfig melatiConfig()
                             throws MelatiException
Set application properties from the default properties file. This method will look for a properties file called org.melati.MelatiConfig.properties; if it finds that the AccessHandler is an Http handler it will set the access handler to OpenAccessHandler. Similarly ServletTemplateEngine is changed to TemplateEngine. To override any setting from MelatiConfig.properties, simply override this method and return a vaild MelatiConfig. eg to use a different AccessHandler from the default:
 protected MelatiConfig melatiConfig() throws MelatiException {
   MelatiConfig config = super.melatiConfig();
   config.setAccessHandler(new YourAccessHandler());
   return config;
 }
 

Throws:
MelatiException - if anything goes wrong with Melati

run

public void run(String[] args)
         throws Exception
Do our thing.

Specified by:
run in interface App
Throws:
Exception

getSysAdminName

public String getSysAdminName()
This method SHOULD be overidden.

Returns:
the System Administrators name.

getSysAdminEmail

public String getSysAdminEmail()
This method SHOULD be overidden.

Returns:
the System Administrators email address.

poemContext

protected PoemContext poemContext(Melati melati)
Set up the (@link PoemContext}, but only the Method.

Parameters:
melati - the current Melati
Returns:
a partially configured PoemContext

applyNamedArguments

protected String[] applyNamedArguments(String[] arguments)

setOutput

public void setOutput(PrintStream out)
Set output. Call this before calling run to change output from System.out.

Specified by:
setOutput in interface App
Parameters:
out - where to write to
See Also:
App.setOutput(java.io.PrintStream)

doConfiguredRequest

protected abstract void doConfiguredRequest(Melati melati)
                                     throws Exception
Instantiate this method to build up your own output.

Parameters:
melati - a configured Melati
Throws:
Exception - if anything goes wrong


Copyright © 2000-2010 PanEris. All Rights Reserved.