Myna

Top Level library package (server-only).

Detail

Contains generally useful functions that don’t fit into the other categories.  The Myna namespace is also contains several other objects and libraries

See

Myna.Database, Myna.DataManager, Myna.File, Myna.HttpConnection, Myna.JavaUtils, Myna.Ldap, Myna.Mail, Myna.Permissions, Myna.Profiler, Myna.Query, Myna.Table, Myna.Template, Myna.Thread, Myna.ValidationResult, Myna.WebService,

Summary
MynaTop Level library package (server-only).
Functions
abortHalts JavaScript execution, optionally showing a message or dumping an object
beanToObjectAttempts to convert a JavaBean in to JavaScript object
captureContentexecutes a function and returns any content generated by that function
createSyncFunctionreturns a thread-safe version of a javascript function
createUuidCreates a Universally Unique Identifier
createByteArrayreturns a java Byte array of the supplied size
createCharArrayreturns a java Character array of the supplied size
dumpreturns nested HTML table representing the supplied object
dumpTextreturns ASCII tree representing the supplied object
execExecute a program and return the result
executeShellExecutes a shell command/script
executeWinBatchExecutes a Windows batch file
formatErrorreturns an html formatted string representing the supplied exception.
freeMemoryattempts to free the specified amount of memory within the timeout, returning true if successful.
enumToArrayConverts a Java enumeration into a JavaScript Array.
getGeneralPropertiesReturns the Java Properties object loaded from /WEB-INF/classes/general.properties
includeexecutes a .js, .sjs, or .ejs file in the current thread
includeDirectoryexecutes all .sjs files in the supplied directory, in the current thread
includeDirectoryOnceexecutes all .sjs files in the supplied directory, in the current thread, if they have not been executed before in this request
includeTextIncludes a text file in the current thread
includeOnceIncludes a text file or executes a .js, .sjs, or .ejs file in the current thread, if that path has not already been loaded.
includeContentIncludes a text file or executes a .js, .sjs, or .ejs file in the current thread, and returns the output instead of printing
includeTemplateIncludes a file as a Myna.XTemplate
loadPropertiesloads a Java properties file and returns it as a JavaScript object
loadAppPropertiesloads an application.sjs file and returns the parsed app object
lockGets an exclusive lock by name.
loglogs a string to the general log table
logSyncA single threaded synchronous version of Myna.log
mapToObjectreturns a Java Map as a JavaScript Object
normalizeErroranalyzes an error object returns a “standard” error.
parseJavaStackreturns an array of strings representing each line of the Java stack in the supplied error object
parseJsStackreturns an array of strings representing each line of the javascript stack in the supplied error object
printThis is an alias for $res.print
printDumpshortcut for $res.print(Myna.dump())
printlnshortcut for this.print(<text> + “<br>”)
printConsoleprints text to java.lang.System.out
sealObjectThis seals a JavaScript object, preventing it from being modified.
savePropertiesSaves the supplied object as a Java Properties file
sleeppauses execution of the current thread for time milliseconds
syncreturns a synchronized version of a function that can only executed by one thread at a time.
threadSafeSetsets a property on an object, if not already set, in a thread-safe manner
xmlToObjectreturns an XML object as a plain JavaScript Object
xmlToPdfConverts an xml/xhtml object into a PDF file
htmlToXhtmlConverts an HTML string into an XHTML string

Functions

abort

Myna.abort=function Myna_abort(label,
value)

Halts JavaScript execution, optionally showing a message or dumping an object

Parameters

labelOptional If supplied by itself, this is simply out put to the browser.  If value is supplied as well, this because the title for the dump.
valueOptional Value to dump

Returns

void

See

Myna.dump

beanToObject

Myna.beanToObject=function Myna_beanToObject(bean)

Attempts to convert a JavaBean in to JavaScript object

Parameters

beanJava object to convert

Returns

JavaScript Object

Detail

This function examines bean and looks for functions that start with “get” followed by at least one other character.  These functions are executed and their values are returned as a Javascript object where the property names are the get functions minus the “get” and the following character lower cased.  Functions that start with “is” are treated similarly, except the “is” is kept in the proerty name

*EXAMPLE*

this class...

public class PersonBean implements java.io.Serializable {
private name="bob";
private deceased=true;
...
public String getName() {
return this.name;
}

public boolean isDeceased() {
return this.deceased;
}
}

would become...

{
name:"bob",
isDeceased:true
}

captureContent

Myna.captureContent=function Myna_captureContent(func,
scope)

executes a function and returns any content generated by that function

Parameters

funcfunction to execute
scopeOptional, default true The scope in which to execute func

Returns

content generated by func

See Also

createSyncFunction

Myna.createSyncFunction=function Myna_createSyncFunction(functionObject)

returns a thread-safe version of a javascript function

Parameters

functionObjectJavaScript Function object to synchronize

Returns

a thread-safe version functionObject, similar to synchronized keyword for Java functions

createUuid

Myna.createUuid=function Myna_createUuid()

Creates a Universally Unique Identifier

Returns

String UUID

Detail

A UUID is a 128 bit number represented as a HEX string that is expected to unique even when compared to numbers generated by other generators.  Here is an example:

f005889f-2b8d-409c-a126-f01eb50846d4

Good uses for UUIDs are anything that needs to be uniquely identified such as :

  • Primary key for a table (especially when you don’t have access to the database at time of generation)
  • Session id
  • Cryptographic salt (this is slow)
  • Temporary File names in a cluster (Two JVM’s may create the same temp file in the save directory using <$lib.file.createTempFile>)

Myna UUID’s are based on a cryptographically secure random number generator, and are therefore NOT sortable by time.

See

http://jug.safehaus.org/

createByteArray

Myna.createByteArray=function Myna_createByteArray(size)

returns a java Byte array of the supplied size

Detail

When working with binary data or streams it is often necessary to pass a Byte array to java functions as a buffer.  This function will create this buffer for you

createCharArray

Myna.createCharArray=function Myna_createCharArray(size)

returns a java Character array of the supplied size

Detail

When working with striong data or streams it is often necessary to pass a Character array to java functions as a buffer.  This function will create this buffer for you

dump

Myna.dump=function Myna_dump(obj,
label,
maxDepth)

returns nested HTML table representing the supplied object

Parameters

objObject to dump
labelOptional Caption for the dump table
maxDepthOptional, default=4 Maximum depth of recursion.  This is to protect against circular references and to speed performance.

Returns

Nested HTML and (client-side) JavaScript table representing the supplied object

dumpText

Myna.dumpText=function Myna_dump(obj,
label,
maxDepth)

returns ASCII tree representing the supplied object

Parameters

objObject to dump
labelOptional Caption for the dump table
maxDepthOptional, default=4 Maximum depth of recursion.  This is to protect against circular references and to speed performance.

exec

Myna.exec = function exec(cmd,
options)

Execute a program and return the result

Parameters

cmdString.  Command to execute, along with any paramters
optionsOptional, default {} extra options.  See Options below

Options

dirMynaPath.  Working directory.  Defaults to $server.currentDir.  Copied to options.env.PWD
envJS Object of environment variables to pass to the process
metaJS Object to store the result details

See Also

  • <String.prototype.pipe>

Example

//simple call
var files = Myna.exec("ls -l");
Myna.println(files);

