1 /***
2 * Copyright 2003-2010 Terracotta, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package net.sf.ehcache.transaction.xa;
18
19 import javax.transaction.RollbackException;
20 import javax.transaction.SystemException;
21 import javax.transaction.xa.XAResource;
22
23 /***
24 * EhcacheXAResource represents an {@link net.sf.ehcache.Ehcache Ehcache} instance.
25 *
26 * @author Nabib El-Rahman
27 * @author Alex Snaps
28 */
29 public interface EhcacheXAResource extends XAResource {
30
31 /***
32 * Add a listener which will be called back according to the 2PC lifecycle
33 * @param listener the XAExecutionListener
34 */
35 void addTwoPcExecutionListener(XAExecutionListener listener);
36
37 /***
38 * Getter to the name of the cache wrapped by this XAResource
39 * @return {@link net.sf.ehcache.Ehcache#getName} value
40 */
41 String getCacheName();
42
43 /***
44 * Obtain the already associated {@link XATransactionContext} with the current Transaction,
45 * or create a new one should none be there yet.
46 * @return The associated Transaction associated {@link XATransactionContext}
47 * @throws SystemException Thrown if the associated transaction manager encounters an unexpected error condition.
48 * @throws RollbackException Thrown if the resource has to be enlisted with the transaction, while it is marked for rollback only.
49 */
50 XATransactionContext createTransactionContext() throws SystemException, RollbackException;
51
52 /***
53 * Gets the current {@link XATransactionContext} associated with this resource
54 * @return the current {@link XATransactionContext}, or null if none
55 */
56 XATransactionContext getCurrentTransactionContext();
57 }