|
||||
Module DevelopmentThe 1060 NetKernel accesses resources in packages called modules. Every aspect of the system from Caches and Transports to Application Libraries and High-Level Applications is provided by modules. Before reading this step-by-step guide to developing a module we recommend you read the module guide which provides a comprehensive discussion of a module's architecture and how they interact with the Kernel and each other.
Note: In earlier NetKernel versions (2.0.x), modules were automatically discovered at runtime from a directory. For NetKernel 2.1.x, in order to provide fully managed installation
and removal of modules, modules are now registered in a module deployment document which by default is You can specify the module deployment document in the system.xml configuration file. Step by Step GuideThis guide shows how to create, register and configure a module by hand. Alternatively the new module wizard can also be used to create and automatically install a new module. Step1 - Create a xar development directoryBy default modules are located in the For example suppose we are creating a module for sprocket processing - we might want to call this
SprocketModule, we would therefore create a directory Register your Module
Starting with NetKernel 2.1.0 modules must be registered in the moduleDeployment.xml document. Add an entry to
<module>modules/SprocketModule/</module>
Step2 - Create a Module DefinitionA module is declared through a module definition resource. This is an XML file, module.xml, located in the root of the module.
In our example we should create a module definition <module>
<!--Identity--> <identity> <uri>urn:com:sprocketsrus:mod:sprocket</uri> <version>1.0</version> </identity> <!--Metadata--> <info> <name>Sprocket Module</name> <description>A module for processing sprockets</description> </info> <!--Publisher--> <publisher> <name>Sprockets-R-Us</name> <uri>http://www.sprocketsrus.com</uri> </publisher> <!--Licence--> <licence> <name>1060 Public License v1.0</name> <uri>http://www.1060research.com/license</uri> </licence> <!--Export--> <export /> <!--Rewrite Rules--> <rewrite /> <!--Mapping--> <mapping /> <!--Transports--> <transports /> <!--Cache--> <cache /> </module> Step3 - Create and Register an Internal Resource URI Address SpaceA module has a private internal URI address space. To create an internal address space we need to create some resources and register their address space.
Suppose we now create a subdirectory
Say we want all resources below com/sprocketsrus/myDir to be available in the internal address space. We do this
by providing a <this>
<match>ffcpl:/com/sprocketsrus/myDir/.*</match> </this>
This makes myDoc.xml internally accessible with the URI Step4 - Export a public URI Address SpaceIn order to be used by other modules your module must export a public URI address space. Suppose we want to expose a public interface ffcpl:/com/sprocketsrus/myDir/public/ , so that everything below public is externally accessible. We would do this with an entry in the export section of the module definition. <uri>
<match>ffcpl:/com/sprocketsrus/myDir/public/.*</match> </uri> Step5 - Create external to internal URI Rewrite RulesIt is useful to be able to map external requests to internal requests using rewrite rules. These are declared in the rewrite section. In our example let's suppose that a higher level module might issue a request for an idoc. Rather than serve the idoc as an xml document we want the request to execute the idoc in the DPML runtime. We need to rewrite the request so that it will result in a request to the DPML runtime accessor. This is accomplished with the following rule. <rule>
<match>(ffcpl:.*\.idoc.*)</match> <to>active:dpml+operand@$1</to> </rule> Step6 - Import Other Modules and Reference SuperIf your module requires resources from other modules they must be imported in the mapping section. Typically other modules may provide Java classes which your Accessors need, XML libraries, or application components. A module is imported by specifying an import declaration in the mapping section. The position in the list of mappings is significant and resources will be resolved in top down order. In our example let's imagine that we are developing a URA that uses the ext_layer1 and ext_xml_ura modules. Let's also import the the ext_dpml DPML runtime module so that we can execute idocs. Our mapping section now looks like this: <mapping>
<import> <uri>urn:org:ten60:netkernel:ext:dpml</uri> </import> <import> <uri>urn:org:ten60:netkernel:ext:xml:ura</uri> </import> <import> <uri>urn:org:ten60:netkernel:ext:layer1</uri> </import> <this> <match>ffcpl:/com/sprocketsrus/myDir/.*</match> </this> <super /> </mapping>
You'll notice we've ended the mapping section with a reference to Within this mapping element you can also register any accessors that are declared by this module. See the URA Registration Guide for details. Step7 - Develop awayThe module definition is sufficient for you to proceed with developing whatever you wish to complete your module. Create your idocs, classes and resources within your module. Items placed in the public sub-directory will be
externally accessible. For example if you create an idoc with the relative path Detecting development changesModules are auto-discovered but it is important to understand how changes and new resources are picked up.
Jar Libraries
If your module uses jar libraries these can also be auto discovered by the Kernel. Jars are discovered in the Transports and CacheletsYou may wish to configure your module to be the home for a transport. Transports are declared in the transports section of the module definition file. In general transports need only be added to a fulcrum module. A module can declare that it requires a specific cache implementation. The cache for a module is declared in the cache section of the module definition. The backend module definition gives an example of specifying both a transport and a cachelet. Step8 - PackageOnce you are happy with a module you can package it up into a Deployment
A packaged module is installed by registering it in the module deployment file
The Kernel will interogate your module's
|
||||
|
© 2003,2004, 1060® Research Limited
1060 registered trademark, NetKernel trademark of 1060 Research Limited
|
||||