Once the control has been associated with a ResourceContext provider, the provider will deliver events to the Control Implementation instance according to the following basic contract:
The following code fragment shows how to receive resource events from within a Control implementation:
import org.apache.beehive.controls.api.events.EventHandler; ... @EventHandler(field="resourceContext", eventSet=ResourceContext.ResourceEvents.class, eventName="onAcquire") public void onAcquire() { // code to obtain connections/sessions/... } @EventHandler(field="resourceContext", eventSet=ResourceContext.ResourceEvents.class, eventName="onRelease") public void onRelease() { // code to release connections/sessions/... }
The onAcquire resource event is guaranteed to be delivered once before any operation declared on a public or extension interface associated with the control. This event will be delivered once, and only once, within a particular resource scope associated with the ResourceContext. If a control needs to utilize its resources in another context (such as in response to a PropertyChange notification), the ResourceContext also provides support for manually acquiring and releasing resources. @see org.apache.beehive.controls.api.context.ResourceContext.ResourceEvents @see org.apache.beehive.controls.api.context.Context @see org.apache.beehive.controls.api.events.EventHandler
|
|
|
|