EAC Toolkit 3.2.1

com.endeca.soleng.eac.toolkit.script
Class Script

java.lang.Object
  extended by com.endeca.soleng.eac.toolkit.base.EacElement
      extended by com.endeca.soleng.eac.toolkit.base.Provisionable
          extended by com.endeca.soleng.eac.toolkit.script.Script

public class Script
extends Provisionable

This class contains logic associated with implementing an EAC script. Typical script implementation is expected to be written as BeanShell script and interpreted and executed by this object. However, this object also supports extension and implementation of the scriptImplementation method as an alternate form of implementing script logic. This class implements methods to communicate with the EAC's script control service, which allows execution of provisioned scripts. However, script execution through this object does not go through the EAC's script control service. Instead, scripts are executed directly in this JVM, though they may also be provisioned and executed through the EAC's script control web service.

Author:
sshusteff

Field Summary
 
Fields inherited from class com.endeca.soleng.eac.toolkit.base.EacElement
appName, dataPrefix, eacHost, eacPort, elementId, lockManager, logDir, sslEnabled, workingDir
 
Constructor Summary
Script()
           
 
Method Summary
 com.endeca.eac.client.ScriptType buildEacStub()
          Builds a ScriptType object to send to the EAC.
 bsh.Interpreter getBeanShellInterpreter()
           
 java.lang.String getBeanShellScript()
           
 java.lang.String getProvisionedScriptCommand()
           
 com.endeca.eac.client.StateType getStatus()
          Retrieves the status of the script.
 com.endeca.eac.client.ScriptType instantiateEacStub()
           
 boolean isActive()
          Returns true if the script is active (i.e.
 boolean isDefined()
          Extending objects will implement this method, returning true if the provisioned object's definition is set in the EAC.
 boolean isDefinitionChanged()
          Extending objects will implement this method, returning true if the provisioned object's definition has changed in the EAC.
 boolean isFailed()
          Returns true if the script failed when it was run most recently.
 void removeDefinition()
          Extending objects will implement this method to remove the definition of the provisioned object from the EAC.
 void run()
          Main execution method for the script.
 void runBeanShellScript(java.lang.String script)
          Invokes the specified String as a BeanShell script.
 void scriptImplementation()
          Extending objects will override this method with script logic.
 void setBeanShellInterpreter(bsh.Interpreter beanShellInterpreter)
           
 void setBeanShellScript(java.lang.String beanShellScript)
           
 void setDefinition()
          Extending objects will implement this method to add the definition of the provisioned object to the EAC.
 void setProvisionedScriptCommand(java.lang.String provisionedScriptCommand)
           
 void updateDefinition()
          Extending objects will implement this method to update the definition of the provisioned object in the EAC.
 
Methods inherited from class com.endeca.soleng.eac.toolkit.base.Provisionable
getAppDefinitionFromEac, getCachedAppDefinition, getProvisioningPort, invalidateCachedAppDefinition, setCachedAppDefinition
 
Methods inherited from class com.endeca.soleng.eac.toolkit.base.EacElement
getAppName, getDataPrefix, getEacHost, getEacPort, getElementId, getLockManager, getLogDir, getWorkingDir, isSslEnabled, setAppName, setDataPrefix, setEacHost, setEacPort, setElementId, setLockManager, setLogDir, setSslEnabled, setWorkingDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Script

public Script()
Method Detail

run

public void run()
         throws AppControlException
Main execution method for the script. Runs the script's provision() method, to provision the hosts/components/sub-scripts associated with the script or to update provisioning, if it's been changed. If a BeanShell script exists, the runBeanShellScript method is called to execute the script. Otherwise, the scriptImplementation method is called. Extending objects will implement the scriptImplementation method with script logic or will rely on BeanShell scripting. If either the BeanShell script or the scriptImplementation method throws an exception, this method releases all locks held by the script before completing.

Throws:
AppControlException - Thrown if the script fails with a known error.

scriptImplementation

public void scriptImplementation()
                          throws AppControlException
Extending objects will override this method with script logic. The method is intentionally implemented as an empty stub that must be overridden (rather than as an abstract method), as implementation isn't required if using BeanShell scripting.

Throws:
AppControlException - Thrown if an exception occurs while executing logic implemented in overriding methods.

runBeanShellScript

public void runBeanShellScript(java.lang.String script)
                        throws AppControlException
Invokes the specified String as a BeanShell script. Sets all members of the script object as fields visible to the BeanShell interpreter.

Parameters:
script - BeanShell script string.
Throws:
AppControlException - If an exception is caught while invoking the BeanShell script.

isDefined

public boolean isDefined()
                  throws EacCommunicationException,
                         EacProvisioningException
Description copied from class: Provisionable
Extending objects will implement this method, returning true if the provisioned object's definition is set in the EAC.

Specified by:
isDefined in class Provisionable
Returns:
True if the object is defined.
Throws:
EacCommunicationException - If a communication error occurs while retrieving the provisioning port.
EacProvisioningException - If an error occurs while trying to retrieve the object definition from the EAC.

isDefinitionChanged

public boolean isDefinitionChanged()
                            throws EacCommunicationException,
                                   EacProvisioningException
Description copied from class: Provisionable
Extending objects will implement this method, returning true if the provisioned object's definition has changed in the EAC.

Specified by:
isDefinitionChanged in class Provisionable
Returns:
True if the object's definition has changed.
Throws:
EacCommunicationException - If a communication error occurs while retrieving the provisioning port.
EacProvisioningException - If an error occurs while trying to retrieve the object definition from the EAC.

removeDefinition

public void removeDefinition()
                      throws EacCommunicationException,
                             EacComponentControlException
Description copied from class: Provisionable
Extending objects will implement this method to remove the definition of the provisioned object from the EAC.

Specified by:
removeDefinition in class Provisionable
Throws:
EacCommunicationException - If a communication error occurs while retrieving the provisioning port.
EacComponentControlException - If an error occurs while trying to start, stop or check the status of a component.

setDefinition

public void setDefinition()
                   throws EacCommunicationException
Description copied from class: Provisionable
Extending objects will implement this method to add the definition of the provisioned object to the EAC.

Specified by:
setDefinition in class Provisionable
Throws:
EacCommunicationException - If a communication error occurs while retrieving the provisioning port.

updateDefinition

public void updateDefinition()
                      throws EacCommunicationException,
                             EacComponentControlException,
                             EacProvisioningException,
                             AppConfigurationException
Description copied from class: Provisionable
Extending objects will implement this method to update the definition of the provisioned object in the EAC.

Specified by:
updateDefinition in class Provisionable
Throws:
EacCommunicationException - If a communication error occurs while retrieving the provisioning port.
EacComponentControlException - If an error occurs while trying to start, stop or check the status of a component.
EacProvisioningException - If an error occurs while provisioning the object or an associated object.
AppConfigurationException - If an object's configuration is invalid.

buildEacStub

public com.endeca.eac.client.ScriptType buildEacStub()
Builds a ScriptType object to send to the EAC. If necessary, translates or transforms fields to match the EAC's requirements.

Returns:
Returns the ScriptType WSDL stub object for this Script.

instantiateEacStub

public com.endeca.eac.client.ScriptType instantiateEacStub()

isActive

public boolean isActive()
                 throws EacCommunicationException,
                        EacComponentControlException
Returns true if the script is active (i.e. not failed or stopped).

Returns:
Returns true of the script is active.
Throws:
EacCommunicationException - If a communication error occurs while requesting the status of the script from the EAC.
EacComponentControlException - If an error occurs while trying to check the status of the script.

isFailed

public boolean isFailed()
                 throws EacCommunicationException,
                        EacComponentControlException
Returns true if the script failed when it was run most recently.

Returns:
Returns true of the script failed.
Throws:
EacCommunicationException - If a communication error occurs while requesting the status of the script from the EAC.
EacComponentControlException - If an error occurs while trying to check the status of the script.

getStatus

public com.endeca.eac.client.StateType getStatus()
                                          throws EacCommunicationException,
                                                 EacComponentControlException
Retrieves the status of the script.

Returns:
Returns a String representation of the script's status.
Throws:
EacCommunicationException - If a communication error occurs while requesting the status of the script from the EAC.
EacComponentControlException - If an error occurs while trying to check the status of the script.

getBeanShellScript

public java.lang.String getBeanShellScript()

setBeanShellScript

public void setBeanShellScript(java.lang.String beanShellScript)

getBeanShellInterpreter

public bsh.Interpreter getBeanShellInterpreter()

setBeanShellInterpreter

public void setBeanShellInterpreter(bsh.Interpreter beanShellInterpreter)

getProvisionedScriptCommand

public java.lang.String getProvisionedScriptCommand()

setProvisionedScriptCommand

public void setProvisionedScriptCommand(java.lang.String provisionedScriptCommand)

EAC Toolkit 3.2.1

Copyright © 2011 Endeca Technologies, Inc. All Rights Reserved.
@VERSION
PRODUCT: EAC Toolkit (eacToolkit)
VERSION: 3.2.1
BUILD:   NONE
ARCH_OS: n/a
DATE:    2011-11-10T16:21:05-0500