ibatis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbe...@apache.org
Subject svn commit: r702322 - in /ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src: main/java/org/apache/ibatis/monarch/builder/ main/java/org/apache/ibatis/monarch/environment/datasource/ main/java/org/apache/ibatis/monarch/environment/transaction/ test/java/o...
Date Tue, 07 Oct 2008 01:48:41 GMT
Author: cbegin
Date: Mon Oct  6 18:48:41 2008
New Revision: 702322

URL: http://svn.apache.org/viewvc?rev=702322&view=rev
Log:
Refactored settings vs properties...still not convinced on the design though

Added:
    ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/Transaction.java
Modified:
    ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/MapperConfigParser.java
    ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/monarch-configuration.dtd
    ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/datasource/UnpooledDataSourceFactory.java
    ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/TransactionManager.java
    ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/example/MapperConfig.xml

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/MapperConfigParser.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/MapperConfigParser.java?rev=702322&r1=702321&r2=702322&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/MapperConfigParser.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/MapperConfigParser.java
Mon Oct  6 18:48:41 2008
@@ -77,11 +77,40 @@
     configuration.setObjectFactory(factory);
   }
 
+  //  <settings url="" resource="">
+  //    <setting name="" value=""/>
+  @Nodelet("/configuration/properties")
+  public void propertiesElement(NodeletContext context) throws Exception {
+    Properties defaults = context.getChildrenAsProperties();
+    String resource = context.getStringAttribute("resource");
+    String url = context.getStringAttribute("url");
+    if (resource != null && url != null) {
+      throw new BuilderException("The properties element cannot specify both a URL and a
resource based property file reference.  Please specify one or the other.");
+    }
+    if (resource != null) {
+      defaults.putAll(Resources.getResourceAsProperties(resource));
+    } else if (url != null){
+      defaults.putAll(Resources.getUrlAsProperties(url));
+    }
+    Properties vars = configuration.getVariables();
+    if (vars != null) {
+      defaults.putAll(vars);
+    }
+    configuration.setVariables(defaults);
+  }
+
   //  <settings>
   //    <setting name="" value=""/>
   @Nodelet("/configuration/settings")
   public void settingsElement(NodeletContext context) throws Exception {
     Properties props = context.getChildrenAsProperties();
+    // Check that all settings are known to the configuration class
+    for (Map.Entry entry : props.entrySet()) {
+      MetaClass metaConfig = MetaClass.forClass(Configuration.class);
+      if (!metaConfig.hasSetter((String)entry.getKey())) {
+        throw new BuilderException("The setting " + entry.getKey() + " is not known.  Make
sure you spelled it correctly (case sensitive).");
+      }
+    }
     configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"),true));
     configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"),true));
     configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"),true));
@@ -90,12 +119,6 @@
     configuration.setGeneratedKeysEnabled(booleanValueOf(props.getProperty("generatedKeysEnabled"),false));
     configuration.setDefaultExecutorType(ExecutorType.valueOf(stringValueOf(props.getProperty("defaultExecutorType"),"SIMPLE")));
     configuration.setDefaultStatementTimeout(integerValueOf(props.getProperty("defaultStatementTimeout"),null));
-    for (Map.Entry entry : props.entrySet()) {
-      MetaClass metaConfig = MetaClass.forClass(Configuration.class);
-      if (!metaConfig.hasSetter((String)entry.getKey())) {
-        throw new BuilderException("The setting " + entry.getKey() + " is not known.  Make
sure you spelled it correctly (case sensitive).");
-      }
-    }
   }
 
   //  <environments default="development">

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/monarch-configuration.dtd
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/monarch-configuration.dtd?rev=702322&r1=702321&r2=702322&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/monarch-configuration.dtd
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/builder/monarch-configuration.dtd
Mon Oct  6 18:48:41 2008
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 
-<!ELEMENT configuration (properties?, typeAliases?, typeHandlers?, objectFactory?, plugins?,
environments?, mappers)>
+<!ELEMENT configuration (properties?, settings?, typeAliases?, typeHandlers?, objectFactory?,
plugins?, environments?, mappers)>
 
 <!ELEMENT properties (property*)>
 <!ATTLIST properties
@@ -14,6 +14,14 @@
 value CDATA #REQUIRED
 >
 
+<!ELEMENT settings (setting*)>
+
+<!ELEMENT setting EMPTY>
+<!ATTLIST setting
+name CDATA #REQUIRED
+value CDATA #REQUIRED
+>
+
 <!ELEMENT typeAliases (typeAlias+)>
 
 <!ELEMENT typeAlias EMPTY>

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/datasource/UnpooledDataSourceFactory.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/datasource/UnpooledDataSourceFactory.java?rev=702322&r1=702321&r2=702322&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/datasource/UnpooledDataSourceFactory.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/datasource/UnpooledDataSourceFactory.java
Mon Oct  6 18:48:41 2008
@@ -1,7 +1,6 @@
 package org.apache.ibatis.monarch.environment.datasource;
 
-import org.apache.ibatis.jdbc.PooledDataSource;
-import org.apache.ibatis.jdbc.DataSourceException;
+import org.apache.ibatis.jdbc.UnpooledDataSource;
 import org.apache.ibatis.reflection.MetaObject;
 import org.apache.ibatis.monarch.environment.EnvironmentException;
 
@@ -13,10 +12,10 @@
   private static final String DRIVER_PROPERTY_PREFIX = "driver.";
   private static final int DRIVER_PROPERTY_PREFIX_LENGTH = DRIVER_PROPERTY_PREFIX.length();
 
-  protected PooledDataSource dataSource;
+  protected DataSource dataSource;
 
   public UnpooledDataSourceFactory() {
-    this.dataSource = new PooledDataSource();
+    this.dataSource = new UnpooledDataSource();
   }
 
   public void setProperties(Properties properties) {
@@ -36,7 +35,7 @@
       }
     }
     if (driverProperties.size() > 0) {
-      dataSource.setDriverProperties(driverProperties);
+      metaDataSource.setValue("driverProperties",driverProperties);
     }
   }
 

Added: ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/Transaction.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/Transaction.java?rev=702322&view=auto
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/Transaction.java
(added)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/Transaction.java
Mon Oct  6 18:48:41 2008
@@ -0,0 +1,12 @@
+package org.apache.ibatis.monarch.environment.transaction;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public interface Transaction {
+
+  Connection getConnection();
+  void commit() throws SQLException;
+  void rollback() throws SQLException;
+
+}

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/TransactionManager.java
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/TransactionManager.java?rev=702322&r1=702321&r2=702322&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/TransactionManager.java
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/main/java/org/apache/ibatis/monarch/environment/transaction/TransactionManager.java
Mon Oct  6 18:48:41 2008
@@ -1,4 +1,10 @@
 package org.apache.ibatis.monarch.environment.transaction;
 
+import java.sql.Connection;
+
 public interface TransactionManager {
+  //TODO:  Create transaction class, wrap connection passed to executor
+
+  Transaction newTransaction(Connection conn);
+
 }

Modified: ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/example/MapperConfig.xml
URL: http://svn.apache.org/viewvc/ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/example/MapperConfig.xml?rev=702322&r1=702321&r2=702322&view=diff
==============================================================================
--- ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/example/MapperConfig.xml
(original)
+++ ibatis/trunk/java/ibatis-3/ibatis-3-monarch/src/test/java/org/apache/ibatis/monarch/example/MapperConfig.xml
Mon Oct  6 18:48:41 2008
@@ -4,6 +4,10 @@
     <property name="" value=""/>
   </properties>
 
+  <settings>
+    <property name="" value=""/>
+  </settings>
+
   <typeAliases>
     <typeAlias alias="" type=""/>
   </typeAliases>



Mime
View raw message