From: <th...@us...> - 2002-08-23 14:24:13
|
Update of /cvsroot/struts/artimus/WEB-INF/src/java/org/apache/artimus/keys In directory usw-pr-cvs1:/tmp/cvs-serv3613 Modified Files: Access.java Log Message: + keys.Access: Revise to extend latest version of scaffold.sql.AccessBase Index: Access.java =================================================================== RCS file: /cvsroot/struts/artimus/WEB-INF/src/java/org/apache/artimus/keys/Access.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Access.java 14 Aug 2002 21:11:59 -0000 1.1.1.1 --- Access.java 23 Aug 2002 14:24:10 -0000 1.2 *************** *** 7,10 **** --- 7,12 ---- import org.apache.commons.scaffold.lang.PropertiesException; import org.apache.commons.scaffold.lang.ResourceException; + + import org.apache.commons.scaffold.sql.AccessBase; import org.apache.commons.scaffold.sql.StatementUtils; *************** *** 16,20 **** * @version $Revision$ $Date$ */ ! public final class Access { --- 18,23 ---- * @version $Revision$ $Date$ */ ! public final class Access extends AccessBase { ! *************** *** 24,28 **** * Token for "keys.table.create" command. */ ! public static String KEYS_CREATE_TABLE = "keys.table.create"; /** --- 27,31 ---- * Token for "keys.table.create" command. */ ! public static String KEYS_TABLE_CREATE = "keys.table.create"; /** *************** *** 37,80 **** - // -------------------------------------------------------------- Commands - - /** - * Our command string properties. - * Can be loaded from an external properties file at startup. - */ - private static Properties commands; - - - /** - * Retrieve command from <code>commands</code> Properties for - * <code>key</code>. - * - * @fixme Could use a merge feature to reuse common substrings, - * like table names ["SELECT ${searchFields} FROM ${articleTable}"] - */ - public static final String getCommand(String key) - throws ResourceException { - - // MissingResourceException ? - if (null==commands) throw new PropertiesException(); - - return commands.getProperty(key); - } - - - /** - * Configure the data access system. - * <p> - * This method sets up the SQL connection pool adaptor. - * A new adaptor can be used by changing this method. - * This can be called once by main or servlet.init at startup. - */ - public static final void init(Properties _commands) { - - if (null==commands) commands = _commands; - - } - - // ------------------------------------------------------------------ API --- 40,43 ---- *************** *** 94,140 **** throws ResourceException { ! try { ! ! int result = StatementUtils.executeUpdate( ! null,getCommand(KEYS_CREATE_TABLE)); ! } ! catch (SQLException e) { ! throw new ResourceException(e); ! } } // end createTable() - - - /** - * Returns next sequential key for given table. - * Calls <code>scaffold.StatementUtils.createKey()</code>. - * - * @return An Integer representing the allocated key - * @exception SQLException if SQL error occurs - * @param keyName The name of the table for this key - */ - public static final Integer createKey(String keyName) - throws ResourceException { - - Object result = null; - - try { - - result = StatementUtils.createKey( - null, - 1, - getCommand(KEYS_NEXT), - keyName, - getCommand(KEYS_INC) - ); - } - - catch (SQLException e) { - throw new ResourceException(e); - } - - return (Integer) result; - - } // end createKey() --- 57,63 ---- throws ResourceException { ! executeUpdate(KEYS_TABLE_CREATE); } // end createTable() |