Package net.officefloor.script
Class AbstractScriptProcedureSourceServiceFactory
- java.lang.Object
-
- net.officefloor.script.AbstractScriptProcedureSourceServiceFactory
-
- All Implemented Interfaces:
ProcedureSourceServiceFactory,ServiceFactory<ProcedureSource>
- Direct Known Subclasses:
JavaScriptProcedureSourceServiceFactory
public abstract class AbstractScriptProcedureSourceServiceFactory extends java.lang.Object implements ProcedureSourceServiceFactory
ProcedureSourceServiceFactoryproviding abstract support for Scripts.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description AbstractScriptProcedureSourceServiceFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ProcedureSourcecreateService(ServiceContext context)Creates the service.protected voiddecorateScriptEngine(javax.script.ScriptEngine engine, SourceContext context)Enables overriding to decorate theScriptEngine.protected abstract java.lang.StringgetMetaDataScriptPath(SourceContext context)Obtains the path to the script that extracts the function meta-data.protected abstract java.lang.StringgetScriptEngineName(SourceContext context)Obtains the name of theScriptEngine.protected ScriptExceptionTranslatorgetScriptExceptionTranslator()Obtains theScriptExceptionTranslator.protected abstract java.lang.String[]getScriptFileExtensions(SourceContext context)Obtains the extensions for the script resource.protected java.lang.StringgetSetupScriptPath(SourceContext context)Obtains the path to the setup script.protected abstract java.lang.StringgetSourceName()Obtains the source name for thisProcedureSource.protected voidlistProcedures(ProcedureListContext context)Lists theProcedureinstances.protected voidloadManagedFunction(ProcedureManagedFunctionContext context)Loads theManagedFunctionfor theProcedure.protected java.lang.StringloadResourceScript(java.lang.String resource, SourceContext sourceContext)Loads the source script.protected javax.script.InvocableloadScriptEngine(javax.script.ScriptEngineManager engineManager, java.lang.String engineName, java.lang.String setupScript, java.lang.String script, java.lang.String metaDataScript, SourceContext sourceContext)Loads theScriptEngine.protected java.lang.StringloadSetupScript(SourceContext sourceContext)Loads the setup script.
-
-
-
Method Detail
-
getSourceName
protected abstract java.lang.String getSourceName()
Obtains the source name for thisProcedureSource.- Returns:
- Source name for this
ProcedureSource.
-
getScriptFileExtensions
protected abstract java.lang.String[] getScriptFileExtensions(SourceContext context) throws java.lang.Exception
Obtains the extensions for the script resource.- Parameters:
context-SourceContext.- Returns:
- Extensions for the script resource.
- Throws:
java.lang.Exception- If fails to obtain the file extensions.
-
getScriptEngineName
protected abstract java.lang.String getScriptEngineName(SourceContext context) throws java.lang.Exception
Obtains the name of theScriptEngine.- Parameters:
context-SourceContext.- Returns:
- Name of the
ScriptEngine. - Throws:
java.lang.Exception- If fails to obtain the name of theScriptEngine.
-
decorateScriptEngine
protected void decorateScriptEngine(javax.script.ScriptEngine engine, SourceContext context) throws java.lang.ExceptionEnables overriding to decorate theScriptEngine.- Parameters:
engine-ScriptEngine.context-SourceContext.- Throws:
java.lang.Exception- If fails to decorate theScriptEngine.
-
getSetupScriptPath
protected java.lang.String getSetupScriptPath(SourceContext context) throws java.lang.Exception
Obtains the path to the setup script.- Parameters:
context-SourceContext.- Returns:
- Path to the setup script or
nullif no setup. - Throws:
java.lang.Exception- If fails to obtain the setup script path.
-
getMetaDataScriptPath
protected abstract java.lang.String getMetaDataScriptPath(SourceContext context) throws java.lang.Exception
Obtains the path to the script that extracts the function meta-data.- Parameters:
context-SourceContext.- Returns:
- Path to the script that extracts the function meta-data.
- Throws:
java.lang.Exception- If fails to obtain the path to the function meta-data script.
-
getScriptExceptionTranslator
protected ScriptExceptionTranslator getScriptExceptionTranslator()
Obtains theScriptExceptionTranslator.- Returns:
ScriptExceptionTranslator.
-
loadSetupScript
protected java.lang.String loadSetupScript(SourceContext sourceContext) throws java.lang.Exception
Loads the setup script.- Parameters:
sourceContext-SourceContext.- Returns:
- Setup script or
nullif no setup. - Throws:
java.lang.Exception- If fails to load setup script.
-
loadResourceScript
protected java.lang.String loadResourceScript(java.lang.String resource, SourceContext sourceContext) throws java.lang.ExceptionLoads the source script.- Parameters:
resource- Resource.sourceContext-SourceContext.- Returns:
- Resource script.
- Throws:
java.lang.Exception- If fails to load resource script.
-
loadScriptEngine
protected javax.script.Invocable loadScriptEngine(javax.script.ScriptEngineManager engineManager, java.lang.String engineName, java.lang.String setupScript, java.lang.String script, java.lang.String metaDataScript, SourceContext sourceContext) throws java.lang.ExceptionLoads theScriptEngine.- Parameters:
engineManager-ScriptEngineManager.engineName- Name of theScriptEngine.setupScript- Setup script. May benullfor no setup.script- Script containing the function(s).metaDataScript- Script to extract meta-data.sourceContext-SourceContext.- Returns:
Invocablefor theScriptEngine.- Throws:
java.lang.Exception- IF fails to load theScriptEngine.
-
listProcedures
protected void listProcedures(ProcedureListContext context) throws java.lang.Exception
Lists theProcedureinstances.- Parameters:
context-ProcedureListContext.- Throws:
java.lang.Exception- If fails to list theProcedureinstances.
-
loadManagedFunction
protected void loadManagedFunction(ProcedureManagedFunctionContext context) throws java.lang.Exception
Loads theManagedFunctionfor theProcedure.- Parameters:
context-ProcedureManagedFunctionContext.- Throws:
java.lang.Exception- If fails to load theManagedFunction.
-
createService
public ProcedureSource createService(ServiceContext context) throws java.lang.Throwable
Description copied from interface:ServiceFactoryCreates the service.- Specified by:
createServicein interfaceServiceFactory<ProcedureSource>- Parameters:
context-ServiceContext.- Returns:
- Service.
- Throws:
java.lang.Throwable- If fails to create the service.
-
-