Setting up the OSGi service usage sample

You use the samples console to set up this sample.

Procedure

  1. Open the Samples Console perspective and start the sample server.
  2. 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.
  3. In the Samples and Tutorials view, click View sample commands for the OSGi sample.
  4. Double-click export.solution and then wait for the Console view to display BUILD SUCCESSFUL. This command exports the solution.
  5. 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.
  6. 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.
  7. 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.

  8. 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
  9. Optional: Set up and use the OSGi console from Liberty:
    1. In the Sample Server view, stop the sample server.
    2. Add the following line to the <WLP_USER_DIR>/servers/cisDev/bootstrap.properties file:
      osgi.console=5471
    3. 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>
    4. In the Sample Server view, start the sample server.
    5. 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.

    6. 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
      ...