helma.framework.core
Class ApplicationBean

java.lang.Object
  extended by helma.framework.core.ApplicationBean
All Implemented Interfaces:
java.io.Serializable

public class ApplicationBean
extends java.lang.Object
implements java.io.Serializable

Application bean that provides a handle to the scripting environment to application specific functionality.

See Also:
Serialized Form

Constructor Summary
ApplicationBean(Application app)
          Creates a new ApplicationBean object.
 
Method Summary
 void addCronJob(java.lang.String functionName)
          Add a cron job that will run once a minute
 void addCronJob(java.lang.String functionName, java.lang.String year, java.lang.String month, java.lang.String day, java.lang.String weekday, java.lang.String hour, java.lang.String minute)
          Add a cron job that will run at the specified time intervals
 void addRepository(java.lang.Object obj)
          Add a repository to the app's repository list.
 void clearCache()
          Clear the application cache.
 int countSessions()
          Return the number of currently active sessions
 SessionBean createSession(java.lang.String sessionID)
          Create a new session with the given session id
 void debug(java.lang.Object msg)
          Log a DEBUG message to the app log if debug is set to true in app.properties.
 void debug(java.lang.String logname, java.lang.Object msg)
          Log a DEBUG message to the log defined by logname if debug is set to true in app.properties.
 Application get__app__()
           
 int getActiveThreads()
          Get the number of currently active request threads
 INode[] getActiveUsers()
          Get an array of currently active registered users
 java.lang.String getAppDir()
          Return the absolute application directory (appdir property in apps.properties file)
 java.util.Map getAppsProperties()
          Get a wrapper around the app's apps.properties
 int getCacheusage()
          Returns the number of elements in the NodeManager's cache
 java.lang.String getCharset()
          Return the app's default charset/encoding.
 java.lang.ClassLoader getClassLoader()
          Get the app's classloader
 java.util.Map getCronJobs()
          Returns an read-only map of the custom cron jobs registered with the app
 INode getData()
          Returns the app's data node used to share data between the app's evaluators
 java.util.Map getDbProperties()
          Get a wrapper around the app's db properties
 DbSource getDbSource(java.lang.String name)
          Return a DbSource object for a given name.
 java.lang.String getDir()
          Returns the absolute path of the app dir.
 long getErrorCount()
           
 int getFreeThreads()
          Get the number of currently available threads/request evaluators
 java.lang.String[] getGlobalMacroPath()
          Get the path for global macro resolution
 org.apache.commons.logging.Log getLogger()
          Get the app's event logger.
 org.apache.commons.logging.Log getLogger(java.lang.String logname)
          Get the app logger.
 int getMaxThreads()
          Get the maximal thread number for this application
 java.util.Map getModules()
          Returns the app's modules map used to register application modules
 java.lang.String getName()
           
 java.util.Map getProperties()
          Get a wrapper around the app's properties
 Prototype getPrototype(java.lang.String name)
          Get a prototype by name.
 Prototype[] getPrototypes()
          Get an array of this app's prototypes
 INode[] getRegisteredUsers()
          Get an array of all registered users
 java.lang.Object[] getRepositories()
          Returns the app's repository list.
 long getRequestCount()
           
 java.lang.String getServerDir()
          Return the absolute server directory
 SessionBean getSession(java.lang.String sessionID)
          Get a session object for the specified session id
 SessionBean[] getSessions()
          Get an array of all active sessions
 SessionBean[] getSessionsForUser(INode usernode)
          Get an array of all currently active sessions for a given user node
 SessionBean[] getSessionsForUser(java.lang.String username)
          Get an array of all currently active sessions for a given user name
 Skin getSkin(java.lang.String protoname, java.lang.String skinname, java.lang.Object[] skinpath)
          Return a skin for a given object.
 java.util.Map getSkinfiles()
          Return a map of skin resources
 java.util.Map getSkinfilesInPath(java.lang.Object[] skinpath)
          Return a map of skin resources including the app-specific skinpath
 java.util.Date getUpSince()
           
 INode getUser(java.lang.String username)
          Get a user object with the given name
 long getXmlrpcCount()
           
 java.lang.Object invoke(java.lang.Object thisObject, java.lang.Object function, java.lang.Object[] args)
          Trigger a synchronous Helma invocation with a default timeout of 30 seconds.
 java.lang.Object invoke(java.lang.Object thisObject, java.lang.Object function, java.lang.Object[] args, long timeout)
          Trigger a synchronous Helma invocation.
 FutureResult invokeAsync(java.lang.Object thisObject, java.lang.Object function, java.lang.Object[] args)
          Trigger an asynchronous Helma invocation.
 FutureResult invokeAsync(java.lang.Object thisObject, java.lang.Object function, java.lang.Object[] args, long timeout)
          Trigger an asynchronous Helma invocation.
 void log(java.lang.Object msg)
          Log a INFO message to the app log.
 void log(java.lang.String logname, java.lang.Object msg)
          Log a INFO message to the log defined by logname.
 INode registerUser(java.lang.String username, java.lang.String password)
          Register a user with the given name and password using the database mapping of the User prototype
 void removeCronJob(java.lang.String functionName)
          Unregister a previously registered cron job
 void setGlobalMacroPath(java.lang.String[] path)
          Set the path for global macro resolution
 void setMaxThreads(int n)
          Set the maximal thread number for this application
 java.lang.String toString()
          Return a string presentation of this AppBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ApplicationBean

