Exposing a Custom Object

You can expose custom objects to a service by implementing the org.eclipse.core.exceptions.ServiceProviderConversionException extension point and the ServiceProviderConversionUtil utility.

This custom object's state can then be persisted to a persistent service using Content Manager.


  1. Create a custom Java object for your service provider (for example, MyServiceProvider.java).
  2. In the manifest editor, expose the object:
    1. Expand the "Java Implementation" category.
    2. Select the custom object you created, and select "Implementation Class."
  3. In the source editor, create a sub-directory for the service provider and create a file MyServiceProvider.java.
  4. Implement the IServiceProviderConversion.getClassForElement(IContentElement) method, overriding it with a method that loads a ContentHandler based on the identifier you use to reference your custom object.

For more information, see content handler.

Running the Content Convenience

By default, when a Java class and a C++ class are defined as ServiceProviderConversionClasses, the Eclipse IDE can convert Java classes to C++ classes. By adding C++ plugin classes as ContentHandlerClasses, the plugin can convert the Java classes to C++. This lets you write Java code, and have it compile into a C++ class.

You can run this example without any user interface. Open org.eclipse.mylyn.convenience.mylynconsole.MylynConsole and start the service using the menu option Mylyn... -> Run Mylyn Console...

With an installed Mylyn project, this example looks for MylynConsole.proj, and creates the Java, C++ and C projects in that project.

With a Mylyn project, Eclipse will look for any files in the workspace that have the file name ending in .proj and make sure there are at least two ProjectContentHandler and ProjectContentConversionHandler registered.

Running the Eclipse Plug-in

To run this example, start Eclipse and select the plug-in via the Run menu option. This example will display a window similar to the following:

Example of using Content Transformation to expose a Java API using a C++ plugin