package com.example.bundle; public interface GreetingService { String getGreeting(); } package com.example.bundle.impl; import com.example.bundle.GreetingService; public class GreetingServiceImpl implements GreetingService { public String getGreeting() { return "Hello, OSGi!"; } } package com.example.app; import com.example.bundle.GreetingService; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; public class AppActivator implements BundleActivator { private ServiceRegistration<GreetingService> registration; public void start(BundleContext context) { GreetingService greetingService = new GreetingServiceImpl(); registration = context.registerService(GreetingService.class, greetingService, null); } public void stop(BundleContext context) { registration.unregister(); } } plaintext Bundle-SymbolicName: com.example.app Bundle-Activator: com.example.app.AppActivator


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