AntóinÓg
AntóinÓg

Reputation: 511

Is having Eclipse OSGI Activators inheriting from each other a good idea?

If you have a common eclipse/osgi code platform on which you build various products can you/should you inherit activators from the common code

E.g.

org.test.common.PluginActivator
org.test.common.ui.UIPluginActivator

org.test.product1.Product1PluginActivator
org.test.product1.ui.Product1UIPluginActivator

org.test.product2.Product2PluginActivator
org.test.product2.ui.Product2PluginActivator

I want to have all the UI activators inheriting from the common one, and the same for the non-ui activators. The start methods would all be calling super... However I am wondering if this is bad osgi/bundle practice or could cause problems.

Does anyone have any ideas/opinions on this?

Upvotes: 1

Views: 290

Answers (3)

inger
inger

Reputation: 20184

I would not, I would actually consider that an abuse of subclassing in general (rather than strictly from OSGi point of view).

IMHO the best is to keep the activator class itself minimal (as in code and as in runtime performance footprint), mainly delegating real work -if any- to worker classes. if you have to subclass anything, you can do that with those worker classes.

Upvotes: 0

SteveD
SteveD

Reputation: 5405

I'm assuming you're doing Eclipse RCP because otherwise I'd recommend Spring DM (or iPOJO, Google Guice with Peaberry, or Declarative Services, ...). That way you'd never need to write another bundle activator again.

On the other hand, my team went with the common abstract BundleActivator for our RCP-related bundles. To me, having the actual bundle activators in a central bundle(s) increases coupling.

Upvotes: 0

Rich Seller
Rich Seller

Reputation: 84028

If the child can't run without the parent's bundle anyway (i.e. it has a functional dependency on it), you're not adding any additional coupling by making the Activator inherit from it.

I'd be wary of inheriting from a common parent unless the plugin already had reason to do so as you're forcing the bundle to be loaded even if you're only inheriting some constant.

Upvotes: 4

Related Questions