KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > ejb > MessageBeanListener


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.ejb;
24
25 import java.lang.reflect.Method JavaDoc;
26 import com.sun.enterprise.resource.ResourceHandle;
27
28 /**
29  * Lifecycle contract for a single MessageBeanListener. Implemented
30  * by the MessageBeanContainer and called by the MessageBeanClient for
31  * each message delivery. Each message delivery MUST call each of the
32  * three methods exactly once, in the same thread, and in the following
33  * order :
34  *
35  * 1. beforeMessageDelivery
36  * 2. deliverMessage
37  * 3. afterMessageDelivery
38  *
39  *
40  * @author Kenneth Saks
41  */

42 public interface MessageBeanListener {
43
44     /**
45      * Pre-delivery notification to the container. Any transaction
46      * initialization is peformed here. In addition, when this method
47      * returns, the current thread's context class loader will be set
48      * the message-bean's application class loader.
49      *
50      * @param method is the method that will be invoked during deliverMessage.
51      * It is used the container during transaction setup to lookup the
52      * appropriate transaction attribute.
53      * @param txImported whether a transaction is being imported
54      *
55      */

56     void beforeMessageDelivery(Method JavaDoc method, boolean txImported);
57     
58     /**
59      * Deliver a message to a message bean instance.
60      *
61      * @param params to use of the method invocation. Can be null or
62      * an 0-length array if there are 0 arguments.
63      *
64      * @throws Throwable This is either an application exception as thrown
65      * from the message bean instance or a javax.ejb.EJBException in the case
66      * that the bean throws a system exception. Note that exceptions are
67      * *always* propagated, regardless of transaction type.
68      */

69     Object JavaDoc deliverMessage(Object JavaDoc[] params) throws Throwable JavaDoc;
70
71     /**
72      * Post-delivery notification to the container. Container will perform
73      * any work required to commit/rollback a container-managed transaction.
74      * When this method returns, the thread's context class loader will be
75      * restored to the value it had when beforeMessageDelivery was called.
76      */

77     void afterMessageDelivery();
78
79     ResourceHandle getResourceHandle();
80
81     void setResourceHandle(ResourceHandle handle);
82
83 }
84
Popular Tags