Package helma.framework.core
Class ApplicationBean
java.lang.Object
helma.framework.core.ApplicationBean
- All Implemented Interfaces:
Serializable
Application bean that provides a handle to the scripting environment to
application specific functionality.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCronJob
(String functionName) Add a cron job that will run once a minutevoid
addCronJob
(String functionName, String year, String month, String day, String weekday, String hour, String minute) Add a cron job that will run at the specified time intervalsvoid
addRepository
(Object obj) Add a repository to the app's repository list.void
Clear the application cache.int
Return the number of currently active sessionscreateSession
(String sessionID) Create a new session with the given session idvoid
Log a DEBUG message to the app log if debug is set to true in app.properties.void
Log a DEBUG message to the log defined by logname if debug is set to true in app.properties.int
Get the number of currently active request threadsINode[]
Get an array of currently active registered usersReturn the absolute application directory (appdir property in apps.properties file)Get a wrapper around the app's apps.propertiesint
Returns the number of elements in the NodeManager's cacheReturn the app's default charset/encoding.Get the app's classloaderReturns an read-only map of the custom cron jobs registered with the appgetData()
Returns the app's data node used to share data between the app's evaluatorsGet a wrapper around the app's db propertiesgetDbSource
(String name) Return a DbSource object for a given name.getDir()
Returns the absolute path of the app dir.long
int
Get the number of currently available threads/request evaluatorsString[]
Get the path for global macro resolutionorg.apache.commons.logging.Log
Get the app's event logger.org.apache.commons.logging.Log
Get the app logger.int
Get the maximal thread number for this applicationReturns the app's modules map used to register application modulesgetName()
Get a wrapper around the app's propertiesgetPrototype
(String name) Get a prototype by name.Get an array of this app's prototypesINode[]
Get an array of all registered usersObject[]
Returns the app's repository list.long
Return the absolute server directorygetSession
(String sessionID) Get a session object for the specified session idGet an array of all active sessionsgetSessionsForUser
(INode usernode) Get an array of all currently active sessions for a given user nodegetSessionsForUser
(String username) Get an array of all currently active sessions for a given user nameReturn a skin for a given object.Return a map of skin resourcesgetSkinfilesInPath
(Object[] skinpath) Return a map of skin resources including the app-specific skinpathGet a user object with the given namelong
Trigger a synchronous Helma invocation with a default timeout of 30 seconds.Trigger a synchronous Helma invocation.invokeAsync
(Object thisObject, Object function, Object[] args) Trigger an asynchronous Helma invocation.invokeAsync
(Object thisObject, Object function, Object[] args, long timeout) Trigger an asynchronous Helma invocation.void
Log a INFO message to the app log.void
Log a INFO message to the log defined by logname.registerUser
(String username, String password) Register a user with the given name and password using the database mapping of the User prototypevoid
removeCronJob
(String functionName) Unregister a previously registered cron jobvoid
setGlobalMacroPath
(String[] path) Set the path for global macro resolutionvoid
setMaxThreads
(int n) Set the maximal thread number for this applicationtoString()
Return a string presentation of this AppBean
-
Constructor Details
-
ApplicationBean
Creates a new ApplicationBean object.- Parameters:
app
- ...
-
-
Method Details
-
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
Get the app logger. This is a commons-logging Log with the categorylogname
.- Returns:
- a logger for the given log name.
-
log
Log a INFO message to the app log.- Parameters:
msg
- the log message
-
log
Log a INFO message to the log defined by logname.- Parameters:
logname
- the name (category) of the logmsg
- the log message
-
debug
Log a DEBUG message to the app log if debug is set to true in app.properties.- Parameters:
msg
- the log message
-
debug
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 logmsg
- the log message
-
getRepositories
Returns the app's repository list.- Returns:
- the an array containing this app's repositories
-
addRepository
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
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
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
Create a new session with the given session id- Parameters:
sessionID
- the session id- Returns:
- the newly created session
-
getSessions
Get an array of all active sessions- Returns:
- an array of session beans
-
registerUser
Register a user with the given name and password using the database mapping of the User prototype- Parameters:
username
- the user namepassword
- the user password- Returns:
- the newly registered user, or null if we failed
-
getUser
Get a user object with the given name- Parameters:
username
- the user name- Returns:
- the user object, or null
-
getActiveUsers
Get an array of currently active registered users- Returns:
- an array of user nodes
-
getRegisteredUsers
Get an array of all registered users- Returns:
- an array containing all registered users
-
getSessionsForUser
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
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
Add a cron job that will run once a minute- Parameters:
functionName
- the function name
-
addCronJob
public void addCronJob(String functionName, String year, String month, String day, String weekday, String hour, String minute) Add a cron job that will run at the specified time intervals- Parameters:
functionName
- the function nameyear
- 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
Unregister a previously registered cron job- Parameters:
functionName
- the function name
-
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
Returns the app's data node used to share data between the app's evaluators- Returns:
- the app.data node
-
getModules
Returns the app's modules map used to register application modules- Returns:
- the module map
-
getDir
Returns the absolute path of the app dir. When using repositories this equals the first file based repository.- Returns:
- the app dir
-
getName
- Returns:
- the app name
-
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__
- Returns:
- the wrapped helma.framework.core.Application object
-
getProperties
Get a wrapper around the app's properties- Returns:
- a readonly wrapper around the application's app properties
-
getDbProperties
Get a wrapper around the app's db properties- Returns:
- a readonly wrapper around the application's db properties
-
getDbSource
Return a DbSource object for a given name. -
getAppsProperties
Get a wrapper around the app's apps.properties- Returns:
- a readonly wrapper around the application's apps.properties
-
getPrototypes
Get an array of this app's prototypes- Returns:
- an array containing the app's prototypes
-
getPrototype
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
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
Return a map of skin resources- Returns:
- a map containing the skin resources
-
getSkinfilesInPath
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
Return the absolute application directory (appdir property in apps.properties file)- Returns:
- the app directory as absolute path
-
getServerDir
Return the absolute server directory- Returns:
- the server directory as absolute path
-
getCharset
Return the app's default charset/encoding.- Returns:
- the app's charset
-
setGlobalMacroPath
Set the path for global macro resolution- Parameters:
path
- an array of global namespaces, or null
-
getGlobalMacroPath
Get the path for global macro resolution- Returns:
- an array of global namespaces, or null
-
invoke
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 invokationfunction
- the function or function name to invokeargs
- an array of arguments- Returns:
- the value returned by the function
- Throws:
Exception
- exception thrown by the function
-
invoke
public Object invoke(Object thisObject, Object function, Object[] args, long timeout) throws Exception Trigger a synchronous Helma invocation.- Parameters:
thisObject
- the object to invoke the function on, or null for global invokationfunction
- the function or function name to invokeargs
- an array of argumentstimeout
- the timeout in milliseconds. After waiting this long, we will try to interrupt the invocation- Returns:
- the value returned by the function
- Throws:
Exception
- exception thrown by the function
-
invokeAsync
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:- running - true while the function is running, false afterwards
- result - the value returned by the function, if any
- exception - the exception thrown by the function, if any
- waitForResult() - wait indefinitely until invocation terminates and return the result
- waitForResult(t) - wait for the specified number of milliseconds for invocation to terminate and return the result
- Parameters:
thisObject
- the object to invoke the function on, or null for global invokationfunction
- the function or function name to invokeargs
- an array of arguments this long, we will try to interrupt the invocation- Returns:
- an object with the properties described above
-
invokeAsync
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:- running - true while the function is running, false afterwards
- result - the value returned by the function, if any
- exception - the exception thrown by the function, if any
- waitForResult() - wait indefinitely until invocation terminates and return the result
- waitForResult(t) - wait for the specified number of milliseconds for invocation to terminate and return the result
- Parameters:
thisObject
- the object to invoke the function on, or null for global invokationfunction
- the function or function name to invokeargs
- an array of argumentstimeout
- the timeout in milliseconds. After waiting this long, we will try to interrupt the invocation- Returns:
- an object with the properties described above
-
toString
Return a string presentation of this AppBean
-