How a POJO can access to the bundle context has been created by Clement Escoffier (May 03, 2007).

Content:

It is possible to a POJO to get its bundle context. A POJO can receive its bundle context as an argument of its constructor. The next code snippet show you an example :

public class ASimplePOJO{
	private BundleContext context;
	public ASimplePOJO(BundleContext bc) {
		context = bc;
		init();
	}}

As you see on the previous snippet, The bundle context is injected to the POJO. Then the POJO can use it as a 'normal' bundle context. The POJO code can :

  • load classes
  • register / unregister services
  • discover, track and use services
  • ...
    However, all these interactions are no more managed by the iPOJO container. So, be carefull to manage correctly dynamism, listener ...


Reply via email to