KeyUtil: Initialize ENCODER_IMPL to StandardKeyEncoder
Also move StandardKeyEncoder to the client package, so that the class
is included in GWT module. Consequently, we don't need to initialize
ENCODER_IMPL to StandardKeyEncoder neither in Database no in
NoSqlDatabase classes.
Change-Id: I4b1b8de6949a6cc94bd004e2f983bb50b0a3270a
diff --git a/src/main/java/com/google/gwtorm/client/KeyUtil.java b/src/main/java/com/google/gwtorm/client/KeyUtil.java
index d815ea6..4bd27a0 100644
--- a/src/main/java/com/google/gwtorm/client/KeyUtil.java
+++ b/src/main/java/com/google/gwtorm/client/KeyUtil.java
@@ -16,7 +16,7 @@
/** Common utility functions for {@link Key} implementors. */
public class KeyUtil {
- private static Encoder ENCODER_IMPL;
+ private static Encoder ENCODER_IMPL = new StandardKeyEncoder();
/**
* Set the encoder implementation to a valid implementation.
diff --git a/src/main/java/com/google/gwtorm/server/StandardKeyEncoder.java b/src/main/java/com/google/gwtorm/client/StandardKeyEncoder.java
similarity index 98%
rename from src/main/java/com/google/gwtorm/server/StandardKeyEncoder.java
rename to src/main/java/com/google/gwtorm/client/StandardKeyEncoder.java
index 1339542..d6d503a 100644
--- a/src/main/java/com/google/gwtorm/server/StandardKeyEncoder.java
+++ b/src/main/java/com/google/gwtorm/client/StandardKeyEncoder.java
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-package com.google.gwtorm.server;
+package com.google.gwtorm.client;
import com.google.gwtorm.client.KeyUtil.Encoder;
import java.io.UnsupportedEncodingException;
diff --git a/src/main/java/com/google/gwtorm/jdbc/Database.java b/src/main/java/com/google/gwtorm/jdbc/Database.java
index 2db2833..2b2aef8 100644
--- a/src/main/java/com/google/gwtorm/jdbc/Database.java
+++ b/src/main/java/com/google/gwtorm/jdbc/Database.java
@@ -25,7 +25,6 @@
import com.google.gwtorm.server.SchemaConstructorGen;
import com.google.gwtorm.server.SchemaFactory;
import com.google.gwtorm.server.SchemaGen;
-import com.google.gwtorm.server.StandardKeyEncoder;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
@@ -45,9 +44,6 @@
* @param <T>
*/
public class Database<T extends Schema> implements SchemaFactory<T> {
- static {
- KeyUtil.setEncoderImpl(new StandardKeyEncoder());
- }
private final DataSource dataSource;
private final JavaSchemaModel schemaModel;
diff --git a/src/main/java/com/google/gwtorm/nosql/NoSqlDatabase.java b/src/main/java/com/google/gwtorm/nosql/NoSqlDatabase.java
index 414e297..f5c25bb 100644
--- a/src/main/java/com/google/gwtorm/nosql/NoSqlDatabase.java
+++ b/src/main/java/com/google/gwtorm/nosql/NoSqlDatabase.java
@@ -24,7 +24,6 @@
import com.google.gwtorm.server.SchemaConstructorGen;
import com.google.gwtorm.server.SchemaFactory;
import com.google.gwtorm.server.SchemaGen;
-import com.google.gwtorm.server.StandardKeyEncoder;
/**
* Base class for NoSQL typed databases.
@@ -49,9 +48,6 @@
@SuppressWarnings("rawtypes")
public abstract class NoSqlDatabase<T extends Schema, S extends NoSqlSchema, A extends NoSqlAccess>
implements SchemaFactory<T> {
- static {
- KeyUtil.setEncoderImpl(new StandardKeyEncoder());
- }
private final SchemaModel schemaModel;
private final SchemaFactory<T> implFactory;
diff --git a/src/test/java/com/google/gwtorm/client/IntKeyTestCase.java b/src/test/java/com/google/gwtorm/client/IntKeyTestCase.java
index 104068a..093a8df 100644
--- a/src/test/java/com/google/gwtorm/client/IntKeyTestCase.java
+++ b/src/test/java/com/google/gwtorm/client/IntKeyTestCase.java
@@ -19,7 +19,6 @@
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import com.google.gwtorm.server.StandardKeyEncoder;
import org.junit.Before;
import org.junit.Test;
diff --git a/src/test/java/com/google/gwtorm/client/LongKeyTestCase.java b/src/test/java/com/google/gwtorm/client/LongKeyTestCase.java
index 17b298b..b0ea010 100644
--- a/src/test/java/com/google/gwtorm/client/LongKeyTestCase.java
+++ b/src/test/java/com/google/gwtorm/client/LongKeyTestCase.java
@@ -19,7 +19,6 @@
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import com.google.gwtorm.server.StandardKeyEncoder;
import org.junit.Before;
import org.junit.Test;
diff --git a/src/test/java/com/google/gwtorm/client/StringKeyTestCase.java b/src/test/java/com/google/gwtorm/client/StringKeyTestCase.java
index 731cf8c..f575fc0 100644
--- a/src/test/java/com/google/gwtorm/client/StringKeyTestCase.java
+++ b/src/test/java/com/google/gwtorm/client/StringKeyTestCase.java
@@ -19,7 +19,6 @@
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import com.google.gwtorm.server.StandardKeyEncoder;
import org.junit.Before;
import org.junit.Test;