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.