Plugging into CentraSite Control
We have now created a Java project inside the PluggableUI web application. However, there is one missing piece that tells CentraSite Control that this folder contains a plug-in: the plug-in configuration file. Amongst other things, the plug-in configuration file contains the information about where a plug-in plugs into in CentraSite Control.
The idea of using plug-ins to extend an application's functionality is quite simple and meanwhile well established by the Eclipse platform. The CentraSite Control software provides so-called extension points. These are positions in the program logic of the CentraSite Control program where functionality can be added by a plug-in. Every time the program flow comes to such an extension point, a search for plug-ins that extend CentraSite Control at this point takes place and the code provided by the plug-ins is invoked.
Let's convert our arbitrary Java project to a CentraSite Control plug-in folder by providing a plug-in configuration file. To do so, follow the steps below:
1. In the context menu of DemoPlugIn01 in the package explorer, choose New > File.
2. Type plugin.xml as the file name and click Finish.
3. Enter the following XML code:
<plugin id="demo.plugin01" order="101">
<requiredPlugin id="com.softwareag.cis.plugin" />
<!-- PlugInInfo -->
<extension point="com.softwareag.cis.plugin.plugInInfo"
id="DemoPlugIn01Info"
class="demo.plugin01.ext.PlugInInfo">
</extension>
</plugin>
4. Save the file using <Ctrl>+S.
First of all a plug-in must have an identifier (here demo.plugin01) which has to be unique among all plug-ins. We recommend you to use naming conventions similar to Java package names.
The order number of a plug-in (here 101) gives CentraSite Control a priority for the sequence in which the plug-ins have to be loaded at startup. The higher the number, the later a plug-in is loaded.
We need to declare our plug-in as being dependent on the plug-in com.softwareag.cis.plugin because we use an extension point provided by this plug-in. This dependency is indicated through the requiredPlugin XML element.
For a list of all supported extension points, see
Extension Points.
The extension XML element in our file DemoPlugIn01/plugin.xml denotes that our plug-in extends the user interface at a point where information about a plug-in can be contributed. The string that looks like a Java package name is the name of the extension point (com.softwareag.cis.plugin.plugInInfo).
The extension identifier (here DemoPlugIn01Info) must be unique among all extension identifiers of a plug-in.
The class attribute specifies the fully qualified name of the class that implements the extension (here demo.plugin01.ext.PlugInInfo). The top level package name for all of our Java code will be demo.plugin01. We choose ext as the subpackage name for the implementing class to denote that code that extends CentraSite Control resides here.
Now we have to implement the extension, that is, we have to provide a Java class called demo.plugin01.ext.PlugInInfo which implements a specific interface required by the extension point.
1. In the context menu of DemoPlugIn01/src in the package explorer, choose New > Class.
2. Specify demo.plugin01.ext for the package name, PlugInInfo for the class name and com.softwareag.cis.plugin.extpt.util.AbstractPlugInInfo for the superclass (you may uses the Browse button to save some typing).
3. Make sure that the check box labeled with Inherited abstract methods is checked and click Finish.
Eclipse now opens the file PlugInInfo.java in the Java editor.
Modify PlugInInfo.java in the Java editor as follows:
package demo.plugin01.ext;
import com.softwareag.cis.plugin.extpt.util.AbstractPlugInInfo;
public class PlugInInfo extends AbstractPlugInInfo {
public String getImageURL() {
return "../DemoPlugIn01/images/star-16x16.gif";
}
public String getLayout() {
return null;
}
public String getTitle() {
return "DemoPlugIn01";
}
public String getVendor() {
return "Software AG";
}
public String getVersion() {
return "0.0.0.1";
}
}
Save the modified file and make sure that no compile errors occur.
When you save the file, the Java file is automatically compiled into the folder classes of the project DemoPlugIn01. (Remember: the classes subfolder of our project is suppressed from displaying). The resulting class file is now accessible for the pluggable user interface of CentraSite Control.
Finally, let's check if CentraSite Control is aware of our minimalist plug-in:
1. Restart the Windows service "Software AG Runtime".
2. Start the CentraSite Control application from the Windows Start > All Programs > Software AG menu, and log in using your usual ID and password.
3. Click the About button at the top of the page. In the subsequent dialog, click Plug-Ins.
If everything works fine, you should see a dialog box whose contents look quite similar to the following screenshot. In particular, the line that represents our sample plug-in DemoPlugIn01 should be visible: