[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: In callback

adrian@jboss.org do-not-reply at jboss.com
Mon Jul 2 12:12:17 EDT 2007


This callback is just an IOC version of something you can do with OSGi
(or even the old JMX notifications).

In OSGi/JMX you can listen to services appearing and disappearing
and do work on them, e.g.


  | public void [un]registerNotification(Event event)
  | {
  |    if (event.getTarget() instanceof Deployer)
  |       [un]register();
  | }
  | 

All the [un]installCallback is doing is removing the need to write the notification
handling and wiring yourself.

Actually, it is slightly more complicated, because you can choose the event
to be a true dependency (i.e. there must be at least N deployers -most likely 1) 
or optional (I don't care if there are no deployers, deploy me anyway)
through the cardinality.

Its probably easier to understand in its alternate form, i.e. as an injection
of a collection of all implementations of a specific type.

e.g. intead of, give me a DataSource

  | @Inject
  | public void setDataSource(DataSource ds);
  | 

it is give me all DataSources

  | @Inject
  | public void setDataSources(Collection<DataSource> all);
  | 

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

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



More information about the jboss-dev-forums mailing list