Package dev.getelements.elements.rt
Interface ResourceContext
- All Known Implementing Classes:
SimpleResourceContext
public interface ResourceContext
The interface for manipulating
Resources in the cluster.-
Method Summary
Modifier and TypeMethodDescriptiondefault ResourceIddefault voidcreateAsync(Consumer<ResourceId> success, Consumer<Throwable> failure, String module, Path path, Object... args) default ResourceIdcreateAttributes(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.default voiddestroy(ResourceId resourceId) Destroys theResourcewith the providedResourceId.default voidPerforms the operations ofdestroyAllResourcesAsync(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.default voiddefault Objectinvoke(ResourceId resourceId, String method, Object... args) Synchronous invoke ofinvokePathAsync(Consumer, Consumer, Path, String, Object...).voidinvokeAsync(Consumer<Object> success, Consumer<Throwable> failure, ResourceId resourceId, String method, Object... args) Invokes the method on theResourceId.default ObjectinvokePath(Path path, String method, Object... args) Synchronous invoke ofinvokePathAsync(Consumer, Consumer, Path, String, Object...).voidinvokePathAsync(Consumer<Object> success, Consumer<Throwable> failure, Path path, String method, Object... args) default voidstart()Starts thisResourceContext.default voidstop()Stops thisResourceContext.
-
Method Details
-
start
default void start()Starts thisResourceContext. -
stop
default void stop()Stops thisResourceContext. -
create
- Parameters:
module- the module to instantiatepath- the pathargs- the arguments to pass to the module instantiation- Returns:
- the system-assigned
ResourceId
-
createAsync
-
createAttributes
default ResourceId createAttributes(String module, Path path, Attributes attributes, Object... args) - Parameters:
module- the module to instantiatepath- the pathargs- the arguments to pass to the module instantiation- Returns:
- the system-assigned
ResourceId
-
createAttributesAsync
void createAttributesAsync(Consumer<ResourceId> success, Consumer<Throwable> failure, String module, Path path, Attributes attributes, Object... args) -
invoke
Synchronous invoke ofinvokePathAsync(Consumer, Consumer, Path, String, Object...).- Parameters:
resourceId- the resource's idmethod- the method nameargs- the argument array- Returns:
- the result of the invocation
-
invokeAsync
void invokeAsync(Consumer<Object> success, Consumer<Throwable> failure, ResourceId resourceId, String method, Object... args) Invokes the method on theResourceId.- Parameters:
success- called when the operation succeedsfailure- called when the operation failsresourceId- the resource's idmethod- the methodargs- the args
-
invokePath
Synchronous invoke ofinvokePathAsync(Consumer, Consumer, Path, String, Object...).- Parameters:
path- the pathmethod- the method nameargs- the argument array- Returns:
- the result of the invocation
-
invokePathAsync
void invokePathAsync(Consumer<Object> success, Consumer<Throwable> failure, Path path, String method, Object... args) - Parameters:
success- called when the operation succeedsfailure- called when the operation failspath- the Pathmethod- the methodargs- the args
-
destroy
Destroys theResourcewith the providedResourceId.- Parameters:
resourceId- theResourceId
-
destroyAsync
Destroys theResourcewith the providedResourceId.- Parameters:
success- called if the operation succeedsfailure- called if the operation failsresourceId- theResourceId
-
destroyAsync
default void destroyAsync(Consumer<Void> success, Consumer<Throwable> failure, String resourceIdString) - Parameters:
resourceIdString- theResourceIdString.
-
destroyAllResources
default void destroyAllResources()Performs the operations ofdestroyAllResourcesAsync(Consumer, Consumer)in a synchronous fashion. -
destroyAllResourcesAsync
Clears 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.
-