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) voidcreateAttributesAsync(Consumer<ResourceId> success, Consumer<Throwable> failure, String module, Path path, Attributes attributes, Object... args) Creates aResourceasynchronously.voidPerforms the operations ofResourceContext.destroyAllResourcesAsync(Consumer, Consumer)in a synchronous fashion.voiddestroyAllResourcesAsync(Consumer<Void> success, Consumer<Throwable> failure) Clears allResourceinstances from the system.voiddestroyAsync(Consumer<Void> success, Consumer<Throwable> failure, ResourceId resourceId) Destroys theResourcewith the providedResourceId.voidinvokeAsync(Consumer<Object> success, Consumer<Throwable> failure, ResourceId resourceId, String method, Object... args) Invokes the method on theResourceId.voidinvokePathAsync(Consumer<Object> success, Consumer<Throwable> failure, Path path, String method, Object... args) voidsetExecutorServiceFactory(ExecutorServiceFactory<ExecutorService> executorServiceFactory) voidsetResourceLoader(ResourceLoader resourceLoader) voidsetResourceService(ResourceService resourceService) voidsetScheduler(Scheduler scheduler) voidstart()Starts thisResourceContext.voidstop()Stops thisResourceContext.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:ResourceContextStarts thisResourceContext.- Specified by:
startin interfaceResourceContext
-
stop
public void stop()Description copied from interface:ResourceContextStops thisResourceContext.- Specified by:
stopin interfaceResourceContext
-
createAttributes
Description copied from interface:ResourceContext- Specified by:
createAttributesin 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:ResourceContextCreates aResourceasynchronously. Once created, theResourcecan be provided to the suppliedConsumer<Resource>.- Specified by:
createAttributesAsyncin interfaceResourceContext- Parameters:
success- theConsumerwhich will be called if the call succeedsfailure- theConsumerwhich will be called if the call fails, capturing any failuremodule- module name to instantiatepath- thePathfor theResourceargs- the arguments to pass to theResourceon initialization
-
destroyAsync
public void destroyAsync(Consumer<Void> success, Consumer<Throwable> failure, ResourceId resourceId) Description copied from interface:ResourceContextDestroys theResourcewith the providedResourceId.- Specified by:
destroyAsyncin 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:ResourceContextInvokes the method on theResourceId.- Specified by:
invokeAsyncin 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:
invokePathAsyncin 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:ResourceContextPerforms the operations ofResourceContext.destroyAllResourcesAsync(Consumer, Consumer)in a synchronous fashion.- Specified by:
destroyAllResourcesin interfaceResourceContext
-
destroyAllResourcesAsync
Description copied from interface:ResourceContextClears allResourceinstances 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:
destroyAllResourcesAsyncin interfaceResourceContext
-
getScheduler
-
setScheduler
-
getResourceLoader
-
setResourceLoader
-
getResourceService
-
setResourceService
-
getExecutorServiceFactory
-
setExecutorServiceFactory
@Inject public void setExecutorServiceFactory(@Named("dev.getelements.elements.rt.executor") ExecutorServiceFactory<ExecutorService> executorServiceFactory)
-