S
S
synapse_people2016-03-22 22:06:21
Java
synapse_people, 2016-03-22 22:06:21

How to get context in Spring service?

How can I get the context in the service?
There is a service that allows everyone to register. and get your partner. Each affiliate program has its own domain..
What is the best way to implement their separation? That is, to have 1 affiliate web app and create a virtual host for each affiliate, passing the affiliate ID with environment variables OR launch 1 context FOR ALL, and then get the affiliate by the header Host by interceptors?
For example, a Web App with a servlet on / hangs on partner/, nginx then proxies all requests to this address.
The Handler Interceptor receives the Host and adds an affiliate entity attribute to the request.
In this case, this entity or affiliate ID must be passed to each service as the first argument.
For example, UserService::userExists(int ppId, String login);
Is it possible to somehow call UserService.userExists(login) and get the affiliate context inside the service?
How would it be correct to pass the essence of the affiliate program to the service or ID, or so that the service knows which affiliate program it is:?
There is another option, for each affiliate program to create its own database, and not how to use the `program_id` column now. But then the question of database data duplication arises if the affiliate is on a different server ..
In general, you can make service interfaces in the context of affiliates and call them on the main server through Hessian, but how will the main server understand which affiliate is requesting data?...
In general, porridge ... Help with advice

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question