labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r606754 - in /labs/fluid/slice: ./ src/main/java/org/apache/openjpa/slice/ src/main/java/org/apache/openjpa/slice/jdbc/ src/main/resources/org/apache/openjpa/slice/jdbc/ src/test/resources/META-INF/
Date Tue, 25 Dec 2007 05:23:47 GMT
Author: ppoddar
Date: Mon Dec 24 21:23:26 2007
New Revision: 606754

URL: http://svn.apache.org/viewvc?rev=606754&view=rev
Log:
Major changes
  Per-slice configuration
  Slice identifier from int to String


Added:
    labs/fluid/slice/openjpa-slice-0.2.0-SNAPSHOT.jar   (with props)
Modified:
    labs/fluid/slice/openjpa-slice-0.1.0-SNAPSHOT.jar
    labs/fluid/slice/pom.xml
    labs/fluid/slice/src/main/java/org/apache/openjpa/slice/DistributionPolicy.java
    labs/fluid/slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java
    labs/fluid/slice/src/main/resources/org/apache/openjpa/slice/jdbc/localizer.properties
    labs/fluid/slice/src/test/resources/META-INF/persistence.xml

Modified: labs/fluid/slice/openjpa-slice-0.1.0-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/labs/fluid/slice/openjpa-slice-0.1.0-SNAPSHOT.jar?rev=606754&r1=606753&r2=606754&view=diff
==============================================================================
Binary files - no diff available.

Added: labs/fluid/slice/openjpa-slice-0.2.0-SNAPSHOT.jar
URL: http://svn.apache.org/viewvc/labs/fluid/slice/openjpa-slice-0.2.0-SNAPSHOT.jar?rev=606754&view=auto
==============================================================================
Binary file - no diff available.

Propchange: labs/fluid/slice/openjpa-slice-0.2.0-SNAPSHOT.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: labs/fluid/slice/pom.xml
URL: http://svn.apache.org/viewvc/labs/fluid/slice/pom.xml?rev=606754&r1=606753&r2=606754&view=diff
==============================================================================
--- labs/fluid/slice/pom.xml (original)
+++ labs/fluid/slice/pom.xml Mon Dec 24 21:23:26 2007
@@ -27,7 +27,7 @@
   <groupId>org.apache.openjpa</groupId>
   <artifactId>openjpa-slice</artifactId>
   <packaging>jar</packaging>
-  <version>0.1.0-SNAPSHOT</version>
+  <version>0.2.0-SNAPSHOT</version>
   <name>Slice</name>
   <description>Distributed Persistence Service using OpenJPA</description>
   <url>http://people.apache.org/~ppoddar/slice/site/index.html</url>

Modified: labs/fluid/slice/src/main/java/org/apache/openjpa/slice/DistributionPolicy.java
URL: http://svn.apache.org/viewvc/labs/fluid/slice/src/main/java/org/apache/openjpa/slice/DistributionPolicy.java?rev=606754&r1=606753&r2=606754&view=diff
==============================================================================
--- labs/fluid/slice/src/main/java/org/apache/openjpa/slice/DistributionPolicy.java (original)
+++ labs/fluid/slice/src/main/java/org/apache/openjpa/slice/DistributionPolicy.java Mon Dec
24 21:23:26 2007
@@ -34,7 +34,7 @@
 	 *  
 	 * @param pc The newly persistent or to-be-merged object. 
 	 * @param slices name of the configured slices.
-	 * @param a opaque context for future use.
+	 * @param context opaque context for future use.
 	 * 
 	 * @return identifier of the slice. This name must match one of the
 	 * configured slice names. 

Modified: labs/fluid/slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java
URL: http://svn.apache.org/viewvc/labs/fluid/slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java?rev=606754&r1=606753&r2=606754&view=diff
==============================================================================
--- labs/fluid/slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java
(original)
+++ labs/fluid/slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCConfigurationImpl.java
Mon Dec 24 21:23:26 2007
@@ -31,6 +31,7 @@
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.TreeMap;
+import java.util.TreeSet;
 
 import javax.sql.DataSource;
 
@@ -43,6 +44,7 @@
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.conf.PluginValue;
+import org.apache.openjpa.lib.conf.StringValue;
 import org.apache.openjpa.lib.jdbc.DecoratingDataSource;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.Localizer;
@@ -63,6 +65,7 @@
 	private DecoratingDataSource virtualDataSource;
 
 	protected BooleanValue lenient;
