Create an OSGi-compliant class that implements a plugin interface
Before you begin
Procedure
-
If you have not previously generated the Java libraries, without Guidewire Studio or
IntelliJ IDEA with OSGi editor open, type the following command at a command prompt in the
PolicyCenter root directory.
gwb genJavaApi -
If IntelliJ with OSGi Editor is not open, type the following command at a command
prompt in the PolicyCenter root directory.
gwb pluginStudio - In IntelliJ IDEA with OSGi Editor, navigate under your OSGi module to the src directory.
-
Create new subpackages as necessary by right-clicking
srcand choosing .For example, create amycompanypackage. -
Create an OSGi-compliant class that implements a plugin interface.
- Right-click the package for your class.
-
Choose .
IntelliJ IDEA with OSGi Editor opens a dialog.
-
In the Plugin class name field, enter the name
of the Java class that you want to create.
For example, type
DemoStartablePlugin. -
In the Plugin interface field, enter the fully
qualified name of the plugin interface that you want to implement. Alternatively, to choose from a list, click
the ellipsis (
...) button. Type some of the name or scroll to the required plugin interface. Select the interface and then click OK.For example, typeIStartablePlugin.IntelliJ IDEA with OSGi Editor displays a dialog Select Methods to Implement. By default, all methods are selected. -
Click OK.
IntelliJ IDEA with OSGi Editor displays your new class with stub versions of all required methods.
- If the top of the Java class editor has a yellow banner that says Project SDK is not defined, you must set your project SDK to a JDK. If the SDK settings are uninitialized or incorrect, your project shows many compilation errors in your new Java class.
-
Add code to the stub methods.
For example, use the code in Example startable plugin in Java using OSGi.
Results
What to do next
If you have several tightly related OSGi plugin implementations, you can optionally deploy them in the same OSGi bundle. To implement additional plugins in this project, repeat this procedure for each plugin implementation class. For example:
A messaging destination implements the MessageTransport interface. A
single messaging destination optionally also implements the MessageReply
plugin interface. If these related plugin implementations have shared code and third-party
libraries, you could deploy them in the same OSGi bundle that encapsulates messaging code
for a messaging destination.
