com.flexive.shared.interfaces
Interface ScriptingEngine

All Known Subinterfaces:
ScriptingEngineLocal

public interface ScriptingEngine

Scripting engine

Author:
Markus Plesser (markus.plesser@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)

Method Summary
 FxScriptMappingEntry createAssignmentScriptMapping(FxScriptEvent scriptEvent, long scriptId, long assignmentId, boolean active, boolean derivedUsage)
          Create a new mapping for assignments with with a given FxScriptEvent
 FxScriptMappingEntry createAssignmentScriptMapping(long scriptId, long assignmentId, boolean active, boolean derivedUsage)
          Create a new mapping for assignments with the default FxScriptEvent the script was created with
 FxScriptInfo createScript(FxScriptEvent event, java.lang.String name, java.lang.String description, java.lang.String code)
          Create a new script (newly created scripts are set to active per default).
 FxScriptInfo createScriptFromDropLibrary(java.lang.String dropName, FxScriptEvent event, java.lang.String libraryname, java.lang.String name, java.lang.String description)
          Create a new script based on a script from the library (newly created scripts are set to active per default).
 FxScriptInfo createScriptFromLibrary(FxScriptEvent event, java.lang.String libraryname, java.lang.String name, java.lang.String description)
          Create a new script based on a script from the library (newly created scripts are set to active per default).
 FxScriptMappingEntry createTypeScriptMapping(FxScriptEvent scriptEvent, long scriptId, long typeId, boolean active, boolean derivedUsage)
          Create a new mapping for types with a given FxScriptEvent
 FxScriptMappingEntry createTypeScriptMapping(long scriptId, long typeId, boolean active, boolean derivedUsage)
          Create a new mapping for types with the default FxScriptEvent the script was created with
 void executeDropRunOnceScripts(Parameter<java.lang.Boolean> param, java.lang.String dropName)
          Execute run-once scripts for drops.
 void executeDropStartupScripts(java.lang.String dropName)
          Execute start up scripts for a specific drop.
 void executeRunOnceScripts()
          Execute run-once scripts.
 void executeStartupScripts()
          Execute start up scripts.
 java.util.List<java.lang.String[]> getAvailableScriptEngines()
          Get a list containing script extension and script engine info as 2-dimensional String array
 java.util.List<java.lang.Long> getByScriptEvent(FxScriptEvent scriptEvent)
          Get scripts by their event
 java.util.List<FxScriptRunInfo> getRunOnceInformation()
          Get information about running/executed runOnce scripts (including all drops) Please note that this method will only return entries if scripts have been executed in the current VM and in the current session (information is not persisted - yet!)
 java.util.List<FxScriptInfo> getScriptInfos()
          Get all available information for all existing scripts
 java.lang.String loadScriptCode(long scriptId)
          Load a scripts code
 FxScriptMapping loadScriptMapping(long scriptId)
          Loads all assignment mappings for a specified script
 void remove(long scriptId)
          Remove a script (will remove all mappings for this script as well)
 void removeAssignmentScriptMapping(long scriptId, long assignmentId)
          Remove a mapping from a script to an assignment (directly mapped, not via inheritance!)
 void removeAssignmentScriptMappingForEvent(long scriptId, long assignmentId, FxScriptEvent event)
          Remove a mapping from a script to an assignment for a specific event (directly mapped, not via inheritance!)
 void removeTypeScriptMapping(long scriptId, long typeId)
          Remove a mapping from a script to a type (directly mapped, not via inheritance!)
 void removeTypeScriptMappingForEvent(long scriptId, long typeId, FxScriptEvent event)
          Remove a mapping from a script to a type (directly mapped, not via inheritance!) for a specific script event
 FxScriptResult runScript(long scriptId)
          Run a script
 FxScriptResult runScript(long scriptId, FxScriptBinding binding)
          Run a script with the given variable binding
 FxScriptResult runScript(java.lang.String scriptName, FxScriptBinding binding)
          Run a script with the given variable binding
 FxScriptResult runScript(java.lang.String name, FxScriptBinding binding, java.lang.String code)
          Execute a script
 FxScriptMappingEntry updateAssignmentScriptMappingForEvent(long scriptId, long assignmentId, FxScriptEvent event, boolean active, boolean derivedUsage)
          Update a mapping for assignments
 void updateScriptCode(long scriptId, java.lang.String code)
          Convenience method to update a scripts code
 void updateScriptInfo(FxScriptInfoEdit scriptInfo)
          Update script info
 void updateScriptInfo(long scriptId, FxScriptEvent event, java.lang.String name, java.lang.String description, java.lang.String code, boolean active)
          Update a scripts info
 FxScriptMappingEntry updateTypeScriptMappingForEvent(long scriptId, long typeId, FxScriptEvent event, boolean active, boolean derivedUsage)
          Update a mapping for types
 

Method Detail

loadScriptCode

java.lang.String loadScriptCode(long scriptId)
                                throws FxApplicationException
Load a scripts code

Parameters:
scriptId - requested script
Returns:
code
Throws:
FxApplicationException - on errors

getScriptInfos

java.util.List<FxScriptInfo> getScriptInfos()
                                            throws FxApplicationException
Get all available information for all existing scripts

Returns:
FxScriptInfo
Throws:
FxApplicationException - on errors

updateScriptInfo

void updateScriptInfo(long scriptId,
                      FxScriptEvent event,
                      java.lang.String name,
                      java.lang.String description,
                      java.lang.String code,
                      boolean active)
                      throws FxApplicationException
Update a scripts info

Parameters:
scriptId - requested script id
event - requested script event
name - new name (or null if unchanged)
description - new description (or null if unchanged)
code - the code
active - if the script is active
Throws:
FxApplicationException - on errors
See Also:
FxScriptEvent

updateScriptInfo

void updateScriptInfo(FxScriptInfoEdit scriptInfo)
                      throws FxApplicationException
Update script info

Parameters:
scriptInfo - the edited script info
Throws:
FxApplicationException - on errors

updateScriptCode

void updateScriptCode(long scriptId,
                      java.lang.String code)
                      throws FxApplicationException
Convenience method to update a scripts code

Parameters:
scriptId - requested script id
code - the code
Throws:
FxApplicationException - on errors
See Also:
updateScriptInfo(long, com.flexive.shared.scripting.FxScriptEvent , String, String, String, boolean)

getByScriptEvent

java.util.List<java.lang.Long> getByScriptEvent(FxScriptEvent scriptEvent)
Get scripts by their event

Parameters:
scriptEvent - requested script event
Returns:
array of id's by event

createScript

FxScriptInfo createScript(FxScriptEvent event,
                          java.lang.String name,
                          java.lang.String description,
                          java.lang.String code)
                          throws FxApplicationException
Create a new script (newly created scripts are set to active per default).

Parameters:
event - script event
name - (unique) name
description - description
code - code
Returns:
FxScriptInfo for the new created script
Throws:
FxApplicationException - on errors
See Also:
FxScriptEvent

createScriptFromLibrary

FxScriptInfo createScriptFromLibrary(FxScriptEvent event,
                                     java.lang.String libraryname,
                                     java.lang.String name,
                                     java.lang.String description)
                                     throws FxApplicationException
Create a new script based on a script from the library (newly created scripts are set to active per default).

Parameters:
event - script event
libraryname - name of the script in the script library
name - (unique) name
description - description
Returns:
FxScriptInfo for the new created script
Throws:
FxApplicationException - on errors
See Also:
FxScriptEvent

createScriptFromDropLibrary

FxScriptInfo createScriptFromDropLibrary(java.lang.String dropName,
                                         FxScriptEvent event,
                                         java.lang.String libraryname,
                                         java.lang.String name,
                                         java.lang.String description)
                                         throws FxApplicationException
Create a new script based on a script from the library (newly created scripts are set to active per default).

Parameters:
dropName - name of the drop to use as repository
event - script event
libraryname - name of the script in the script library
name - (unique) name
description - description
Returns:
FxScriptInfo for the new created script
Throws:
FxApplicationException - on errors
See Also:
FxScriptEvent

remove

void remove(long scriptId)
            throws FxApplicationException
Remove a script (will remove all mappings for this script as well)

Parameters:
scriptId - id of the script and its mappings to remove
Throws:
FxApplicationException - on errors

runScript

FxScriptResult runScript(java.lang.String scriptName,
                         FxScriptBinding binding)
                         throws FxApplicationException
Run a script with the given variable binding

Parameters:
scriptName - name of the script to run
binding - variable binding to use (all bound variables have to be serializable!)
Returns:
script result
Throws:
FxApplicationException - on errors

runScript

FxScriptResult runScript(long scriptId,
                         FxScriptBinding binding)
                         throws FxApplicationException
Run a script with the given variable binding

Parameters:
scriptId - id of the script to run
binding - variable binding to use (all bound variables have to be serializable!)
Returns:
script result
Throws:
FxApplicationException - on errors

runScript

FxScriptResult runScript(java.lang.String name,
                         FxScriptBinding binding,
                         java.lang.String code)
                         throws FxApplicationException
Execute a script

Parameters:
name - name of the script, extension is needed to choose interpreter
binding - bindings to apply
code - the script code
Returns:
last script evaluation result
Throws:
FxApplicationException - on errors

getAvailableScriptEngines

java.util.List<java.lang.String[]> getAvailableScriptEngines()
                                                             throws FxApplicationException
Get a list containing script extension and script engine info as 2-dimensional String array

Returns:
list containing script extension and script engine info as 2-dimensional String array
Throws:
FxApplicationException - on errors

runScript

FxScriptResult runScript(long scriptId)
                         throws FxApplicationException
Run a script

Parameters:
scriptId - id of the script to run
Returns:
script result
Throws:
FxApplicationException - on errors

createAssignmentScriptMapping

FxScriptMappingEntry createAssignmentScriptMapping(long scriptId,
                                                   long assignmentId,
                                                   boolean active,
                                                   boolean derivedUsage)
                                                   throws FxApplicationException
Create a new mapping for assignments with the default FxScriptEvent the script was created with

Parameters:
scriptId - id of the script
assignmentId - id of the assignment
active - mapping is active?
derivedUsage - mapping used in derived assignments?
Returns:
the created entry
Throws:
FxApplicationException - on errors

createAssignmentScriptMapping

FxScriptMappingEntry createAssignmentScriptMapping(FxScriptEvent scriptEvent,
                                                   long scriptId,
                                                   long assignmentId,
                                                   boolean active,
                                                   boolean derivedUsage)
                                                   throws FxApplicationException
Create a new mapping for assignments with with a given FxScriptEvent

Parameters:
scriptEvent - FxScriptEvent for this mapping (on create, save, remove, etc.)
scriptId - id of the script
assignmentId - id of the assignment
active - mapping is active?
derivedUsage - mapping used in derived assignments?
Returns:
the created entry
Throws:
FxApplicationException - on errors

loadScriptMapping

FxScriptMapping loadScriptMapping(long scriptId)
                                  throws FxLoadException,
                                         java.sql.SQLException
Loads all assignment mappings for a specified script

Parameters:
scriptId - the script
Returns:
the script mappings
Throws:
FxLoadException - on errors
java.sql.SQLException - on errors

createTypeScriptMapping

FxScriptMappingEntry createTypeScriptMapping(long scriptId,
                                             long typeId,
                                             boolean active,
                                             boolean derivedUsage)
                                             throws FxApplicationException
Create a new mapping for types with the default FxScriptEvent the script was created with

Parameters:
scriptId - id of the script
typeId - id of the type
active - mapping is active?
derivedUsage - mapping used in derived types?
Returns:
the created entry
Throws:
FxApplicationException - on errors

createTypeScriptMapping

FxScriptMappingEntry createTypeScriptMapping(FxScriptEvent scriptEvent,
                                             long scriptId,
                                             long typeId,
                                             boolean active,
                                             boolean derivedUsage)
                                             throws FxApplicationException
Create a new mapping for types with a given FxScriptEvent

Parameters:
scriptEvent - FxScriptEvent for this mapping (on create, save, remove, etc.)
scriptId - id of the script
typeId - id of the type
active - mapping is active?
derivedUsage - mapping used in derived types?
Returns:
the created entry
Throws:
FxApplicationException - on errors

removeAssignmentScriptMapping

void removeAssignmentScriptMapping(long scriptId,
                                   long assignmentId)
                                   throws FxApplicationException
Remove a mapping from a script to an assignment (directly mapped, not via inheritance!)

Parameters:
scriptId - id of the script
assignmentId - id of the assignment
Throws:
FxApplicationException - on errors

removeAssignmentScriptMappingForEvent

void removeAssignmentScriptMappingForEvent(long scriptId,
                                           long assignmentId,
                                           FxScriptEvent event)
                                           throws FxApplicationException
Remove a mapping from a script to an assignment for a specific event (directly mapped, not via inheritance!)

Parameters:
scriptId - id of the script
assignmentId - id of the assignment
event - the script event
Throws:
FxApplicationException - on errors

removeTypeScriptMapping

void removeTypeScriptMapping(long scriptId,
                             long typeId)
                             throws FxApplicationException
Remove a mapping from a script to a type (directly mapped, not via inheritance!)

Parameters:
scriptId - id of the script
typeId - id of the type
Throws:
FxApplicationException - on errors

removeTypeScriptMappingForEvent

void removeTypeScriptMappingForEvent(long scriptId,
                                     long typeId,
                                     FxScriptEvent event)
                                     throws FxApplicationException
Remove a mapping from a script to a type (directly mapped, not via inheritance!) for a specific script event

Parameters:
scriptId - id of the script
typeId - id of the type
event - the script event
Throws:
FxApplicationException - on errors

updateAssignmentScriptMappingForEvent

FxScriptMappingEntry updateAssignmentScriptMappingForEvent(long scriptId,
                                                           long assignmentId,
                                                           FxScriptEvent event,
                                                           boolean active,
                                                           boolean derivedUsage)
                                                           throws FxApplicationException
Update a mapping for assignments

Parameters:
scriptId - id of the script
assignmentId - id of the assignment
event - the script event
active - mapping is active?
derivedUsage - mapping used in derived assignments?
Returns:
the updated entry
Throws:
FxApplicationException - on errors

updateTypeScriptMappingForEvent

FxScriptMappingEntry updateTypeScriptMappingForEvent(long scriptId,
                                                     long typeId,
                                                     FxScriptEvent event,
                                                     boolean active,
                                                     boolean derivedUsage)
                                                     throws FxApplicationException
Update a mapping for types

Parameters:
scriptId - id of the script
typeId - id of the type
event - the script event
active - mapping is active?
derivedUsage - mapping used in derived types?
Returns:
the updated entry
Throws:
FxApplicationException - on errors

executeRunOnceScripts

void executeRunOnceScripts()
                           throws FxApplicationException
Execute run-once scripts. No exceptions are throws since there is no means of user feedback. If errors occur, they are written to the logfile. run-once scripts are only executed once in the lifetime of a division! consecutive calls have no effect and nothing will be executed!

Throws:
FxApplicationException - on errors

executeStartupScripts

void executeStartupScripts()
Execute start up scripts. No exceptions are throws since there is no means of user feedback. If errors occur, they are written to the logfile. start up scripts are only executed once each time the application server is started. consecutive calls *will* execute start up scripts again!


executeDropRunOnceScripts

void executeDropRunOnceScripts(Parameter<java.lang.Boolean> param,
                               java.lang.String dropName)
                               throws FxApplicationException
Execute run-once scripts for drops. run-once scripts are only executed once in the lifetime of a division! consecutive calls have no effect and nothing will be executed! param will be set to "true" once the scripts are run and will be checked to be "false" prior to run

Parameters:
param - boolean parameter to mark scripts as being run
dropName - name of the drop (WAR archive name without extension)
Throws:
FxApplicationException - if the requested drop is unknown or invalid

executeDropStartupScripts

void executeDropStartupScripts(java.lang.String dropName)
                               throws FxApplicationException
Execute start up scripts for a specific drop. To be called from a filter or the like. No exceptions are throws since there is no means of user feedback. If errors occur, they are written to the logfile. start up scripts are only executed once each time the application server is started. consecutive calls *will* execute start up scripts again!

Parameters:
dropName - name of the drop (WAR archive name without extension)
Throws:
FxApplicationException - if the requested drop is unknown or invalid

getRunOnceInformation

java.util.List<FxScriptRunInfo> getRunOnceInformation()
                                                      throws FxApplicationException
Get information about running/executed runOnce scripts (including all drops) Please note that this method will only return entries if scripts have been executed in the current VM and in the current session (information is not persisted - yet!)

Returns:
information
Throws:
FxApplicationException - on errors