Using an existing GORM data model in standalone Java app - java

I have an existing Grails app and a separate, existing Java app. I would like the Java app to access the same database schema as the Grails app. Is there a way I can rip out the domain classes and GORM dependencies from the Grails app into a library that the Java app can access?
I'd also be happy to hear alternative approaches that would be less work than rewriting my DAO layer in the Java app.

This isn't supported and may or may not work. See
http://www.grails.org/GORM+-+StandAlone+Gorm
You could always use pure Hibernate from your Java app and create the Hibernate model by reverse engineering your existing Grails database scghema.

Here's another workaround:
http://burtbeckwith.com/blog/?p=72

You could use web services and call into grails service classes from the Java app.

Related

Can I use the Room Persistence Library for Java desktop applications?

Is it possible to use the Room Persistence Library from Google's Android Architecture Components in a java desktop application or in other words – as I haven't found anything on that – which things needed to be done and how complicated would that be?
No, you can't. When creating a Room database, you need to supply an android Context, but that does not exist outside of android projects. I would suggest trying an ORM like exposed or ktorm instead

Using Grails to build web UI for Java-based business objects?

I am working on a project where the business object model and their persistence are already defined and implemented in Java (with JPA), my task is to develop a Web UI on top of them. The UI will be customized for the business operations, so it is not simple CRUD. Another goal is to build a set of REST API for external clients to access these business objects.
My question is, is Grails a good framework to use for my situation? Can I use Grails to wrap around my existing business object model instead of handling the persistence by itself? How easy it is for Grails to build highly customized UI (instead of straight CRUD UI that it generates for you automatically)? I suppose it should be really easy to build a REST API layer with Grails, is that correct?
Thanks for any feedback,
Yu
The short answer is Yes.
The reason why the answer is Yes, is because Grails is a framework. Just because Grails has Hibernate and GORM and uses Domain classes defined in Groovy doesn't mean your application has to. Have JPA backed objects? Great. Wire up some services (Since Grails is a Spring application you can do JPA through Spring) and make use of that.
Same with the UI. You don't have to use scaffolding. Plenty of Grails applications have very customized UIs that have nothing to do with scaffolding.
Grails offers you lots of tools for building REST APIs, they may fit your needs.
Take a good look through the Grails documentation and you will see it covers all layers of a modern web application. I know it's a lot of information to take in but there is a lot of details along the way in each layer that explains your options. That's the key. You always have options with Grails. This could be anything from a new view rendering engine to some Spring project or feature to one of the many Grails plugins. Take the time and do some research and I think you will find Grails is a very flexible option to consider.
The key take away is that Grails is a framework. Powered by Spring and Java. You can use all of the framework or some of it. You can use Groovy or Java. You can use Spring. The entire Java ecosystem is available to you. All in, Grails.
So, Yes.

Is it possible to use Enterprise Java Beans in a django project?

I've seen that it is possible to run the django web framework on a GlassFish application server. Is it also possible to use a simple Enterprise Java Bean in a django project which runs on the basis of Jython? My idea is to have a django website for the frontend and Java EE in the backend (to manage the database access, etc.). Does anyone have experience with that?
A possibly easier variant would be to expose the EJB functionality using REST or possibly SOAP to get around interface problems between jython and java rather than do the call directly.

Architecture to develop an application in java that could be used with desktop and web interface too

I'm developing a java application or service for execute remote commands or another applications and receive the results of these commands. And I think about to project this application to be possible his use with a swing interface or a web interface.
I have to take care with the parameters to pass for my businnes classes and how I will deal with the results. I need to use a architecture and project that let me able to use my classes with a desktop application or web application too.
I believe this is related with API and service design. Some popular applications have a web interface or dashboard for control services, and the services are manageable by agents installed for execute some demons, services or applications. To do start or stop commands for database systems, directory services an other tasks
There are some guides to how develop applications and services in java that can I use with web and desktop environments?
I felling a bite confusing about this, because in my mind if I choose to develop this with a swing approach all the thinks turn clear for me. But when I imagining the same project using the web perspective I lose my directives.
Sorry and Ihope that someone could undertand me. :-P
Consider spring and MVC architecture. Neither of them is constrained to Web development only, however they are extensively used as such.
You might look into Naked Objects ,where you develop a domain object model and gets the UI more or less for free (You can get a desktop GUI, and various forms of web UIs). This is probably not a feasible approach if you're developing a public facing application, but more suited towards applications developed for expert users.
I have been in a similar situation recently while I started working on a simple CMS. I wanted my cms engine to be free of what UI/client is used to interact with it and finally I settled for a Web Service oriented approach. As a student of RESTful WS/ROA I usually like to take that approach.
If I understand your problem correctly, I would design it to be, each external program, service, web service I want to provide remote access to would be a 'Application' to my web service, where 'Application' would be a 'Resource'. Performing actions on the 'Application' resource would mean executing GET requests with different query parameters. How the 'Application' infers would depend on the 'Application' resource.
A similar approach I took in the CMS engine is for generating representations for a content. I support Ruby (JRuby), Groovy, JavaScript (Rhino) and Velocity template for generating representation. User creates the template script as a resource and refers then in the content type definition. Clients are provided URI's to the representation from the content generic media formats (Atom XML, JSON) and upon fetching them receives the output generated by the script. I am tempted to take a similar approach for your problem. It would not only separated the UI from the business objects, but also provide flexibility to add new backend services in the long run.
As tools for RESTful WS over Java I would recommend, Jersey, Abdera, Jackson. As an example for how use them together you can have a look at the CMS project I was referring to.
Hi i would suggest you to build your system with a modular approach such that
you have all your business logic is exposed as a service which can be accessed by REST,
in addition create you can have web application layer and a desktop layer.
schemantically it will look like be at a higher level
weblayer/desktop---------{REST interface} ------- {business logic}-----EIS
and for modularisation you can consider OSGI
hope this helps

Web services creation and consumption

I'd like to learn how to create a java web service that can be consumed by a web tier, which is constituted of java and flex.
What books can help me learn how to create a java web service and consume it via java & flex?
Should I look to build a web service from scratch or from frameworks like: XFire, Axis, CXF, Spring Web Services, etc.?
If using a framework is recommended, which of the above or any others makes the most sense to learn/use?
EDIT:
Both the java AND flex components of the web tier need to independently access the web service. For example, the flex component helps the user create & save a spreadsheet; the java component retrieves the spreadsheet data and displays it accordingly.
Flex should do the job: Web Services with Flex tutorial
You may not need a web service. Your Flex app can consume Java POJOs directly using Spring and BlazeDS.
What kind of a service are we looking at? If it requires database integration you probably need at least some kind of a framework - you really don't want to be putting your SQL queries hard coded into the app. Spring + Hibernate seems to be one of the most popular choices for a Java server implementation, but both of them are quite massive and require some effort. Appfuse could be something that provides a good starting point for building a service.
Why do you want to do your service with Java anyway? Is this because you know only Java or because there is a Java container already running on your server? I've seen great results with Ruby on Rails too and now there's some buzz about Scala too in the Java world. This could be your chance to try out something new and more flexible ;)
I'll take this opportunity to plug my own book, Eclipse Web Tools Platform: Developing Java Web Applications. Chapter 10 deals exclusively with creating Java Web services. Although the examples are all shown using WTP tooling the lessons discuss Java Web services created with Apache Axis.

Categories