Dan,

The Controls Programming Tutorial is a bit-of-date when it comes to resource 
events.   Steve Hansen is working on updating the docs on the site, and when 
the content is refreshed this particular area will be fixed.

It is possible to get resource events, but instead of these being events on the 
ControlBeanContext, there is instead a separate context (ResourceContext) that 
provides resource notifications.   The rationale for this is that it enables 
the easy identification of controls that need resource events (and thus a 
container that provides a notion of resource scope) from ones that do not 
(basic JavaBeans).

A control impl can get these events by simply declaratively defining a 
ResourceContext instance, as follows:

        @Context org.apache.beehive.controls.context.ResourceContext 
resourceContext;

Then it uses the exact same syntax as you show below, but as a ResourceContext 
event instead of a ControlBeanContextEvent:

    @EventHandler (field="resourceContext", 
eventSet=ResourceContext.ResourceEvents.class, eventName="onAcquire")
    /* package */ void onAcquire()
    {
        ...
    }

    @EventHandler (field="resourceContext", 
eventSet=ResourceContext.ResourceEvents.class, eventName="onRelease")
    protected void onRelease()
    {
        ...
    }

The Controls tests contains a sample bean that tests resource events at:

        
controls/test/src/controls/org/apache/beehive/controls/test/controls/context/BaseContextImpl.jcs

-- Kyle

> -----Original Message-----
> From: Dan Diephouse [mailto:[EMAIL PROTECTED]
> Sent: Saturday, October 30, 2004 12:36 PM
> To: Beehive Developers
> Subject: LifeCycle Support
> 
> 
> I am looking at the Controls Programming tutorial and in the 
> JMS example 
> it has:
> 
> @EventHandler (field="context", 
> eventSet=ControlBeanContext.Lifecycle.class , eventName="onRelease")
> public void onRelease()
> 
> 
> Yet there isn't an "onRelease" method on the LifeCycle class. 
>  Is this 
> supported at all?
> 
>     [apt] Compiling 1 source file to 
> C:\eclipse\workspace\controlhaus-hibernate\target\classes
>     [apt] warning: Annotation types without processors: 
> [org.apache.beehive.controls.api.context.Context, org.apache.bee
> hive.controls.api.events.EventHandler]
>     [apt] 
> C:\eclipse\workspace\controlhaus-hibernate\src\main\org\contro
> lhaus\hibernate\HibernateControlImpl.java:75: 
> No
>  event method with matching name and signature found on EventSet: 
> org.apache.beehive.controls.api.context.ControlBeanCon
> text.LifeCycle
>     [apt]     public void onRelease()
>     [apt]                 ^
> 
> Thanks,
> Dan
> 
> -- 
> Dan Diephouse
> Envoi Solutions LLC
> http://envoisolutions.com/people/dan
> 
> 

Reply via email to