Configuring and Deploying a Custom Module
After you create or download a custom module, you can deploy it to your server so that app services can use it when processing request and response data.
To deploy a custom module:
These steps are described in detail below.
Compiling your custom module
If your module is a single class, you only need to compile it into a *.class file. In Eclipse, for example, the IDE creates a class file in your workspace every time you save your project.
If your module uses multiple classes, or a class and additional resources, then you can create a JAR file that includes those classes and resources.
Add the module to your Akula project
After compiling your custom module, you must add the module to your AKZ file. This section describes the changes you must make to your Akula project to include your new custom module.
Add the module to your AKZ file
You must add the module's class or JAR file to your AKZ file so that your app scope can use it.
To add the module to your AKZ file:
- Find the source files in a directory that you created.
- Depending on the type of file that your module is in (standalone class or JAR file):
For a *.class file:
- Create a
project_root/AKZ-INF/classesdirectory in your Akula project if there is not already one.
- Create a set of sub-directories that match the package name of the class. For example, if your class is in the com.example.mymodules package, create the following structure under the
- Copy the *.class file into the directory you just created. For example, copy it to the
- Create a
project_root/AKZ-INF/libdirectory in your Akula project, if one does not already exist.
- Copy the JAR file into the
- Create a
Map the class to a prefix
You must map a prefix to the custom module's class name so that the Akula Server can find the class when it encounters the module in a route. You do this by creating a prefix mapping file.
To map the module's class name to a prefix:
- Create the moduleschemes.xml file in the
project_root/AKZ-INF/config/scopedirectory of your Akula project.
- Open the moduleschemes.xml file and add
<custom-modules>as the root tag.
Add a new
<module>child tag for each of your custom modules, with the following attributes:
The fully-qualified class name of the new component. For example,
com.verivo.module.MyCustomModule. If the module is not in a package, then just the module name is sufficient.
The prefix to reference the component with in the route configuration file. For example,
Set this value to false. If it is not set, it defaults to false.
The following example shows a new prefix mapping:
You can add any number of
<module>child tags to your prefix mapping file.
Use the module in a route
To use a module with your app scope, you add it to one or more routes in your Akula project.
To use a module in a route in your app scope:
- Open the route configuration file.
- Add a new
Define the new route by setting the value of the
uriproperty in the
<to>tag. To do this, use the following sytax:
<to uri="prefix://directive" />
prefixis the value of the
<prefix>element in the prefix mapping file. For more information, see Map the class to a prefix.
directive is an optional instruction to pass to the custom module. Unless you instruct your module to handle directives, this is just used as a placeholder. For more information, see Getting the Module Directive.
The following example shows a route configuration file with a new route that references a custom module:
You can optionally pass parameters to the module by using route properties. The following example passes the name parameter with the value "nick danger":
Values that you pass in must be URL encoded. For example, replace an ampersand (&) with %26.
For information about using parameters within the module, see Initializing a Custom Module.
Deploy the new AKZ file
After adding your custom module to your Akula project, you can re-archive and re-deploy the AKZ file.
To deploy your new AKZ file:
- Re-archive your AKZ file with the Java
jarutility. For example:
jar cfM HelloWorld.akz *
Re-deploy your AKZ file to the Akula Server by copying it to the
- Restart your app server.
For more information about deploying AKZ files, see Building and Deploying AKZ Files.