4 November 2007
As a great deal of this article is about developing your own software component, I assume that you are comfortable coding in Java. You should also have a basic working knowledge of the LiveCycle ES workflow environment, including the LiveCycle ES Workbench tool.
Intermediate
This is Part 1 of the series. The goal of this article is to introduce the basic environment around a custom Document Service Component (DSC) and to show how you can go about developing one yourself. Part 2 will expand on that information and demonstrate more advanced Java constructs (beans, enumerated types, etc.).
With Adobe LiveCycle ES software, you have the ability to extend the product's functionality using Java classes. This means that you can develop your own Java classes that act as operations within a LiveCycle ES workflow. Extending the LiveCycle product in this way enables you to add your own functionality, interact with your existing programs, and integrate with third-party applications. Once a component is deployed to LiveCycle ES software, the services contained within the component become LiveCycle services.
Document Service Components consist of three main elements (see Figure 1):
These files will be combined into a single JAR file that will be imported into LiveCycle ES software using the Workbench tool.
The easiest way to explain DSC development is to build a custom component. Here I will use a very simple "Hello, world" example consisting of a single Java class file and the required component.xml.
Create a simple project and Java class file using your favorite editor (I prefer Eclipse, but the choice is up to you) called helloComponent.java. Put it in whatever package you want; I'm using com.adobe.sample. Add a method that takes a string and returns another. You can then add some code to return a string that includes the input string—something like this:
package com.adobe.sample;
public class helloComponent {
public String hi(String yourName){
return "Hello, " + yourName;
}
}
Compile the class into a .class file.
Okay, now that you have a simple Java class, add the component descriptor file. To be frank, it's a bit of a pain to write the XML file from scratch. You can copy one from an existing component (or from this article).
<component xmlns="http://adobe.com/idp/dsc/component/document">
<component-id>com.adobe.sample.helloComponent</component-id>
<version>8.0.0</version>
<supported-connectors/>
<supports-export>true</supports-export>
<services>
<service name="helloComponent" orchestrateable="true" title="Hello Component">
<hint>A simple component to show how to build a DSC</hint>
<auto-deploy major-version="1" minor-version="0" category-id="Hello"/>
<implementation-class>com.adobe.sample.helloComponent</implementation-class>
<operations>
<operation name="hi">
<hint>Returns a string</hint>
<input-parameter name="yourName" title="Put your name here" type="java.lang.String">
<hint>Put your name here</hint>
<supported-expr-types>Literal,XPath,Template,Variable</supported-expr-types>
</input-parameter>
<output-parameter name="result" title="Result" type="java.lang.String">
<description>A message from the component</description>
<hint>A message from the component</hint>
</output-parameter>
<description>A Hello, world component</description>
</operation>
</operations>
</service>
</services>
</component>
This sample includes the following tags:
component-id: a unique identifier for your component.version: the version info for your componentsupports-export: specifies whether the component should beincluded if you export an archive that uses the component; that is, should thecomponent be exported as part of the LiveCycle Archive (LAR) file.services: describes the services included in this component(this one only has one service)service name: the name of the serviceonce it is deployedauto-deploy: The category-id attribute is the name of the service category in which this componentwill be deployed.implementation-class: the package andclass name of your componentoperations: These equate to publicmethods in your class. Any methods you wish to expose need to have theirown operation tag.operation name: the name of the methodinput-parameter: where you list themethod's input parameters. Note that the type attributecorresponds to the Java class for that parameter.output-parameter: the object that isreturned by the method.Note that there are many other tags, but this is all we needfor this simple example.
Now that you have a compiled class file and the propercomponent.xml file, you can create a Java Archive file that will contain all ofthe component parts. The JAR file will be imported into LiveCycle ES software usingthe Workbench tool. You can build the JAR file using a command line tool orusing your IDE; however, there are a few things to keep in mind:
Note: If you use Eclipse to create your JAR file,make sure that that the "Compress the contents of the JAR file"option is off. You will not be able to import compressed JAR files.
The following steps will import your component intoLiveCycle ES software:
The component should now appear in the Services tab underthe category you specified in the component.xml file (see Figure 2). You cannow use your component in your workflow process. Note that the property sheetwill reflect the information you put in the component.xml file.
This article shows a pretty simple component, but it is a starting point. To learn how to create an advanced service component, read Part 2 of this series. For more in-depth information on developing components, please refer to the official Adobe documentation.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License