Hi All,
C5 project is now following the standardized annotation based model with
declarative service components, which is specified in the OSGi compendium
specification [1]. These standard annotation related classes are available
with the following dependency.
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
Apache Felix scr.ds-annotations and maven-scr-plugin [2] can be used to
process the annotated class and generate the component descriptors (the
meta files).
Here is an example usage.
@*Component*(
name = "org.wso2.carbon.kernel.internal.CommandProvider",
immediate = true
)
public class CarbonKernelCommandProvider implements CommandProvider {
private CarbonRuntime carbonRuntime;
private ServiceRegistration<CommandProvider> serviceRegistration;
@*Activate*
public void registerCommandProvider(BundleContext bundleContext) {
serviceRegistration =
bundleContext.registerService(CommandProvider.class, this, null);
}
@*Deactivate*
public void unregisterCommandProvider(BundleContext bundleContext) {
serviceRegistration.unregister();
}
@*Reference*(
name = "carbon.runtime.service",
service = CarbonRuntime.class,
cardinality = ReferenceCardinality.MANDATORY,
policy = ReferencePolicy.DYNAMIC,
unbind = "unsetCarbonRuntime"
)
public void setCarbonRuntime(CarbonRuntime carbonRuntime) {
this.carbonRuntime = carbonRuntime;
}
public void unsetCarbonRuntime(CarbonRuntime carbonRuntime) {
this.carbonRuntime = null;
}
}
This will be documented for development with C5.
Thanks,
Kishanthan.
[1] http://www.osgi.org/download/r5/osgi.cmpn-5.0.0.pdf
[2]
https://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-maven-scr-plugin-use.html
<https://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin/apache-felix-maven-scr-plugin-use.html>
--
*Kishanthan Thangarajah*
Senior Software Engineer,
Platform Technologies Team,
WSO2, Inc.
lean.enterprise.middleware
Mobile - +94773426635
Blog - *http://kishanthan.wordpress.com <http://kishanthan.wordpress.com>*
Twitter - *http://twitter.com/kishanthan <http://twitter.com/kishanthan>*
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture