1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 *
4 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
5 *
6 * The contents of this file are subject to the terms of either the GNU
7 * General Public License Version 2 only ("GPL") or the Common Development
8 * and Distribution License("CDDL") (collectively, the "License"). You
9 * may not use this file except in compliance with the License. You can obtain
10 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
11 * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
12 * language governing permissions and limitations under the License.
13 *
14 * When distributing the software, include this License Header Notice in each
15 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
16 * Sun designates this particular file as subject to the "Classpath" exception
17 * as provided by Sun in the GPL Version 2 section of the License file that
18 * accompanied this code. If applicable, add the following below the License
19 * Header, with the fields enclosed by brackets [] replaced by your own
20 * identifying information: "Portions Copyrighted [year]
21 * [name of copyright owner]"
22 *
23 * Contributor(s):
24 *
25 * If you wish your version of this file to be governed by only the CDDL or
26 * only the GPL Version 2, indicate your decision by adding "[Contributor]
27 * elects to include this software in this distribution under the [CDDL or GPL
28 * Version 2] license." If you don't indicate a single choice of license, a
29 * recipient has the option to distribute your version of this file under
30 * either the CDDL, the GPL Version 2 or to extend the choice of license to
31 * its licensees as provided above. However, if you add GPL Version 2 code
32 * and therefore, elected the GPL Version 2 license, then the option applies
33 * only if the new code is made subject to such option by the copyright
34 * holder.
35 */
36
37 package javax.resource.spi.endpoint;
38
39 import java.lang.NoSuchMethodException;
40 import javax.resource.ResourceException;
41 import javax.resource.spi.ResourceAdapterInternalException;
42 import javax.resource.spi.ApplicationServerInternalException;
43 import javax.resource.spi.IllegalStateException;
44 import javax.resource.spi.UnavailableException;
45
46 /**
47 * This defines a contract for a message endpoint. This is implemented by an
48 * application server.
49 *
50 * @version 1.0
51 * @author Ram Jeyaraman
52 */
53 public interface MessageEndpoint {
54
55 /**
56 * This is called by a resource adapter before a message is delivered.
57 *
58 * @param method description of a target method. This information about
59 * the intended target method allows an application server to decide
60 * whether to start a transaction during this method call, depending
61 * on the transaction preferences of the target method.
62 * The processing (by the application server) of the actual message
63 * delivery method call on the endpoint must be independent of the
64 * class loader associated with this descriptive method object.
65 *
66 * @throws NoSuchMethodException indicates that the specified method
67 * does not exist on the target endpoint.
68 *
69 * @throws ResourceException generic exception.
70 *
71 * @throws ApplicationServerInternalException indicates an error
72 * condition in the application server.
73 *
74 * @throws IllegalStateException indicates that the endpoint is in an
75 * illegal state for the method invocation. For example, this occurs when
76 * <code>beforeDelivery</code> and <code>afterDelivery</code>
77 * method calls are not paired.
78 *
79 * @throws UnavailableException indicates that the endpoint is not
80 * available.
81 */
82 void beforeDelivery(java.lang.reflect.Method method)
83 throws NoSuchMethodException, ResourceException;
84
85 /**
86 * This is called by a resource adapter after a message is delivered.
87 *
88 * @throws ResourceException generic exception.
89 *
90 * @throws ApplicationServerInternalException indicates an error
91 * condition in the application server.
92 *
93 * @throws IllegalStateException indicates that the endpoint is in an
94 * illegal state for the method invocation. For example, this occurs when
95 * beforeDelivery and afterDelivery method calls are not paired.
96 *
97 * @throws UnavailableException indicates that the endpoint is not
98 * available.
99 */
100 void afterDelivery() throws ResourceException;
101
102 /**
103 * This method may be called by the resource adapter to indicate that it
104 * no longer needs a proxy endpoint instance. This hint may be used by
105 * the application server for endpoint pooling decisions.
106 */
107 void release();
108 }