Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags.
   * See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
   * of the GNU Lesser General Public License, v. 2.1.
  * This program is distributed in the hope that it will be useful, but WITHOUT A
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public License,
  * v.2.1 along with this distribution; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
  *
  * (C) 2005-2006,
  * @author JBoss Inc.
  */
 /*
  * Copyright (C) 2000, 2001,
  *
  * Arjuna Solutions Limited,
  * Newcastle upon Tyne,
  * Tyne and Wear,
  * UK.
  *
  * $Id: JDBCStore.java 2342 2006-03-30 13:06:17Z  $
  */
 
 package com.arjuna.ats.internal.arjuna.objectstore.jdbc;
 
 import java.util.Map;
 
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.
 
 
 public class JDBCStore implements ObjectStoreAPI {
     protected JDBCImple_driver _theImple;
     private static final String DEFAULT_TABLE_NAME = "JBossTSTxTable";
     protected String tableName;
     private String _storeName;
     private static Map<StringJDBCImple_driverimples = new HashMap<StringJDBCImple_driver>();
     private static Map<StringStringstoreNames = new HashMap<StringString>();
 
     @Override
     public void start() {
     }
 
     @Override
     public void stop() {
     }

    
Does this store need to do the full write_uncommitted/commit protocol?

Returns:
true if full commit is needed, false otherwise.
 
 
     public boolean fullCommitNeeded() {
         return true;
     }

    
Some object store implementations may be running with automatic sync disabled. Calling this method will ensure that any states are flushed to disk.
 
 
     public void sync() throws java.io.SyncFailedExceptionObjectStoreException {
     }

    
Is the current state of the object the same as that provided as the last parameter?

Parameters:
u The object to work on.
tn The type of the object.
st The expected type of the object.
Returns:
true if the current state is as expected, false otherwise.
    public boolean isType(Uid uString tnint stthrows ObjectStoreException {
        return (currentState(utn) == st);
    }
    public String getStoreName() {
        return ;
    }
    public boolean allObjUids(String sInputObjectState buffthrows ObjectStoreException {
        return allObjUids(sbuff.);
    }
    public boolean commit_state(Uid objUidString tNamethrows ObjectStoreException {
        return .commit_state(objUidtName);
    }
    public boolean hide_state(Uid objUidString tNamethrows ObjectStoreException {
        return .hide_state(objUidtName);
    }
    public boolean reveal_state(Uid objUidString tNamethrows ObjectStoreException {
        return .reveal_state(objUidtName);
    }
    public int currentState(Uid objUidString tNamethrows ObjectStoreException {
        return .currentState(objUidtName);
    }
    public InputObjectState read_committed(Uid storeUidString tNamethrows ObjectStoreException {
        return .read_state(storeUidtName.);
    }
    public InputObjectState read_uncommitted(Uid storeUidString tNamethrows ObjectStoreException {
        return .read_state(storeUidtName.);
    }
    public boolean remove_committed(Uid storeUidString tNamethrows ObjectStoreException {
        return .remove_state(storeUidtName.);
    }
    public boolean remove_uncommitted(Uid storeUidString tNamethrows ObjectStoreException {
        return .remove_state(storeUidtName.);
    }
    public boolean write_committed(Uid storeUidString tNameOutputObjectState statethrows ObjectStoreException {
        return .write_state(storeUidtNamestate.);
    }
    public boolean write_uncommitted(Uid storeUidString tNameOutputObjectState statethrows ObjectStoreException {
        return .write_state(storeUidtNamestate.);
    }
    public boolean allObjUids(String tNameInputObjectState stateint matchthrows ObjectStoreException {
        return .allObjUids(tNamestatematch);
    }
    public boolean allTypes(InputObjectState foundTypesthrows ObjectStoreException {
        return .allTypes(foundTypes);
    }
    public synchronized void packInto(OutputBuffer buffthrows IOException {
        buff.packString();
    }
    public synchronized void unpackFrom(InputBuffer buffthrows IOException {
        this. = buff.unpackString();
    }

    
Create a new JDBCStore

Parameters:
jdbcStoreEnvironmentBean The environment bean containing the configuration
Throws:
com.arjuna.ats.arjuna.exceptions.ObjectStoreException In case the store environment bean was not correctly configured
FatalError In case the configured store cannot be connected to
    public JDBCStore(ObjectStoreEnvironmentBean jdbcStoreEnvironmentBeanthrows ObjectStoreException {
        this. = jdbcStoreEnvironmentBean;
        String connectionDetails = jdbcStoreEnvironmentBean.getJdbcAccess();
        String key;
        if (connectionDetails == null) {
        }
        String impleTableName = ;
        final String tablePrefix = jdbcStoreEnvironmentBean.getTablePrefix();
        if ((tablePrefix != null) && (tablePrefix.length() > 0)) {
            impleTableName = tablePrefix + impleTableName;
        }
         = impleTableName;
		key = connectionDetails + ;
         = .get(key);
         = .get(key);
        if ( == null) {
            try {
                StringTokenizer stringTokenizer = new StringTokenizer(connectionDetails";");
                JDBCAccess jdbcAccess = (JDBCAccess) Class.forName(stringTokenizer.nextToken()).newInstance();
                jdbcAccess.initialise(stringTokenizer);
                 = jdbcAccess.getClass().getName() + ":" + ;
                Connection connection = jdbcAccess.getConnection();
                String name;
                int major;
                int minor;
                try {
                    DatabaseMetaData md = connection.getMetaData();
                    name = md.getDriverName();
                    major = md.getDriverMajorVersion();
                    minor = md.getDriverMinorVersion();
                } finally {
                    connection.close();
                }
                /*
                 * 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.replaceAll("-""_");
                name = name.toLowerCase();
                final String packagePrefix = JDBCStore.class.getName().substring(0, JDBCStore.class.getName().lastIndexOf('.')) + ".drivers.";
                Class jdbcImpleClass = null;
                try {
                    jdbcImpleClass = Class.forName(packagePrefix + name + "_" + major + "_" + minor + "_driver");
                } catch (final ClassNotFoundException cnfe) {
                    try {
                        jdbcImpleClass = Class.forName(packagePrefix + name + "_" + major + "_driver");
                    } catch (final ClassNotFoundException cnfe2) {
                        jdbcImpleClass = Class.forName(packagePrefix + name + "_driver");
                    }
                }
                 = (com.arjuna.ats.internal.arjuna.objectstore.jdbc.JDBCImple_driverjdbcImpleClass.newInstance();
                .initialise(jdbcAccessjdbcStoreEnvironmentBean);
                .put(key);
                .put(key);
            } catch (Exception e) {
                ..fatal_objectstore_JDBCStore_2(e);
                throw new ObjectStoreException(e);
            }
        }
    }
New to GrepCode? Check out our FAQ X