The sample portlet calculates the sum of two numbers.
Figure 1: The Arquillian Sample Portlet calculates the sum of two numbers.
The portlet project comprises a portlet class, service classes, and JSPs. It
follows the standard OSGi module folder structure with Java files in
src/main/java/
, resource files in src/main/resources/META-INF/resources
, and
build files in the project root.
Here are the primary files:
-
SampleService.java
: Provides an interface that defines methodpublic long add(final int addend1, final int addend2)
for returning the sum of two numbers. -
SampleServiceImpl.java
: Uses OSGi Declarative Services to implement theSampleService
interface. -
SamplePortlet.java
: Extends LiferayMVCPortlet
and processes portlet action commands and renders the result of executing theadd
service. -
bnd.bnd
: Specifies the module’s name, symbolic name, and version. -
init.jsp
: Imports classes and tag libraries for the view layer. -
view.jsp
: Provides a form for calculating the sum of two numbers.
You’ll examine the tests next.