SDK samples
You can use the sample tools and components included in the samples directory to find out how to make the most of the WorldServer SDK.
Tools and components
The SDK includes pre-compiled versions of the SDK sample tools and components in the samples\dist directory. You can upload the sample components into your WorldServer test environment to understand the types of features available through the WorldServer SDK.
The components that you can upload into WorldServer (such as automatic actions) are packaged into .zip files. Command-line tools, on the other hand, are packaged into .jar files that you can include in your class path and run.
Uploading SDK samples
You can upload SDK samples by following the standard procedure for adding custom components.
Information and documentation
You can find documentation for all the SDK samples in the samples\docs\api directory. This documentation is in the form of Javadoc for each sample.
The Javadoc provides information about how each sample works, as well as information about how to use it. For example, the Javadoc for the sample automatic actions describes the behavior of these actions, the parameters they take, their return values, as well as the situations in which they might return error messages.
Some of the samples provide abstract base classes that you can extend to create your own implementation. In these cases, the Javadoc also describes how to create your own samples.
Source code
The SDK also includes source code for all the sample tools and components. This source code is provided to demonstrate how to use the WorldServer SDK.
You can find the source code in the samples\src directory. The contents of this directory follow the standard Java convention of using the package name as the directory hierarchy. Therefore, the samples are all located in the samples\src\com\idiominc\wssdk\samples directory.
Modifying samples
Although the SDK comes with pre-compiled versions of the samples, you may want to modify the existing samples and recompile them.
- Compiles all the sample code.
- Re-creates all the contents of the dist directory based on the new code.
- Re-creates all the sample Javadoc.
To run this build script, you must have Apache Ant and the J2SE SDK 1.4.2 or higher installed on your machine and set up appropriately in your environment path. You can then invoke Ant from the samples directory to perform all these tasks. The Ant script sets up your class path and includes all the relevant libraries required to build the samples.
Writing new code
One of the easiest ways to start writing your own SDK code is to use the existing build system by adding your code to the existing sample packages and running Ant again to rebuild the samples.
For example, if you want to write a new automatic action, you can create a new directory called samples\src\com\idiominc\wssdk\samples\component\autoaction\mypackage, and then create one or more classes inside this directory. Add your classes to samples\src\com\idiominc\wssdk\samples\component\autoaction\desc.xml to make sure that they get registered in WorldServer the next time you upload the distribution.
The next time you run the Ant script, it compiles all these classes and includes them in the autoaction_samples.zip file in the samples\dist directory. By using this approach, you can create new components and upload them into WorldServer more quickly.