At the moment, we have multiple grails applications built on grails 2.5.0
Our Model is in a grails plugin (2.5.0), published to a local maven repository. So far everything works great.
Now we want to create a new application with Grails 3, which relies on some of the basic Domains located in a grails2 plugin (User, Group, etc).
What would be the best way, to share those ? I dont want to maintain two code-bases for our model, one for v2 and one for v3 ...
The only thing which came into my mind is, building everything in plain groovy Classes / Interfaces, and then extending / implementing the Model in both grails2 and grails3 plugins
core-model (contains Interfaces, abstract classes)
grails-model-v2
grails-model-v3
You're on the right track. The domain classes will probably work unchanged, but the problem is the grails plugin projects are incompatible. So you can use a plain groovy project to house your domains and then have each plugin depend on the domain project. The tricky part is telling grails that those plain groovy classes are domains. In grails 3 you can probably just apply the groovy traits that grails automatic applies to domains using doWithSpring(). I think grails 2 uses metaClass to accomplish the same thing, so the approach might be similar.
Related
I'm an owl/protege newbe with some grails experience.
I would like to transform my protege ontology file anyOntology.owl to grails domain classes. In the next step I would use grails generate-all command to obtain the respective controllers and views to obtain the executable model with CRUD functionality, which would be my executable ontology.
Is there already something like a protege-export or a grails-import as a plugin, or is someone already planning/working on such a feature?
Peter
in the meantime I developed a 0.1 Version for the above Problem and promoted it to
https://github.com/pstrotmann/ontology/tree/HEAD/owlToOO
It is a grails Application, that transforms an xxxx.owl file to grails Domain classes that can be transformed to a grails application by using the generate_all feature of grails thus obtaining a CRUD functionality.
In addition a graphViz input is generated from the xxxx.owl file that can be transformed by graphViz to an UML-Diagram.
in addition there is runnable version of owlToOO that can be accessed via
http://partnerontology.strotmann.org
with a generated Partner application
I have a Grails application with outsourced (in a separate Grails Plugin) domain objects and would like to use the domain objects in a Java application.
If this is possible, how to do that?
Thanks
In order to use them as domain classes, you need GORM-plugin to be installed somehow in your java code. Without the plugin the domain classes lose their "active record" aspect and can be used only as POJOs.
I can barely imagine how to do that w/o lot of pain
You need to define your custom hbm.xml hibernate mapping files. See hibernate doc
I'm trying to include Grails applications into a Liferay portlet. I tried the Grails Liferay Portlets Plugin but it did not work for me at all.
Does anybody know any other possibilities? Which do you think is the best and why?
We had our Grails project integrated with Liferay at one point but it was a mess. Inevitably we pulled it out of Liferay and we were able to use Grails properly again. In our instance the question became, why are we using Liferay and do we really need it?
Now if you have a requirement for Liferay you might try simply using Spring Portlet support and use parts of Grails you like but not fully integration. Spring Portlets with Groovy were much easier and cleaner to do. If you simply want Grails goodies for services etc. you can try deploying a Grails WAR on the same tomcat and expose services to your portlets through REST, Hessian, Burlap or some other easy service serialization mechanism in Spring/Grails. In this case you have a Liferay UI app that calls your Grails services.
Once again, try some options, then decide if you truly need (or have) to use Liferay. With advances in Javascript UI packages, I'm not sure 'portlet' spec apps are as appealing as they once were and the word 'portal' is something that sounds good to management but inevitably means little to what needs to be implemented.
I have already create a Grails application. For some reasons I need to create another console application for someone to modify database data.
Is it possible to package Grails application as a JAR library, so that the console application can reuse those domain classes?
Or, I add/create some classes in Grails application and package it as a JAR and run as console application?
If no better answer, probably I will use the batch-launcher plugin to do that.
You can put the domain classes in a JAR and tell Grails that these are your domain classes by adding a Hibernate XML file (in grails-app/conf/hibernate) that refers to the classes in this JAR. You can use this JAR in any other Java/Groovy application, but obviously they'll only have the persistence methods (dynamic finders, save(), etc.) when used in a Grails app.
I'm writing a Grails app which I'd like 3rd parties to augment at runtime. Ideally they would be able to add a JAR/WAR to the webapp directory which contains new domain, controller and service classes, new views, and other content.
Is there a simple way to do this within grails? Would it be simplest to create a startup script which copies the new classes etc. into the relevant directories and then updates grails.xml and web.xml?
You will be able to do this in version 2 of grails in which plugins will be also OSGI plugins http://jira.codehaus.org/browse/GRAILS/fixforversion/15421
It seems that the Grails plugins will actually fit quite well for this: http://www.grails.org/Understanding+Plugins
A plugin can do just about anything... One thing a plugin cannot do though is modify the web-app/WEB-INF/web.xml or web-app/WEB-INF/applicationContext.xml files. A plugin can participate in web.xml generation, but not modify the file or provide a replacement. A plugin can NEVER change the applicationContext.xml file, but can provide runtime bean definitions