+	protected StringValue  master;
 	protected PluginValue distributionPolicyPlugin;
 
 	private static Localizer _loc =
@@ -78,6 +81,7 @@
 		distributionPolicyPlugin = addPlugin("DistributionPolicy", true);
 		distributionPolicyPlugin.setDynamic(true);
 		lenient = addBoolean("Lenient");
+		master = addString("Master");
 		setSlices(cp.getProperties());
 	}
 
@@ -238,6 +242,8 @@
 		for (String key : slices) {
 			JDBCConfiguration slice = new JDBCConfigurationImpl();
 			slice.fromProperties(replaceKeys(p, prefix(key), "openjpa."));
+			if (slice.getConnectionURL() == null)
+				throw new UserException(_loc.get("slice-no-url", key));
 			_slices.put(key, slice);
 			if (log != null && log.isInfoEnabled())
 				log.info(_loc.get("slice-configuration", key, slice
@@ -250,7 +256,7 @@
 	}
 
 	Set<String> findSlices(Map p) {
-		Set<String> slices = new HashSet<String>();
+		Set<String> slices = new TreeSet<String>();
 		for (Object o : p.keySet()) {
 			if (o instanceof String && o.toString().startsWith(PREFIX_SLICE)) {
 				String sliceName =
@@ -264,8 +270,10 @@
 
 	boolean isKnownProperty(String property) {
 		return distributionPolicyPlugin.getProperty().equals(property)
-				|| lenient.getProperty().equals(property);
+				|| lenient.getProperty().equals(property)
+				|| master.getProperty().equals(property);
 	}
+
 
 	static String chopHead(String s, String head) {
 		if (s.startsWith(head))

Modified: labs/fluid/slice/src/main/resources/org/apache/openjpa/slice/jdbc/localizer.properties
URL: http://svn.apache.org/viewvc/labs/fluid/slice/src/main/resources/org/apache/openjpa/slice/jdbc/localizer.properties?rev=606754&r1=606753&r2=606754&view=diff
==============================================================================
--- labs/fluid/slice/src/main/resources/org/apache/openjpa/slice/jdbc/localizer.properties
(original)
+++ labs/fluid/slice/src/main/resources/org/apache/openjpa/slice/jdbc/localizer.properties
Mon Dec 24 21:23:26 2007
@@ -1,4 +1,9 @@
 slice-not-found: No slice named "{0}" can be found. Available slices are "{1}"
+slice-no-url: Slice "{0}" has no database URL. Specify a valid database URL \
+	as the value of "slice.{0}.ConnectionURL" property. ConnectionURL is the \
+	only mandatory property of a slice. If any other slice property \
+	is not specified, then the corresponding openjpa.* property value is used \
+	as default.
 slice-none-configured: No slice has been configured. Specify slice.XYZ as \
 	property name to register a slice named XYZ.
 slice-configuration: Slice "{0}" configured with "{1}"

Modified: labs/fluid/slice/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/labs/fluid/slice/src/test/resources/META-INF/persistence.xml?rev=606754&r1=606753&r2=606754&view=diff
==============================================================================
--- labs/fluid/slice/src/test/resources/META-INF/persistence.xml (original)
+++ labs/fluid/slice/src/test/resources/META-INF/persistence.xml Mon Dec 24 21:23:26 2007
@@ -1,5 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
+   <!-- ==================================================================== -->
+   <!-- Configuration for testing basic per-slice configuration              -->
+   <!-- ==================================================================== -->
+   
    <persistence-unit name="per-slice">
       <properties>
          <property name="openjpa.BrokerFactory" value="slice"/>
@@ -7,13 +11,14 @@
          <property name="slice.One.ConnectionURL" value="jdbc:mysql://localhost/slice1"/>
          <property name="slice.Two.ConnectionURL" value="jdbc:mysql://localhost/slice2"/>
          <property name="slice.Three.ConnectionURL" value="jdbc:mysql://localhost/slice3"/>
-         <property name="slice.Three.ConnectionDriverName" value="x.y.z"/>
-         
          <property name="slice.DistributionPolicy" value="org.apache.openjpa.slice.policy.UserDistributionPolicy"/>
-         <property name="slice.Lenient" value="false"/>
+         <property name="slice.Lenient" value="true"/>
       </properties>
    </persistence-unit>
    
+   <!-- ==================================================================== -->
+   <!-- Configuration for testing basic CRUD operations                      -->
+   <!-- ==================================================================== -->
    <persistence-unit name="slice">
         <class>domain.PObject</class>
         <class>domain.Person</class>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message