You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Clinton Begin (JIRA)" <ib...@incubator.apache.org> on 2005/01/20 23:10:18 UTC

[jira] Updated: (IBATIS-57) Refactoring classes in the com.ibatis.common.jdbc package

     [ http://issues.apache.org/jira/browse/IBATIS-57?page=history ]

Clinton Begin updated IBATIS-57:
--------------------------------

    Priority: Minor  (was: Major)


>> the developer need to read the implementaion 

No, the developer needs to read the documentation.  

ScriptRunner will be deprecated, and deleted, which will resolve the consistency issue.  

SimpleDataSource will likely be modified to support a more JavaBean based configuration approach, similar to DBCP.  Then the parameterized constructor can go away completely.

> Refactoring classes in the com.ibatis.common.jdbc package
> ---------------------------------------------------------
>
>          Key: IBATIS-57
>          URL: http://issues.apache.org/jira/browse/IBATIS-57
>      Project: iBatis for Java
>         Type: Improvement
>     Versions: 2.0.9
>  Environment: 2.0.9
>     Reporter: Siveton Vincent
>     Priority: Minor

>
> In the current release, each class in com.ibatis.common.jdbc package has a public constructor with a given map as parameter. 
> Using maps implies that the developer should know exactly the needed keys to construct a valid object. Actually, the developer need to read the implementaion to know which are the needed properties (the needed properties are not the same between constructor, checks SimpleDataSource and ScriptRunner classes...)
> Moreover, no validation of keys exists or throws conventional errors between these classes. Maybe, we can have something like:
> if (props.get(PROP_JDBC_DRIVER) == null) {
>   throw new NestedRuntimeException("The property '" + PROP_JDBC_DRIVER + "' is required.");
> } else {
>   jdbcDriver = (String) props.get(PROP_JDBC_DRIVER);
> }
> PROP_JDBC_DRIVER is a public static field in an interface or an abstract class because all classes use it.
> Like SimpleDataSource class contains only getter, I propose to use an immutable object to instanciate this object and maybe the same pattern for all classes in this package. 
> The main idea of this code refactoring is to configure more easily theses objects like:
> Properties props = new Properties();
> URL url = new URL(MyTest.class.getResource("/").toString()+ myPropertiesConf);
> props.load(url.openStream());
> DataSource ds = new SimpleDataSource(props);
> OR 
> ScriptRunner sr = new ScriptRunner(props);

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira