org.tentackle.appworx
Class ConsoleApplication

java.lang.Object
  extended by org.tentackle.appworx.AbstractApplication
      extended by org.tentackle.appworx.ConsoleApplication

public abstract class ConsoleApplication
extends AbstractApplication

Abstract class to handle the application's lifecycle for a console application (no gui). Tentackle applications should extend this class and invoke start(java.lang.String[]). To shutdown gracefully, application should invokd stop().

The subclass just needs to provide a main-method, for example:

  MyApplication app = new MyApplication();
  app.start(args);
  
  // do something...
  
  app.stop();
 

Author:
harald

Constructor Summary
ConsoleApplication(String name)
          Creates an application.
 
Method Summary
 ModificationThread createModificationThread()
          Creates the modification thread ready for being started.
protected  void doFinishStartup()
          Finishes the startup.
Invoked after all has been displayed.
protected  ContextDb doLogin()
          Connects to the database backend (or application server).
protected  void doStop(int exitValue)
          Terminates the application gracefully.
 CommandLine getCommandLine()
          Gets the command line.
 String getName()
          Gets the application name.
protected  void installPreferences()
          Installs the preferences backend.
The default implementation installs the DbPreferencesFactory unless "--nodbprefs" is given.
protected  void installSecurityManager()
          installs the tentackle security manager
 void start(String[] args)
          Launches the application.
 void stop()
          Gracefully terminates the application.
 String toString()
          Gets the application's name.
 
Methods inherited from class org.tentackle.appworx.AbstractApplication
createContextDb, createDb, createUserInfo, detectEE, detectJNLP, doConfigureApplication, doInitialize, getContextDb, getDb, getProperties, getProperty, getRunningApplication, getUser, getUser, getUserInfo, isDeployedByEE, isDeployedByJNLP, register, securityRulesChanged, setContextDb, setProperties, setUserInfo, unregister, updateUserId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConsoleApplication

public ConsoleApplication(String name)
Creates an application.

Parameters:
name - the application's name
Method Detail

start

public void start(String[] args)
Launches the application.

Parameters:
args - the arguments (usually from commandline)

stop

public void stop()
Gracefully terminates the application. Usually invoked from an exit-Button or when window is closed.


toString

public String toString()
Gets the application's name.

Overrides:
toString in class Object
Returns:
the name

getCommandLine

public CommandLine getCommandLine()
Gets the command line.

Returns:
the command line

getName

public String getName()
Gets the application name.

Returns:
the application name

createModificationThread

public ModificationThread createModificationThread()
Creates the modification thread ready for being started. The default implementation creates the modthread with a polling interval of 2 seconds and which runs on a cloned db-connection.

Overrides:
createModificationThread in class AbstractApplication
Returns:
the created modification thread

installPreferences

protected void installPreferences()
Installs the preferences backend.
The default implementation installs the DbPreferencesFactory unless "--nodbprefs" is given. The option "--sysprefs" forces usage of system preferences only. "--roprefs" sets the preferences to readonly.

Overrides:
installPreferences in class AbstractApplication

installSecurityManager

protected void installSecurityManager()
installs the tentackle security manager

Overrides:
installSecurityManager in class AbstractApplication

doLogin

protected ContextDb doLogin()
                     throws ApplicationException
Connects to the database backend (or application server).

Returns:
the connected context db, null if login aborted or authentication failed
Throws:
ApplicationException

doFinishStartup

protected void doFinishStartup()
                        throws ApplicationException
Finishes the startup.
Invoked after all has been displayed. The default implementation starts the modification thread, unless "--nomodthread" given.

Overrides:
doFinishStartup in class AbstractApplication
Throws:
ApplicationException

doStop

protected void doStop(int exitValue)
Terminates the application gracefully. (this is the only do.. method that does not throw ApplicationException)

Parameters:
exitValue - the doStop value for System.exit()


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de