|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ail.core.Type
com.ail.core.command.AbstractCommand
com.ail.core.command.Accessor
com.ail.core.command.BeanShellAccessor
public class BeanShellAccessor
This accessor supports the use of BeanShell scripts as services. BeanShell is an open source java interpreter (www.beanshell.org). It interprets a scripting language that looks very like java - the most notable exception being that the variables are not "typed". It literally interprets - from Strings or files, there is no compilation phase involved.
The interpreter runs 'in-jvm' and through the adoption of a simple convension it has access to the command argument instance passed to the service, and can modify the instance's values.
This accessor supports the notion of extending (or inheriting) from another BeanShell service.
In effect, the script defined in the extended service is prepended to the script defined in
this service and the result is executed. The service will walk up a tree of services if
necessary - i.e. if the parent script extends a further service then it also get includes.
The sample configuration below shows how the extends feature is setup; the line in bold
shows forces BeanShellService2 to extend BeanShellService:
<service name="BeanShellService" builder="ClassBuilder" key="com.ail.core.command.BeanShellAccessor" >
<parameter name="Script"><![CDATA[
if (args.getX()<100) {
args.setR(args.getX()+args.getY());
}
else {
args.setR((2*args.getX())+args.getY());
}
]]></parameter>
</service>
<service name="BeanShellService2" builder="ClassBuilder" key="com.ail.core.command.BeanShellAccessor">
<parameter name="Extend">BeanShellService</parameter>
<parameter name="Script"><![CDATA[
if (args.getX()>1000) {
args.setR(args.getX()-(2*args.getY()));
}
]]></parameter>
</service>
| Field Summary |
|---|
| Fields inherited from class com.ail.core.Type |
|---|
jXPathContext, NOT_PERSISTED |
| Constructor Summary | |
|---|---|
BeanShellAccessor()
|
|
| Method Summary | |
|---|---|
CommandArg |
getArgs()
Get the argument set associated with this command. |
Configuration |
getConfiguration()
Fetch the configuration of the entry point associated with this command. |
java.lang.String |
getConfigurationNamespace()
Return the caller's configuration namespace. |
Core |
getCore()
|
java.lang.String |
getExtend()
|
java.lang.String |
getScript()
|
java.security.Principal |
getSecurityPrincipal()
Get the callers security principal. |
java.lang.String |
getUrl()
|
Version |
getVersion()
Fetch the version of the command (entry point) associated with this command. |
VersionEffectiveDate |
getVersionEffectiveDate()
The Core uses this callback to determin which versions of artefacts it should use on the CoreUser's behalf. |
java.lang.String |
getWholeScript()
|
void |
invoke()
Invoke the command associated with this command object. |
void |
resetConfiguration()
Factory reset. |
void |
setArgs(CommandArg args)
Update this Command object's arguments with those taken from the command arg passed in. |
void |
setConfiguration(Configuration properties)
Update the configuration of the entry point associated with this command. |
void |
setExtend(java.lang.String extend)
|
void |
setScript(java.lang.String script)
|
void |
setUrl(java.lang.String url)
|
void |
setWholeScript(java.lang.String wholeScript)
|
| Methods inherited from class com.ail.core.command.Accessor |
|---|
getLoggingIndicator, getLoggingIndicatorAsString, setLoggingIndicator, setLoggingIndicatorAsString |
| Methods inherited from class com.ail.core.Type |
|---|
addAttribute, clone, deleteLock, deleteSerialVersion, fetchJXPathContext, getAttribute, getAttribute, getAttributeCount, getForeignSystemId, getLock, getSerialVersion, getSystemId, hasLock, hasSerialVersion, hasSystemId, isPersisted, markAsNotPersisted, mergeWithDataFrom, removeAttribute, removeAttribute, setAttribute, setForeignSystemId, setLock, setSerialVersion, setSystemId, xpathGet, xpathGet, xpathIterate, xpathSet |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BeanShellAccessor()
| Method Detail |
|---|
public void setArgs(CommandArg args)
AbstractCommand
setArgs in class AbstractCommandargs - Source for argumentspublic CommandArg getArgs()
AbstractCommand
getArgs in class AbstractCommand
public void invoke()
throws BaseException
AbstractCommand
invoke in class AbstractCommandBaseExceptionpublic Version getVersion()
AbstractCommandNote: This method does not return the version of the command.
getVersion in class AbstractCommandpublic Configuration getConfiguration()
AbstractCommand
getConfiguration in interface ConfigurationOwnergetConfiguration in class AbstractCommandpublic void setConfiguration(Configuration properties)
AbstractCommand
setConfiguration in interface ConfigurationOwnersetConfiguration in class AbstractCommandproperties - Properties to replace the current configuration.public void setScript(java.lang.String script)
public java.lang.String getScript()
public void setUrl(java.lang.String url)
public java.lang.String getUrl()
public VersionEffectiveDate getVersionEffectiveDate()
CoreUser
getVersionEffectiveDate in interface CoreUserpublic java.security.Principal getSecurityPrincipal()
CoreUser
getSecurityPrincipal in interface CoreUserpublic java.lang.String getConfigurationNamespace()
getConfigurationNamespace in interface CoreUserpublic void resetConfiguration()
ConfigurationOwner
resetConfiguration in interface ConfigurationOwnerpublic Core getCore()
public java.lang.String getExtend()
public void setExtend(java.lang.String extend)
public java.lang.String getWholeScript()
public void setWholeScript(java.lang.String wholeScript)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||