Package org.intocps.maestro.interpreter
Class DefaultExternalValueFactory
- java.lang.Object
-
- org.intocps.maestro.interpreter.DefaultExternalValueFactory
-
- All Implemented Interfaces:
IExternalValueFactory
public class DefaultExternalValueFactory extends Object implements IExternalValueFactory
Default interpreter factory with framework support and other basic features. This class provides run-time support only. It creates and destroys certain types based on load and unload
-
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,IValueLifecycleHandler>lifecycleHandlersprotected Map<Value,IValueLifecycleHandler>values
-
Constructor Summary
Constructors Constructor Description DefaultExternalValueFactory(File workingDirectory, InputStream config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLifecycleHandler(Class<? extends IValueLifecycleHandler> handlerClass)voidaddLifecycleHandler(IValueLifecycleHandler handler)IExternalValueFactorychangeWorkingDirectory(Path newSuggestion, InputStream config)Requests the current factory to return a new instance with the working directory changedcom.spencerwi.either.Either<Exception,Value>create(String loaderName, List<Value> args)Creates a new interpreter value for the specified type using the supplied argumentsValuedestroy(Value value)Destruction of values created by the factory.booleansupports(String type)Check if a certain type is supported by the external value factory
-
-
-
Field Detail
-
lifecycleHandlers
protected Map<String,IValueLifecycleHandler> lifecycleHandlers
-
values
protected Map<Value,IValueLifecycleHandler> values
-
-
Constructor Detail
-
DefaultExternalValueFactory
public DefaultExternalValueFactory(File workingDirectory, InputStream config) throws IOException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException
-
-
Method Detail
-
addLifecycleHandler
public void addLifecycleHandler(Class<? extends IValueLifecycleHandler> handlerClass) throws InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchMethodException
-
addLifecycleHandler
public void addLifecycleHandler(IValueLifecycleHandler handler)
-
supports
public boolean supports(String type) throws Exception
Description copied from interface:IExternalValueFactoryCheck if a certain type is supported by the external value factory- Specified by:
supportsin interfaceIExternalValueFactory- Returns:
- true if the type is supported by
IExternalValueFactory.create(String, List) - Throws:
Exception
-
create
public com.spencerwi.either.Either<Exception,Value> create(String loaderName, List<Value> args)
Description copied from interface:IExternalValueFactoryCreates a new interpreter value for the specified type using the supplied arguments- Specified by:
createin interfaceIExternalValueFactory- Parameters:
loaderName- the type to createargs- the arguments used to create the value- Returns:
- the value or an exception if creation fails
-
destroy
public Value destroy(Value value)
Description copied from interface:IExternalValueFactoryDestruction of values created by the factory. Destruction must make sure all resources hold by this value is freed- Specified by:
destroyin interfaceIExternalValueFactory- Parameters:
value- the value to destroy- Returns:
- void return
-
changeWorkingDirectory
public IExternalValueFactory changeWorkingDirectory(Path newSuggestion, InputStream config) throws IOException, InvocationTargetException, NoSuchMethodException, IllegalAccessException, InstantiationException
Description copied from interface:IExternalValueFactoryRequests the current factory to return a new instance with the working directory changed- Specified by:
changeWorkingDirectoryin interfaceIExternalValueFactory- Parameters:
newSuggestion- a suggested path for a new directoryconfig- optionally a new config can be null- Returns:
- a new factory which operates from the suggested path
- Throws:
IOExceptionInvocationTargetExceptionNoSuchMethodExceptionIllegalAccessExceptionInstantiationException
-
-