How to Create a Service

Viewpoint
Teradata Viewpoint is Teradata's strategic and innovative SOV (single operational view) for Teradata DB, Aster, and HDP Hadoop systems management and monitoring that enables Teradata's Unified Data Architecture (UDA).
Teradata Employee

How to Create a Service

The following article gives you a summary on how to implement the service layer in your portlet.

An MVC application typically contains:

  • Models to hold data
  • Views to render the data
  • Controllers to respond to browser requests

For ease of maintenance, you want your implementations of these classes to be as lean as possible. So where do you put your business logic?

Your business logic should live in the service layer. This layer implements the Business Delegate pattern. When your controller needs to fetch data to be displayed, it should do so by calling a method in your service interface. This shields your controller from any future changes in how that data is collected. The service should only be called from the controller, not from a model or view.

When you create a portlet project with the Portlet Generator a skeleton of the service is created and wired into your controllers via the spring configuration files. In the service directory you will find the service interface and a subdirectory named Impl. In this subdirectory is the actual service class. In your java source code, the service is usually referred to as the manager.

Tags (3)