public ApplicationBean(Application app)
Creates a new ApplicationBean object.

Parameters:
app - ...
Method Detail

clearCache

public void clearCache()
Clear the application cache.


getLogger

public org.apache.commons.logging.Log getLogger()
Get the app's event logger. This is a Log with the category helma.[appname].event.

Returns:
the app logger.

getLogger

public org.apache.commons.logging.Log getLogger(java.lang.String logname)
Get the app logger. This is a commons-logging Log with the category logname.

Returns:
a logger for the given log name.

log

public void log(java.lang.Object msg)
Log a INFO message to the app log.

Parameters:
msg - the log message

log

public void log(java.lang.String logname,
                java.lang.Object msg)
Log a INFO message to the log defined by logname.

Parameters:
logname - the name (category) of the log
msg - the log message

debug

public void debug(java.lang.Object msg)
Log a DEBUG message to the app log if debug is set to true in app.properties.

Parameters:
msg - the log message

debug

public void debug(java.lang.String logname,
                  java.lang.Object msg)
Log a DEBUG message to the log defined by logname if debug is set to true in app.properties.

Parameters:
logname - the name (category) of the log
msg - the log message

getRepositories

public java.lang.Object[] getRepositories()
Returns the app's repository list.

Returns:
the an array containing this app's repositories

addRepository

public void addRepository(java.lang.Object obj)
Add a repository to the app's repository list. The .zip extension is automatically added, if the original library path does not point to an existing file or directory.

Parameters:
obj - the repository, relative or absolute path to the library.

getClassLoader

public java.lang.ClassLoader getClassLoader()
Get the app's classloader

Returns:
the app's classloader

countSessions

public int countSessions()
Return the number of currently active sessions

Returns:
the current number of active sessions

getSession

public SessionBean getSession(java.lang.String sessionID)
Get a session object for the specified session id

Parameters:
sessionID - the session id
Returns:
the session belonging to the session id, or null

createSession

public SessionBean createSession(java.lang.String sessionID)
Create a new session with the given session id

Parameters:
sessionID - the session id
Returns:
the newly created session

getSessions

public SessionBean[] getSessions()
Get an array of all active sessions

Returns:
an array of session beans

registerUser

public INode registerUser(java.lang.String username,
                          java.lang.String password)
Register a user with the given name and password using the database mapping of the User prototype

Parameters:
username - the user name
password - the user password
Returns:
the newly registered user, or null if we failed

getUser

public INode getUser(java.lang.String username)
Get a user object with the given name

Parameters:
username - the user name
Returns:
the user object, or null

getActiveUsers

public INode[] getActiveUsers()
Get an array of currently active registered users

Returns:
an array of user nodes

getRegisteredUsers

public INode[] getRegisteredUsers()
Get an array of all registered users

Returns:
an array containing all registered users

getSessionsForUser

public SessionBean[] getSessionsForUser(INode usernode)
Get an array of all currently active sessions for a given user node

Parameters:
usernode - the user node
Returns:
an array of sessions for the given user

getSessionsForUser

public SessionBean[] getSessionsForUser(java.lang.String username)
Get an array of all currently active sessions for a given user name

Parameters:
username - the user node
Returns:
an array of sessions for the given user

addCronJob

public void addCronJob(java.lang.String functionName)
Add a cron job that will run once a minute

Parameters:
functionName - the function name

addCronJob

public void addCronJob(java.lang.String functionName,
                       java.lang.String year,
                       java.lang.String month,
                       java.lang.String day,
                       java.lang.String weekday,
                       java.lang.String hour,
                       java.lang.String minute)
Add a cron job that will run at the specified time intervals

Parameters:
functionName - the function name
year - comma separated list of years, or *
month - comma separated list of months, or *
day - comma separated list of days, or *
weekday - comma separated list of weekdays, or *
hour - comma separated list of hours, or *
minute - comma separated list of minutes, or *

removeCronJob

public void removeCronJob(java.lang.String functionName)
Unregister a previously registered cron job

Parameters:
functionName - the function name

getCronJobs

public java.util.Map getCronJobs()
Returns an read-only map of the custom cron jobs registered with the app

Returns:
a map of cron jobs

getCacheusage

public int getCacheusage()
Returns the number of elements in the NodeManager's cache


getData

public INode getData()
Returns the app's data node used to share data between the app's evaluators

Returns:
the app.data node

getModules

public java.util.Map getModules()
Returns the app's modules map used to register application modules

Returns:
the module map

getDir

public java.lang.String getDir()
Returns the absolute path of the app dir. When using repositories this equals the first file based repository.

Returns:
the app dir

getName

public java.lang.String getName()
Returns:
the app name

getUpSince

public java.util.Date getUpSince()
Returns:
the application start time

getRequestCount

public long getRequestCount()
Returns:
the number of requests processed by this app

getXmlrpcCount

