Package dev.getelements.elements.rt
Interface ResourceContext
- All Known Implementing Classes:
SimpleResourceContext
public interface ResourceContext
The interface for manipulating
Resource
s in the cluster.-
Method Summary
Modifier and TypeMethodDescriptiondefault ResourceId
default void
createAsync
(Consumer<ResourceId> success, Consumer<Throwable> failure, String module, Path path, Object... args) default ResourceId
createAttributes
(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.default void
destroy
(ResourceId resourceId) Destroys theResource
with the providedResourceId
.default void
Performs the operations ofdestroyAllResourcesAsync(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
.default void
default Object
invoke
(ResourceId resourceId, String method, Object... args) Synchronous invoke ofinvokePathAsync(Consumer, Consumer, Path, String, Object...)
.void
invokeAsync
(Consumer<Object> success, Consumer<Throwable> failure, ResourceId resourceId, String method, Object... args) Invokes the method on theResourceId
.default Object
invokePath
(Path path, String method, Object... args) Synchronous invoke ofinvokePathAsync(Consumer, Consumer, Path, String, Object...)
.void
invokePathAsync
(Consumer<Object> success, Consumer<Throwable> failure, Path path, String method, Object... args) default void
start()
Starts thisResourceContext
.default void
stop()
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 theResource
with the providedResourceId
.- Parameters:
resourceId
- theResourceId
-
destroyAsync
Destroys theResource
with 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
- theResourceId
String
.
-
destroyAllResources
default void destroyAllResources()Performs the operations ofdestroyAllResourcesAsync(Consumer, Consumer)
in a synchronous fashion. -
destroyAllResourcesAsync
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.
-