Over a million developers have joined DZone.

SOA and REST with Grails

DZone's Guide to

SOA and REST with Grails

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

In my previous articles I’ve introduced REST and how to leverage RESTful web services on the Grails platform. We will further discuss Grails in a service-oriented architecture using RESTful services, and we will try to visualize the architecture in detail.

SOA is a useful architectual pattern that makes highly interoperable applications.  According to Thomas Erl, “SOA is a term that represents a model in which automation logic is decomposed into smaller, distinct units of logic. Collectively, these units comprise a larger piece of business automation logic. Individually these units can be distributes.”

SOA and RESTfu1 are architectural considerations that exist independently from the specific technologies you use, like Java or SQL vs. NoSQL databases. It represents how data communicates between application components, and it determines the guidelines that need to be followed during data transfers between distributed systems.  This allows a high level of interoperability if the SOA is built properly.

RESTful web services in conjunction with SOAP can add REST’s simplicity, flexibility, and low overhead without compromising the power or manageability of service-oriented solutions and architectures.

Without debating whether REST or SOAP is better, I would like discuss how we harness both using the Grails application framework

The clickable diagram below depicts an example of SOA and REST using Grails:



Components: A component is an encapsulated, independent part of the system’s build based on OO software principles. It will be accessed by the service layer using well-defined interfaces. Service components could be POJO-based Grails Domain, Grails plug-ins or plain Groovy or Java components.

Composites Services
: A composite service uses individually developed components and wires them together to create highly reusable, flexible and extensible business services that can be exposed and consumed by distributed systems. This is one level above the Components layer and can be made from Groovy, Java or Grails-defined services. Spring’s dependency injection pattern will be leveraged to access these components.

Service Resources
: This layer contains all the business services used by resource services in the form of GET, POST, PUT and DELETE. Service Resource Services are lightweight, stateless and independent services that communicate with a consumer via HTTP(S) protocols over various data formats such as XML, JSON, MIME, Byte etc. Service resources access business processes or composite services and expose them with HTTP(S) protocols.

Business Processes
: A business process is an abstract specification of business-aligned IT functions and used by resource services or a distributed system. Business processes orchestrate business composite services that perform well-defined business functions. These processes depend on the services layer to provide the building blocks for necessary functionality. Grails provides automated dependency injection through Spring core DI for Groovy, Java and Grails Services.

Integration (Enterprise Service Bus): The ESB layer provides a mechanism to expose the SOA’s services. The resource services are exposed using RESTful or SOAP-based web services and business processes. It may also provide message transformation, routing decisions, and protocol conversion capabilities.

Quality of Services: This layer provides services that enable infrastructure services for the solution and ease runtime environment management and monitoring.

Grails does an excellent job of helping developers use SOA and REST to deliver scalable, interoperable solutions in enterprise environments.

•   http://www.soapatterns.org/
•   Service-Oriented Architecture (SOA): Concepts, Technology, and Design by Thomas Erl
•   http://www.ibm.com/developerworks/webservices/library/ws-soa-ref-arch/

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.


Published at DZone with permission of Nitin Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}