0

I have a frontend running on an IIS web server on port 80. It is written in HTML5 using the angular.js framework.

I have a RESTful backend running on a GlassFish application server on port 8084. It is written using the Jersey JAX-RS implementation.

The backend uses a Neo4J database which is created in the constructor of a Singleton class. So when there doesn't exist an instance of said class, the database is created. If the instance does exist, it uses the same GraphDatabaseService which was stored as an attribute. I do this to prevent Lock Store errors. If the class wasn't a singleton, it would every time try to create a new GraphDatabaseService to the same databasepath, and you can only have one at a time.

The needs for my application have changed however. A login will be required, and every user will get his own database. The username will be used in the databasepath and has to be passed on to the (what now still is a) singleton class.

How can I change my setup, so that every user gets his own database, and that every RESTcall that user makes, is performed on that database. Users should be able to simultaneously use the web application.

Pieter-Jan
  • 1,675
  • 2
  • 19
  • 25

2 Answers2

0

It appears this is unpossible. I tried by mapping several instances in a multiton. Unfortunately, it appears that actions in one database are aborted when a request is made to do something in another database.

Pieter-Jan
  • 1,675
  • 2
  • 19
  • 25
0

You have to retrieve user informations from httpRequest.
How do I access the HTTP request?
Anyway The best way to bound a class instance to http session is to use statefull ejb BUT restful architecture is not designed to be stateful, in fact each rest request will occurs in his own http session.
Read https://community.jboss.org/thread/179777 for more information

Community
  • 1
  • 1
Gab
  • 7,869
  • 4
  • 37
  • 68