com.oktiva.mogno
Class Application

java.lang.Object
  extended bycom.oktiva.mogno.Application
All Implemented Interfaces:
java.lang.Cloneable

public class Application
extends java.lang.Object
implements java.lang.Cloneable

The main Mogno application class. It's the "runnable" class, called from the servlet.

 import com.oktiva.mogno.*;
 ...
 Application myApp = new Application();
 myApp.addTopLevel("formLogin", "com.oktiva.myapp.TopLevel1", "TopLevel1.xml");
 myApp.addTopLevel("cadastroUsuario", "com.oktiva.myapp.TopLevel2", "TopLevel2.xml");
 myApp.addTopLevel("formBusca", "com.oktiva.myapp.TopLevel3", "TopLevel3.xml");
 myApp.setDefaultTopLevel("formLogin");
 

Version:
$Id: Application.java,v 1.1.1.1 2005/01/05 16:52:43 ruoso Exp $
Author:
Itamar Carvalho <itamar@oktiva.com.br>

Field Summary
protected  ApplicationFiler applicationFiler
           
protected  java.util.Hashtable applicationFilerParams
           
protected  java.lang.String defaultTopLevel
           
protected  boolean designing
           
protected  javax.servlet.http.HttpServletRequest request
           
protected  javax.servlet.http.HttpServletResponse response
           
protected  javax.servlet.http.HttpSession session
           
protected  java.util.Hashtable topLevels
           
protected  java.util.Hashtable topLevelsData
          Hashtable of Hashtables.
 
Constructor Summary
Application()
          Creates a new instance of Application
 
