OSLC / ldp-app

A simple client application to do CRUD operations on an LDP server and create a graphic display of an LDPC
Apache License 2.0
4 stars 1 forks source link

ldp-service needs to have it storage service configured by the using app #4

Closed jamsden closed 5 years ago

jamsden commented 5 years ago

An application, say an OSLC server, could need multiple ldp-services on different routes, each one configured with a different storage.js concrete implementation. This needs to be configured in the app using ldp-service, not in ldp-service itself.

ldp-app (oslc-server, or any other app that uses ldp-service) should require the storage service(s) it needs, add it to env.storageService and let ldp-service get the database from here.

ldp-service now has index.js which exports storageService and ldpService.

ldp-service-jena now depends on ldp-service and its storage.js requires('ldp-service').storageService and then replaces the abstract methods with concrete methods.

Finally, ldp-app requires ldpService and instantiates the desired storage service.

var ldpService = require('ldp-service').ldpService;
env.storageService = require('ldp-service-jena');
app.use(ldpService(env))

The app can then set the env properties to different values and instantiate another ldpService on a different route.

jamsden commented 5 years ago

Implemented and tested with skeleton oslc-server. This seems OK.