This is a continuation of a series of blog posts demonstrating the use of the ECF Remote Services JAX-RS Jersey Client within an Eclipse RCP application. The previous posts are:
- Eclipse RCP and REST – An Introduction
- Eclipse RCP and REST – Making Asynchronous Calls
- Eclipse RCP and REST – JAX-RS Extensions
The REST calls made by the Eclipse RCP SpaceX client are done using the ECF Remote Services framework. To make it easier to configure these services, two new additional features have been added in ECF 3.14.18 released this week.
Support for properties files alongside the EDEF XML
Up to this point ECF Remote Services endpoints have been configured with an EDEF file, which is an XML file containing the endpoint definition. While that still works well, it’s now possible to create a properties file alongside the EDEF file. The properties file must be in the same directory and have the same base filename as the EDEF file.
So in our SpaceX client we have an XML file called LaunchService_EDEF.xml
.
<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
<endpoint-description>
<property name="ecf.endpoint.id" value-type="String" value="https://api.spacexdata.com/v3" />
<property name="objectClass" value-type="String">
<array>
<value>com.modumind.spacex.service.LaunchService</value>
</array>
</property>
<!-- More properties here -->
</endpoint-description>
</endpoint-descriptions>
Using the new ECF support for local properties we can create a file (in the same directory) called LaunchService_EDEF.properties
. Properties specified in this file will override any set in the XML file.
# This URL will be used to locate the endpoint
ecf.endpoint.id=https://api.spacexdata.com/v3
Support for multiple configurations using profiles
Endpoint definitions often need to vary based on some runtime configuration. For example, you may have a different endpoint URL for various environments.
ECF Remote Services endpoints now support this type of configuration using a profile name and matching properties files. The profile name itself is specified as a command line argument:
-Dorg.eclipse.ecf.osgi.services.remoteserviceadmin.EndpointDescriptionLocator.localPropertiesProfile=dev
The framework will attempt to locate a properties file (again, in the same directory as the EDEF XML file) that has the profile name attached to the base file name: basename-{profile}.properties
.
Given this argument set to dev
, the framework will be looking for a matching properties file named LaunchService_EDEF-dev.properties
.
Wrapping up
These additional features make it easier to create and manage REST clients using the ECF Remote Services framework. If you’re buried in low-level Java REST client code, the ECF Remote Services JAX-RS Jersey Client can offer a much simpler and cleaner approach.
Note that if you’ve been using earlier versions of ECF Remote Services, you’ll need to reload the SpaceX Client target to bring in the latest version (3.14.18 or later).
The latest SpaceX client code can be found here: