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 package net.sf.ehcache.transaction.manager;
17
18 import javax.transaction.TransactionManager;
19
20 import net.sf.ehcache.transaction.xa.EhcacheXAResource;
21
22 import java.util.Properties;
23
24 /***
25 * Interface to enable a XA transactional cache to access the JTA TransactionManager.
26 * The implementing class can be configured in your xml file. It will then be instanciated by the Cache, during
27 * {@link net.sf.ehcache.Cache#initialise() initialization}. It'll then have the properties injected, should any have been specified. And finally,
28 * the TransactionManager will be queried for using #getTransactionManager.
29 *
30 * @author Alex Snaps
31 */
32 public interface TransactionManagerLookup {
33
34 /***
35 * Lookup available txnManagers
36 * @return TransactionManager
37 */
38 TransactionManager getTransactionManager();
39
40 /***
41 * execute txnManager specific code to register the XAResource for recovery.
42 * @param resource the XAResource to register for recovery in the choosen TM.
43 */
44 void register(EhcacheXAResource resource);
45
46 /***
47 * execute txnManager specific code to unregister the XAResource for recovery.
48 * @param resource the XAResource to register for recovery in the choosen TM.
49 */
50 void unregister(EhcacheXAResource resource);
51
52 /***
53 * Setter to the properties properties. This will be called right after the class has been instantiated.
54 *
55 * @param properties the properties parsed from the config file's
56 * transactionManagerLookup tag's properties attribute
57 */
58 void setProperties(Properties properties);
59 }