Class RouteLayer
java.lang.Object
org.apache.opendal.Layer
org.apache.opendal.layer.RouteLayer
- All Implemented Interfaces:
AutoCloseable
Routes storage operations by matching paths against glob patterns in the order the routes were added.
The first match wins. Unmatched paths use the operator to which the layer is applied.
Copy and rename select the service using the source path and operate within that service. The layer reports capabilities based on the wrapped operator's capabilities, without aggregating the targets' capabilities.
Close the layer after applying it to every operator that needs it. The resulting operators retain the routes and can continue using them after the layer is closed.
try (RouteLayer.RouteLayerBuilder builder = RouteLayer.builder()) {
builder.route("archive/**", archive);
try (RouteLayer layer = builder.build();
AsyncOperator routed = primary.layer(layer)) {
routed.write("archive/example.txt", "example").join();
}
}
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classCollects ordered routes and builds one layer. -
Method Summary
Modifier and TypeMethodDescriptionstatic RouteLayer.RouteLayerBuilderbuilder()Creates a builder with no routes.voidclose()Releases the layer's reference to the routes.protected longlayer(long nativeOp)
-
Method Details
-
builder
Creates a builder with no routes. Close the builder if construction is abandoned before callingbuild().- Returns:
- a new route layer builder
-
layer
-
close
public void close()Releases the layer's reference to the routes. Operators already using the layer retain their routes.- Specified by:
closein interfaceAutoCloseable
-