Thursday, April 30, 2009

Liferay - SOA in Three Steps

The Liferay portal comes packaged with a powerful tool known as ServiceBuilder to helps developers quickly implement a Service-Oriented Architecture (SOA). Most technologies needed for SOA (Web Services, Spring, Hibernate, etc.) require a tremendous amount of files to be written and configured. For any developer, this can quickly become tedious and nurture an environment of copy-and-paste purgatory.

Liferay's ServiceBuilder automates most of this so that you, the developer, can focus your energy on your project's business logic. It only takes three steps to implement a powerful SOA in Liferay.

1. Define a Data Model

All you need to do is write an XML file called service.xml, based on a DTD provided by Liferay. The file should specify all necessary fields, keys and finder methods. Run ServiceBuilder using Ant, and you are done!

Over a dozen files were generated for you for each table you specified. This includes the following types of files:

  • Spring configuration files and Stubbed Remote/Local service classes
  • SOAP and Tunnel classes; WSDL files and Javascript Web Services methods
  • Data Model classes
  • Hibernate classes and configuration files
  • SQL create and index scripts

2. Declare Business Methods

Empty Remote and Local service classes have been stubbed out for your by ServiceBuilder. All you have to do is declare the methods you want and run the ServiceBuilder task in Ant again, and you are done!

Any business methods declared in the Remote service classes will be propagated into the SOAP and Tunnel classes, WSDL files and added into the list of Javascript Web Services methods. Like the definition of the data model, any subsequent changes should be followed by a run of the ServiceBuilder and the methods will be appropriately propagated.

3. Implement Business Logic

Like any other J2EE application, the Remote implementation class should do any security and permission checks that you may need; the Local implementation class should contain the business logic that you allow trusted sources to invoke. After you are done, compile your code and you now have a SOA!

Liferay's ServiceBuilder has created all the necessary files you need for a Service-Oriented Architecture. Rather than hours and hours of tedious copy and pasting, the ServiceBuilder automates all of this in a matter of seconds. You can now spend all that time saved on the place where your expertise should be focused: on the business logic.

1 comment:

  1. If you want publish service classes (SOA), then go for "Remote implementation class"

    example :
    &lt entity name="BookmarksEntry" local-service="true" remote-service="true" &gt

    remote-service="true" generates necessary WSDL files

    ReplyDelete