Class RouteLayer

java.lang.Object
org.apache.opendal.Layer
org.apache.opendal.layer.RouteLayer
All Implemented Interfaces:
AutoCloseable

public final class RouteLayer extends Layer implements 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:
  • Method Details

    • builder

      public static RouteLayer.RouteLayerBuilder builder()
      Creates a builder with no routes. Close the builder if construction is abandoned before calling build().
      Returns:
      a new route layer builder
    • layer

      protected long layer(long nativeOp)
      Specified by:
      layer in class Layer
    • close

      public void close()
      Releases the layer's reference to the routes. Operators already using the layer retain their routes.
      Specified by:
      close in interface AutoCloseable