Comaprison of Liferay ServiceBuilder to other Code generation tools like AndroMDA

1.5k views Asked by At

I started digging into the liferay 6.x ServiceBuilder framework and really liked its code generation approach. A simple service.xml file can generate ready to use powerful services without even writing a single line of code.

I also tried looking into AndroMDA which can generate similar services from the UML model, which sounds even more interesting since it will link my business model directly without me needing to learn a new xml config for service.xml (in case of liferay ServiceBuilder)

now I am in the process of deciding which tool should I use. Based on your experience with any of these tools Please let me know what are Pros/Cons of using any of this library,

I am interested to know these aspects, along with your own thoughts

  1. Which is better to keep my development more productive in long term.
  2. If I use ServiceBuilder will I be able to use the services outside portal env (lets say running same service from a non-portal app server.
  3. Is UML driven approach always good or there are some practical cons/challenges of it.
  4. Do you know of any other code generation library which is better than these two for liferay 6.x development? I also checked these SO Threads

2

There are 2 answers

0
lisak On

There is an important fact that you should be aware of. ServiceBuilder has been used to help building the portal itself and it is tightly integrated into it. You cannot use it outside of Liferay...I mean it probably could be taken and modified for general usage, but I doubt it would make sense.

Most importantly because Portal and each plugin that you are developing have their own web application context in a servlet container - each has its own classloader. Plugins are using Portal classloader and portal services, etc. etc.

Simply put, ServiceBuilder generated code and spring context can exist only if there is a webapp/ROOT/ which is Liferay Portal with portal classloader etc.

AndroMDA is a MDA framework for general usage. I don't know it much, so that I'm rather not going to make comparisons. The power of ServiceBuilder is that it is not a framework for general usage - the more powerful it is for liferay plugin development.

2
Ganesh Gembali On

Following few problems I have experienced with Servicebuilder (I am using liferay 5.2.3) :

  1. Not able to make use ORM framework. There is no way to generate relations among objects. Because of this I am effectively working just object mapper. It is not generating onetomany kind of relations
  2. Can not use basic object oriented things like inheritance with domain or services
  3. It is quite hard to write unit test cases
  4. I still didn't understand what is the need of complex domain structure
  5. I feel the code it is generating can be quickly written using an IDE

But definitely it has its own benefits like Egar said, it is specifically made for Liferay. So it can quickly generate everything that is needed for liferay. I heard in latest versions of liferay few of above problems are fixed.

Overall it depends on your requirement. If you need more control over your ORM layer and you have complex business logic which needs quite a lot of unit testing, go for normal spring services which can be exposed as webservices or REST services to your portlets.

Otherwise service builder is also good for simple portlets. Other approach could be using both. All complex services as a separate project and simple ones with service builder.