001 /** 002 * 003 * Copyright 2004 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 package org.apache.geronimo.transaction.manager; 019 020 import javax.transaction.xa.XAResource; 021 import javax.transaction.xa.Xid; 022 import javax.transaction.xa.XAException; 023 024 import org.apache.geronimo.transaction.manager.NamedXAResource; 025 026 /** 027 * 028 * 029 * @version $Rev: 355877 $ $Date: 2005-12-10 18:48:27 -0800 (Sat, 10 Dec 2005) $ 030 * 031 * */ 032 public class WrapperNamedXAResource implements NamedXAResource { 033 034 private final XAResource xaResource; 035 private final String name; 036 037 public WrapperNamedXAResource(XAResource xaResource, String name) { 038 this.xaResource = xaResource; 039 this.name = name; 040 } 041 042 public String getName() { 043 return name; 044 } 045 046 public void commit(Xid xid, boolean onePhase) throws XAException { 047 xaResource.commit(xid, onePhase); 048 } 049 050 public void end(Xid xid, int flags) throws XAException { 051 xaResource.end(xid, flags); 052 } 053 054 public void forget(Xid xid) throws XAException { 055 xaResource.forget(xid); 056 } 057 058 public int getTransactionTimeout() throws XAException { 059 return xaResource.getTransactionTimeout(); 060 } 061 062 public boolean isSameRM(XAResource other) throws XAException { 063 if (other instanceof WrapperNamedXAResource) { 064 return xaResource.isSameRM(((WrapperNamedXAResource)other).xaResource); 065 } 066 return false; 067 } 068 069 public int prepare(Xid xid) throws XAException { 070 return xaResource.prepare(xid); 071 } 072 073 public Xid[] recover(int flag) throws XAException { 074 return xaResource.recover(flag); 075 } 076 077 public void rollback(Xid xid) throws XAException { 078 xaResource.rollback(xid); 079 } 080 081 public boolean setTransactionTimeout(int seconds) throws XAException { 082 return xaResource.setTransactionTimeout(seconds); 083 } 084 085 public void start(Xid xid, int flags) throws XAException { 086 xaResource.start(xid, flags); 087 } 088 } 089 090