Creating a service

You can create a plug-in to define a service that performs operations on a content server. For example, you can create a service that provides a viewer for specific document types on a IBM FileNet® P8 server.

About this task

You use the application programming interfaces (APIs) that are native to the content server to define the operations that are performed by the service.

Tip: Follow best practices for servlets when you implement an IBM Content Navigator plug-in service:
  • Because the application server is multithreaded, the plug-in service needs to handle multiple threads safely.
  • The service will be called on multiple threads for multiple users; therefore, do not use instance variables. Using instance variables can have side effects such as unintentional sharing of information among users.

Procedure

To create a service:

  1. Extend the PluginService class to create the service:
    1. Implement the execute method to provide the service with access to the APIs for the content server.
    2. If this service replaces one of the IBM Content Navigator services, implement the getOverriddenService method to identify that service.
    3. If the service requires configuration, use the PluginServiceCallbacks.loadConfiguration method to obtain the values that were configured for the service.
  2. If the service provides a custom viewer, extend the PluginViewerDef class to define the URL template to launch the viewer.
  3. Add the service as a component in your Plugin.java subclass:
    1. Implement the getServices method to return an instance of the PluginService.java class that you created in step 1.
    2. If the service provides a custom viewer, implement the getViewers method to return an instance of the PluginViewerDef class that you created in step 2.

Sample plug-in files for a custom service

The following files in the sample plug-in define a service:
Table 1. Sample files that define a plug-in service
File Description
SamplePluginService.java This file extends the PluginService class to define a service that obtains system-related details about a document. To obtain this information, the service invokes the appropriate API depending on whether the document is in an IBM Content Manager, IBM Content Manager OnDemand, or IBM FileNet P8 repository.
SamplePluginViewerDef.java This file extends the PluginViewerDef class to define the URL template to launch the viewer that is defined in the SamplePluginViewerService.java file.
SamplePluginViewerService.java This file extends the PluginService class to define a service that provides a custom viewer that does simple formatting of an archived RSS feed.

What to do next

Call the service as needed from your custom actions, viewers, or features. You then use the IBM Content Navigator to associate these components with a desktop, which makes the service available to users.