com.scooterframework.admin
Class ApplicationConfig

java.lang.Object
  extended by com.scooterframework.admin.ApplicationConfig

public class ApplicationConfig
extends java.lang.Object

ApplicationConfig class configures an application in one of the three modes.

  1. WEB
  2. APP
  3. ORM

In the WEB mode, the application runs in a web container. Its file structure follows Scooter's file structure, unless you reset locations of some files as specified below.

In the APP mode, the application runs outside of a web container. Its file structure follows Scooter's file structure, unless you reset locations of some files as specified below. Scooter's JUnit test uses this mode.

In the ORM mode, no web container is necessary to use scooter. Any application can use Scooter's Active Record or SQL Data Express (SDE) capability in their data access layer. This can be achieved by just using scooter.jar file and some config property files (database.properties, environment.properties, log4j.properties, and sql.properties). The config files must be on the classpath of the running application.

In the ORM mode, application's file structure does not need to follow Scooter's file structure. This is good for those applications that want to include Scooter in their own data access layers.

See sample stand-alone application scooter-orm for more details.

For either WEB or APP mode, application path is required. It is automatically set by WebApplicationStartListener for web application or detected for non-web application.

For example, it the application is located in c:\>project\petclinic, then the application path would be 'c:\>project\petclinic'.

In either WEB or APP mode, the following properties can be set through System property from command line.

 Configurable System Properties and corresponding default values for web application:
         class.file.location => {app.path}/WEB-INF/classes
      property.file.location => {app.path}/WEB-INF/config
        source.file.location => {app.path}/WEB-INF/src
     reference.file.location => {scooter.home}/lib
 


Field Summary
static boolean noConsoleDisplay
           
static java.lang.String SYSTEM_KEY_CLASSFILE
           
static java.lang.String SYSTEM_KEY_PLUGINFILE
           
static java.lang.String SYSTEM_KEY_PROPERTYFILE
           
static java.lang.String SYSTEM_KEY_REFERENCEFILE
           
static java.lang.String SYSTEM_KEY_SOURCEFILE
           
 
Method Summary
 boolean applicationStarted()
           
static ApplicationConfig configInstanceForApp()
          Returns an instance of ApplicationConfig for non-web application based on Scooter's directory structure.
static ApplicationConfig configInstanceForOrmAlone()
          Returns an instance of ApplicationConfig for non-web application using only Scooter's ORM.
static ApplicationConfig configInstanceForWeb(java.lang.String webappPath, java.lang.String contextName)
          Returns an instance of ApplicationConfig for web application.
static java.lang.String detectRootPath()
           
 void endApplication()
           
 java.lang.String getApplicationPath()
           
 long getApplicationStartTime()
           
 java.lang.String getClassFileLocationPath()
           
 java.lang.String getConfiguredMode()
           
 java.lang.String getContextName()
           
static ApplicationConfig getInstance()
          Returns an instance of ApplicationConfig.
 java.lang.String getPluginsPath()
           
 java.lang.String getPropertyFileLocationPath()
           
 java.lang.String getReferencesLibPath()
           
 java.lang.String getRunningEnvironment()
          Returns running environment
static int getSessionCount()
          Returns number of sessions in the container.
 java.lang.String getSourceFileLocationPath()
           
 java.lang.String getWebappLibPath()
           
 boolean isApp()
          Return true if the current app is configured as a regular app.
 boolean isInDevelopmentEnvironment()
          Checks if the current running environment is development environment.
 boolean isInProductionEnvironment()
          Checks if the current running environment is production environment.
 boolean isInTestEnvironment()
          Checks if the current running environment is test environment.
 boolean isOrmAlone()
          Return true if the current app is configured to use orm alone.
 boolean isWebApp()
          Return true if the current app is configured as a web app.
 void setClassFileLocationPath(java.lang.String classFileLocationPath)
           
 void setPropertyFileLocationPath(java.lang.String propertyFileLocationPath)
           
 void setRunningEnvironment(java.lang.String runningEnvironment)
           
 void setSourceFileLocationPath(java.lang.String sourceFileLocationPath)
           
 void startApplication()
           
 void startORMApplication()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

noConsoleDisplay

public static boolean noConsoleDisplay

SYSTEM_KEY_CLASSFILE

public static final java.lang.String SYSTEM_KEY_CLASSFILE
See Also:
Constant Field Values

SYSTEM_KEY_PROPERTYFILE

public static final java.lang.String SYSTEM_KEY_PROPERTYFILE
See Also:
Constant Field Values

SYSTEM_KEY_SOURCEFILE

public static final java.lang.String SYSTEM_KEY_SOURCEFILE
See Also:
Constant Field Values

SYSTEM_KEY_PLUGINFILE

public static final java.lang.String SYSTEM_KEY_PLUGINFILE
See Also:
Constant Field Values

SYSTEM_KEY_REFERENCEFILE

public static final java.lang.String SYSTEM_KEY_REFERENCEFILE
See Also:
Constant Field Values
Method Detail

configInstanceForWeb

public static ApplicationConfig configInstanceForWeb(java.lang.String webappPath,
                                                     java.lang.String contextName)
Returns an instance of ApplicationConfig for web application. This method should be called the first time the application is accessed or by a start-up method of a web application.


configInstanceForApp

public static ApplicationConfig configInstanceForApp()
Returns an instance of ApplicationConfig for non-web application based on Scooter's directory structure. This method should be called in the application start program. Subsequent use of ApplicationConfig can then use ApplicationConfig.getInstance().

This method assumes the current directory as the application's root directory.


configInstanceForOrmAlone

public static ApplicationConfig configInstanceForOrmAlone()
Returns an instance of ApplicationConfig for non-web application using only Scooter's ORM. This method should be called in the application start program. Subsequent use of ApplicationConfig can then use ApplicationConfig.getInstance().

This method assumes that Scooter's config files are on classpath of the calling application.


getInstance

public static ApplicationConfig getInstance()
Returns an instance of ApplicationConfig. You should call either getInstanceForWeb() or getInstanceForApp() or getInstanceForOrmAlone() method before using this getInstance() method.


startORMApplication

public void startORMApplication()

startApplication

public void startApplication()

endApplication

public void endApplication()

detectRootPath

public static java.lang.String detectRootPath()

getSessionCount

public static int getSessionCount()
Returns number of sessions in the container.


getApplicationStartTime

public long getApplicationStartTime()

getApplicationPath

public java.lang.String getApplicationPath()

getContextName

public java.lang.String getContextName()

applicationStarted

public boolean applicationStarted()

getConfiguredMode

public java.lang.String getConfiguredMode()

isWebApp

public boolean isWebApp()
Return true if the current app is configured as a web app.


isApp

public boolean isApp()
Return true if the current app is configured as a regular app.


isOrmAlone

public boolean isOrmAlone()
Return true if the current app is configured to use orm alone.


getRunningEnvironment

public java.lang.String getRunningEnvironment()
Returns running environment


setRunningEnvironment

public void setRunningEnvironment(java.lang.String runningEnvironment)

isInDevelopmentEnvironment

public boolean isInDevelopmentEnvironment()
Checks if the current running environment is development environment.

Returns:
true if the current running environment is development.

isInTestEnvironment

public boolean isInTestEnvironment()
Checks if the current running environment is test environment.

Returns:
true if the current running environment is test.

isInProductionEnvironment

public boolean isInProductionEnvironment()
Checks if the current running environment is production environment.

Returns:
true if the current running environment is production.

getClassFileLocationPath

public java.lang.String getClassFileLocationPath()

getPropertyFileLocationPath

public java.lang.String getPropertyFileLocationPath()

getSourceFileLocationPath

public java.lang.String getSourceFileLocationPath()

getWebappLibPath

public java.lang.String getWebappLibPath()

getPluginsPath

public java.lang.String getPluginsPath()

getReferencesLibPath

public java.lang.String getReferencesLibPath()

setClassFileLocationPath

public void setClassFileLocationPath(java.lang.String classFileLocationPath)

setPropertyFileLocationPath

public void setPropertyFileLocationPath(java.lang.String propertyFileLocationPath)

setSourceFileLocationPath

public void setSourceFileLocationPath(java.lang.String sourceFileLocationPath)