//call with working dir and result object
var result ={};
var files = Myna.exec("ls -l",{
dir:"/WEB-INF",
meta:result
});
Myna.println(files);
Myna.println(result.exitCode);
Myna.println(result.errors;

//Using String.pipe();

var sortedFiles = Myna.exec("ls -a",{dir:"/"}).pipe("egrep -v ~").pipe("sort -h");

executeShell

Myna.executeShell=function Myna_executeShell(shellCommand,
script,
waitForOutput)

Executes a shell command/script

Parameters

shellCommandCommand shell to execute such as “cmd”, “csh”, “bash”.  Can include a platform specific path and arguments to the shell like “/bin/perl -I/usr/local/perl_includes”
scriptString of commands to execute in the shell
waitForOutputOptional, default=true If true, this function will wait for the script to complete and return a result object with stderr, stdout, and the exit code.  If False returns empty result object immediately

Returns

A JavaScript object that looks like this:

{
output:"here is the stdout",
errors:"here is the stderr",
exitCode:-1
}

Detail

This function attempts to execute the supplied script in the supplied shell.  This is obviously platform dependent, so you may want to consult $server.osName.  It saves script to a tempfile and then executes shellCommand with the temp file name as the last parameter

Example

var result =Myna.executeShell("bash",<ejs>
echo "began script at `date`"
du -sh "<%=new Myna.File("/").javaFile.getAbsolutePath()%>"
echo "finished script at `date`"
</ejs>)
if (result.exitCode == 0){
Myna.print("<pre>" +result.output + "</pre>");
} else {
Myna.print("<pre>" +result.errors + "</pre>");
}

executeWinBatch

Myna.executeWinBatch=function Myna_executeWinBatch(script,
waitForOutput)

Executes a Windows batch file

Parameters

scriptString of commands to execute in the shell
waitForOutputOptional, default=true If true, this function will wait for the script to complete and return a result object with stderr, stdout, and the exit code.  If False returns empty result object immediately

Returns

A JavaScript object that looks like this:

{
output:"here is the stdout",
errors:"here is the stderr",
exitCode:-1
}

Detail

This function attempts to execute the supplied script as a Windows batch file.  This is obviously platform dependent, so you may want to consult $server.osName.  It saves script to a tempfile and then executes that file at a windows batch file

See Also: executeShell

Examples

Myna.executeWinBatch("notepad.exe i:\\custom\\mpages\\applist.js")

formatError

Myna.formatError=function Myna_formatError(e)

returns an html formatted string representing the supplied exception.

Parameters

ea caught exception

freeMemory

Myna.freeMemory=function Myna_freeMemory(size,
timeout)

attempts to free the specified amount of memory within the timeout, returning true if successful.

Parameters

sizenumber of bytes to free
timeoutOptional, default 0 timeout in miliseconds to wait for memory to become available;

Returns

true if memory is available

Detail

if timeout is 0, or memory is currently avaialble, this function will return immediately.  Otherwise this function will repeatedly call System.gc() to attempt to free memory until enough is available or the timeout is exceeded

See

$server.memMax, $server.memCurrent, $server.memAvailable, $server.memFree, $server.memUsed

enumToArray

Myna.enumToArray=function Myna_enumToArray(enumeration)

Converts a Java enumeration into a JavaScript Array.

Parameters

enumerationJava enumeration to iterate over

Returns

JS Array object

getGeneralProperties

Myna.getGeneralProperties=function Myna_getGeneralProperties()

Returns the Java Properties object loaded from /WEB-INF/classes/general.properties

include

Myna.include=function Myna_include(path,
scope)

executes a .js, .sjs, or .ejs file in the current thread

Parameters

pathMynaPath or Myna.File representing location of file
scopeOptional, default <$server.globalScope> This is the object that will be passed as the “this” object to the script. any “global” variables created in the script will be created on scope object instead.

Returns

scope after execution

Detail

If the file extension is one of js, sjs, or ejs:

This function executes the the script at path against the supplied scope.  This behavior is similar to the JavaScript “apply” function.  The code in the file will be treated like the body of a function on scope.

See

includeDirectory

Myna.includeDirectory=function Myna_includeDirectory(path,
scope)

executes all .sjs files in the supplied directory, in the current thread

Parameters

pathMynaPath representing a directory
scopeOptional, default <$server.globalScope> This is the object that will be passed as the “this” object to the each script in path.  Any “global” variables created in the script will be created on scope object instead.

Returns

scope after execution

See

includeDirectoryOnce

Myna.includeDirectoryOnce=function Myna_includeDirectory(path,
scope)

executes all .sjs files in the supplied directory, in the current thread, if they have not been executed before in this request

Parameters

pathMynaPath representing a directory
scopeOptional, default <$server.globalScope> This is the object that will be passed as the “this” object to the each script in path.  Any “global” variables created in the script will be created on scope object instead.

Returns

scope after execution

See

includeText

Myna.includeText=function Myna_includeText(path)

Includes a text file in the current thread

Parameters

pathMynaPath repesenting location of file

Returns

void

See

includeOnce

Myna.includeOnce=function Myna_includeOnce(path,
scope)

Includes a text file or executes a .js, .sjs, or .ejs file in the current thread, if that path has not already been loaded.

Parameters

pathMynaPath repesenting location of file
scopeOptional, default <$server.globalScope> This is the object that will be passed as the “this” object to the script

Returns

scope after execution

Detail

This function will call include for this path only once in this request.

See

includeContent

Myna.includeContent=function Myna_includeContent(path,
scope,
cacheOptions)

Includes a text file or executes a .js, .sjs, or .ejs file in the current thread, and returns the output instead of printing

Parameters

pathMynaPath repesenting location of file
scopeOptional, default <$server.globalScope> This is the object that will be passed as the “this” object to the script
cacheOptionsOptional, default null If this is defined, then these options will be passed to a Myna.Cache instance for the results of this include

Returns

content generated by the included file

See

includeTemplate

Myna.includeTemplate=function Myna_includeTemplate(path,
values)

Includes a file as a Myna.XTemplate

Parameters

pathMynaPath repesenting location of file
valuesOptional, default {} An object representing the values to qapply to this template

Returns

void

Detail

This function combines an Myna.XTemplate definition stored in a text file with a set of values and prints the result.

See

loadProperties

Myna.loadProperties=function Myna_loadProperties(filepath)

loads a Java properties file and returns it as a JavaScript object

Parameters

filepathMynaPath of properties file

Returns

JavaScript object of the Properties Map, as per Myna.mapToObject

loadAppProperties

Myna.loadAppProperties=function Myna_loadProperties(filepath)

loads an application.sjs file and returns the parsed app object

Parameters

filepathMynaPath of application.sjs file

Example

var admin_props = Myna.loadAppProperties("/myna/administrator/application.sjs");
Myna.println(admin_props.appname);

lock

Myna.lock=function Myna_getLock(name,
timeout,
func)

Gets an exclusive lock by name.

Parameters

namename of the lock to acquire
timeouttime in seconds to wait to acquire a lock.  If this is 0, the lock will only be acquired if no other thread is using it
funcfunction to execute inside the lock

Returns

true if a lock was acquired and func was executed

Detail

If more than one thread calls lock() near the same time, the first call will get access and the other call will be placed in a FIFO queue until the first thread lock finishes.  For this reason it is best to “return” from func as soon as possible.  If your function throws an exception, its lock will be released.  If timeout is exceeded while waiting for a lock, then Myna.lock will return false

Example

// classic check-lock-check-update algorithm
// this is the most thread-safe way to create global resources
if (!$server.get("globalVar")){
Myna.lock("create globalVar",0,function(){
//second check in case another thread created globalVar
if (!$server.get("globalVar")){
$server.set("globalVar",{})
}
})
}

log

Myna.log=function Myna_log(type,
label,
detail,
app_name,
sync)

logs a string to the general log table

Parameters

typeAny short text value representing the type of log, such as DEBUG, INFO, ERROR, WARN, PROFILE, etc.  This value is forced upper case
labelAs short single-line text description of the log
detailOptional, default null an HTML description of the log
app_nameOptional, default $application.appName A short text value representing the application that generated the log.  This value is forced lower case
syncOptional, default false if, true, logging is preformed in the current thread.  This is a good idea for logs made inside nested threads.  See logSync

Detail

This function logs to the myna_log_general table in the myna_log datasource.  If you run multiple instances of Myna, it may be helpful to point the myna_log datasource of each instance to the same database.  You Can view the logs through the Myna Administrator

Normally Myna.log attempts to perform logging in a low priority asynchronous thread.  If Myna.log is called from within a Myna.Thread instance, however, it will not spawn a separate thread for logging.  This prevents recursive thread spawning for logging.  For example if you need to call Myna.dump on a large object, you may get better performance by dumping in a separate thread:

//slow way:
Myna.log("debug","Dump of myHugeQuery",Myna.dump(myHugeQuery));

//faster way (releases the current thread immediately)
new Myna.Thread(function(myHugeQuery){
Myna.log("debug","Dump of myHugeQuery",Myna.dump(myHugeQuery));
},[myHugeQuery],-90)

logSync

Myna.logSync=function Myna_logSync(type,
label,
detail,
app_name,
sync)

A single threaded synchronous version of Myna.log

This is equivalent to log but always passes true as the sync parameter

See Myna.log for parameters and detail

mapToObject

Myna.mapToObject=function Myna_mapToObject(map)

returns a Java Map as a JavaScript Object

Parameters

mapJava Map (or subclass/implementation)

Returns

a Java Map as a JavaScript Object

Detail

This function loops through all of the entries in the map and creates a property on the returned object for each key and sets it equal to the entry’s value.

normalizeError

Myna.normalizeError=function Myna_normalizeError(e)

analyzes an error object returns a “standard” error.

Parameters

ea caught exception

”standard” error properties

messageShort error message
fileFile containing the error
lineLine number of the error
javaStackreturn from parseJavaStack
jsStackreturn from parseJsStack

parseJavaStack

Myna.parseJavaStack=function Myna_parseJavaStack(e,
spacer)

returns an array of strings representing each line of the Java stack in the supplied error object

Parameters

ea caught exception

Detail

This function calls Java’s internal stacktrace function and splits the result by line

parseJsStack

Myna.parseJsStack=function Myna_parseJsStack(e)

returns an array of strings representing each line of the javascript stack in the supplied error object

Parameters

ea caught exception

Detail

This function calls Rhino’s internal stacktrace function and splits the result by line

print

Myna.print=function Myna_print(string)

This is an alias for $res.print

Parameters

stringstring to append to the output buffer

Returns

void

printDump

Myna.printDump=function Myna_printDump(obj,
label,
maxDepth)

shortcut for $res.print(Myna.dump())

Parameters

objObject to dump
labelOptional Caption for the dump table
maxDepthOptional, default=4 Maximum depth of recursion.  This is to protect against circular references and to speed performance.

Returns

void

println

Myna.println=function Myna_println(text)

shortcut for this.print(<text> + “<br>”)

Parameters

texttext to print

Returns

void

printConsole

Myna.printConsole=function(header,
text)

prints text to java.lang.System.out

Parameters

headerText label to print first, including timestamp.  If text is omitted then this is assumed to be the text and will be printed without a header
textIf provided this will be printed after the header

sealObject

Myna.sealObject=function Myna_sealObject(obj)

This seals a JavaScript object, preventing it from being modified.

Parameters

objJavaScript Object to seal

saveProperties

Myna.saveProperties=function Myna_saveProperties(object,
filepath)

Saves the supplied object as a Java Properties file

Parameters

objectA Java or JavaScript Object
filepathMynaPath of destination file

Returns

void

Detail

This function loops over the keys of object, and saves each non-function property and it’s value as a Java properties file.

See

<Myna.getKeys>

sleep

Myna.sleep=function Myna_sleep(time)

pauses execution of the current thread for time milliseconds

Parameters

timetime in miliseconds pause execution;

sync

Myna.sync=function(func)

returns a synchronized version of a function that can only executed by one thread at a time.

This is a shortcut for Myna.JavaUtils.createSyncFunction

Parameters

funcfunction to synchronize

threadSafeSet

Myna.threadSafeSet = function(scope,
prop,
func)

sets a property on an object, if not already set, in a thread-safe manner

Parameters

scopeeither a simple JS object, or any object with get() and set() functions.  If scope has get/set, then those will be used.
propString name of property to set
funca function that returns the value to be set

Returns

The value of _scope_[prop] or scope.get(prop) if it exists, or the result of _func_() if the property did not exist.

Detail

The primary use of this function is to create singleton instances of objects by storing them in a shared scope.  Because the scope is shared, you want make sure that concurrent threads do not try to set the object at the same time, overwriting each other.

Examples

//simple objects
Myna.threadSafeSet($application,"settings",function(){
return Myna.include("app_settings.sjs",{})
})

//singleton constructor
// calls to new MyClass(ds) will return the singleton instance
var MyClass = function(ds){
return Myna.threadSafeSet($server,"MyClassSingleton",function(){
this.dataSource = ds;
return this;
})
}
MyClass.prototype.dataSource=""

xmlToObject

Myna.xmlToObject=function xmlToObject(xml)

returns an XML object as a plain JavaScript Object

Parameters

xmlXML object

Detail

This function recursively loops through all of the nodes in xml and returns an Object representing its structure.  Since this removes all the advantages of XML objects, it is best used only for debugging.

Example

var xml =
<topnode>
<list>
<thing type="color">
red
</thing>
<thing type="emotion">
twiterpated
</thing>
</list>
</topnode>;
Myna.println(
Myna.xmlToObject(
xml
).toJson()
)
//prints:
{
"attributes":{},
"children":[{
"attributes":{},
"children":[{
"attributes":{
"type":"color"
},
"children":[],
"name":"thing",
"namespace":"",
"value":"red"
},{
"attributes":{
"type":"emotion"
},
"children":[],
"name":"thing",
"namespace":"",
"value":"twiterpated"
}],
"name":"list",
"namespace":"",
"value":null
}],
"name":"topnode",
"namespace":"",
"value":null
}

xmlToPdf

Myna.xmlToPdf= function(input,
output,
baseUrl)

Converts an xml/xhtml object into a PDF file

Parameters

inputInput XML.  See Input Types below
outputoptional, default null Output location.  See Output Types below
baseUrlOptional, default null Only necessary for input types that don’t include a path, but do refer to images or css via relative paths.  Input Types:
  • XML string - May require baseUrl
  • E4X XML instance - May require baseUrl
  • Java InputStream - May require baseUrlxmlToPdf will not close this stream
  • MynaPath - to an XML/XHTML file
  • Myna.File - to an XML/XHTML file
  • URL string - to an XML/XHTML File

Output Types

  • null - A byte array containing the PDF content will be returned
  • Java OutputStream - xmlToPdf will not close this stream
  • MynaPath - PDF output will be written to this file.
  • Myna.File - PDF output will be written to this file.

Detail

This function uses Flying Saucer (xhtmlrenderer) to convert XML/XHTML content, resolving embedded stylesheets and images.

Flying Saucer understands most CSS 2.1 definitions.

For XHTML, STYLE tags need to be in the HEAD section.  External stylesheets need to be in a LINK tag in the HEAD section

For raw XML, a <?xml-stylesheet href=’’ type=’text/css’?> definition is necessary

Examples

//Transform any page to a PDF (assuming it is valid XHTML)
//at the bottom of a page
...
if ($req.data.asPDF=="true"){
$res.printBinary(Myna.xmlToPdf($res.clear()),"application/pdf","WebPage.pdf");
}

See

htmlToXhtml

Myna.htmlToXhtml =function(html,
isFragment)

Converts an HTML string into an XHTML string

Parameters

htmlHTML string.  Can be a whole document or a fragment
isFragmentoptional, default false set to true to treat html as a fragment and not create missing HTML and BODY tags

Detail

HTML allows a lot of sloppiness that is not valid in XHTML.  Start tags with no end tag, mis-matched case, missing parent tags like body and HTML.  Also, to properly display XHTML in browsers, it is necessary to both escape SCRIPT and STYLE tag contents in CDATA tags, but also comment those CDATA sections.

This function takes an HTML string, and attempts to transform it into valid XHTML.  Missing end tags are guessed and case is normalized.  SCRIPT and STYLE sections are escaped properly, and well-formed, indented XHTML is returned.

Note

The returned XHTML string will not include a ?xml? or DOCTYPE header.  If you want those things, you will need to prepend them yourself.

Myna.abort=function Myna_abort(label,
value)
Halts JavaScript execution, optionally showing a message or dumping an object
Myna.beanToObject=function Myna_beanToObject(bean)
Attempts to convert a JavaBean in to JavaScript object
Myna.captureContent=function Myna_captureContent(func,
scope)
executes a function and returns any content generated by that function
Myna.createSyncFunction=function Myna_createSyncFunction(functionObject)
returns a thread-safe version of a javascript function
Myna.createUuid=function Myna_createUuid()
Creates a Universally Unique Identifier
Myna.createByteArray=function Myna_createByteArray(size)
returns a java Byte array of the supplied size
Myna.createCharArray=function Myna_createCharArray(size)
returns a java Character array of the supplied size
Myna.dump=function Myna_dump(obj,
label,
maxDepth)
returns nested HTML table representing the supplied object
Myna.dumpText=function Myna_dump(obj,
label,
maxDepth)
returns ASCII tree representing the supplied object
Myna.exec = function exec(cmd,
options)
Execute a program and return the result
Myna.executeShell=function Myna_executeShell(shellCommand,
script,
waitForOutput)
Executes a shell command/script
Myna.executeWinBatch=function Myna_executeWinBatch(script,
waitForOutput)
Executes a Windows batch file
Myna.formatError=function Myna_formatError(e)
returns an html formatted string representing the supplied exception.
Myna.freeMemory=function Myna_freeMemory(size,
timeout)
attempts to free the specified amount of memory within the timeout, returning true if successful.
Myna.enumToArray=function Myna_enumToArray(enumeration)
Converts a Java enumeration into a JavaScript Array.
Myna.getGeneralProperties=function Myna_getGeneralProperties()
Returns the Java Properties object loaded from /WEB-INF/classes/general.properties
Myna.include=function Myna_include(path,
scope)
executes a .js, .sjs, or .ejs file in the current thread
Myna.includeDirectory=function Myna_includeDirectory(path,
scope)
executes all .sjs files in the supplied directory, in the current thread
Myna.includeDirectoryOnce=function Myna_includeDirectory(path,
scope)
executes all .sjs files in the supplied directory, in the current thread, if they have not been executed before in this request
Myna.includeText=function Myna_includeText(path)
Includes a text file in the current thread
Myna.includeOnce=function Myna_includeOnce(path,
scope)
Includes a text file or executes a .js, .sjs, or .ejs file in the current thread, if that path has not already been loaded.
Myna.includeContent=function Myna_includeContent(path,
scope,
cacheOptions)
Includes a text file or executes a .js, .sjs, or .ejs file in the current thread, and returns the output instead of printing
Myna.includeTemplate=function Myna_includeTemplate(path,
values)
Includes a file as a Myna.XTemplate
An extention of Myna.Template that supports looping and conditional operations
Myna.loadProperties=function Myna_loadProperties(filepath)
loads a Java properties file and returns it as a JavaScript object
Myna.loadAppProperties=function Myna_loadProperties(filepath)
loads an application.sjs file and returns the parsed app object
Myna.lock=function Myna_getLock(name,
timeout,
func)
Gets an exclusive lock by name.
Myna.log=function Myna_log(type,
label,
detail,
app_name,
sync)
logs a string to the general log table
Myna.logSync=function Myna_logSync(type,
label,
detail,
app_name,
sync)
A single threaded synchronous version of Myna.log
Myna.mapToObject=function Myna_mapToObject(map)
returns a Java Map as a JavaScript Object
Myna.normalizeError=function Myna_normalizeError(e)
analyzes an error object returns a “standard” error.
Myna.parseJavaStack=function Myna_parseJavaStack(e,
spacer)
returns an array of strings representing each line of the Java stack in the supplied error object
Myna.parseJsStack=function Myna_parseJsStack(e)
returns an array of strings representing each line of the javascript stack in the supplied error object
Myna.print=function Myna_print(string)
This is an alias for $res.print
print:function (text)
Appends content to the response buffer.
Myna.printDump=function Myna_printDump(obj,
label,
maxDepth)
shortcut for $res.print(Myna.dump())
Myna.println=function Myna_println(text)
shortcut for this.print(text + “br”)
Myna.printConsole=function(header,
text)
prints text to java.lang.System.out
Myna.sealObject=function Myna_sealObject(obj)
This seals a JavaScript object, preventing it from being modified.
Myna.saveProperties=function Myna_saveProperties(object,
filepath)
Saves the supplied object as a Java Properties file
Myna.sleep=function Myna_sleep(time)
pauses execution of the current thread for time milliseconds
Myna.sync=function(func)
returns a synchronized version of a function that can only executed by one thread at a time.
Myna.threadSafeSet = function(scope,
prop,
func)
sets a property on an object, if not already set, in a thread-safe manner
Myna.xmlToObject=function xmlToObject(xml)
returns an XML object as a plain JavaScript Object
Myna.xmlToPdf= function(input,
output,
baseUrl)
Converts an xml/xhtml object into a PDF file
Myna.htmlToXhtml =function(html,
isFragment)
Converts an HTML string into an XHTML string
Provides database metadata and manages Myna.Table objects
Creates Objects for reading from and writing to database tables
A Javascript friendly proxy for java.io.File
Connects to HTTP resources
Collection of static functions for working with Java objects
Represents a connection to an LDAP server
Email Object
A static class that provides access to the Myna Permissions System
Stores execution times between begin() and end() functions
Sql query object Overview: The Query object can be used for queries that return a result set (select statements), as well as those that do not (create, update, insert, delete etc...)
Create modify and delete SQL tables
Create a text template with placeholders that can be merged with data at runtime
Executes code in a separate thread
Stores the results of one or more validation operations
A WebService meta object that can serve requests for SOAP, XML-RPC, JSON-RPC, JSON-MYNA, and Ext.Direct
String representing the host operating system type.
The maximum heap size
The current heap size in bytes.
The number of free bytes on the heap + unallocaed heap space.
The current number of free bytes on the heap.
The number of used bytes on the heap
A MynaPath is a file URI String with certain automatic translations.
Creates and manages cached objects
Myna.JavaUtils.createSyncFunction=function(functionObject)
returns a thread-safe version of a javascript function
Rhino’s E4X object