Compile and install your OSGi plugin as an OSGi bundle
To use your OSGi plugin with PolicyCenter, you compile the plugin and then use Studio to register the plugin.
Before you begin
Procedure
-
If IntelliJ with OSGi Editor is not open, type the following command at a command
prompt in the PolicyCenter root directory.
gwb pluginStudio -
Open the OSGi Ant build script:
-
Click .
The Ant pane opens in IntelliJ with OSGi Editor.
-
If OSGi plugin bundle is not
open in the Ant pane, click the plus sign (
+) in the navigation bar on that pane. In Select Ant Build File, navigate to and select build.xml in the project folder. Then, click OK.OSGi plugin bundle opens.
-
Click .
-
Run the Ant install command:
- Expand OSGi plugin bundle.
- Right-click install and click Run Target.
- To see the result of running the command, click . Expand the targets to see the messages from each step.
The command generates messages about compiling source files, generating files, copying files, building a JAR file, and finally copying that JAR file to the bundle deployment folder of PolicyCenter. If the command succeeds, the following output appears.Ant build completed successfully
If the build completes with warnings, check the warnings and correct them if necessary.
-
Switch to, or open, Guidewire Studio, not the IntelliJ IDEA with OSGi Editor. Navigate
in the Project pane to the path . Confirm that you see the newly-deployed file
YOUR_JAR_NAME.jar.
The JAR file name is based on the module symbolic name followed by the version. If the JAR file is not present at that location, check the Ant console output for the directory path where the script copied the JAR file. If you recently installed a new version of PolicyCenter at a different path, or moved your Guidewire product directory, you must immediately update your OSGi settings in your OSGi project.
-
In Guidewire Studio, register your OSGi plugin implementation.
Registering a plugin implementation defines where to find a plugin implementation class and what interface the class implements.
- In the Project window, navigate to .
- Right-click the registry, and choose .
-
In the plugin dialog, enter the plugin name in the Name field.
For plugin interfaces that support only one implementation, enter the interface name without the package. For example:
IBaseURLBuilder. The text that you enter becomes the basis for the file name that ends in .gwp. The .gwp file represents one item in the Plugins registry.If the plugin interface supports multiple implementations, like messaging plugins or startable plugins, this name can be any name of your choice.
If you are registering a messaging plugin, the plugin name must match the plugin name in fields in the separate Messaging editor in Studio.
For this demonstration implementation of the
IStartablePlugininterface, enter the plugin nameDemoStartablePlugin. -
In the plugin dialog, next to the Interface field, click the ellipsis (
...), find the interface class, and select it. If you want to type the name, enter the interface name without the package.For this demonstration implementation of the
IStartablePlugininterface, find or type the interface nameIStartablePlugin. - Click OK.
-
In the Plugins registry main pane for the new plugin, click the plus sign
(
+) and click Add OSGi Plugin. -
In the Service PID field,
type the fully qualified Java class name for your OSGi implementation class.
Note that this name is different from the bundle name or the bundle symbolic name. The ellipsis (
...) button does not display a picker to find available OSGi classes, so you must type the class name in the field.For this demonstration implementation of the
IStartablePlugininterface, type the fully-qualified class namemycompany.DemoStartablePlugin. - Set any other fields that your plugin implementation needs, such as environment, server, or plugin parameters.
- Make whatever other changes you need to make in Guidewire Studio. For example, if your plugin is a messaging plugin, configure a new messaging destination. You might need to make other changes such as changes to your rule sets or other related Gosu code.
-
Start the server.
Click the Run or Debug menu items or buttons.
Alternatively, run the QuickStart server from the command prompt. Open a command prompt in the root application directory and run the following command.gwb runServer
Example
Example startable plugin in Java using OSGi shows an example startable plugin. If you used that example, closely read the console messages during server start-up. The example OSGi startable plugin prints messages during server start-up. These messages demonstrate that PolicyCenter successfully called your OSGi plugin implementation.
