KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > container > mdb > MDBMessageEndPoint


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: MDBMessageEndPoint.java 1132 2006-09-29 13:56:41Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.container.mdb;
27
28 import java.lang.reflect.Method JavaDoc;
29
30 import javax.resource.ResourceException JavaDoc;
31 import javax.resource.spi.endpoint.MessageEndpoint JavaDoc;
32 import javax.transaction.xa.XAResource JavaDoc;
33
34 import org.objectweb.easybeans.api.Factory;
35 import org.objectweb.easybeans.api.bean.EasyBeansMDB;
36
37 /**
38  * Implementation of the MessageEndPoint interface.<br/> These methods will be
39  * called by the Resource Adapter.
40  * @author Florent Benoit
41  */

42 public class MDBMessageEndPoint implements MessageEndpoint JavaDoc {
43
44     /**
45      * MDB object Wrapped by this message end point.
46      */

47     private EasyBeansMDB easyBeansMDB = null;
48
49     /**
50      * Reference to the message end point factory.
51      */

52     private MDBMessageEndPointFactory mdbMessageEndPointFactory = null;
53
54     /**
55      * XAResource of this message end point. This resource will be
56      * enlisted/delisted.
57      */

58     private XAResource JavaDoc xaResource = null;
59
60     /**
61      * Constructor : Build an endpoint with a reference to the message end point
62      * factory.
63      * @param mdbMessageEndPointFactory the message end point factory.
64      * @param easyBeansMDB the message driven bean object that is wrapped.
65      */

66     public MDBMessageEndPoint(final MDBMessageEndPointFactory mdbMessageEndPointFactory, final EasyBeansMDB easyBeansMDB) {
67         this.mdbMessageEndPointFactory = mdbMessageEndPointFactory;
68         this.easyBeansMDB = easyBeansMDB;
69     }
70
71     /**
72      * This is called by a resource adapter before a message is delivered.
73      * @param method description of a target method. This information about the
74      * intended target method allows an application server to decide
75      * whether to start a transaction during this method call, depending
76      * on the transaction preferences of the target method. The
77      * processing (by the application server) of the actual message
78      * delivery method call on the endpoint must be independent of the
79      * class loader associated with this descriptive method object.
80      * @throws NoSuchMethodException - indicates that the specified method does
81      * not exist on the target endpoint.
82      * @throws ResourceException - generic exception.
83      * @throws ApplicationServerInternalException - indicates an error condition
84      * in the application server.
85      * @throws IllegalStateException - indicates that the endpoint is in an
86      * illegal state for the method invocation. For example, this occurs
87      * when beforeDelivery and afterDelivery method calls are not
88      * paired.
89      * @throws UnavailableException - indicates that the endpoint is not
90      * available.
91      */

92     public void beforeDelivery(Method JavaDoc method) throws NoSuchMethodException JavaDoc, ResourceException JavaDoc {
93         //TODO : implement this !
94
throw new UnsupportedOperationException JavaDoc("Not implemented");
95     }
96
97     /**
98      * This is called by a resource adapter after a message is delivered.
99      * @throws ResourceException - generic exception.
100      * @throws ApplicationServerInternalException - indicates an error condition
101      * in the application server.
102      * @throws IllegalStateException - indicates that the endpoint is in an
103      * illegal state for the method invocation. For example, this occurs
104      * when beforeDelivery and afterDelivery method calls are not
105      * paired.
106      * @throws UnavailableException - indicates that the endpoint is not
107      * available.
108      */

109     public void afterDelivery() throws ResourceException JavaDoc {
110         //TODO : implement this !
111
throw new UnsupportedOperationException JavaDoc("Not implemented");
112     }
113
114     /**
115      * This method may be called by the resource adapter to indicate that it no
116      * longer needs a proxy endpoint instance. This hint may be used by the
117      * application server for endpoint pooling decisions.
118      */

119     public void release() {
120         mdbMessageEndPointFactory.releaseEndPoint(this);
121     }
122
123     /**
124      * Gets the factory of the bean.
125      * @return factory of the bean.
126      */

127     public Factory getEasyBeansFactory() {
128         return mdbMessageEndPointFactory;
129     }
130
131
132     /**
133      * Gets the wrapped Message Driven Bean object.
134      * @return wrapped Message Driven Bean object.
135      */

136     public EasyBeansMDB getEasyBeansMDB() {
137         return easyBeansMDB;
138     }
139
140     /**
141      * Gets the XAResource of this message end point.
142      * @return the XAResource of this message end point
143      */

144     protected XAResource JavaDoc getXaResource() {
145         return xaResource;
146     }
147
148     /**
149      * Sets the XAResource of this message end point.
150      * @param xaResource the XAResource of this message end point
151      */

152     protected void setXaResource(XAResource JavaDoc xaResource) {
153         this.xaResource = xaResource;
154     }
155 }
156
Popular Tags