[jboss-dev-forums] [Design of OSGi Integration] - BundleActivatorDeployer Questions

johnbailey do-not-reply at jboss.com
Sun Feb 17 14:04:24 EST 2008


Currently there is a deployer for the MetaData and BundleActivator.  I am not sure the BundleActivator deployer makes sense.  I understand how it is working, but looking through the API for OSGI it seems pretty clear the BundleActivator should be started/stopped during the start and stop invocations on the Bundle itself (http://www.osgi.org/javadoc/r4/org/osgi/framework/Bundle.html#start(int)   - see step 8).


In the BundleActivatorDeploymentVisitor a BundleContext is created, which will lazily create the Bundle.  BeanMeteData for the BundleActivator is then installed into the controller with start and stop parameters of the BundleContext.

  | public void deploy(DeploymentUnit unit, OSGiMetaData deployment) throws DeploymentException
  |       {
  |          String bundleActivator = deployment.getBundleActivator();
  |          if (bundleActivator != null)
  |          {
  |             String name = createBundleActivatorBeanName(deployment);
  |             // todo - get deployment context in non-depricated way
  |             BundleContext bundleContext = new BundleContextImpl(unit);
  |             BeanMetaDataBuilder builder = 
  | 		BeanMetaDataBuilderFactory.createBuilder(name, bundleActivator)
  |                   .addStartParameter(BundleContext.class.getName(), bundleContext)
  |                   .addStopParameter(BundleContext.class.getName(), bundleContext);
  |             BeanMetaData beanMetaData = builder.getBeanMetaData();
  |             try
  |             {
  |                controller.install(beanMetaData);
  |             }
  |             catch (Throwable throwable)
  |             {
  |                throw DeploymentException.rethrowAsDeploymentException("Unable to install BundleActivator.", throwable);
  |             }
  |          }
  |       }
  | 

Would it make sense to use the Deployer to instead create BeanMetaData for the Bundle itself and install it with the start and stop  applied to the Bundle, which will internally call the BundleActivator when the Bundle is started?   It also seems like the BundleActivator BundleContext should only live within the context of the Bundle and should not be available to any other Bundle or Kernel service.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129931#4129931

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129931



More information about the jboss-dev-forums mailing list