KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > ipanema > asyncinvoke > AsyncInvokerInvocationBean


1 /*
2  * Created on Mar 23, 2005
3  */

4 package com.nightlabs.ipanema.asyncinvoke;
5
6 import java.io.Serializable JavaDoc;
7
8 /**
9  * @ejb.bean name="ipanema/mdb/IpanemaBaseBean/AsyncInvokerInvocation"
10  * acknowledge-mode="Auto-acknowledge"
11  * destination-type="javax.jms.Queue"
12  * transaction-type="Container"
13  * destination-jndi-name="queue/ipanema/IpanemaBaseBean/AsyncInvokerInvocationQueue"
14  *
15  * @ejb.transaction type="Required"
16  *
17  * @jboss.destination-jndi-name name="queue/ipanema/IpanemaBaseBean/AsyncInvokerInvocationQueue"
18  *
19  * @!jboss.subscriber name="_LocalQueueReader_" password="test"
20  */

21 public class AsyncInvokerInvocationBean
22 extends AsyncInvokerBaseBean
23 {
24     /**
25      * @see com.nightlabs.ipanema.asyncinvoke.AsyncInvokerBaseBean#doInvoke(com.nightlabs.ipanema.asyncinvoke.AsyncInvokeEnvelope, AsyncInvokerDelegateLocal)
26      */

27     protected void doInvoke(AsyncInvokeEnvelope envelope, AsyncInvokerDelegateLocal invokerDelegate)
28     {
29         boolean success = false;
30         try {
31             Serializable JavaDoc result = invokerDelegate.doInvocation(envelope);
32             envelope.setResult(result);
33             success = true;
34         } catch (Throwable JavaDoc x) {
35             logger.error("Invocation failed!", x);
36             messageContext.setRollbackOnly();
37             try {
38                 envelope.setError(x);
39                 invokerDelegate.enqueueErrorCallback(envelope);
40             } catch (Throwable JavaDoc x2) {
41                 logger.fatal("invokerDelegate.enqueueErrorCallback(...) failed!", x2);
42             }
43         }
44
45         if (success) {
46             SuccessCallback successCallback = envelope.getSuccessCallback();
47             if (successCallback != null) {
48                 try {
49                     new AsyncInvoke().enqueue(AsyncInvoke.QUEUE_SUCCESSCALLBACK, envelope);
50                 } catch (Throwable JavaDoc x) {
51                     logger.fatal("Failed to enqueue in AsyncInvoke.QUEUE_SUCCESSCALLBACK!", x);
52                     messageContext.setRollbackOnly();
53                 }
54             } // if (successCallback != null) {
55
} // if (success) {
56
}
57 }
58
Popular Tags