A document illustrating the steps for creating a component, which provides a service.
To create a component that provides a service, you have to go through the following stages:
The following example is the HelloService interface:
package simple.service;
public interface HelloService {
public void hello();
}
Here is the HelloService implementation class:
package simple.service.impl;
import simple.service.HelloService;
public class HelloServiceImpl implements HelloService {
public void hello() {
System.out.println("Hello components!");
}
}
The XML description of the HelloServiceComponent is the following.
<?xml version="1.0" encoding="UTF-8"?>
<scr:component name="HelloServiceComponent"
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
<!-- The component's implementation class-->
<implementation class="simple.service.impl.HelloServiceImpl"/>
<service>
<!--The interface of the service provided by the component-->
<provide interface="simple.service.HelloService"/>
</service>
</scr:component>