Resolve "Server: make binary transfer utilities available in Context"

Closes #24 (closed)

Changes

  • Add BinaryDatabaseInjector implements ServerInterceptorwhich attaches a reference to theBinaryDatabase` to every call context
  • Add BinaryDatabase.current() to get a reference to the BinaryDatabase from the current call context
  • Add SiLAServer.Builder.withBinaryDatabaseInjector() which adds a BinaryDatabaseInjector to the built server

New API

// in server builder
SiLAServer.Builder.newBuilder(...)
    .withBinaryTransferSupport(true)  // creates the database
    .withBinaryDatabaseInjector()

// in feature implementation
BinaryDatabase.current().uploadBinary(...)
BinaryDatabase.current().getBinaryInfo(...)
BinaryDatabase.current().getBinary(...)

Why is this important?

A complex API is acceptable for users who want custom behavior for the binary database. But implementing binary transfer in SiLA features should be easy. This MR enables users to easily use binary transfer in their feature definitions.

Without this, the feature implementations need to get a reference to the binary database in another way, usually the constructor. But the database needs the server UUID for its constructor. And the SiLAServer.Builder API makes it easy to let the server create the database, but hard to provide it from outside.

Edited by Niklas Mertsch

Merge request reports

Loading