Apache Felix Dependency Manager - Getting StartedPage edited by Marcel OffermansGetting StartedWhen developing an OSGi bundle that has dependencies and possibly registers services, there are two classes in particular we need to implement:
When using the dependency manager, your bundle activator is a subclass of DependencyActivatorBase. It needs to implement two life cycle methods: init and destroy. Both methods take two arguments: BundleContext and DependencyManager. The latter is your interface to the declarative API you can use to define your services and dependencies. The following paragraphs will show various examples that explain how to do this. Subsequently, some more advanced scenarios will be covered that involve listening to dependency and service state changes and interacting with the OSGi framework from within your service implementation. Registering a servicepublic class Activator extends DependencyActivatorBase { public void init(BundleContext context, DependencyManager manager) throws Exception { manager.add(createService() .setInterface(Store.class.getName(), null) .setImplementation(MemoryStore.class) ); } public void destroy(BundleContext context, DependencyManager manager) throws Exception {} } public interface Store { public void put(String key, Object value); public Object get(String key); } public class MemoryStore implements Store { private Map m_map = new HashMap(); public Object get(String key) { return m_map.get(key); } public void put(String key, Object value) { m_map.put(key, value); } } Depending on a serviceTracking services with callbacksDepending on a configuration...
Change Notification Preferences
View Online
|
View Change
|
Add Comment
|
- [CONF] Apache Felix > Apache Felix Dependency Manager - Gett... confluence
- [CONF] Apache Felix > Apache Felix Dependency Manager -... confluence
- [CONF] Apache Felix > Apache Felix Dependency Manager -... confluence
- [CONF] Apache Felix > Apache Felix Dependency Manager -... confluence
- [CONF] Apache Felix > Apache Felix Dependency Manager -... confluence
- [CONF] Apache Felix > Apache Felix Dependency Manager -... confluence
- [CONF] Apache Felix > Apache Felix Dependency Manager -... confluence
- [CONF] Apache Felix > Apache Felix Dependency Manager -... confluence
- [CONF] Apache Felix > Apache Felix Dependency Manager -... confluence
