3

I am having Grails GORM based application.One web service and one website both are running on different port and sharing common database and tables.
What i have done is created domain class for both application which are having same fields and domain class name.For example Registration table having userName and password fields.One can register through web service and also from website.
My current applications is working fine...but is it a feasible solution..?

Thanks,
Viral

  • Why do you want to do this? If they have the same fields and same functions isn't aren't they a copies? – marko Mar 24 '12 at 11:04

2 Answers2

3

You could run into race/locking conditions but I've seen this done on many occasions. My only suggestion is that you not maintain separate domain classes. Put common domain classes in a plugin and install said plugin in both applications.

Another common approach I've seen that mimics your approach is deploying a customer facing app separate from the admin/cms. Both talk to the same database, they're just running in different tomcat instances.

Gregg
  • 34,973
  • 19
  • 109
  • 214
  • Just a note that deploying separate apps to cloundfoundry is challenging. http://stackoverflow.com/questions/8684429/how-to-deploy-a-modular-multi-app-system-to-cloundfoundry – Brad Rhoads Mar 24 '12 at 19:42
  • @BradRhoads deploying a single app to cloudfoundry is challenging – Dónal Mar 26 '12 at 08:58
  • @Gregg thanks, but for first option of your solution to make plugin in that, should i configure my datasource.groovy at my application or at my plugin..? – Viral Thakkar Mar 28 '12 at 14:13
0

You can create a separate Gradle application which use GORM depenancy which only contains common domain classes. Create those classes (POJO) into src/main/groovy/bla/xyz, annotate them with

grails.gorm.annotation.Entity

This will make GORM identify your POJO as domain classes.

Build this application, publish it and use that as your dependancy into your other Grails application.

Before going all out, do try this with one single POJO class. Publish it into your local m2 repo and use it as dependancy into your grails application, check it out.

Hope this will help

Milan
  • 21
  • 1
  • 4