@Component public class ExampleComponent { @Inject private ExampleDependency dependency; @Activate public void activate() { System.out.println("Component activated."); } @Deactivate public void deactivate() { System.out.println("Component deactivated."); } public void execute() { dependency.doSomething(); } } @Component public class ExampleDependency { public void doSomething() { System.out.println("Dependency action executed."); } } <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="ExampleComponent"> <implementation class="com.example.ExampleComponent" /> <service> <provide interface="com.example.ExampleInterface" /> </service> </scr:component>


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