atg.endeca.eacclient
Class ScriptRunner

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.endeca.eacclient.ScriptRunner
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
ScriptIndexable

public class ScriptRunner
extends GenericService

A Nucleus service that can execute an Endeac EAC script. Generally used for kicking off baseline or partial indexing tasks.

Created: November 14 2011

See Also:

Field Summary
static java.lang.String CLASS_VERSION
          Class version string from source code control system.
static int DEFAULT_SLEEP_TIME
          Our default sleep time when polling for status.
static java.lang.String SERVICE_SUFFIX
          URL suffix for our end point.
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ScriptRunner()
           
 
Method Summary
protected  java.lang.String calculateEndpointAddress()
          Calculate our endepoint address from serviceProtocol, eacHost, eacPort and SERVICE_SUFFIX.
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
 StateType exec(java.lang.String pAppId, java.lang.String pScriptId)
          execute EAC script for given application id and script id.
 void externalExec(java.lang.String pAppId, java.lang.String pScriptId)
          Execute the specified script.
protected  ScriptControlServiceLocator getControlLocator()
          Return the script control service locator given our current configuration.
protected  ScriptControlPort getControlPort()
          Return the control port based on our current configuration.
 java.lang.String getEACHost()
          Returns property EACHost.
 int getEACPort()
          Returns property EACPort.
 long getEACScriptTimeout()
          Returns property EACScriptTimeout in milliseconds.
 java.lang.String getServiceProtocol()
          Returns property serviceProtocol.
 int getSleepTime()
          Returns property sleepTime.
 void setEACHost(java.lang.String pEACHost)
          Sets property EACHost.
 void setEACPort(int pEACPort)
          Sets property EACPort.
 void setEACScriptTimeout(long pEACScriptTimeout)
          Sets property EACScriptTimeout in milliseconds.
 void setServiceProtocol(java.lang.String pServiceProtocol)
          Sets property serviceProtocol.
 void setSleepTime(int pSleepTime)
          Sets property sleepTime.
 ScriptControlPort startScript(java.lang.String pAppId, java.lang.String pScriptId)
          Start EAC script for given application id and script id.
 ScriptControlPort stopScript(java.lang.String pAppId, java.lang.String pScriptId)
          Stop/cancel EAC script for given application id and script id.
 void testExec()
          Test BaselineUpdate script directly Not used anymore
 void testStartWait()
          Test BaselineUpdate script directly using startScript and waitForScript Not used anymore
 StateType waitForScript(ScriptControlPort pScriptControlPort, java.lang.String pAppId, java.lang.String pScriptId)
          Wait for the specified EAC script to finish.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string from source code control system.

See Also:
Constant Field Values

DEFAULT_SLEEP_TIME

public static final int DEFAULT_SLEEP_TIME
Our default sleep time when polling for status.

See Also:
Constant Field Values

SERVICE_SUFFIX

public static final java.lang.String SERVICE_SUFFIX
URL suffix for our end point.

See Also:
Constant Field Values
Constructor Detail

ScriptRunner

public ScriptRunner()
Method Detail

setEACHost

public void setEACHost(java.lang.String pEACHost)
Sets property EACHost. The hostname or IP of EAC.


getEACHost

public java.lang.String getEACHost()
Returns property EACHost. The hostname or IP of EAC.


setEACPort

public void setEACPort(int pEACPort)
Sets property EACPort. The port used by EAC service.


getEACPort

public int getEACPort()
Returns property EACPort. The port used by EAC service.


setEACScriptTimeout

public void setEACScriptTimeout(long pEACScriptTimeout)
Sets property EACScriptTimeout in milliseconds. It is timeout for executing EAC script


getEACScriptTimeout

public long getEACScriptTimeout()
Returns property EACScriptTimeout in milliseconds. It is timeout for executing EAC script


setSleepTime

public void setSleepTime(int pSleepTime)
Sets property sleepTime. Number of milliseconds to sleep while polling.


getSleepTime

public int getSleepTime()
Returns property sleepTime. Number of milliseconds to sleep while polling.


setServiceProtocol

public void setServiceProtocol(java.lang.String pServiceProtocol)
Sets property serviceProtocol. The protocol to use to contact the EAC server. Defaults to "http"


getServiceProtocol

public java.lang.String getServiceProtocol()
Returns property serviceProtocol. The protocol to use to contact the EAC server. Defaults to "http"


doStartService

public void doStartService()
                    throws ServiceException
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

externalExec

public void externalExec(java.lang.String pAppId,
                         java.lang.String pScriptId)
                  throws atg.repository.search.indexing.IndexingException
Execute the specified script.

Parameters:
pAppId - the specified Endeca application ID.
pScriptId - the specified script ID.
Throws:
atg.repository.search.indexing.IndexingException - if execution failed

exec

public StateType exec(java.lang.String pAppId,
                      java.lang.String pScriptId)
               throws atg.repository.search.indexing.IndexingException
execute EAC script for given application id and script id.

Parameters:
pAppId - the Endeca application ID.
pScriptId - the Endeca script name.
Returns:
the state (status).
Throws:
atg.repository.search.indexing.IndexingException - if execution failed

calculateEndpointAddress

protected java.lang.String calculateEndpointAddress()
Calculate our endepoint address from serviceProtocol, eacHost, eacPort and SERVICE_SUFFIX.


startScript

public ScriptControlPort startScript(java.lang.String pAppId,
                                     java.lang.String pScriptId)
                              throws atg.repository.search.indexing.IndexingException
Start EAC script for given application id and script id.

Parameters:
pAppId - the Endeca applicaiton ID
pScriptId - the Endeca script ID.
Throws:
atg.repository.search.indexing.IndexingException - if script failed to start

stopScript

public ScriptControlPort stopScript(java.lang.String pAppId,
                                    java.lang.String pScriptId)
                             throws atg.repository.search.indexing.IndexingException
Stop/cancel EAC script for given application id and script id.

Parameters:
pAppId - the Endeca applicaiton ID
pScriptId - the Endeca script ID.
Throws:
atg.repository.search.indexing.IndexingException - if script stop did not succeed

getControlLocator

protected ScriptControlServiceLocator getControlLocator()
                                                 throws javax.xml.rpc.ServiceException
Return the script control service locator given our current configuration.

Returns:
new scriptControlLocator.
Throws:
ServiceException - if unable to retrieve script service locator
javax.xml.rpc.ServiceException

getControlPort

protected ScriptControlPort getControlPort()
                                    throws javax.xml.rpc.ServiceException
Return the control port based on our current configuration.

Throws:
ServiceException - if unable to retrieve script control port
javax.xml.rpc.ServiceException

waitForScript

public StateType waitForScript(ScriptControlPort pScriptControlPort,
                               java.lang.String pAppId,
                               java.lang.String pScriptId)
                        throws atg.repository.search.indexing.IndexingException
Wait for the specified EAC script to finish.

Parameters:
pScriptControlPort - the control port
pAppId - the Endeca application ID
pScriptId - the Endeca script ID.
Throws:
atg.repository.search.indexing.IndexingException - if script execution failed

testExec

public void testExec()
Test BaselineUpdate script directly Not used anymore


testStartWait

public void testStartWait()
Test BaselineUpdate script directly using startScript and waitForScript Not used anymore