The application object (app) is automatically instantiated and provides application wide methods and properties. It is global, which means you can access this object from any script. This object has an API for searching data, and managing users and sessions.
app.data
Description
app.data
(Object) - Used to store global application specific data during runtime.
Examples
app.data.runlevel = 4; app.data.language = "en";
if (app.data.language == "en") {
res.write("English");
}
Notes
The data stored here only persists during runtime.
Also See...
app.addCronJob()
Description
app.addCronJob(functionName, year, month, day, weekday, hour, minute)
Adds a global function to the list of CronJobs that are being called periodically.
Parameters
- functionName (String) - Name of the Global function to be called on the cron job.
- year (String, Optional) - Year, using Unix Crontab Syntax.
- month (String, Optional) - Month (1-12), using Unix Crontab Syntax.
- day (String, Optional) - Day (0-31), using Unix Crontab Syntax.
- weekday (String, Optional) - Weekday (0-6, with 0 being Sunday), using Unix Crontab Syntax.
- hour (String, Optional) - Hour (0-23), using Unix Crontab Syntax.
- minute (String, Optional) - Minute (0-59), using Unix Crontab Syntax.
Notes
If none of the optional parameters are used, the function passed in will be called every 60 seconds. This default can be changed by setting the "scheduleInterval" property in the application's app.properties file.
The optional parameters are required to be in Unix Crontab Syntax. The possible values for each of these parameters are a "*", indicating every value, or a list of elements separated by commas. An element can consist of either a number in the ranges shown above, or two numbers in the range separated by a hyphen (meaning an inclusive range).
Examples
app.addCronJob('test', '*', '*', '*', '2-5', '0', '5,25,45')
This example sets up the function test() to be called at 12:05, 12:25, and 12:45, every Monday through Friday.
Also See...
app.addRepository()
Description
app.addRepository(repository)
Adds a code repository to the current application.
Parameters
- repository (String) - Path to code repository.
app.clearCache()
Description
app.clearCache()
Reset the application's object cache, causing all objects to be refetched from the database. The cache size can be set in app.properties.
Also See...
app.countSessions()
Description
app.countSessions()
Returns the number of currently active Session Objects.
Returns
(Number) - Number of currently active Session Objects.
app.debug()
Description
app.debug(message)
Logs a message if debug is set to true in app.properties. Log file is named axiom.appname.log, and is located in your axiom installation's log directory.
Parameters
- message (String) - String to add to the log.
Also See...
app.getActiveThreads()
Description
app.getActiveThreads()
Returns the number of currently active threads.
Returns
(Number) - The number of currently active threads.
Also See...
app.getActiveUsers()
Description
app.getActiveUsers()
Returns an array of all the currently authenticated users associated with an active session in the application.
Returns
(Array) - Currently authenticated users in the application.
app.getAxiomVersion()
Description
app.getAxiomVersion()
Returns the current version of Axiom Stack.
Returns
(String) - Current version of Axiom Stack.
app.getBlobDir()
Description
app.getBlobDir()
Returns the absolute file system path to your binary large object storage directory. This directory can be set in app.properties.
Returns
(String) - Absolute file system path to your binary large object storage directory.
app.getCacheusage()
Description
app.getCacheusage()
Returns the number of objects currently in the object cache. The cache size can be set in app.properties.
Returns
(Number) - Number of objects currently in the object cache.
Also See...
app.getCharset()
Description
app.getCharset()
Returns the character set being used by the current application. This can be set in app.properties.
Returns
(String) - Character set being used by the current application.
Also See...
app.getCookieDomain()
Description
app.getCookieDomain()
Returns the cookie domain being used by the current application. This can be set in app.properties.
Returns
(String) - Cookie Domain being used by the current application.
Also See...
app.getCronJobs()
Description
app.getCronJobs()
Returns data on all the cron jobs registered with the application.
Returns
(Object) - Object whose properties are the function names, and values are the actual cron jobs registered with the application.
Also See...
app.getData()
Description
app.getData()
Returns the data Object used by app.data.
Returns
(Object) - The data Object used by app.data.
Also See...
app.getDbProperties()
Description
app.getDbProperties()
Returns a read-only wrapper around the application's db.properties file contents. The wrapper is a map of name/value pairs in the db.properties file.
Returns
(Object) - Read-only wrapper map around the app's db.properties.
app.getDir()
Description
app.getDir()
Returns the absolute file system path to your application.
Returns
(String) - Absolute file system path to your application.
app.getErrorCount()
Description
app.getErrorCount()
Returns the number of unhandled exceptions thrown by the current application.
Returns
(Number) - Number of unhandled exceptions thrown by the current application.
app.getFields()
Description
app.getFields(field, prototypes, filter, options)
Return an Array of values in the specified field for the objects that match the criteria specified in the parameters.
Parameters
- field (String) - The property to return from the matching objects.
- prototypes (String or Array, Optional) - A String or Array of Strings of Prototype names that will be searched for matches.
- filter (Filter, Optional) - A search Filter object.
- options (Object, Optional) - An options Object with the following properties/values:
- sort (Sort) - A Sort object. The properties are the fields to sort on, the values are either 'asc' for Ascending, or 'desc' for descending.
- maxlength (Number) - Limit on total number or results returned.
- path (String) - Match objects in the given path.
- unique (Boolean) - Only return unique matches.
Returns
(Array) - Array of values that match the criteria specified in the parameters.
Examples
app.getFields("username", "User", new Filter({firstname: "Mary"}), {sort: new Sort({lastname: "asc"}), maxlength: 5})
This example will return an array of the first 5 usernames for Axiom Objects of the User prototype, whose firstname property is set to "Mary", sorted ascending by the lastname property. An example of the results could be:
["mallen","mjenkins","mlane","mreynolds","msmith"]
Also See...
app.getFreeThreads()
Description
app.getFreeThreads()
Returns the number of currently free threads.
Returns
(Number) - The number of currently free threads.
Also See...
app.getHitCount()
Description
app.getHitCount(prototypes, filter)
Returns the number of Axiom Objects that match the criteria specified in the parameters.
Parameters
- prototypes (String or Array, Optional) - A String or Array of Strings of Prototype names that will be searched for matches.
- filter (Filter, Optional) - A search Filter object.
Returns
(Number) - The number of Axiom Objects that match the criteria specified in the parameters.
Examples
var num_hits = app.getHitCount("User", new Filter({firstname: "Mary"}), {sort: new Sort({lastname: "asc"})})
This example will set the variable "hits" to the number of Axiom Objects of the User prototype, whose firstname property is set to "Mary", sorted ascending by the lastname property. You could then use the resulting number for tests or display purposes:
if (num_hits > 0) {
...
}
Also See...
app.getHits()
Description
app.getHits(prototypes, filter, options)
Returns a Hits object, which is a result set consisting of the Axiom Objects that match the criteria specified in the parameters.
Parameters
- prototypes (String or Array, Optional) - A String or Array of Strings of Prototype names that will be searched for matches.
- filter (Filter, Optional) - A search Filter object.
- options (Object, Optional) - An options Object with the following properties/values:
- sort (Sort) - A Sort object. The properties are the fields to sort on, the values are either 'asc' for Ascending, or 'desc' for descending.
- maxlength (Number) - Limit on total number or results returned.
- path (String) - Match objects in the given path.
- unique (Boolean) - Only return unique matches.
Returns
(Hits) - A Hits object, which is a result set consisting of Axiom Objects that match the criteria specified in the parameters.
Examples
var hits = app.getHits("User", new Filter({firstname: "Mary"}), {sort: new Sort({lastname: "asc"})})
This example will set the variable "hits" to a Hits object consisting of all of the Axiom Objects of the User prototype, whose firstname property is set to "Mary", sorted ascending by the lastname property. You could then access a subset of the results like this:
return hits.objects(0,15)
This will return an Array of the first 15 Axiom Objects in the result set.
Also See...
app.getMaxThreads()
Description
app.getMaxThreads()
Returns the max number of threads available to the application. This can be set in app.properties.
Returns
(Number) - The max number of threads available to the application.
Also See...
app.getName()
Description
app.getName()
Returns the name of the current application.
Returns
(String) - Name of the current application.
app.getObjects()
Description
app.getObjects(prototypes, filter, options)
Returns an Array of Axiom Objects that match the criteria specified in the parameters.
Parameters
- prototypes (String or Array, Optional) - A String or Array of Strings of Prototype names that will be searched for matches.
- filter (Filter, Optional) - A search Filter object.
- options (Object, Optional) - An options Object with the following properties/values:
- sort (Sort) - A Sort object. The properties are the fields to sort on, the values are either 'asc' for Ascending, or 'desc' for descending.
- maxlength (Number) - Limit on total number or results returned.
- path (String) - Match objects in the given path.
- unique (Boolean) - Only return unique matches.
Returns
(Array) - An Array of Axiom Objects that match the criteria specified in the parameters.
Examples
var objs = app.getObjects("User", new Filter({firstname: "Mary"}), {sort: new Sort({lastname: "asc"})})
This example will set the variable "objs" to an Array of Axiom Objects of the User prototype, whose firstname property is set to "Mary", sorted ascending by the lastname property.
Also See...
app.getProperties()
Description
app.getProperties()
Returns an Object that is a mapping of app.properties.
Returns
(Object) - Object that is a mapping of app.properties.
Examples
app.getProperties()['charset']
This will return 'UTF-8', if that is what the charset property is set to in app.properties.
Also See...
app.getPrototypeResources()
Description
app.getPrototypeResources(prototype)
Returns a list of resources being used by the specified prototype.
Parameters
- prototype (String) - The prototype whose resources are being retrieved.
Returns
(Array) - A list of resources being used by the specified prototype.
app.getPrototypes()
Description
app.getPrototypes()
Returns an array of the names of all the prototypes in the application.
Returns
(Array) - Array of the names of all application prototypes.
app.getReferences()
Description
app.getReferences(source, target)
Returns References between two Axiom Objects.
Parameters
- source (Axiom Object) - The source Axiom Object.
- target (Axiom Object) - The target Axiom Object.
Returns
(Array) - Array of References between the source and target.
app.getRequestCount()
Description
app.getRequestCount()
Returns the number of requests served for the current application.
Returns
(Number) - Number of requests served for the current application.
app.getRewriteRules()
Description
app.getRewriteRules()
Returns an Array of Arrays, which represents the current application's rewrite rules, as in rewrite.properties.
Returns
(Array) - Array of Arrays, which represents the current application's rewrite rules, as in rewrite.properties.
Also See...
app.getServerDir()
Description
app.getServerDir()
Returns the absolute file system path to your Axiom Stack root directory.
Returns
(String) - Absolute file system path to your Axiom Stack directory.
app.getSession()
Description
app.getSession(sessionid)
Returns the Session Object belonging to the specified session id.
Parameters
- sessionid (String) - Session ID to retrieve.
Returns
(Object) - Session Object belonging to the specified session id.
app.getSessions()
Description
app.getSessions()
Returns all currently active Session Objects.
Returns
(Array) - An Array of all currently active Session Objects.
app.getSessionsForUser()
Description
app.getSessionsForUser(user)
Returns all currently active Session Objects associated to the specified User Object.
Parameters
- user (Axiom Object) - User Axiom Object whose active sessions are being retrieved.
Returns
(Array) - An Array of all currently active Session Objects.
app.getSourceCount()
Description
app.getSourceCount(target, prototypes, statuses)
Returns the number of Axiom Objects making a reference to the specified target Axiom Object, matching the criteria specified.
Parameters
- target (Axiom Object) - Axiom Object whose sources are being searched for.
- prototypes (String or Array, Optional) - A String or Array of Strings of Prototype names that will be searched for matches.
- status (String or Array, Optional) - A String or Array of Strings of Object Statuses to match.
Returns
(Number) - Number of Axiom Objects making a reference to the specified target Axiom Object, matching the criteria specified.
Also See...
app.getSources()
Description
app.getSources(target, prototypes, statuses)
Returns the Axiom Objects making a reference to the specified target Axiom Object, matching the criteria specified.
Parameters
- target (Axiom Object) - Axiom Object whose sources are being searched for.
- prototypes (String or Array, Optional) - A String or Array of Strings of Prototype names that will be searched for matches.
- status (String or Array, Optional) - A String or Array of Strings of Object Statuses to match.
Returns
(Array) - An Array of Axiom Objects making a reference to the specified target Axiom Object, matching the criteria specified.
Also See...
app.getStaticMountpoint()
Description
app.getStaticMountpoint(action)
Returns the current application's static file mountpoint path. This is configured in app.properties.
Parameters
- action (String, Optional) - Optional String to add to the end of the static file mountpoint path.
Returns
(String) - String representing the current application's static file mountpoint path.
Examples
app.getStaticMountpoint('css/styles.css')
This call may return a string like this:
/static/css/styles.css
app.getTargetCount()
Description
app.getTargetCount(source, prototypes, statuses)
Returns the number of Axiom Objects the specified source Axiom Object is referencing, matching the criteria specified.
Parameters
- source (Axiom Object) - Axiom Object whose targets are being searched for.
- prototypes (String or Array, Optional) - A String or Array of Strings of Prototype names that will be searched for matches.
- status (String or Array, Optional) - A String or Array of Strings of Object Statuses to match.
Returns
(Number) - Number of Axiom Objects the specified source Axiom Object is referencing, matching the criteria specified.
Also See...
app.getTargets()
Description
app.getTargetCount(source, prototypes, statuses)
Returns the Axiom Objects the specified source Axiom Object is referencing, matching the criteria specified.
Parameters
- source (Axiom Object) - Axiom Object whose targets are being searched for.
- prototypes (String or Array, Optional) - A String or Array of Strings of Prototype names that will be searched for matches.
- status (String or Array, Optional) - A String or Array of Strings of Object Statuses to match.
Returns
(Array) - An Array of Axiom Objects the specified source Axiom Object is referencing, matching the criteria specified.
Also See...
app.getTmpDir()
Description
app.getTmpDir()
Returns the absolute file system path to your temporary storage directory. This directory can be set in app.properties.
Returns
(String) - Absolute file system path to your temporary storage directory.
app.getUpSince()
Description
app.getUpSince()
Returns the date and time the Axiom Stack server the application is running on was start up.
Returns
(Date) - Date and time the Axiom Stack server the application is running on was start up.
app.get__app__()
Description
app.get__app__()
Returns the Java Application Object underlying the current application.
Returns
(Object) - The Java Application Object underlying the current application.
app.log()
Description
app.log(message)
Logs a message. Log file is named axiom.appname.log, and is located in your axiom installation's log directory.
Parameters
- message (String) - String to add to the log.
Also See...
app.removeCronJob()
Description
app.removeCronJob(functionName)
Removes a global function to the list of CronJobs that are being called periodically.
Parameters
- functionName (String) - Name of the Global function to be removed from the cron job.
Also See...
app.setMaxThreads()
Description
app.setMaxThreads(threads)
Sets the max number of threads available to the application. This can also be done via app.properties.
Parameters
- threads (Number) - Number of threads to set the new max to.
Also See...
