Context Service SDK Components
The Context Service Java SDK provides:
Static SDK jar—Contains all classes and methods used to integrate with Context Service. Your application has a compile-time dependency on this file. Include this file in your application classpath. The SDK is designed to dynamically update the extension jar using the connector.property file.
Dynamic SDK extension jar—Contains the implementation of the static jar API. You must save the dynamic jar file outside your application classpath. This allows you to isolate dependencies from your application. The extension jar file is dynamically updated at application runtime using the connector.property file.
You must have write permissions to the directory that you store the dynamic SDK extension jar in.
connector.property—Property file specifying the name and location of the extension jar file. The connector.property
file is saved by default to the root resource directory of your application.
Context Service SDK POM—POM file that lists the maven dependencies for the SDK.
The static SDK uses the connector.property file to access and dynamically update the SDK extension jar. If the connector.property
file is not in the default location, you can manually load the connector.property
file. For an example on how to manually load the connector.property
file, see Initialize Connector Factory.
Initialize Connector Factory
The connector factory must be initialized:
If the connector.property
file is not in the default location, then you must manually initialize the factory with the correct path to connector.property
. This example shows how to initialize the connector factory:
Update Extension Jar Automatically
The extension SDK does not have a compile-time dependency with the base SDK. This enables your application to dynamically update the extension SDK at runtime. When your application starts, the management connection functionality automatically checks the version of the SDK and updates to the latest available extension JAR.
To allow the extension JAR to update automatically, edit the connector.property
file and set the appropriate write privileges to the directory that contains the extension JAR.
The location of the SDK extension JAR is specified in the connector.property
file. By default, the base SDK looks for connector.property
in the same directory from which the application is launched.
connector.property
contains two properties:
path
—Path to the extension SDK.
jar-name
—Name of the extension jar file.
For example:
path=plugin jar-name=context-service-sdk-extension-2.0.1.jar
The path
property must specify a path that the Java process can write to, and cannot be in the Java CLASSPATH. The Java process must also be able to write to the extension JAR file to enable automatic updates.
Once your application has the latest SDK extension you can connect to Context Service.
SDK Client Logging
The Context Service SDK logs diagnostic messages to the SLF4J interface. By default, the SDK includes the logback binding for SLF4J. Use logback for logging or configure a different SLF4J-compatible logger.
Include logback.xml in your class path to enable Logback to detect your configuration. For more information on Logback, see
the Logback manual.
To configure Context Service SDK to use a different SLF4J-compatible logger than the default Logback:
- Exclude Logback-classic from your project.
- Include SLF4J bindings for the new logger.
- Include the new logger.
To learn more about configuring your new logger with SLF4J, see the SLF4J documentation.