Hello,

I don't believe its possible to change the signature of
onAcquire/onRelease event handlers since they are part of the core
controls package.  I think the documentation you mentioned was
referring to custom event handlers defined by a user.

What we have done in the past when it was desirable to throw an
exception from one of these methods has been to wrap the exception in
a org.apache.beehive.controls.api.ControlException which is a runtime
exception and can be thrown from anywhere.

  - Chad

On 10/6/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am working in a WebLogic/Workshop environment, and am VERY new to Beehive.
>
> I'm currently upgrading an application that was originally written in Workshop
> 8.1 to WebLogic/Workshop 9.2.  This application uses several custom controls,
> and after upgrading by Workshop (via an import), the original custom controls
> got "converted" to Beehive controls.
>
> The original custom controls used what use to be the context_onAcquire() and
> context_onRelease() methods to setup the environment for the control code, and
> to cleanup the environment, respectively, and after the initial conversion,
> these two methods weren't being called.
>
> So, I manually added the necessary "things", e.g.:
>
> import org.apache.beehive.controls.api.events.EventHandler;
> import org.apache.beehive.controls.api.context.ResourceContext;
> .
> .
>     @org.apache.beehive.controls.api.context.Context
>     ResourceContext resourceContext;
> .
> .
>     @EventHandler(field="resourceContext",
>             eventSet=ResourceContext.ResourceEvents.class,
>             eventName="onAcquire")
> public void onAcquire() throws Exception
> {
> .. code that use to be in context_onAcquire()
> }
>
>
> @EventHandler(field="resourceContext",
>             eventSet=ResourceContext.ResourceEvents.class,
>             eventName="onRelease")
> public void onRelease() throws Exception
> {
> .. code that use to be in context_onRelease()
> }
>
> However, when I did that, and tried to build the application, I got an
> "Unhandled exception type Exception" in a module named
> "XXXImplInitializer.java":
>
>         public void onAcquire()
>         {
>             __bc_impl.onAcquire();
>         }
>
> [In the original non-Beehive code, context_onAcquire() had:
>
>     public void context_onAcquire() throws Exception
> ]
>
> I eventually worked around this problem by removing the "throws Exception" 
> from
> the "public void onAcquire()" and by commenting out all of the "throw new
> Exception(...)" lines in the onAcquire() method.
>
> I think that info on the following page speaks to this under "Upgrading
> Exception Handling in Control Event Handlers":
>
> http://edocs.bea.com/workshop/docs92/ws_platform/upgrading/conUpgradingJavaContr
> ols.html
>
> As I mentioned, I am really new to Beehive, but I think that my "workaround" 
> is
> doing the 2nd option that page mentions, i.e.:
>
> "Remove the throws clause from the event handler code and implement another 
> way
> to handle exceptions generated from the event"
>
> But, I'd like to reinstate things so that my controls do throw exceptions, but
> I'm not quite sure I understand how to implement the 1st option:
>
> "Add the throws clause your event handler is throwing to the EventSet event
> method. You will also need to add a corresponding try/catch block to code that
> invokes the event method"
>
> Is this just a matter of adding something to the "eventSet" in the
> "EventHandler" annotation, and also, if that is the case, can someone tell me
> exactly what I need to add there?
>
> Or, if I need to do something additional, what else do I need to do?
>
> Thanks in advance,
> Jim
>
>
>

Reply via email to