COR•REC Service CorrecService.class is how others access your service. The CorrecService.class that you extend is the class you ultimately register as a service.
Creating a COR•REC Service begins by downloading COR•REC Sandbox that contains the sandbox-target. From the sandbox target add the following three plug-ins to your target.
You may not need to override any methods in the CorrecService.class but you will need to add the following methods:
<@Override
public Object collaborate(Integer action, Map>String, Object> map)
<@Override
public String getID();//unique ID given to your service
Once a consumer has acquired your service and confirmed its availability, they can make their request using the collaborative method. COR•REC Services regards the "action" parameter as the request itself and the "map" parameter as the necessary data to execute the action. You have the freedom to define whatever you wish for the action and map parameters. The action parameter may align with the static action values found in com.corgroup.bmp.osgi.service.CorrecService_I however this is not required.
Most services should be registered at startup. But again where and when you register and or unregister your service is wholly at your discretion. Here we extend org.eclipse.ui.IStartup.class utilizing the org.eclipse.ui.startup extension. Registering a CorrecService may also be done in a plugins Activator if the plugin is loaded at startup.
This requires the MANIFEST.MF/Extensions to contain the org.eclipse.ui.startup extension with its class attribute pointing to the Startup class created.
The actions required to register your service are described next:
When the plugin in shutdown un-register your registered services.
CorrecServiceRegistry.UNREGISTER_SERVICE is called once for each consumer.
Reference Links: