I am ok with this, although the names Event and EventListener needs to
be more specific I think.



On Mon, May 30, 2011 at 10:36 AM, Rickard Öberg <[email protected]> wrote:
> Hi,
>
> In my own app I've had a need to allow higher layers to listen for
> activate/passivate events from underlying layers. Specifically, if some
> infrastructure service is activated I want a JMX service in a top layer to
> know this, so that it can expose the service properly, and then unexport it
> if the service is passivated.
>
> There's tons of ways to do this, but I've opted for a simple model where a
> listener can be registered on Application/Layer/Model/ServiceReference
> levels, and then get notifications about activations. A listener on the
> Application level gets all events published. A listener on a particular
> ServiceReference only gets events from that service.
>
> Example:
> app.registerEventListener( new EventListener()
> {
>    @Override
>    public void onEvent( Event event )
>    {
>        System.out.println(event.toString()):
>    }
> });
>
> assembler.application().activate();
> ---
> This will simply output all activation/passivation events as they occur.
> Events are ACTIVATING,ACTIVATED,PASSIVATING,PASSIVATED so listeners can
> react accordingly, if necessary.
>
> Does this seem like an ok way to do it? Any other requirements that you have
> come across? To me, the main usecases are logging/debugging and exporting
> services dynamically. Anything else?
>
> /Rickard
>
> _______________________________________________
> qi4j-dev mailing list
> [email protected]
> http://lists.ops4j.org/mailman/listinfo/qi4j-dev
>



-- 
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

I live here; http://tinyurl.com/3xugrbk
I work here; http://tinyurl.com/24svnvk
I relax here; http://tinyurl.com/2cgsug

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to