0

Because of some stupidity in a client library I am using I think the only solution would be to implement a singleton that is global across all wars. What is the quickest possibility? Will I need to fiddle with the classloader? Is JNDI the best solution? I will need to implement it in such a way that it also works locally too (i.e. also works in tests) so would rather stay away from container apis like jndi.

dashambles
  • 529
  • 8
  • 22
  • Can you not wrap a REST service or something around the client and just deploy that as a separate war? That way you'll ensure a singleton. – horatius Jan 15 '16 at 18:14
  • Not an option unfortunately. The object instance I want from the singleton is basically a wrapper around an object from a lib that is somehow also process global. – dashambles Jan 15 '16 at 18:17
  • Does the library object contains only data or has behavior that forces you to have only one copy active at any time? If it contains only data, then, you can use a cache and put the object in external cache or JNDI. If its the behavior of the object, then, wrapping the object around a webservice seems like a good idea. It could even be as simple as a servlet that you can POST to to simulate method calls. Remember servlet is singleton. – Wand Maker Jan 15 '16 at 18:26
  • 1
    I think the (now deleted) answer of @spa which recommends to place the singleton code in tomcat/lib is the easiest solution. Don't know who downvoted the answer – wero Jan 15 '16 at 18:32
  • It wasn't me (that deleted the answer).. not sure how anyway. Yes I think the other answer, answers the question. Thanks to all. – dashambles Jan 15 '16 at 21:02

0 Answers0