[jboss-svn-commits] JBL Code SVN: r13035 - labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jul 3 06:41:01 EDT 2007
Author: mark.little at jboss.com
Date: 2007-07-03 06:41:01 -0400 (Tue, 03 Jul 2007)
New Revision: 13035
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCStore.java
Log:
removed unused imports.
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCStore.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCStore.java 2007-07-03 10:37:31 UTC (rev 13034)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/objectstore/JDBCStore.java 2007-07-03 10:41:01 UTC (rev 13035)
@@ -39,8 +39,6 @@
import com.arjuna.ats.arjuna.logging.tsLogger;
import com.arjuna.ats.arjuna.logging.FacilityCode;
-import com.arjuna.common.util.propertyservice.PropertyManager;
-import com.arjuna.ats.arjuna.gandiva.*;
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
import com.arjuna.ats.arjuna.objectstore.ObjectStoreImple;
import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
@@ -52,7 +50,6 @@
import com.arjuna.common.util.logging.DebugLevel;
import com.arjuna.common.util.logging.VisibilityLevel;
-import java.io.*;
import java.sql.*;
import java.util.HashMap;
@@ -63,728 +60,842 @@
import java.io.IOException;
/**
- * An object store implementation which uses a JDBC database for
- * maintaining object states. All states are maintained within a
- * single table.
- *
- * It is assumed that only one object will use a given instance of
- * the JDBCStore. Hence, there is no need for synchronizations.
- *
- * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1 [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1] - JDBCStore could not setup store < {0} , {1} >
- * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2 [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2] - Received: {0} for: {1}
- * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_3 [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_3] - JDBCStore.setupStore failed to initialise!
- * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_4 [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_4] - JDBCStore invalid ObjectName parameter: {0}
- * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_5 [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_5] - No JDBCAccess implementation provided!
-*/
+ * An object store implementation which uses a JDBC database for maintaining
+ * object states. All states are maintained within a single table.
+ *
+ * It is assumed that only one object will use a given instance of the
+ * JDBCStore. Hence, there is no need for synchronizations.
+ *
+ * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1
+ * [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1] - JDBCStore
+ * could not setup store < {0} , {1} >
+ * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2
+ * [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2] - Received:
+ * {0} for: {1}
+ * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_3
+ * [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_3] -
+ * JDBCStore.setupStore failed to initialise!
+ * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_4
+ * [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_4] - JDBCStore
+ * invalid ObjectName parameter: {0}
+ * @message com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_5
+ * [com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_5] - No
+ * JDBCAccess implementation provided!
+ */
public class JDBCStore extends ObjectStoreImple
{
- public String getStoreName ()
- {
- if (storeValid())
- return getAccessClassName() + ":" + getTableName();
- else
- return "Invalid";
- }
-
- public int typeIs ()
- {
- return ObjectStoreType.JDBC;
- }
-
- public boolean commit_state (Uid objUid, String tName) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public String getStoreName()
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, "JDBCStore.commit_state("+objUid+", "+tName+")");
+ if (storeValid())
+ return getAccessClassName() + ":" + getTableName();
+ else
+ return "Invalid";
}
-
- /* Bail out if the object store is not set up */
- if (!storeValid())
- return false;
- else
- return _theImple.commit_state(objUid, tName, getTableName());
- }
-
- public boolean hide_state (Uid objUid, String tName) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public int typeIs()
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, "ShadowingStore.hide_state("+objUid+", "+tName+")");
+ return ObjectStoreType.JDBC;
}
-
- /* Bail out if the object store is not set up */
- if (storeValid())
- return _theImple.hide_state(objUid, tName, getTableName());
- else
- return false;
- }
-
- public boolean reveal_state (Uid objUid, String tName) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public boolean commit_state(Uid objUid, String tName)
+ throws ObjectStoreException
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, "ShadowingStore.reveal_state("+objUid+", "+tName+")");
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "JDBCStore.commit_state(" + objUid + ", " + tName + ")");
+ }
+
+ /* Bail out if the object store is not set up */
+
+ if (!storeValid())
+ return false;
+ else
+ return _theImple.commit_state(objUid, tName, getTableName());
}
-
- if (storeValid())
- return _theImple.reveal_state(objUid, tName, getTableName());
- else
- return false;
- }
-
- /*
- * Determine current state of object.
- * State search is ordered OS_UNCOMMITTED, OS_UNCOMMITTED_HIDDEN, OS_COMMITTED, OS_COMMITTED_HIDDEN
- */
- public int currentState (Uid objUid, String tName) throws ObjectStoreException
- {
- if (storeValid())
- return _theImple.currentState(objUid, tName, getTableName());
- else
- return ObjectStore.OS_UNKNOWN;
- }
+ public boolean hide_state(Uid objUid, String tName)
+ throws ObjectStoreException
+ {
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "ShadowingStore.hide_state(" + objUid + ", " + tName + ")");
+ }
- /**
- * Read an uncommitted instance of State out of the object store.
- * The instance is identified by the unique id and type
- */
+ /* Bail out if the object store is not set up */
- public InputObjectState read_committed (Uid storeUid, String tName) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
- {
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, "JDBCStore.read_committed("+storeUid+", "+tName+")");
+ if (storeValid())
+ return _theImple.hide_state(objUid, tName, getTableName());
+ else
+ return false;
}
-
- return read_state(storeUid, tName, ObjectStore.OS_COMMITTED);
- }
- public InputObjectState read_uncommitted (Uid storeUid, String tName) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public boolean reveal_state(Uid objUid, String tName)
+ throws ObjectStoreException
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, "JDBCStore.read_uncommitted("+storeUid+", "+tName+")");
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "ShadowingStore.reveal_state(" + objUid + ", " + tName
+ + ")");
+ }
+
+ if (storeValid())
+ return _theImple.reveal_state(objUid, tName, getTableName());
+ else
+ return false;
}
-
- return read_state(storeUid, tName, ObjectStore.OS_UNCOMMITTED);
- }
- public boolean remove_committed (Uid storeUid, String tName) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ /*
+ * Determine current state of object. State search is ordered
+ * OS_UNCOMMITTED, OS_UNCOMMITTED_HIDDEN, OS_COMMITTED, OS_COMMITTED_HIDDEN
+ */
+
+ public int currentState(Uid objUid, String tName)
+ throws ObjectStoreException
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, "JDBCStore.remove_committed("+storeUid+", "+tName+")");
+ if (storeValid())
+ return _theImple.currentState(objUid, tName, getTableName());
+ else
+ return ObjectStore.OS_UNKNOWN;
}
-
- return remove_state(storeUid, tName, ObjectStore.OS_COMMITTED);
- }
- public boolean remove_uncommitted (Uid storeUid, String tName) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ /**
+ * Read an uncommitted instance of State out of the object store. The
+ * instance is identified by the unique id and type
+ */
+
+ public InputObjectState read_committed(Uid storeUid, String tName)
+ throws ObjectStoreException
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE,
- "JDBCStore.remove_uncommitted("+storeUid+", "+tName+")");
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger
+ .debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_OBJECT_STORE,
+ "JDBCStore.read_committed(" + storeUid + ", "
+ + tName + ")");
+ }
+
+ return read_state(storeUid, tName, ObjectStore.OS_COMMITTED);
}
-
- return remove_state(storeUid, tName, ObjectStore.OS_UNCOMMITTED);
- }
- public boolean write_committed (Uid storeUid, String tName, OutputObjectState state) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public InputObjectState read_uncommitted(Uid storeUid, String tName)
+ throws ObjectStoreException
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, "JDBCStore.write_committed("+storeUid+", "+tName+")");
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "JDBCStore.read_uncommitted(" + storeUid + ", " + tName
+ + ")");
+ }
+
+ return read_state(storeUid, tName, ObjectStore.OS_UNCOMMITTED);
}
-
- return write_state(storeUid, tName, state, ObjectStore.OS_COMMITTED);
- }
- public boolean write_uncommitted (Uid storeUid, String tName, OutputObjectState state) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public boolean remove_committed(Uid storeUid, String tName)
+ throws ObjectStoreException
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE,
- "JDBCStore.write_uncommitted("+storeUid+", "+tName+", "+state+")");
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "JDBCStore.remove_committed(" + storeUid + ", " + tName
+ + ")");
+ }
+
+ return remove_state(storeUid, tName, ObjectStore.OS_COMMITTED);
}
-
- return write_state(storeUid, tName, state, ObjectStore.OS_UNCOMMITTED);
- }
- public final boolean storeValid ()
- {
- return _isValid;
- }
+ public boolean remove_uncommitted(Uid storeUid, String tName)
+ throws ObjectStoreException
+ {
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "JDBCStore.remove_uncommitted(" + storeUid + ", " + tName
+ + ")");
+ }
- /*
- * Given a type name return an ObjectState that contains all of the
- * uids of objects of that type
- */
+ return remove_state(storeUid, tName, ObjectStore.OS_UNCOMMITTED);
+ }
- public boolean allObjUids (String tName, InputObjectState state, int match) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public boolean write_committed(Uid storeUid, String tName,
+ OutputObjectState state) throws ObjectStoreException
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE,
- "JDBCStore.allObjUids("+tName+", "+state+", "+match+")");
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "JDBCStore.write_committed(" + storeUid + ", " + tName
+ + ")");
+ }
+
+ return write_state(storeUid, tName, state, ObjectStore.OS_COMMITTED);
}
-
- if (storeValid())
- return _theImple.allObjUids(tName, state, match, getTableName());
- else
- return false;
- }
-
- public boolean allTypes (InputObjectState foundTypes) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+
+ public boolean write_uncommitted(Uid storeUid, String tName,
+ OutputObjectState state) throws ObjectStoreException
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, "JDBCStore.allTypes("+foundTypes+")");
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "JDBCStore.write_uncommitted(" + storeUid + ", " + tName
+ + ", " + state + ")");
+ }
+
+ return write_state(storeUid, tName, state, ObjectStore.OS_UNCOMMITTED);
}
-
- if (storeValid())
- return _theImple.allTypes(foundTypes, getTableName());
- else
- return false;
- }
- public synchronized void packInto (OutputBuffer buff) throws IOException
- {
- buff.packString(getAccessClassName());
- buff.packString(getTableName());
- }
-
- public synchronized void unpackFrom (InputBuffer buff) throws IOException
- {
- setAccessClassName(buff.unpackString());
- setTableName(buff.unpackString());
- }
-
- public ClassName className ()
- {
- return ArjunaNames.Implementation_ObjectStore_JDBCStore();
- }
-
- public static ClassName name ()
- {
- return ArjunaNames.Implementation_ObjectStore_JDBCStore();
- }
-
- protected InputObjectState read_state (Uid objUid, String tName, int ft) throws ObjectStoreException
- {
- if (!storeValid())
- return null;
- else
- return _theImple.read_state(objUid, tName, ft, getTableName());
- }
-
- /**
- * We don't actually delete the state entry, only change
- * its type.
- */
-
- protected boolean remove_state (Uid objUid, String name, int ft) throws ObjectStoreException
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public final boolean storeValid()
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PROTECTED,
- FacilityCode.FAC_OBJECT_STORE,
- "JDBCStore.remove_state("+objUid+", "+name+", "+ObjectStore.stateTypeString(ft)+")");
+ return _isValid;
}
-
- if (!storeValid())
- return false;
- else
- return _theImple.remove_state(objUid, name, ft, getTableName());
- }
-
- protected boolean write_state (Uid objUid, String tName, OutputObjectState state, int s) throws ObjectStoreException
- {
- if (!storeValid())
- return false;
- else
- return _theImple.write_state(objUid, tName, state, s, getTableName());
- }
- public static JDBCStore create ()
- {
- return new JDBCStore();
- }
+ /*
+ * Given a type name return an ObjectState that contains all of the uids of
+ * objects of that type
+ */
- public static JDBCStore create (Object[] param)
- {
- if (param == null)
- return null;
+ public boolean allObjUids(String tName, InputObjectState state, int match)
+ throws ObjectStoreException
+ {
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "JDBCStore.allObjUids(" + tName + ", " + state + ", "
+ + match + ")");
+ }
- return new JDBCStore((String) param[0]); /* param[0] should be the table name */
- }
+ if (storeValid())
+ return _theImple.allObjUids(tName, state, match, getTableName());
+ else
+ return false;
+ }
- public static JDBCStore create (ObjectName param)
- {
- if (param == null)
- return null;
+ public boolean allTypes(InputObjectState foundTypes)
+ throws ObjectStoreException
+ {
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ "JDBCStore.allTypes(" + foundTypes + ")");
+ }
- return new JDBCStore(param);
- }
+ if (storeValid())
+ return _theImple.allTypes(foundTypes, getTableName());
+ else
+ return false;
+ }
- protected JDBCStore ()
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public synchronized void packInto(OutputBuffer buff) throws IOException
{
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, getClass().getName() + "()");
+ buff.packString(getAccessClassName());
+ buff.packString(getTableName());
}
- try
+ public synchronized void unpackFrom(InputBuffer buff) throws IOException
{
- initialise("");
+ setAccessClassName(buff.unpackString());
+ setTableName(buff.unpackString());
}
- catch (Exception e)
+
+ public ClassName className()
{
- throw new ObjectStoreError();
+ return ArjunaNames.Implementation_ObjectStore_JDBCStore();
}
- }
- protected JDBCStore (String tableName)
- {
- if (tsLogger.arjLogger.debugAllowed())
+ public static ClassName name()
{
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, getClass().getName() + "(" + tableName + ")");
+ return ArjunaNames.Implementation_ObjectStore_JDBCStore();
}
-
- try
+
+ protected InputObjectState read_state(Uid objUid, String tName, int ft)
+ throws ObjectStoreException
{
- initialise(tableName);
+ if (!storeValid())
+ return null;
+ else
+ return _theImple.read_state(objUid, tName, ft, getTableName());
}
- catch (Exception e)
+
+ /**
+ * We don't actually delete the state entry, only change its type.
+ */
+
+ protected boolean remove_state(Uid objUid, String name, int ft)
+ throws ObjectStoreException
{
- throw new ObjectStoreError();
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PROTECTED,
+ FacilityCode.FAC_OBJECT_STORE, "JDBCStore.remove_state("
+ + objUid + ", " + name + ", "
+ + ObjectStore.stateTypeString(ft) + ")");
+ }
+
+ if (!storeValid())
+ return false;
+ else
+ return _theImple.remove_state(objUid, name, ft, getTableName());
}
- }
- protected JDBCStore (ObjectName objName)
- {
- if (tsLogger.arjLogger.debugAllowed())
+ protected boolean write_state(Uid objUid, String tName,
+ OutputObjectState state, int s) throws ObjectStoreException
{
- tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_OBJECT_STORE, getClass().getName() + "(" + objName + " )");
+ if (!storeValid())
+ return false;
+ else
+ return _theImple.write_state(objUid, tName, state, s,
+ getTableName());
}
-
- try
+
+ public static JDBCStore create()
{
- parseObjectName(objName);
+ return new JDBCStore();
}
- catch (Exception e)
+
+ public static JDBCStore create(Object[] param)
{
- throw new ObjectStoreError();
+ if (param == null)
+ return null;
+
+ return new JDBCStore((String) param[0]); /*
+ * param[0] should be the
+ * table name
+ */
}
- }
-
- /**
- * Get the JDBC access class name.
- * @return The access class name.
- */
- protected String getAccessClassName()
- {
- if (_jdbcAccessClassName == null)
- _jdbcAccessClassName = arjPropertyManager.propertyManager.getProperty(Environment.JDBC_USER_DB_ACCESS);
- return _jdbcAccessClassName;
- }
- /**
- * Set the JDBC access class name.
- * @param The access class name.
- */
- protected void setAccessClassName(String jdbcAccessClassName)
- {
- _jdbcAccessClassName = jdbcAccessClassName;
- }
+ public static JDBCStore create(ObjectName param)
+ {
+ if (param == null)
+ return null;
- /**
- * Get the JDBC default table name.
- * @return The default table name.
- */
- protected String getDefaultTableName()
- {
- return _defaultTableName;
- }
+ return new JDBCStore(param);
+ }
- /**
- * Get the JDBC access class name from an object.
- * @param The object name.
- * @return The access class name.
- */
- protected String getAccessClassNameFromObject(ObjectName objName) throws IOException
- {
- return objName.getStringAttribute(Environment.JDBC_USER_DB_ACCESS);
- }
+ protected JDBCStore()
+ {
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ getClass().getName() + "()");
+ }
- /**
- * Get the JDBC table name from an object.
- * @param The object name.
- * @return The table name.
- */
- protected String getTableNameFromObject(ObjectName objName) throws IOException
- {
- return objName.getStringAttribute(ArjunaNames.Implementation_ObjectStore_JDBC_tableName());
- }
+ try
+ {
+ initialise("");
+ }
+ catch (Exception e)
+ {
+ throw new ObjectStoreError();
+ }
+ }
- /**
- * Get the JDBC access class.
- * @return The jdbc access variable.
- */
- protected JDBCAccess getJDBCAccess()
- {
- return _jdbcAccess;
- }
+ protected JDBCStore(String tableName)
+ {
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ getClass().getName() + "(" + tableName + ")");
+ }
- /**
- * Set the JDBC access class.
- * @param jdbcAccess The jdbc access variable.
- */
- protected void setJDBCAccess(JDBCAccess jdbcAccess)
- {
- _jdbcAccess = jdbcAccess ;
- }
+ try
+ {
+ initialise(tableName);
+ }
+ catch (Exception e)
+ {
+ throw new ObjectStoreError();
+ }
+ }
- /**
- * Get the JDBC table name.
- * @return The table name.
- */
- protected String getTableName()
- {
- return _jdbcTableName;
- }
+ protected JDBCStore(ObjectName objName)
+ {
+ if (tsLogger.arjLogger.debugAllowed())
+ {
+ tsLogger.arjLogger.debug(DebugLevel.CONSTRUCTORS,
+ VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_OBJECT_STORE,
+ getClass().getName() + "(" + objName + " )");
+ }
- /**
- * Set the JDBC table name.
- * @param tableName The table name.
- */
- protected void setTableName(String tableName)
- {
- _jdbcTableName = tableName ;
- }
+ try
+ {
+ parseObjectName(objName);
+ }
+ catch (Exception e)
+ {
+ throw new ObjectStoreError();
+ }
+ }
- protected void initialise (String tableName) throws Exception
- {
- String jdbcAccessClassName = getAccessClassName();
-
- if (jdbcAccessClassName == null)
+ /**
+ * Get the JDBC access class name.
+ *
+ * @return The access class name.
+ */
+ protected String getAccessClassName()
{
- if (tsLogger.arjLoggerI18N.isFatalEnabled())
- tsLogger.arjLoggerI18N.fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_5");
+ if (_jdbcAccessClassName == null)
+ _jdbcAccessClassName = arjPropertyManager.propertyManager
+ .getProperty(Environment.JDBC_USER_DB_ACCESS);
+ return _jdbcAccessClassName;
+ }
- throw new FatalError(tsLogger.log_mesg.getString("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_5"));
+ /**
+ * Set the JDBC access class name.
+ *
+ * @param The
+ * access class name.
+ */
+ protected void setAccessClassName(String jdbcAccessClassName)
+ {
+ _jdbcAccessClassName = jdbcAccessClassName;
}
- try
+ /**
+ * Get the JDBC default table name.
+ *
+ * @return The default table name.
+ */
+ protected String getDefaultTableName()
{
- setupStore(jdbcAccessClassName, tableName);
+ return _defaultTableName;
}
- catch (Exception e)
+
+ /**
+ * Get the JDBC access class name from an object.
+ *
+ * @param The
+ * object name.
+ * @return The access class name.
+ */
+ protected String getAccessClassNameFromObject(ObjectName objName)
+ throws IOException
{
- if (tsLogger.arjLoggerI18N.isFatalEnabled())
- {
- tsLogger.arjLoggerI18N.fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1",
- new Object[]{getJDBCAccess(), getTableName()});
- }
- throw e;
+ return objName.getStringAttribute(Environment.JDBC_USER_DB_ACCESS);
}
- _isValid = true;
- }
-
- protected void parseObjectName (ObjectName objName) throws Exception
- {
- String jdbcAccessClassName, tableName;
- JDBCAccess jdbcAccess;
-
- if (objName == null)
+ /**
+ * Get the JDBC table name from an object.
+ *
+ * @param The
+ * object name.
+ * @return The table name.
+ */
+ protected String getTableNameFromObject(ObjectName objName)
+ throws IOException
{
- if (tsLogger.arjLoggerI18N.isFatalEnabled())
- {
- tsLogger.arjLoggerI18N.fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_4",
- new Object[]{"null"});
- }
- throw new Exception();
+ return objName.getStringAttribute(ArjunaNames
+ .Implementation_ObjectStore_JDBC_tableName());
}
- try
+ /**
+ * Get the JDBC access class.
+ *
+ * @return The jdbc access variable.
+ */
+ protected JDBCAccess getJDBCAccess()
{
- jdbcAccessClassName = getAccessClassNameFromObject(objName);
- tableName = getTableNameFromObject(objName);
+ return _jdbcAccess;
}
- catch (Exception e)
+
+ /**
+ * Set the JDBC access class.
+ *
+ * @param jdbcAccess
+ * The jdbc access variable.
+ */
+ protected void setJDBCAccess(JDBCAccess jdbcAccess)
{
- if (tsLogger.arjLoggerI18N.isFatalEnabled())
- {
- tsLogger.arjLoggerI18N.fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_4",
- new Object[]{objName});
- }
- throw e;
+ _jdbcAccess = jdbcAccess;
}
-
- try
+
+ /**
+ * Get the JDBC table name.
+ *
+ * @return The table name.
+ */
+ protected String getTableName()
{
- setupStore(jdbcAccessClassName, tableName);
+ return _jdbcTableName;
}
- catch (Exception e)
+
+ /**
+ * Set the JDBC table name.
+ *
+ * @param tableName
+ * The table name.
+ */
+ protected void setTableName(String tableName)
{
- if (tsLogger.arjLoggerI18N.isFatalEnabled())
- {
- tsLogger.arjLoggerI18N.fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1",
- new Object[]{getJDBCAccess(), getTableName()});
- }
- throw e;
+ _jdbcTableName = tableName;
}
- _isValid = true;
- }
-
- /*
- * Try to create the original and shadow/hidden tables. If this
- * fails, then we will exit.
- */
- protected void setupStore(String jdbcAccessClassName, String tableName) throws Exception
- {
- if (jdbcAccessClassName == null || jdbcAccessClassName.length() == 0)
- throw new ObjectStoreException() ;
+ protected void initialise(String tableName) throws Exception
+ {
+ String jdbcAccessClassName = getAccessClassName();
- final JDBCAccess jdbcAccess ;
- synchronized(_theAccesses)
+ if (jdbcAccessClassName == null)
+ {
+ if (tsLogger.arjLoggerI18N.isFatalEnabled())
+ tsLogger.arjLoggerI18N
+ .fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_5");
+
+ throw new FatalError(
+ tsLogger.log_mesg
+ .getString("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_5"));
+ }
+
+ try
+ {
+ setupStore(jdbcAccessClassName, tableName);
+ }
+ catch (Exception e)
+ {
+ if (tsLogger.arjLoggerI18N.isFatalEnabled())
+ {
+ tsLogger.arjLoggerI18N
+ .fatal(
+ "com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1",
+ new Object[]
+ { getJDBCAccess(), getTableName() });
+ }
+ throw e;
+ }
+
+ _isValid = true;
+ }
+
+ protected void parseObjectName(ObjectName objName) throws Exception
{
- final Object jdbcAccessObject = _theAccesses.get(jdbcAccessClassName) ;
- if (jdbcAccessObject != null)
- {
- jdbcAccess = (JDBCAccess)jdbcAccessObject ;
- }
- else
- {
- try
- {
- final Class jdbcAccessClass = Thread.currentThread().getContextClassLoader().loadClass(jdbcAccessClassName) ;
- jdbcAccess = (JDBCAccess)jdbcAccessClass.newInstance() ;
- }
- catch (final Exception ex)
- {
- if (tsLogger.arjLoggerI18N.isFatalEnabled())
- {
- tsLogger.arjLoggerI18N.fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2",
- new Object[]{ex, jdbcAccessClassName});
- }
- throw ex ;
- }
- _theAccesses.put(jdbcAccessClassName, jdbcAccess) ;
- }
- }
- setJDBCAccess(jdbcAccess) ;
-
- final String impleTableName ;
- if ((tableName != null) && (tableName.length() > 0))
- {
- impleTableName = tableName ;
- }
- else
- {
- final String jdbcAccessTableName = jdbcAccess.tableName() ;
- if ((jdbcAccessTableName != null) && (jdbcAccessTableName.length() > 0))
- {
- impleTableName = jdbcAccessTableName ;
- }
- else
- {
- impleTableName = getDefaultTableName() ;
- }
- }
-
- setTableName(impleTableName) ;
-
- final String impleKey = jdbcAccessClassName + ":" + impleTableName ;
-
- synchronized(_theImples)
- {
- final Object currentImple = _theImples.get(impleKey) ;
- if (currentImple != null)
- {
- _theImple = (JDBCImple)currentImple ;
- }
- else
- {
- try
- {
- /*
- * This had better not be an Arjuna jdbc connection!
- */
- final Connection connection ;
-
- try
- {
- connection = jdbcAccess.getConnection() ;
- }
- catch(final SQLException sqle)
- {
- if (tsLogger.arjLoggerI18N.isFatalEnabled())
- {
- tsLogger.arjLoggerI18N.fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2",
- new Object[]{sqle, "getConnection()"});
- }
- throw sqle;
- }
-
- if (connection == null)
- {
- if (tsLogger.arjLoggerI18N.isFatalEnabled())
- {
- tsLogger.arjLoggerI18N.fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1",
- new Object[]{getJDBCAccess(), getTableName()});
- }
- throw new SQLException("getConnection returned null");
- }
- boolean success = false ;
- try
- {
- connection.setAutoCommit(true) ;
- final JDBCImple jdbcImple ;
- try
- {
- final Class jdbcImpleClass = getJDBCClass(connection) ;
- jdbcImple = (JDBCImple)jdbcImpleClass.newInstance() ;
- jdbcImple.setShareStatus(shareStatus) ;
- }
- catch (final Exception ex)
- {
- if (tsLogger.arjLoggerI18N.isFatalEnabled())
- {
- tsLogger.arjLoggerI18N.fatal("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2",
- new Object[]{ex, getJDBCAccess()}) ;
- }
- throw ex ;
- }
-
- if (!jdbcImple.initialise(connection, jdbcAccess, impleTableName))
- {
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_3") ;
- throw new ObjectStoreException() ;
- }
- else
- {
- _theImples.put(impleKey, jdbcImple);
- _theImple = jdbcImple ;
- success = true ;
- }
- }
- finally
- {
- if (!success)
- {
- try
- {
- connection.close() ;
- }
- catch (final SQLException sqle) {} // Ignore exception
- }
- }
- }
- catch (Exception e)
- {
- tsLogger.arjLogger.warn(e.toString());
- throw e;
- }
- }
- _isValid = true ;
- }
- }
+ String jdbcAccessClassName, tableName;
+ JDBCAccess jdbcAccess;
- /**
- * Attempt to load the database class. This method searches for a
- * class called <name>_<major>_<minor>, then <name>_<major> and
- * finally <dbName>
- *
- * @param conn A database connection.
- * @return The database class.
- * @throws ClassNotFoundException If no database class can be found.
- * @throws SQLException If the database connection cannot be interrogated.
- */
- protected Class getJDBCClass(Connection conn)
- throws ClassNotFoundException, SQLException
- {
- DatabaseMetaData md = conn.getMetaData();
+ if (objName == null)
+ {
+ if (tsLogger.arjLoggerI18N.isFatalEnabled())
+ {
+ tsLogger.arjLoggerI18N
+ .fatal(
+ "com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_4",
+ new Object[]
+ { "null" });
+ }
+ throw new Exception();
+ }
- String name = md.getDriverName();
- int major = md.getDriverMajorVersion();
- int minor = md.getDriverMinorVersion();
+ try
+ {
+ jdbcAccessClassName = getAccessClassNameFromObject(objName);
+ tableName = getTableNameFromObject(objName);
+ }
+ catch (Exception e)
+ {
+ if (tsLogger.arjLoggerI18N.isFatalEnabled())
+ {
+ tsLogger.arjLoggerI18N
+ .fatal(
+ "com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_4",
+ new Object[]
+ { objName });
+ }
+ throw e;
+ }
+ try
+ {
+ setupStore(jdbcAccessClassName, tableName);
+ }
+ catch (Exception e)
+ {
+ if (tsLogger.arjLoggerI18N.isFatalEnabled())
+ {
+ tsLogger.arjLoggerI18N
+ .fatal(
+ "com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1",
+ new Object[]
+ { getJDBCAccess(), getTableName() });
+ }
+ throw e;
+ }
+
+ _isValid = true;
+ }
+
/*
- * Check for spaces in the name - our implementation classes
- * are always just the first part of such names.
+ * Try to create the original and shadow/hidden tables. If this fails, then
+ * we will exit.
*/
+ protected void setupStore(String jdbcAccessClassName, String tableName)
+ throws Exception
+ {
+ if (jdbcAccessClassName == null || jdbcAccessClassName.length() == 0)
+ throw new ObjectStoreException();
- int index = name.indexOf(' ');
+ final JDBCAccess jdbcAccess;
+ synchronized (_theAccesses)
+ {
+ final Object jdbcAccessObject = _theAccesses
+ .get(jdbcAccessClassName);
+ if (jdbcAccessObject != null)
+ {
+ jdbcAccess = (JDBCAccess) jdbcAccessObject;
+ }
+ else
+ {
+ try
+ {
+ final Class jdbcAccessClass = Thread.currentThread()
+ .getContextClassLoader().loadClass(
+ jdbcAccessClassName);
+ jdbcAccess = (JDBCAccess) jdbcAccessClass.newInstance();
+ }
+ catch (final Exception ex)
+ {
+ if (tsLogger.arjLoggerI18N.isFatalEnabled())
+ {
+ tsLogger.arjLoggerI18N
+ .fatal(
+ "com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2",
+ new Object[]
+ { ex, jdbcAccessClassName });
+ }
+ throw ex;
+ }
+ _theAccesses.put(jdbcAccessClassName, jdbcAccess);
+ }
+ }
+ setJDBCAccess(jdbcAccess);
- if (index != -1)
- name = name.substring(0, index);
+ final String impleTableName;
+ if ((tableName != null) && (tableName.length() > 0))
+ {
+ impleTableName = tableName;
+ }
+ else
+ {
+ final String jdbcAccessTableName = jdbcAccess.tableName();
+ if ((jdbcAccessTableName != null)
+ && (jdbcAccessTableName.length() > 0))
+ {
+ impleTableName = jdbcAccessTableName;
+ }
+ else
+ {
+ impleTableName = getDefaultTableName();
+ }
+ }
- name = name.toLowerCase();
-
- final ClassLoader classLoader = Thread.currentThread().getContextClassLoader() ;
- final String packageName = getClass().getPackage().getName() + ".jdbc." ;
- try
- {
- return classLoader.loadClass(packageName + name + "_" + major + "_" + minor + "_driver") ;
- }
- catch (final ClassNotFoundException cnfe)
+ setTableName(impleTableName);
+
+ final String impleKey = jdbcAccessClassName + ":" + impleTableName;
+
+ synchronized (_theImples)
+ {
+ final Object currentImple = _theImples.get(impleKey);
+ if (currentImple != null)
+ {
+ _theImple = (JDBCImple) currentImple;
+ }
+ else
+ {
+ try
+ {
+ /*
+ * This had better not be an Arjuna jdbc connection!
+ */
+ final Connection connection;
+
+ try
+ {
+ connection = jdbcAccess.getConnection();
+ }
+ catch (final SQLException sqle)
+ {
+ if (tsLogger.arjLoggerI18N.isFatalEnabled())
+ {
+ tsLogger.arjLoggerI18N
+ .fatal(
+ "com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2",
+ new Object[]
+ { sqle, "getConnection()" });
+ }
+ throw sqle;
+ }
+
+ if (connection == null)
+ {
+ if (tsLogger.arjLoggerI18N.isFatalEnabled())
+ {
+ tsLogger.arjLoggerI18N
+ .fatal(
+ "com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_1",
+ new Object[]
+ { getJDBCAccess(), getTableName() });
+ }
+ throw new SQLException("getConnection returned null");
+ }
+ boolean success = false;
+ try
+ {
+ connection.setAutoCommit(true);
+ final JDBCImple jdbcImple;
+ try
+ {
+ final Class jdbcImpleClass = getJDBCClass(connection);
+ jdbcImple = (JDBCImple) jdbcImpleClass
+ .newInstance();
+ jdbcImple.setShareStatus(shareStatus);
+ }
+ catch (final Exception ex)
+ {
+ if (tsLogger.arjLoggerI18N.isFatalEnabled())
+ {
+ tsLogger.arjLoggerI18N
+ .fatal(
+ "com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_2",
+ new Object[]
+ { ex, getJDBCAccess() });
+ }
+ throw ex;
+ }
+
+ if (!jdbcImple.initialise(connection, jdbcAccess,
+ impleTableName))
+ {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ tsLogger.arjLoggerI18N
+ .warn("com.arjuna.ats.internal.arjuna.objectstore.JDBCStore_3");
+ throw new ObjectStoreException();
+ }
+ else
+ {
+ _theImples.put(impleKey, jdbcImple);
+ _theImple = jdbcImple;
+ success = true;
+ }
+ }
+ finally
+ {
+ if (!success)
+ {
+ try
+ {
+ connection.close();
+ }
+ catch (final SQLException sqle)
+ {
+ } // Ignore exception
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tsLogger.arjLogger.warn(e.toString());
+ throw e;
+ }
+ }
+ _isValid = true;
+ }
+ }
+
+ /**
+ * Attempt to load the database class. This method searches for a
+ * class called <name>_<major>_<minor>, then <name>_<major> and finally
+ * <dbName>
+ *
+ * @param conn
+ * A database connection.
+ * @return The database class.
+ * @throws ClassNotFoundException
+ * If no database class can be found.
+ * @throws SQLException
+ * If the database connection cannot be interrogated.
+ */
+ protected Class getJDBCClass(Connection conn)
+ throws ClassNotFoundException, SQLException
{
+ DatabaseMetaData md = conn.getMetaData();
+
+ String name = md.getDriverName();
+ int major = md.getDriverMajorVersion();
+ int minor = md.getDriverMinorVersion();
+
+ /*
+ * Check for spaces in the name - our implementation classes are always
+ * just the first part of such names.
+ */
+
+ int index = name.indexOf(' ');
+
+ if (index != -1)
+ name = name.substring(0, index);
+
+ name = name.toLowerCase();
+
+ final ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ final String packageName = getClass().getPackage().getName() + ".jdbc.";
+ try
+ {
+ return classLoader.loadClass(packageName + name + "_" + major + "_"
+ + minor + "_driver");
+ }
+ catch (final ClassNotFoundException cnfe)
+ {
+ }
+ try
+ {
+ return classLoader.loadClass(packageName + name + "_" + major
+ + "_driver");
+ }
+ catch (final ClassNotFoundException cnfe)
+ {
+ }
+ return classLoader.loadClass(packageName + name + "_driver");
}
- try
- {
- return classLoader.loadClass(packageName + name + "_" + major + "_driver") ;
- }
- catch (final ClassNotFoundException cnfe)
+
+ protected boolean supressEntry(String name)
{
+ return true;
}
- return classLoader.loadClass(packageName + name + "_driver") ;
- }
-
- protected boolean supressEntry (String name)
- {
- return true;
- }
+ /*
+ * Instance specific data.
+ */
- /*
- * Instance specific data.
- */
+ protected boolean _isValid;
- protected boolean _isValid;
- protected JDBCImple _theImple;
+ protected JDBCImple _theImple;
- private JDBCAccess _jdbcAccess;
- private String _jdbcAccessClassName;
- private String _jdbcTableName;
- private static String _defaultTableName = "JBossTSTable";
+ private JDBCAccess _jdbcAccess;
- /*
- * Class data.
- */
+ private String _jdbcAccessClassName;
- protected static final HashMap _theImples = new HashMap();
- protected static final HashMap _theAccesses = new HashMap();
+ private String _jdbcTableName;
+
+ private static String _defaultTableName = "JBossTSTable";
+
+ /*
+ * Class data.
+ */
+
+ protected static final HashMap _theImples = new HashMap();
+
+ protected static final HashMap _theAccesses = new HashMap();
}
More information about the jboss-svn-commits
mailing list