Setting up the OSGi service usage sample
You use the samples console to set up this sample.
Procedure
- Open the Samples Console perspective and start the sample server.
- In the <InstallDir>/samples/osgi/OSGISampleClient/testdriver.properties file, change the value of the trustStoreLocation property to be the same as your installation directory. You must edit the file in the file system, not in the Eclipse workspace.
- In the Samples and Tutorials view, click View sample commands for the OSGi sample.
- Double-click export.solution and then wait for the Console view to display BUILD SUCCESSFUL. This command exports the solution.
- Double-click install.service.api, wait for the Console view to display CWWKF1017I: One or more features installed successfully: [LoanServiceFeatureApi_1.0.0.0], and then wait for the Console view to display BUILD SUCCESSFUL. This command compiles, packages, and deploys a Liberty feature that contains the OSGi service API that the Java™ agent uses. Then, it deploys the solution because the solution requires the service API to be available to be deployed.
- To ensure that the solution is deployed, in the Sample Server view click Insights sample server > View the deployed solutions by using the REST API and wait for the solution to be displayed.
- To verify that the OSGi feature is installed, view the contents of the <WLP_USER_DIR>/servers/cisDev/server.xml file.
The <WLP_USER_DIR> part of this path refers to the location of the Liberty /usr directory, which for Decision Server Insights is <InstallDir>/runtime/wlp/usr by default.
At the bottom of this file, you can see that the LoanServiceFeatureApi_1.0.0.0 feature is now on the server.
- Optional: In Windows Explorer or at a command line, open the <WLP_USER_DIR>/extension/lib folder, and
verify that it contains the following imported files for the OSGi feature:
- features/LoanServiceFeatureApi_1.0.0.0.mf
- com.ibm.cis.sample.LoanServicesApi_1.0.0.jar
Similarly, you can check that the following files are present for the solution:- features/OSGISampleSolution-0.20.mf
- OSGISampleSolution.init.loan.model.Customer_0.20.*.jar
- OSGISampleSolution.modelExecutable_0.20.*.jar
- OSGISampleSolution.OSGISampleJavaAgent_0.20.*.jar
- OSGISampleSolution.OSGISampleRuleAgent_0.20.*.jar
- OSGISampleSolution.solutionbundle_0.20.*.jar
- Optional: Set up and use the OSGi console from
Liberty:
- In the Sample Server view, stop the sample server.
- Add the following line to the <WLP_USER_DIR>/servers/cisDev/bootstrap.properties file:
osgi.console=5471 - Add the OSGi console feature to the <WLP_USER_DIR>/servers/cisDev/server.xml file
by adding the following line after <feature>solutions:OSGISampleSolution-0.20</feature>
<feature>osgiconsole-1.0</feature> - In the Sample Server view, start the sample server.
- Run the following shell command: telnet localhost
5471
On Windows, if the Telnet Client is not active, first turn on the feature: open the Control Panel, click Programs, click Turn Windows features on or off, and select Telnet Client.
- Enter the following command: ss The installed bundles are displayed, similar to the following
partial list:
... 187 ACTIVE com.ibm.cis.sample.LoanServicesApi_1.0.0.0 188 ACTIVE OSGISampleSolution.modelExecutable_0.20.0.20140930140359 189 ACTIVE OSGISampleSolution.OSGISampleRuleAgent_0.20.0.20140930140359 190 ACTIVE OSGISampleSolution.init.loan.model.Customer_0.20.0.20140930140359 191 ACTIVE OSGISampleSolution.OSGISampleJavaAgent_0.20.0.20140930140359 192 ACTIVE OSGISampleSolution.solutionbundle_0.20.0.20140930140359 ...
Next topic: OSGi service usage sample details
Parent topic: Sample: OSGi service usage