public class MyServiceImplementation implements MyService { @Override public void sayHello(String name) { System.out.println("Hello, " + name + "!"); } } public interface MyAdapterService { void greet(String name); } @Component public class MyAdapter implements MyAdapterService { @Reference private MyService myService; @Override public void greet(String name) { myService.sayHello(name); } } OSGI-INF/components.xml <?xml version="1.0" encoding="UTF-8"?> <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="my.adapter" immediate="true"> <implementation class="com.example.MyAdapter"/> <service> <provide interface="com.example.MyAdapterService"/> </service> </scr:component>


上一篇:
下一篇:
切换中文