public class ScriptDriver extends BaseApp
Modifier and Type | Class and Description |
---|---|
class |
ScriptDriver.MethodInfo
MethodInfo holds information about a method (operation) specified.
|
m_currentuser, m_session
m_defaultWriter, m_logWriter, m_parametertable, m_timervalue
Constructor and Description |
---|
ScriptDriver(String[] args)
Constructs a ScriptDriver.
|
Modifier and Type | Method and Description |
---|---|
protected void |
applyLogLevelOverride(String logEntry)
Apply a log level overrides.
|
protected void |
applyLogLevelOverrides(String[] logEntries)
Apply a set of log level overrides.
|
protected boolean |
businessObjectExists(String tag)
Check whether a BusinessObject has been registered for the specified tag.
|
protected LibraryObjectDefinition |
cloneDefinition(LibrarySession sess,
String sourceDefTag,
String cloneDefTag)
Clone a LibraryObjectDefinition by the specified source tag.
|
ScriptDriver.MethodInfo |
createMethodInfo(String token,
ParameterTable ptArg)
Construct and return a MethodInfo instance.
|
protected boolean |
definitionExists(String tag)
Check whether a definition has been registered for the specified tag.
|
protected void |
deregisterBusinessObject(String tag)
De-register a BusinessObject by name.
|
protected void |
deregisterDefinition(String tag)
De-register a LibraryObjectDefinition by name.
|
protected void |
deregisterObject(String tag)
De-register a LibraryObject by name.
|
protected void |
deregisterSession(String tag,
LibrarySession sess)
De-register a session.
|
protected Transaction |
deregisterTransaction(String trantag)
De-register a transaction.
|
String |
getArrayTokenDelimiter()
Get the delimiter to use when parsing array tokens (defaults to ",").
|
AuditDriverHelper |
getAuditDriverHelper()
Return the AuditDriverHelper in use.
|
protected LibrarySession |
getCurrentSession()
Get the current session.
|
protected ScriptOperations |
getDefaultScriptOperations(ScriptDriver driver)
Return a newly constructed instance of the ScriptOperations instance
to use by default.
|
protected PrintWriter |
getLogWriter()
Return the log writer in use.
|
protected boolean |
getShowDates()
Return indication as to whether dates should be shown in the output.
|
protected String[] |
getStringsFromArrayToken(String token)
Get String array from a value of the form
"{value1, value2, value3}".
|
protected boolean |
getStripNumbersFromAuditEventProperties()
Return indication as to whether numbers should be replaced in
audit event properties in
ShowUtils.showAuditEvents . |
String |
getSubstitutionPrefix()
Get the prefix indicating a substitution reference.
|
protected void |
initializeLogging(ParameterTable params)
Initialize logging context.
|
void |
log(String msg)
Log the specified message to the logger's log.
|
protected void |
logToLogger(Level level,
String msg)
Log the specified message to the logger's log.
|
protected void |
logToLogger(String msg)
Log the specified message to the logger's log.
|
protected void |
logToOutput(String msg)
Log the specified message to the configured output log.
|
protected Object |
lookupBusinessObject(LibrarySession session,
String tag)
Lookup a BusinessObject by the specified tag.
|
protected LibraryObjectDefinition |
lookupDefinition(LibrarySession sess,
String tag)
Lookup a LibraryObjectDefinition by the specified tag.
|
protected LibraryObjectDefinition |
lookupDefinition(LibrarySession sess,
String tag,
String className)
Lookup a LibraryObjectDefinition by the specified tag and that is the
appropriate instance for the specified classobject name.
|
protected LibraryObject |
lookupObject(LibrarySession sess,
String tag)
Lookup a LibraryObject by the specified tag.
|
protected LibraryObject |
lookupObject(LibrarySession sess,
String tag,
String className)
Lookup a LibraryObject by the specified tag and that is an instance
of the specified class.
|
AttributeValue |
lookupObjectAttributeValue(String tag)
Lookup an AttributeValue that identifies a LibraryObject,
by the specified tag.
|
protected Long |
lookupObjectId(LibrarySession sess,
String tag)
Lookup a LibraryObject's ID by the specified tag.
|
protected LibrarySession |
lookupSessionByTag(String tag)
Lookup a session by the session tag that was used to register it.
|
protected String |
lookupTagBySessionId(Long sessid)
Lookup a session tag by the session ID.
|
protected boolean |
objectExists(String tag)
Check whether an object has been registered for the specified tag.
|
protected void |
registerBusinessObject(String tag,
Object obj)
Register a BusinessObject by name.
|
protected void |
registerDefinition(String tag,
LibraryObjectDefinition def)
Register a LibraryObjectDefinition by name.
|
protected void |
registerNewSession(String sesstag,
LibrarySession sess)
Register a session.
|
protected void |
registerObject(String tag,
LibraryObject obj)
Register a LibraryObject by name.
|
protected void |
registerTransaction(String trantag,
Transaction tran)
Register a transaction.
|
protected LibrarySession |
replaceSession(String tag,
LibrarySession newSess)
Replace a previously registered session with a different session.
|
void |
run()
Run the driver.
|
protected boolean |
sessionExists(String tag)
Check whether a session has been registered for the specified tag.
|
void |
setArrayTokenDelimiter(String delim)
Set the delimiter to use when parsing array tokens.
|
protected void |
setCurrentSession(LibrarySession session)
Make the specified session the default.
|
void |
setDefaultScriptOperations(ScriptOperations ops)
Sets the instance to use as the default script operations
class.
|
void |
setDefaultScriptOperationsClass()
Restores the script operations class to the initial default.
|
void |
setDefaultScriptOperationsClass(String className)
Sets the class name of the instance to use as the
default script operations class.
|
void |
setMainSession(LibrarySession session)
Set the Main session, to avoid constructing a new one.
|
protected void |
setMainSessionAsCurrentSession()
Sets the main session as the current session.
|
void |
setMethodList(String[] methods)
Set the method list, instead of picking this up from the
ParameterTable.
|
void |
setSubstitutionPrefix(String prefix)
Set the prefix indicating a substitution reference.
|
protected boolean |
transactionExists(String tag)
Check whether a Transaction has been registered for the specified tag.
|
protected void |
verifyBusinessObjectTagNotExists(String defTag)
Verify that the specified BusinessObject tag does not already exist.
|
protected void |
verifyDefinitionTagNotExists(String defTag)
Verify that the specified definition tag does not already exist.
|
protected void |
verifyDefinitionWriteable(LibrarySession sess,
String tag)
Verify that a LibraryObjectDefinition identified by the specified tag
is writeable.
|
protected void |
verifyObjectTagNotExists(String objTag)
Verify that the specified object tag does not already exist.
|
connect, Connect, connect, Connect, Connect, Connect, connect, Connect, connect, Connect, Disconnect, getCachePerformanceString, getCleartextCredential, getCleartextCredential, getConnectionPoolPerformanceString, getConnectOptions, getConnectOptions, getConnectOptions, getLocale, showCachePerformance, showConnectionPoolPerformance
getElapsedTime, getParameterTable, initTrace, log, logCurrentTimestamp, printStackTrace, setTimer, showElapsedTime
public ScriptDriver(String[] args)
args
- commandline argumentspublic void setMainSession(LibrarySession session)
This session will NOT get automatically disconnected as part
on run
.
session
- the main sessionpublic void setMethodList(String[] methods)
methods
- the method listpublic void run()
This consumes any exception after reporting it in the log.
public ScriptDriver.MethodInfo createMethodInfo(String token, ParameterTable ptArg)
token
- the token to parseprotected String[] getStringsFromArrayToken(String token) throws IfsException
token
- the string tokenIfsException
- if the operation failsprotected LibrarySession getCurrentSession() throws IfsException
The current session starts out as a session tagged as "Main", and can be switched to any other connected session. I new session gets connected via the createSession() operation. The current session is the session specified in the last switchSession() or createSession() statement. If the current session is removed, the current session becomes "Main".
IfsException
- if the operation failsprotected void setCurrentSession(LibrarySession session) throws IfsException
session
- the sessionIfsException
- if the operation failsprotected void setMainSessionAsCurrentSession() throws IfsException
IfsException
- if the operation failsprotected void registerNewSession(String sesstag, LibrarySession sess) throws IfsException
This registers a two-way lookup, enabling finding the session by the specified session tag, and the ability to determine the session tag from the LibrarySession.
sesstag
- the session tagsess
- the sessionIfsException
- if the operation failsprotected void deregisterSession(String tag, LibrarySession sess) throws IfsException
This is called automatically as part of removeSession(). If the specified tag does not identify a currently registered session, the operation is a no-op (no exception is thrown).
tag
- the session tagsess
- the session contextIfsException
- if the operation failsprotected LibrarySession replaceSession(String tag, LibrarySession newSess) throws IfsException
Disconnects the previous session (if any).
tag
- the session tagnewSess
- the new session contextIfsException
- if the operation failsprotected LibrarySession lookupSessionByTag(String tag)
A RuntimeException is thrown if there is no session registered with the specified tag.
tag
- the session tagprotected boolean sessionExists(String tag)
tag
- the session tagprotected String lookupTagBySessionId(Long sessid)
A RuntimeException is thrown if there is no session registered with the specified ID.
sessid
- the session IDprotected void registerTransaction(String trantag, Transaction tran)
trantag
- the Transaction tagtran
- the Transactionprotected Transaction deregisterTransaction(String trantag)
trantag
- the Transaction tagprotected boolean transactionExists(String tag)
tag
- the Transaction tagpublic AttributeValue lookupObjectAttributeValue(String tag) throws IfsException
tag
- the tagIfsException
- if the operation fails.protected LibraryObject lookupObject(LibrarySession sess, String tag) throws IfsException
A RuntimeException is thrown if there is no object registered with the specified tag, or if the object previously registered with that tag no longer exists.
sess
- the sessiontag
- the object tagIfsException
- if the operation failsprotected Long lookupObjectId(LibrarySession sess, String tag) throws IfsException
A RuntimeException is thrown if there is no object registered with the specified tag.
sess
- the sessiontag
- the object tagIfsException
- if the operation failsprotected LibraryObject lookupObject(LibrarySession sess, String tag, String className) throws IfsException
A RuntimeException is thrown if there is no object registered with the specified tag, or if the registered object is not an instance of the specified class.
sess
- the sessiontag
- the object tagclassName
- the desired classIfsException
- if the operation failsprotected boolean objectExists(String tag)
tag
- the object tagprotected void verifyObjectTagNotExists(String objTag)
objTag
- the object tagprotected void registerObject(String tag, LibraryObject obj) throws IfsException
tag
- the object tagobj
- the objectIfsException
- if the operation failsprotected void deregisterObject(String tag) throws IfsException
tag
- the object tagIfsException
- if the operation failsprotected LibraryObjectDefinition lookupDefinition(LibrarySession sess, String tag) throws IfsException
A RuntimeException is thrown if there is no definition registered with the specified tag.
sess
- the sessiontag
- the definition tagIfsException
- if the operation failsprotected void verifyDefinitionWriteable(LibrarySession sess, String tag) throws IfsException
A RuntimeException is thrown if there is no definition registered with the specified tag, or if it is not writeable.
sess
- the sessiontag
- the definition tagIfsException
- if the operation failsprotected LibraryObjectDefinition lookupDefinition(LibrarySession sess, String tag, String className) throws IfsException
A RuntimeException is thrown if there is no definition registered with the specified tag, or if the registered definition is not compatible with the specified class.
sess
- the sessiontag
- the definition tagclassName
- the desired classIfsException
- if the operation failsprotected LibraryObjectDefinition cloneDefinition(LibrarySession sess, String sourceDefTag, String cloneDefTag) throws IfsException
A RuntimeException is thrown if there is no definition registered with the specified source tag.
sess
- the sessionsourceDefTag
- the source definition tagcloneDefTag
- the tag for the cloned definitionIfsException
- if the operation failsprotected boolean definitionExists(String tag)
tag
- the definition tagprotected void verifyDefinitionTagNotExists(String defTag)
defTag
- the definition tagprotected void registerDefinition(String tag, LibraryObjectDefinition def) throws IfsException
tag
- the definition tagdef
- the definitionIfsException
- if the operation failsprotected void deregisterDefinition(String tag) throws IfsException
tag
- the definition tagIfsException
- if the operation failsprotected Object lookupBusinessObject(LibrarySession session, String tag) throws IfsException
A RuntimeException is thrown if there is no BusinessObject registered with the specified tag.
session
- the LibrarySessiontag
- the BusinessObject tagIfsException
- if the operation failsprotected boolean businessObjectExists(String tag)
tag
- the BusinessObject tagprotected void verifyBusinessObjectTagNotExists(String defTag)
defTag
- the BusinessObject tagprotected void registerBusinessObject(String tag, Object obj) throws IfsException
tag
- the BusinessObject tagobj
- the BusinessObjectIfsException
- if the operation failsprotected void deregisterBusinessObject(String tag) throws IfsException
tag
- the BusinessObject tagIfsException
- if the operation failsprotected void initializeLogging(ParameterTable params) throws IfsException
params
- ParameterTable containing the parameters
(LogLevel and LogFileName parameters used here).IfsException
- if the operation failsprotected void applyLogLevelOverrides(String[] logEntries)
logEntries
- the log override entriesprotected void applyLogLevelOverride(String logEntry)
logEntry
- the log override entryprotected PrintWriter getLogWriter()
protected boolean getShowDates()
protected boolean getStripNumbersFromAuditEventProperties()
ShowUtils.showAuditEvents
.public AuditDriverHelper getAuditDriverHelper()
public String getArrayTokenDelimiter()
public void setArrayTokenDelimiter(String delim)
delim
- the delimiter to use when parsing array tokenspublic String getSubstitutionPrefix()
Defaults to "$$".
public void setSubstitutionPrefix(String prefix)
public void log(String msg)
protected void logToLogger(String msg)
msg
- The log messageprotected void logToLogger(Level level, String msg)
level
- The log levelmsg
- The log messageprotected void logToOutput(String msg)
msg
- The log messageprotected ScriptOperations getDefaultScriptOperations(ScriptDriver driver)
driver
- ScriptDriver contextpublic void setDefaultScriptOperationsClass()
public void setDefaultScriptOperationsClass(String className)
className
- the name of the default ops class to usepublic void setDefaultScriptOperations(ScriptOperations ops)
ops
- the default ops class to useCopyright © 2023. All rights reserved.