Announcement: You can find the guides for Commerce 7.5 and later on the new Elastic Path Documentation site. This Developer Center contains the guides for Commerce 6.13.0 through 7.4.1.Visit new site

This version of Elastic Path Commerce is no longer supported or maintained. To upgrade to the latest version, contact your Elastic Path representative.

Tutorial 1 - Hello World

Tutorial 1 - Hello World

Introduction

In this tutorial, you will learn how to run an extension resource and use REST to interact with the resource. We will also take a closer look at the different components that make up a resource to see how the resource works to output "Hello World".

Warning: Before you begin

Make sure your development environment has been properly set up as described in Setting up your Developer Environment.

Begin: Installing Cortex API Tutorials

Source files

The files created in this tutorial are found in the tutorials zip under /Rest-Tutorials/rest-resource-helloworld directory.

Both the resource created in this tutorial and rest-resource-helloworld have the following directory structure:

permission.properties

permission.properties defines the resource's default role permissions. For more information on roles and permissions, see Cortex API Authorization: Roles and Permissions

applicationContext-helloworld-resource.xml

The Spring configuration file for the resource.

helloworld-blueprint.xml

The OSGi bundle configuration file for the resource.

HelloWorldResourceRels.java

HelloWorldResourceRels.java is the resource's properties file.

HelloWorldMutator.java

HelloWorldMutator.java is the resource's mutator. It sets values to the resource's representation.

HelloWorldResourceOperatorImpl.java

HelloWorldResourceOperatorImpl.java is the resource's operator implementation. The operator is what processes requests to this resource.

HelloWorldRepresentation.java

HelloWorldRepresentation.java is the resource's representation. The representation is what the resource outputs to the kernel.

springCtx-import.xml

springCtx-import.xml imports the applicationContext-resource-server.xml file into Spring.

target

The target directory is created when the Maven package goal is executed. It contains the extension resource's JAR file.

test

The test directory is where you would place your unit test java code. It follows the same structure as the main directory.