To create a new extension:
- Optionally: Modify default values
for the extension generation process.
- Create a new extension.
- Reference the new extension in
the localextensions.xml file.
- Rebuild the hybris Commerce
Suite.
- Update the hybris Commerce Suite.
Afterwards, you can start
implementing your business logic in the new extension.
The hybris Commerce Suite comes
with an extension generator system called extgen located in
the ${HYBRIS_BIN_DIR} /platform/extgen/ directory.
Using extgen, you can create new extensions based on extension
templates.
Creating a New Extension:
Step 1: Optional: Setting
Default Values for New Extensions
You can personalize extgen default
behavior by modifying the project.properties file located in ${HYBRIS_BIN_DIR} /platform/extgen. Extgen
then uses your settings as the default to generate the extension.
Modifying the default values is only necessary for advanced settings. Extgen prompts you to provide the basic values during the extension generation process.
Step 2: Copy an Extension Template
Using Extgen
An extension template is
a predefined basic extension to be duplicated. The copy serves as a starting
point for creating a new extension, typically used for a customer specific
implementations.
- Open a
command prompt.
- Navigate to
the ${HYBRIS_BIN_DIR} /platform directory.
- Run
the ${HYBRIS_BIN_DIR} /platform/setantenv.bat file.
Do not close the command prompt as the settings are transient and are lost
if the command prompt is closed.
- Run ant
extgen in ${HYBRIS_BIN_DIR} /platform directory.
This internally runs ant in the extgen directory.
project.properties
file in the extgen
directory.Extgen prompts you to
specify:
- The extension's name.
- The extension's Java package.
- The extension template to use.
After you have provided
the prompted values, extgen:
- Copies the
extension template to a temporary directory.
- Modifies the
extension template to reflect the specified values.
- Copies the
new extension from the temporary directory to the directory specified by
the extgen.extension.path property in the project.properties file.
After the copy process
is completed, the extension is ready to be referenced in the localextensions.xml.
Step 3: Reference the New
Extension in localextensions.xml File
To make sure that an
extension is integrated into the build framework, you need to reference the
extension
in the localextensions.xml file.
Please note that by default this file only contains references to folders
from which it loads all
extensions:
localextensions.xml |
<path autoload="true" dir="${HYBRIS_BIN_DIR}/ext-platform"/> <path autoload="true" dir="${HYBRIS_BIN_DIR}/ext-cockpit"/> <path dir="${HYBRIS_BIN_DIR}"/> |
Hence, if you want to
add a new extension, myextension, add this line
to localextensions.xml:
localextensions.xml |
<extension
name="myextension"/> |
Step 4: Rebuild the hybris Commerce Suite
- Open a command prompt.
- Navigate to the ${HYBRIS_BIN_DIR}/platform directory.
- Make sure that a compliant version is
used:
- On the Windows operating system, call
the ${HYBRIS_BIN_DIR}/platform/setantenv.bat file.
Do not close the command prompt after this call as the settings are
transient and would get lost if the command prompt is closed.
- On the Unix operating system, call
the ${HYBRIS_BIN_DIR}/platform/setantenv.sh file,
such as: . ./setantenv.sh.
- Call ant clean all to
build the entire hybris Commerce Suite
An extension is
configured by the extensioninfo.xml file. It defines the
contained extension modules
and list of extensions
that the current extension depends on.
To define properties of
the extension, use the local.properties file.