Package com.avoka.fc.core.service
Class AbstractGroovyService
- java.lang.Object
-
- com.avoka.fc.core.service.BaseService
-
- com.avoka.fc.core.service.AbstractGroovyService
-
- All Implemented Interfaces:
IServiceDefinitionAware
,IUnitTestableService
- Direct Known Subclasses:
GroovyDeliveryProcessService
,GroovyDynamicDataService
,GroovyFormPrefillService
,GroovyFormSavedProcessor
,GroovyFormSecurityFilterService
,GroovyFormVersionSelectorService
,GroovyReceiptNumberService
,GroovyRenderReceiptService
,GroovyScheduledService
,GroovyServiceImpl
,GroovySubmissionCompletedProcessor
,GroovySubmissionDataValidator
,GroovySubmissionPreprocessor
,GroovyTaskExpiryService
,GroovyTrackingNumberService
,TransactionHistoryPublisherImpl
public abstract class AbstractGroovyService extends BaseService implements IServiceDefinitionAware, IUnitTestableService
Provides an abstract Groovy service which implement common properties.- Since:
- 4.2.0
-
-
Constructor Summary
Constructors Constructor Description AbstractGroovyService()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected ApplicationException
createExceptionAndLog(Date startTime, com.jezhumble.javasysmon.CpuTimes startCpuTimes, Long startFreeMemory, Throwable cause, String context, String userMsg, String solution, Submission submission, Form form, Client client)
Create application exception and optionally log ErrorLog and GroovyServiceLog records if Groovy Logging enabled.protected Object
executeGroovyScript(Map<String,Object> parameters, Client client)
Execute the service Groovy Script using the given parameters and security context client.protected Object
executeGroovyScript(Map<String,Object> parameters, Client client, boolean commitChanges)
Execute the service Groovy Script using the given parameters and security context client.protected Throwable
getCause(Throwable e)
Return the root cause of the exceptionabstract String
getErrorType()
Integer
getExecutionTimeout()
Return the GroovyScript execution timeout in milliseconds.String
getGroovyScript()
GroovyServiceLog
getGroovyServiceLog()
Return the GroovyServiceLog record created after executing the script.ServiceDefinition
getServiceDefinition()
Return the service definitionprotected String
getServiceName()
Deprecated.this no longer uniquely identifies the service - use getNameAndVersion() where possibleprotected String
getServiceNameAndVersion()
protected Integer
getServiceTimeout()
String
getTestLogOutput()
Return the service Unit Test Script logger output.boolean
isExceptionDebugLoggingEnabled()
Return true if the Exception DEBUG level message recording is enabled.Boolean
isGroovyDebugLogging()
Return true if GroovyLogger DEBUG level message recording is enabled.boolean
isGroovyLoggingEnabled()
Return true if the Groovy Service logging is enabled.boolean
isGroovyTypeChecked()
Deprecated.Throwable
runUnitTest()
Run the service's Unit Test Script if defined for the service, returning null if succeeded or an error if it failed.void
setExceptionDebugLoggingEnabled(Boolean debugEnabled)
Specify whether the Exception DEBUG level message recording is enabled.void
setExecutionTimeout(Integer timeout)
Return the GroovyScript execution timeout in milliseconds.void
setGroovyDebugLogging(Boolean debugEnabled)
Set whether GroovyLogger DEBUG level message recording is enabled.void
setGroovyLoggingEnabled(Boolean loggingEnabled)
Specify whether the Groovy Service logging is enabled.void
setGroovyScript(String script)
void
setGroovyTypeChecked(boolean typeChecked)
Deprecated.void
setServiceDefinition(ServiceDefinition serviceDefinition)
Set the service definition.void
setUseModuleClassLoader(boolean useModuleClassLoader)
This does nothing and is provided as a stub backward compatibility with older service definition parameter configurations.-
Methods inherited from class com.avoka.fc.core.service.BaseService
getLogger
-
-
-
-
Method Detail
-
getErrorType
public abstract String getErrorType()
- Returns:
- the service error type to be used to classify the error logging records
- Since:
- 4.3.4
-
runUnitTest
public Throwable runUnitTest()
Run the service's Unit Test Script if defined for the service, returning null if succeeded or an error if it failed. If there is no 'Unit Test Script' defined, this method will return null.- Specified by:
runUnitTest
in interfaceIUnitTestableService
- Returns:
- an Exception if the test case failed, or null if the test case succeeded or no 'Unit Test Script' defined.
- Since:
- 4.3.0
- See Also:
IUnitTestableService.runUnitTest()
-
getTestLogOutput
public String getTestLogOutput()
Return the service Unit Test Script logger output.- Specified by:
getTestLogOutput
in interfaceIUnitTestableService
- Returns:
- the service Unit Test Script logger output
- Since:
- 17.10.0
- See Also:
IUnitTestableService.getTestLogOutput()
-
getGroovyServiceLog
public GroovyServiceLog getGroovyServiceLog()
Return the GroovyServiceLog record created after executing the script.- Returns:
- the GroovyServiceLog record created after executing the script.
-
isGroovyDebugLogging
public Boolean isGroovyDebugLogging()
Return true if GroovyLogger DEBUG level message recording is enabled.- Returns:
- true if GroovyLogger DEBUG level message recording is enabled.
- Since:
- 4.3.4
-
setGroovyDebugLogging
public void setGroovyDebugLogging(Boolean debugEnabled)
Set whether GroovyLogger DEBUG level message recording is enabled.- Parameters:
debugEnabled
- the groovyDebugLoggingEnabled to set- Since:
- 4.3.4
-
isGroovyLoggingEnabled
public boolean isGroovyLoggingEnabled()
Return true if the Groovy Service logging is enabled.- Returns:
- true if the Groovy Service logging is enabled.
-
setGroovyLoggingEnabled
public void setGroovyLoggingEnabled(Boolean loggingEnabled)
Specify whether the Groovy Service logging is enabled.- Parameters:
loggingEnabled
- specify whether the Groovy Service logging is enabled
-
setExceptionDebugLoggingEnabled
public void setExceptionDebugLoggingEnabled(Boolean debugEnabled)
Specify whether the Exception DEBUG level message recording is enabled.- Parameters:
debugEnabled
- specify the Exception DEBUG level message recording is enabled- Since:
- 19.5.3
-
isExceptionDebugLoggingEnabled
public boolean isExceptionDebugLoggingEnabled()
Return true if the Exception DEBUG level message recording is enabled.- Returns:
- true if the Exception DEBUG level message recording is enabled.
- Since:
- 19.5.3
-
getGroovyScript
public String getGroovyScript()
- Returns:
- the Groovy Script content to execute
-
setGroovyScript
public void setGroovyScript(String script)
- Parameters:
script
- the Groovy Script content to execute
-
isGroovyTypeChecked
@Deprecated public boolean isGroovyTypeChecked()
Deprecated.- Returns:
- false
-
setGroovyTypeChecked
@Deprecated public void setGroovyTypeChecked(boolean typeChecked)
Deprecated.- Parameters:
typeChecked
- does nothing
-
getExecutionTimeout
public Integer getExecutionTimeout()
Return the GroovyScript execution timeout in milliseconds.- Returns:
- the GroovyScript execution timeout in milliseconds
-
setExecutionTimeout
public void setExecutionTimeout(Integer timeout)
Return the GroovyScript execution timeout in milliseconds.- Parameters:
timeout
- the GroovyScript execution timeout in milliseconds
-
getServiceDefinition
public ServiceDefinition getServiceDefinition()
Return the service definition- Specified by:
getServiceDefinition
in interfaceIServiceDefinitionAware
- Returns:
- the service definition.
-
setServiceDefinition
public void setServiceDefinition(ServiceDefinition serviceDefinition)
Set the service definition.- Specified by:
setServiceDefinition
in interfaceIServiceDefinitionAware
- Parameters:
serviceDefinition
- the service definition to set
-
setUseModuleClassLoader
public void setUseModuleClassLoader(boolean useModuleClassLoader)
This does nothing and is provided as a stub backward compatibility with older service definition parameter configurations.- Parameters:
useModuleClassLoader
- this does nothing.
-
executeGroovyScript
protected Object executeGroovyScript(Map<String,Object> parameters, Client client)
Execute the service Groovy Script using the given parameters and security context client.- Parameters:
parameters
- the script parameters (required)client
- the calling client (optional)- Returns:
- a new GroovyScript runtime for the given client
-
executeGroovyScript
protected Object executeGroovyScript(Map<String,Object> parameters, Client client, boolean commitChanges)
Execute the service Groovy Script using the given parameters and security context client.- Parameters:
parameters
- the script parameters (required)client
- the calling client (optional)commitChanges
- the commit changes with to the Groovy Service Log- Returns:
- a new GroovyScript runtime for the given client
- Since:
- 4.3.3.1
-
createExceptionAndLog
protected ApplicationException createExceptionAndLog(Date startTime, com.jezhumble.javasysmon.CpuTimes startCpuTimes, Long startFreeMemory, Throwable cause, String context, String userMsg, String solution, Submission submission, Form form, Client client)
Create application exception and optionally log ErrorLog and GroovyServiceLog records if Groovy Logging enabled.- Parameters:
startTime
- the time the service was invoked prior to the errorstartCpuTimes
- the CPU times when the service was invoked (required)startFreeMemory
- the free memory in bytes when the service was invoked (required)cause
- the root cause of the errorcontext
- the error context informationuserMsg
- the user messagesolution
- the solutionsubmission
- the submission objectform
- the formclient
- the client- Returns:
- a new application exception
-
getServiceName
protected String getServiceName()
Deprecated.this no longer uniquely identifies the service - use getNameAndVersion() where possible- Returns:
- the service definition service name
-
getServiceNameAndVersion
protected String getServiceNameAndVersion()
- Returns:
- the service definition name and version number
-
getServiceTimeout
protected Integer getServiceTimeout()
- Returns:
- the service timeout
-
-