public long getXmlrpcCount()
Returns:
the number of XML-RPC requests processed

getErrorCount

public long getErrorCount()
Returns:
the number of errors encountered

get__app__

public Application get__app__()
Returns:
the wrapped helma.framework.core.Application object

getProperties

public java.util.Map getProperties()
Get a wrapper around the app's properties

Returns:
a readonly wrapper around the application's app properties

getDbProperties

public java.util.Map getDbProperties()
Get a wrapper around the app's db properties

Returns:
a readonly wrapper around the application's db properties

getDbSource

public DbSource getDbSource(java.lang.String name)
Return a DbSource object for a given name.


getAppsProperties

public java.util.Map getAppsProperties()
Get a wrapper around the app's apps.properties

Returns:
a readonly wrapper around the application's apps.properties

getPrototypes

public Prototype[] getPrototypes()
Get an array of this app's prototypes

Returns:
an array containing the app's prototypes

getPrototype

public Prototype getPrototype(java.lang.String name)
Get a prototype by name.

Parameters:
name - the prototype name
Returns:
the prototype

getFreeThreads

public int getFreeThreads()
Get the number of currently available threads/request evaluators

Returns:
the currently available threads

getActiveThreads

public int getActiveThreads()
Get the number of currently active request threads

Returns:
the number of currently active threads

getMaxThreads

public int getMaxThreads()
Get the maximal thread number for this application

Returns:
the maximal number of threads/request evaluators

setMaxThreads

public void setMaxThreads(int n)
Set the maximal thread number for this application

Parameters:
n - the maximal number of threads/request evaluators

getSkin

public Skin getSkin(java.lang.String protoname,
                    java.lang.String skinname,
                    java.lang.Object[] skinpath)
Return a skin for a given object. The skin is found by determining the prototype to use for the object, then looking up the skin for the prototype.


getSkinfiles

public java.util.Map getSkinfiles()
Return a map of skin resources

Returns:
a map containing the skin resources

getSkinfilesInPath

public java.util.Map getSkinfilesInPath(java.lang.Object[] skinpath)
Return a map of skin resources including the app-specific skinpath

Parameters:
skinpath - an array of directory paths or HopObjects to search for skins
Returns:
a map containing the skin resources

getAppDir

public java.lang.String getAppDir()
Return the absolute application directory (appdir property in apps.properties file)

Returns:
the app directory as absolute path

getServerDir

public java.lang.String getServerDir()
Return the absolute server directory

Returns:
the server directory as absolute path

getCharset

public java.lang.String getCharset()
Return the app's default charset/encoding.

Returns:
the app's charset

setGlobalMacroPath

public void setGlobalMacroPath(java.lang.String[] path)
Set the path for global macro resolution

Parameters:
path - an array of global namespaces, or null

getGlobalMacroPath

public java.lang.String[] getGlobalMacroPath()
Get the path for global macro resolution

Returns:
an array of global namespaces, or null

invoke

public java.lang.Object invoke(java.lang.Object thisObject,
                               java.lang.Object function,
                               java.lang.Object[] args)
                        throws java.lang.Exception
Trigger a synchronous Helma invocation with a default timeout of 30 seconds.

Parameters:
thisObject - the object to invoke the function on, or null for global invokation
function - the function or function name to invoke
args - an array of arguments
Returns:
the value returned by the function
Throws:
java.lang.Exception - exception thrown by the function

invoke

public java.lang.Object invoke(java.lang.Object thisObject,
                               java.lang.Object function,
                               java.lang.Object[] args,
                               long timeout)
                        throws java.lang.Exception
Trigger a synchronous Helma invocation.

Parameters:
thisObject - the object to invoke the function on, or null for global invokation
function - the function or function name to invoke
args - an array of arguments
timeout - the timeout in milliseconds. After waiting this long, we will try to interrupt the invocation
Returns:
the value returned by the function
Throws:
java.lang.Exception - exception thrown by the function

invokeAsync

public FutureResult invokeAsync(java.lang.Object thisObject,
                                java.lang.Object function,
                                java.lang.Object[] args)
Trigger an asynchronous Helma invocation. This method returns immedately with an object that allows to track the result of the function invocation with the following properties:

Parameters:
thisObject - the object to invoke the function on, or null for global invokation
function - the function or function name to invoke
args - an array of arguments this long, we will try to interrupt the invocation
Returns:
an object with the properties described above

invokeAsync

public FutureResult invokeAsync(java.lang.Object thisObject,
                                java.lang.Object function,
                                java.lang.Object[] args,
                                long timeout)
Trigger an asynchronous Helma invocation. This method returns immedately with an object that allows to track the result of the function invocation with the following methods and properties:

Parameters:
thisObject - the object to invoke the function on, or null for global invokation
function - the function or function name to invoke
args - an array of arguments
timeout - the timeout in milliseconds. After waiting this long, we will try to interrupt the invocation
Returns:
an object with the properties described above

toString

public java.lang.String toString()
Return a string presentation of this AppBean

Overrides:
toString in class java.lang.Object
Returns:
string description of this app bean object


Copyright © 1998-1998-${year} Helma.org. All Rights Reserved.