Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

To create and commit a DTK plugin: 

  1. Create the different Java files required for the type of plugin you want to create. See the chapters describing each plugin for further information.

  2. Compile all the Java files for your plugin into classes:

    Code Block
    > javac -classpath $CLASSPATH com/mycompany/myagent/*.java
Note

Caution!
Do not use the default package context in the Java code. All classes in MediationZone must have unique names.

  1. Create a user-defined *.jar file containing the classes, see https://infozone.atlassian.net/wiki/spaces/MD92/pages/111782614/Creating+a+DTK+Plugin#Creating-a-User-Defined-Jar below.

  2. Create a user-defined *.mzp package containing the *.jar file, see https://infozone.atlassian.net/wiki/spaces/MD92/pages/111782614/Creating+a+DTK+Plugin#Creating-a-User-Defined-Package below.

  3. Commit your user-defined package, see https://infozone.atlassian.net/wiki/spaces/MD92/pages/111782614/Creating+a+DTK+Plugin#Committing-a-User-Defined-Package below.

Creating a User-Defined Jar

To create a *.jar file containing the classes, use the following command syntax:

Code Block
> jar cvf my_agent.jar com/mycompany/myagent/*.class

It is also possible to add resources to a jar file, just append any resource name to your "jar create" command. This allows you to, for instance, add images that your class depends on to the jar:

Code Block
> jar cvf my_agent.jar com/mycompany/myagent/*.class com/mycompany/myagent/myagent_icon.svg

Creating a User-Defined Package

To insert the *.jar file into MediationZone, a package containing the jar file must first be created. A package gives the *.jar file a name and a version. The mzsh pcreate command creates a code package used for composing packages (.mzp) to create additional functionality and updates. The name and version will be visible in the About window once the new package has been committed into the system.

A package is created using the pcreate command in the mzsh Command Line Tool:

Code Block
usage: pcreate <name> <version> <package-file> [-level <default level>] [-revision <revision> ] [-repository <repository> ] [-hidden] [[-level <level name>] file=<file-to-include> ... ] [-osgi <true/false>] [-exported <export-version> file=<jar file>]

For Private Cloud, AWS or when you do not have a local installation, do:
java -jar $DEVKIT_JAR pcreate ...

Argument

Description

<name>

The name of the package

<version>

The version string of the package

<package-file>

The resulting package file name

[ -level <default level>]

Specifies if this software should support updates to a running system. The default level can either be platform or execution. Execution implies that the component can be updated when the system is running, for example upgrading to a newer agent version.

Note!

Not all kinds of software using the Development Toolkit can be updated and also that a third-party library being used by the software may or may not support the execution level.

[ -revision <revision>]

Used to show the revision number from which the .mzp file is built, that is from a revision management system.

[ -repository <repository>]

Used to show the repository from which the .mzp file is built, that is from a revision management system.

-hidden

Used if the .mzp file is not supposed to be visible in the system, for example in the ">About dialog.

[ -level <level name>] file=<file-to-include>

The level name can either be platform or execution. Each filename to be included can optionally be preceded by a level.

[ -osgi <true/false> ]

Anchor
myagentkey
myagentkey
When this argument is set to true, the MZP will be built as an OSGi bundle. This ensures that the Java code within the bundle is isolated from the rest of MediationZone.

Use OSGi bundling when your DTK plugin depends on third-party libraries that you need to include in the MZP, so they do not cause any conflicts with the rest of the system. Only the Java packages explicitly exported will be visible to MediationZone.

To specify which Java packages to export, use the following options:

-exportpackages <javapackagename> - Will export the specified Java package(s).
-exported <export-version> file=<jar file> - Will export all Java packages contained within the specified JAR file.

The default value is false.

[ -exportpackages <Java wrapper>]

When the -osgi true argument is used, this argument states the Java package(s) to be exported. Multiple packages can be exported by stating them in a comma-separated list, for example:

com.mycompany.myagent1,com.mycompany.myagent2

Info

Example - Using -osgi and -exportpackages

Code Block
mzsh username/password pcreate "My Agent" 1.0 my_agent.mzp -level platform file=my_agent.jar file=my_third_party_library.jar -osgi true -exportpackages com.mycompany.myagent

[ -exported <export-version> file=<jar file>]

This argument will export all Java packages contained within the specified JAR file when used with the argument -osgi true. This argument can be used multiple times if you need to export Java packages from multiple JAR files.

Info

Example Using -osgi and -exported

Code Block
mzsh username/password pcreate "My Agent" 1.0 my_agent.mzp -level platform file=my_third_party_library.jar -osgi true -exported 1.0.0 file=my_agent.jar

Committing a User-Defined Package

Code Block
For Bare Metal installations:
1. sftp mzp to test server
2. Login on the test server
3. $ mzsh user/pw pcommit my_agent.mzp

Note!

The name (My Agent in the example above, https://infozone.atlassian.net/wiki/spaces/MD92/pages/111782614/Creating+a+DTK+Plugin#Creating-a-User-Defined-Jar) is the package key, meaning that if a new package with the same name is inserted, then the old code for that package name is replaced.