The process for expanding Cortex API capabilities is to create a new resource and add it to the resource layer or create a resource integration and add that to the integration layer. Even if you want to expand the functionality of an existing resource, you still create a new resource to do this. For more on why we expand the API by creating new resources instead of modifying the existing ones, see Cortex API Fundamentals.
Cortex API's resource layer is built on an OSGi Framework, where each resource in the layer is a single OSGi bundle. The framework's flexibility allows new resource bundles to be added to Cortex API without requiring extensive customizations to wire in the new resource.
Elastic Path provides a Maven Archetype to simplify the programmer's job for customizing Cortex API.
The best place to the learn how to properly customize Cortex API is to start with these tutorials:
- Tutorial 1 - HelloWorld - Creates a new resource that outputs "Hello World".
- Tutorial 2 - ExtensionProfile - Creates a new resource with a linking strategy that attaches a ProfileID to the profiles resource. When a customer's profile is retrieved, the returned JSON object contains the customer's standard profile data and the customer's ProfileID.
- Tutorial 3 - CoreLookup - Creates an email subresource with a LookUp that retrieves a customer's email address from the Elastic Path core. The email resource is accessed through the profiles resource, so it is considered a subresource.
- Tutorial 4 - StopCondition - Creates a resource that adds a need info link to the purchases resource. The needinfo stops the order from being completed until the customer agrees to some terms and conditions. Once the customer agrees, needinfo link disappears and the purchase can be completed.
- Tutorial 5 - Creating a Resource Integration - Explains how to create a resource integration and swap it with another resource integration. The tutorial swaps out the existing assets resource integration and replaces it with the one you code in this tutorial
- Tutorial 6 - Adding third party jars to Cortex API - Explains how to add third party jars as OSGi dependencies to Cortex API.
- Tutorial 7 - Integrating Cortex API with an alternate Identity Management System - Explains an overview of how you could swap out the out-of-the-box identity management integration resource and integrate a custom one.
- Tutorial 8 - Cortex API Implementation Patterns - Explains some of the common Cortex API implementation patterns for building/customizing your Cortex API. Understanding these patterns can help you get quickly started building out solutions.
Make sure your development environment has been properly set up as described in Setting up your Developer Environment.
The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Elastic Path does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Elastic Path shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.