Method Summary
 void addTopLevel(java.lang.String name, java.lang.String topLevelClass)
          Add the TopLevel data supplied to the topLevelsData Hashtable.
 void addTopLevel(java.lang.String name, java.lang.String topLevelClass, java.lang.String xmlFileName)
          Add the TopLevel data supplied to the topLevelsData Hashtable.
 void emergency(java.lang.Throwable e)
          Prints the stack trace for an exception to the user, in text/plain format.
 Application getClone()
           
 java.lang.String getDefaultTopLevel()
           
 java.lang.String getRootDir()
          Get the root dir for this application.
 javax.servlet.http.HttpServletRequest getServletRequest()
           
 javax.servlet.http.HttpServletResponse getServletResponse()
           
 javax.servlet.http.HttpSession getSession()
           
 TopLevel getTopLevel(java.lang.String name)
          Get the TopLevel registered under the name supplied.
 java.lang.String getTopLevelClassname(java.lang.String topLevelName)
           
 java.util.Hashtable getTopLevelsData()
          Get the Hashtable with the data of this application's TopLevels.
 java.lang.String getTopLevelXmlFileName(java.lang.String topLevelName)
           
 void initialize()
          Initialize this application with a custom filer.
 void initialize(java.io.File xmlFile)
          Initialize this application passing the XML file to load.
 void initialize(java.lang.String xmlFileName)
          Initialize this application passing the XML file to load.
 boolean isDesigning()
          Getter for property designing.
 void out(java.lang.String str)
          Outputs the string received without setting any header.
 void outHtml(java.lang.String html)
          Outputs the string received as text/html content to the user.
 void removeTopLevel(java.lang.String name)
          Remove from the application the TopLevel registered under the name supplied.
 void run(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Run this application, with the data in the request.
 void setApplicationFiler(ApplicationFiler filer)
          Set a custom ApplicationFiler to use instead of the DefaultApplicationFiler.
 void setApplicationFilerParams(java.util.Hashtable params)
          Set the params for the custom ApplicationFiler.
 void setDefaultTopLevel(java.lang.String name)
          Set the TopLevel that will be shown when this application is called without mognoOrigin parameter.
 void setDesigning(boolean designing)
          Setter for property designing.
 void setRootDir(java.lang.String dir)
          Set the root dir for this application.
 void store()
          Store the current application into the file defined by the xmlFileName property
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

request

protected javax.servlet.http.HttpServletRequest request

response

protected javax.servlet.http.HttpServletResponse response

session

protected javax.servlet.http.HttpSession session

defaultTopLevel

protected java.lang.String defaultTopLevel

topLevels

protected java.util.Hashtable topLevels

topLevelsData

protected java.util.Hashtable topLevelsData
Hashtable of Hashtables. The keys are the TopLevels names and the inner Hashtables has the keys class and xml.


applicationFiler

protected ApplicationFiler applicationFiler

applicationFilerParams

protected java.util.Hashtable applicationFilerParams

designing

protected boolean designing
Constructor Detail

Application

public Application()
Creates a new instance of Application

Method Detail

initialize

public void initialize(java.lang.String xmlFileName)
                throws java.io.IOException
Initialize this application passing the XML file to load.

Parameters:
xmlFileName - The path to the XML file to load.
Throws:
java.io.IOException

initialize

public void initialize(java.io.File xmlFile)
                throws java.io.IOException
Initialize this application passing the XML file to load.

Parameters:
xmlFile - The File whith XML to load.
Throws:
java.io.IOException
See Also:
initialize(String)

initialize

public void initialize()
                throws java.io.IOException
Initialize this application with a custom filer. You need to use setApplicationFiler and setApplicationFilerParams.

Throws:
java.io.IOException

setApplicationFiler

public void setApplicationFiler(ApplicationFiler filer)
Set a custom ApplicationFiler to use instead of the DefaultApplicationFiler.

Parameters:
filer - The ApplicationFiler to use.
See Also:
setApplicationFilerParams(Hashtable), initialize()

setApplicationFilerParams

public void setApplicationFilerParams(java.util.Hashtable params)
Set the params for the custom ApplicationFiler.

Parameters:
params - The params to pass to the filer.
See Also:
setApplicationFiler(ApplicationFiler), initialize()

store

public void store()
           throws java.io.IOException
Store the current application into the file defined by the xmlFileName property

Throws:
java.io.IOException

addTopLevel

public void addTopLevel(java.lang.String name,
                        java.lang.String topLevelClass)
                 throws com.oktiva.mogno.DuplicatedTopLevelException
Add the TopLevel data supplied to the topLevelsData Hashtable. The XML file name defaults to name.xml.

Parameters:
name - Name of the TopLevel. Must be unique.
topLevelClass - Fully qualified name of the TopLevel class.
Throws:
com.oktiva.mogno.DuplicatedTopLevelException - If there is already a TopLevel with the specified name.

addTopLevel

public void addTopLevel(java.lang.String name,
                        java.lang.String topLevelClass,
                        java.lang.String xmlFileName)
                 throws com.oktiva.mogno.DuplicatedTopLevelException
Add the TopLevel data supplied to the topLevelsData Hashtable.

Parameters:
name - Name of the TopLevel. Must be unique.
topLevelClass - Fully qualified name of the TopLevel class.
xmlFileName - Name of the XML file for this TopLevel, without path.
Throws:
com.oktiva.mogno.DuplicatedTopLevelException - If there is already a TopLevel with the specified name.

removeTopLevel

public void removeTopLevel(java.lang.String name)
                    throws com.oktiva.mogno.TopLevelNotFoundException
Remove from the application the TopLevel registered under the name supplied. Does not change the XML, you must call store() if you want this.

Parameters:
name - Name of the TopLevel to remove.
Throws:
com.oktiva.mogno.TopLevelNotFoundException - If the name is not the name of a registered TopLevel.

getTopLevelsData

public java.util.Hashtable getTopLevelsData()
Get the Hashtable with the data of this application's TopLevels.

See Also:
topLevelsData

setDefaultTopLevel

public void setDefaultTopLevel(java.lang.String name)
                        throws com.oktiva.mogno.TopLevelNotFoundException
Set the TopLevel that will be shown when this application is called without mognoOrigin parameter.

Parameters:
name - Name of the default TopLevel.
Throws:
com.oktiva.mogno.TopLevelNotFoundException - If the name is not the name of a registered TopLevel.

getDefaultTopLevel

public java.lang.String getDefaultTopLevel()
Returns:
The name of the default TopLevel.

getTopLevel

public TopLevel getTopLevel(java.lang.String name)
                     throws java.lang.ClassNotFoundException,
                            java.lang.InstantiationException,
                            java.lang.IllegalAccessException,
                            InitializeException,
                            com.oktiva.mogno.TopLevelNotFoundException
Get the TopLevel registered under the name supplied.

Parameters:
name - Name of the TopLevel to get.
Returns:
The TopLevel associated with the name or null if the name is not found.
Throws:
java.lang.ClassNotFoundException - If the class of the TopLevel can not be found in the CLASSPATH.
java.lang.InstantiationException - If the reflection system can't instantiate the TopLevel's class.
java.lang.IllegalAccessException - If the class or it's constructor is not acessible.
InitializeException - If the initialization proccess of the TopLevel fails.
com.oktiva.mogno.TopLevelNotFoundException

setRootDir

public void setRootDir(java.lang.String dir)
Set the root dir for this application.


getRootDir

public java.lang.String getRootDir()
Get the root dir for this application.


getTopLevelClassname

public java.lang.String getTopLevelClassname(java.lang.String topLevelName)
                                      throws com.oktiva.mogno.TopLevelNotFoundException
Throws:
com.oktiva.mogno.TopLevelNotFoundException

getTopLevelXmlFileName

public java.lang.String getTopLevelXmlFileName(java.lang.String topLevelName)
                                        throws com.oktiva.mogno.TopLevelNotFoundException
Throws:
com.oktiva.mogno.TopLevelNotFoundException

run

public void run(javax.servlet.http.HttpServletRequest request,
                javax.servlet.http.HttpServletResponse response)
         throws java.io.IOException
Run this application, with the data in the request.

Throws:
java.io.IOException

emergency

public void emergency(java.lang.Throwable e)
               throws java.io.IOException
Prints the stack trace for an exception to the user, in text/plain format.

Throws:
java.io.IOException

outHtml

public void outHtml(java.lang.String html)
             throws java.io.IOException
Outputs the string received as text/html content to the user.

Throws:
java.io.IOException

out

public void out(java.lang.String str)
         throws java.io.IOException
Outputs the string received without setting any header. You must get and configure the response object to do what you want.

Throws:
java.io.IOException

getServletRequest

public javax.servlet.http.HttpServletRequest getServletRequest()
Returns:
the servlet request passed to run()

getServletResponse

public javax.servlet.http.HttpServletResponse getServletResponse()
Returns:
the servlet response passed to run()

getSession

public javax.servlet.http.HttpSession getSession()
Returns:
the HTTP Session

getClone

public Application getClone()

isDesigning

public boolean isDesigning()
Getter for property designing.

Returns:
Value of property designing.
See Also:
designing

setDesigning

public void setDesigning(boolean designing)
Setter for property designing.

Parameters:
designing - New value of property designing.
See Also:
designing