views:

62

answers:

2

Hi,

We have a Java/Spring/Hibernate codebase which is the core to our pretty large platform. We also have quite a few separate Java webapps (Struts or Spring MVC) running alongside which reference the core system, pulling in the applicationContext and services from it.

We have a requirement to build another webapp that also references the same core system, so I was hoping to do this with Grails. From what I've found it appears you can easily jar up legacy Java code, place it in your Grails project lib directory and reference it that way.

http://www.itexto.net/devkico/?p=333

Unfortunately this will not work for me as I need to reference the running core system and its services from my Grails app, as you would reference a Java app from another Java app. Is there any way to do this or is it just not possible with Grails?

Any information would really help...

Thanks,

Justin.

+1  A: 

See documentation on Grails+Spring integration. When you have gotten Spring working inside Grails, next steps should already be standard Spring.

As you have not detailed, how your existing Struts and Spring MVC applications "pull in applicationContext and services" I cannot comment on the details. However, it should be similar to the way your existing applications do it.

EDIT: check also answers to this question on how to organize your Spring beans.

Neeme Praks
I understand how Grails can reference other Spring AppContexts which are then loaded into the Grails project, but I don't want to create and run the core AppContext within the Grails project. It really is very large and complex and needs to run externally.
Justin
As I wrote in my answer, it is impossible to help you with the question of "how to interface with external application context" if you do not provide details on how your existing applications interface with that same application context. Based on the current information, I can only say "to it the same way as your existing applications are doing it". Your comment about "Eclipse build path" only affects the build-time aspect. At the same time, the "it is very large and complex and needs to run externally" deals with the runtime aspect - the comment about Eclipse is not relevant at runtime.
Neeme Praks
+1  A: 

I would look into building a Service Layer on top of your Spring services/beans. This is a pattern documented in Martin Fowler's Patterns of Enterprise Application Architecture book. Essentially you want a thin layer that wraps your Spring services (your business logic) that can be called by a web service or a remote call of some sort from your web-apps. This will allow you to host your applications in different processes but still be able to communicate between them without trying to hack everything into the same web container and figure out how to reference the same running processes.

Javid Jamae