Search code examples
javaweb-servicesejbjndi

Legacy app made accesible in the same server or via ws


In our system we have a legacy standalone java application which we are trying to made available for new webapps we are developing all together running in a server (f.e. Tomcat) In order to made requests to this app lighter we thought about made them directly to the same vm using jndi instead of developing a webservice interface.

I would like to start this application environment in some webapp context and make some API available to other webapps and invoke interfaces' methods.

I've not been able to bind this objects by JNDI in the Tomcat's read-only Context without adding the app in the Common lib, when I get more problems due to incompatibilities between dependencies versions. Maybe the best solution is to deploy these interfaces as EJBs so I'd use a Java EE Server instead of a servlet container. Or maybe I'd use some other framework such as Camel or something.

Thanks in advance and any suggestion will be helpful.


Solution

  • I would suggest to wrap your legacy java interfaces in REST. When you expose them as REST APIs, they will become available for any client, not only java. Also you don't need any Application Servers for that, all you need is a jar file for your REST reference implementation.

    From performance perspective, well, I know theoretically JNDI should be faster, but in the real world the difference in performance becomes significant ONLY for very very performance intensive applications.

    However, if performance is your primary requirement then wrap your legacy interfaces in EJBs.

    Manual JNDI/RMI lookups are going to be the fastest, BUT and this is a rather big but, unless you are well experienced in network programming and multi threading, I would advise you to steer clear of that, and use a container. There are a lot of nitty gritty details that the container takes care of and you can concentrate on implementing your business logic.