Package dev.getelements.elements.rt
Class SimpleResourceContext
java.lang.Object
dev.getelements.elements.rt.SimpleResourceContext
- All Implemented Interfaces:
ResourceContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateAttributes
(String module, Path path, Attributes attributes, Object... args) void
createAttributesAsync
(Consumer<ResourceId> success, Consumer<Throwable> failure, String module, Path path, Attributes attributes, Object... args) Creates aResource
asynchronously.void
Performs the operations ofResourceContext.destroyAllResourcesAsync(Consumer, Consumer)
in a synchronous fashion.void
destroyAllResourcesAsync
(Consumer<Void> success, Consumer<Throwable> failure) Clears allResource
instances from the system.void
destroyAsync
(Consumer<Void> success, Consumer<Throwable> failure, ResourceId resourceId) Destroys theResource
with the providedResourceId
.void
invokeAsync
(Consumer<Object> success, Consumer<Throwable> failure, ResourceId resourceId, String method, Object... args) Invokes the method on theResourceId
.void
invokePathAsync
(Consumer<Object> success, Consumer<Throwable> failure, Path path, String method, Object... args) void
setExecutorServiceFactory
(ExecutorServiceFactory<ExecutorService> executorServiceFactory) void
setResourceLoader
(ResourceLoader resourceLoader) void
setResourceService
(ResourceService resourceService) void
setScheduler
(Scheduler scheduler) void
start()
Starts thisResourceContext
.void
stop()
Stops thisResourceContext
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.getelements.elements.rt.ResourceContext
create, createAsync, destroy, destroyAsync, invoke, invokePath
-
Constructor Details
-
SimpleResourceContext
public SimpleResourceContext()
-
-
Method Details
-
start
public void start()Description copied from interface:ResourceContext
Starts thisResourceContext
.- Specified by:
start
in interfaceResourceContext
-
stop
public void stop()Description copied from interface:ResourceContext
Stops thisResourceContext
.- Specified by:
stop
in interfaceResourceContext
-
createAttributes
Description copied from interface:ResourceContext
- Specified by:
createAttributes
in interfaceResourceContext
- Parameters:
module
- the module to instantiatepath
- the pathargs
- the arguments to pass to the module instantiation- Returns:
- the system-assigned
ResourceId
-
createAttributesAsync
public void createAttributesAsync(Consumer<ResourceId> success, Consumer<Throwable> failure, String module, Path path, Attributes attributes, Object... args) Description copied from interface:ResourceContext
Creates aResource
asynchronously. Once created, theResource
can be provided to the suppliedConsumer<Resource>
.- Specified by:
createAttributesAsync
in interfaceResourceContext
- Parameters:
success
- theConsumer
which will be called if the call succeedsfailure
- theConsumer
which will be called if the call fails, capturing any failuremodule
- module name to instantiatepath
- thePath
for theResource
args
- the arguments to pass to theResource
on initialization
-
destroyAsync
public void destroyAsync(Consumer<Void> success, Consumer<Throwable> failure, ResourceId resourceId) Description copied from interface:ResourceContext
Destroys theResource
with the providedResourceId
.- Specified by:
destroyAsync
in interfaceResourceContext
- Parameters:
success
- called if the operation succeedsfailure
- called if the operation failsresourceId
- theResourceId
-
invokeAsync
public void invokeAsync(Consumer<Object> success, Consumer<Throwable> failure, ResourceId resourceId, String method, Object... args) Description copied from interface:ResourceContext
Invokes the method on theResourceId
.- Specified by:
invokeAsync
in interfaceResourceContext
- Parameters:
success
- called when the operation succeedsfailure
- called when the operation failsresourceId
- the resource's idmethod
- the methodargs
- the args
-
invokePathAsync
public void invokePathAsync(Consumer<Object> success, Consumer<Throwable> failure, Path path, String method, Object... args) Description copied from interface:ResourceContext
- Specified by:
invokePathAsync
in interfaceResourceContext
- Parameters:
success
- called when the operation succeedsfailure
- called when the operation failspath
- the Pathmethod
- the methodargs
- the args
-
destroyAllResources
public void destroyAllResources()Description copied from interface:ResourceContext
Performs the operations ofResourceContext.destroyAllResourcesAsync(Consumer, Consumer)
in a synchronous fashion.- Specified by:
destroyAllResources
in interfaceResourceContext
-
destroyAllResourcesAsync
Description copied from interface:ResourceContext
Clears allResource
instances from the system. This is a call that should be used with extreme care as it can possibly destroy the whole system. This is primarily used for testing, or restarting or shutting down handler instances which are intended to be short-lived. This may not exist for all implementations ofResourceContext
, and may simply provide an exception indicating so.- Specified by:
destroyAllResourcesAsync
in interfaceResourceContext
-
getScheduler
-
setScheduler
-
getResourceLoader
-
setResourceLoader
-
getResourceService
-
setResourceService
-
getExecutorServiceFactory
-
setExecutorServiceFactory
@Inject public void setExecutorServiceFactory(@Named("dev.getelements.elements.rt.executor") ExecutorServiceFactory<ExecutorService> executorServiceFactory)
-