Update of /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/jdbc-manager/src/main/java/org/commonjava/j2ee/services
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1684/projects/jdbc-manager/src/main/java/org/commonjava/j2ee/services
Modified Files:
JDBCManager.java
Added Files:
DefaultJDBCManager.java
Log Message:
refactored to provide an interface and default impl for each manager type, instead of merely a manager concrete impl. This will allow for easier mocking.
Index: JDBCManager.java
===================================================================
RCS file: /cvsroot/commonjava/commonjava-projects/commonjava-enterprise-services/projects/jdbc-manager/src/main/java/org/commonjava/j2ee/services/JDBCManager.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- JDBCManager.java 23 Mar 2004 14:58:58 -0000 1.1
+++ JDBCManager.java 8 Apr 2004 15:19:36 -0000 1.2
@@ -1,47 +1,27 @@
-/* Created on Mar 22, 2004 */
+/*
+ * Created on Apr 8, 2004
+ *
+ */
package org.commonjava.j2ee.services;
import javax.naming.NamingException;
-import javax.rmi.PortableRemoteObject;
import javax.sql.DataSource;
import org.commonjava.config.snapin.SnapInLoaderException;
-import org.commonjava.j2ee.services.ServiceLocator;
-/**
- * @author jdcasey
+//TODO: Add JavaDoc to JDBCManager in commonjava-enterprise-services!
+/**
+ *
+ * @
+ *
*/
-public final class JDBCManager extends AbstractManager{
-
+public interface JDBCManager {
public static final String STANDARD_JDBC_JNDI_CONFIG_NAME = "jdbc";
-
- /**
- *
- */
- public JDBCManager() {
- setJndiConfigName(STANDARD_JDBC_JNDI_CONFIG_NAME);
- }
-
- public JDBCManager(ServiceLocator locator){
- super(locator);
- setJndiConfigName(STANDARD_JDBC_JNDI_CONFIG_NAME);
- }
/** Retrieve the JNDI configuration for JDBC lookups, then lookup the specified
* jndi binding and return a JDBC DataSource.
* @param jndiName The JNDI binding
*/
- public DataSource getDataSource(String jndiName)
- throws NamingException, SnapInLoaderException
- {
- Object result = getLocator().lookup(getJndiConfigName(), jndiName);
-
- // not sure this is ever necessary...
- if(result != null && !DataSource.class.isInstance(result)){
- result = PortableRemoteObject.narrow(result, DataSource.class);
- }
-
- return (DataSource)result;
- }
-
-}
+ public abstract DataSource getDataSource(String jndiName)
+ throws NamingException, SnapInLoaderException;
+}
\ No newline at end of file
--- NEW FILE: DefaultJDBCManager.java ---
/* Created on Mar 22, 2004 */
package org.commonjava.j2ee.services;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import javax.sql.DataSource;
import org.commonjava.config.snapin.SnapInLoaderException;
import org.commonjava.j2ee.services.ServiceLocator;
/**
* @author jdcasey
*/
public final class DefaultJDBCManager extends AbstractManager implements JDBCManager{
/**
*
*/
public DefaultJDBCManager() {
setJndiConfigName(STANDARD_JDBC_JNDI_CONFIG_NAME);
}
public DefaultJDBCManager(ServiceLocator locator){
super(locator);
setJndiConfigName(STANDARD_JDBC_JNDI_CONFIG_NAME);
}
/** Retrieve the JNDI configuration for JDBC lookups, then lookup the specified
* jndi binding and return a JDBC DataSource.
* @param jndiName The JNDI binding
*/
public DataSource getDataSource(String jndiName)
throws NamingException, SnapInLoaderException
{
Object result = getLocator().lookup(getJndiConfigName(), jndiName);
// not sure this is ever necessary...
if(result != null && !DataSource.class.isInstance(result)){
result = PortableRemoteObject.narrow(result, DataSource.class);
}
return (DataSource)result;
}
}
|