MCInfo.java

00001 /*
00002  * JOnAS: Java(TM) Open Application Server
00003  * Copyright (C) 1999 Bull S.A.
00004  * Contact: jonas-team@objectweb.org
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00019  * USA
00020  *
00021  * --------------------------------------------------------------------------
00022  * $Id: MCInfo.java,v 1.7 2004/10/29 23:33:37 ehardesty Exp $
00023  * --------------------------------------------------------------------------
00024  */
00025 
00026 package org.objectweb.jonas.resource;
00027 
00028 import java.util.HashSet;
00029 import java.util.Vector;
00030 import javax.resource.ResourceException;
00031 import javax.resource.spi.ManagedConnection;
00032 import javax.transaction.Synchronization;
00033 import javax.transaction.xa.XAResource;
00034 
00041 public class MCInfo {
00045     public ManagedConnection mc;
00046 
00050     public Vector usedCs = null;
00051 
00055     public RMEImpl rme = null;
00056 
00060     public boolean rmeCalled = false;
00061 
00065     public boolean localTransaction = false;
00066 
00071     public LocalXAWrapper lw = null;
00072 
00080     public Object ctx;
00081 
00086     public Synchronization synchro = null;
00087 
00092     public Vector pStmts = null;
00093 
00098     public HashSet stmtHash = null;
00099 
00100 
00104     public boolean connectionEventListener = false;
00105 
00110     public MCInfo(ManagedConnection mc) {
00111         this.mc = mc;
00112         localTransaction = false;
00113         usedCs = new Vector();
00114         pStmts = new Vector();
00115         stmtHash = new HashSet();
00116     }
00117 
00118 
00125     public String getState(String prefix) {
00126         String res = prefix + "* mc=" + mc + "\n";
00127         res += prefix + "Context=" + ctx + "\n";
00128         res += prefix + "size of usedCs:" + usedCs.size() + "\n";
00129         for (int i = 0; i < usedCs.size(); i++) {
00130             res += prefix + "\t" + usedCs.elementAt(i).toString() + "\n";
00131         }
00132         res += prefix + "size of pStmts:" + pStmts.size() + "\n";
00133         for (int i = 0; i < pStmts.size(); i++) {
00134             res += prefix + "\t" + pStmts.elementAt(i).toString() + "\n";
00135         }
00136         return res;
00137     }
00138 
00139 
00144     public String getState() {
00145         return getState("");
00146     }
00147 
00152     public boolean isFreeStmt() {
00153         Object obj = pStmts.firstElement();
00154         if (stmtHash.contains(obj)) {
00155             return false;
00156         }
00157         return true;
00158     }
00159 
00164     public void destroy() throws Exception {
00165         mc.destroy();
00166     }
00167 
00173     public XAResource getXAResource() throws ResourceException {
00174         if (lw != null) {
00175             return lw;
00176         } else {
00177             return mc.getXAResource();
00178         }
00179     }
00180 }
00181 
00182 

Generated on Tue Feb 15 15:05:19 2005 for JOnAS by  doxygen 1.3.9.1