import org.amdatu.remote.annotation.Export;
import org.amdatu.remote.example.Greeting;
import org.apache.felix.dm.annotation.api.Component;
@Component
@Export(Greeting.class)
public class GreetingImpl implements Greeting {
public String sayHello(String name) {
return "Hello, " + name + "!";
}
}
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns="http://www.osgi.org/xmlns/scr/v1.3.0"
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/scr/v1.3.0 http://www.osgi.org/xmlns/scr/v1.3.0">
<service>
<provide interface="org.amdatu.remote.example.Greeting"/>
</service>
<property name="service.exported.interfaces" value="org.amdatu.remote.example.Greeting"/>
<property name="service.exported.configs" value="ecf.generic.server"/>
</scr:component>
import org.amdatu.remote.example.Greeting;
import org.apache.felix.dm.annotation.api.Component;
import org.apache.felix.dm.annotation.api.ServiceDependency;
@Component
public class GreetingConsumer {
@ServiceDependency
private volatile Greeting greeting;
public void greet() {
String result = greeting.sayHello("Alice");
System.out.println(result);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns="http://www.osgi.org/xmlns/scr/v1.3.0"
xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/scr/v1.3.0 http://www.osgi.org/xmlns/scr/v1.3.0">
<reference name="greeting" interface="org.amdatu.remote.example.Greeting" cardinality="1..1" policy="static"/>
</scr:component>