diff options
Diffstat (limited to 'src/main/java/com/amazon/carbonado/info')
3 files changed, 49 insertions, 2 deletions
diff --git a/src/main/java/com/amazon/carbonado/info/ChainedProperty.java b/src/main/java/com/amazon/carbonado/info/ChainedProperty.java index 71f1ba5..d30fc8f 100644 --- a/src/main/java/com/amazon/carbonado/info/ChainedProperty.java +++ b/src/main/java/com/amazon/carbonado/info/ChainedProperty.java @@ -19,6 +19,7 @@ package com.amazon.carbonado.info;
import java.io.IOException;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -36,7 +37,9 @@ import com.amazon.carbonado.util.Appender; *
* @author Brian S O'Neill
*/
-public class ChainedProperty<S extends Storable> implements Appender {
+public class ChainedProperty<S extends Storable> implements Serializable, Appender {
+ private static final long serialVersionUID = 1L;
+
static WeakCanonicalSet cCanonical = new WeakCanonicalSet();
/**
@@ -578,4 +581,8 @@ public class ChainedProperty<S extends Storable> implements Appender { app.append(')');
}
}
+
+ private Object readResolve() {
+ return cCanonical.put(this);
+ }
}
diff --git a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java index 7e8fbf8..fdfb51f 100644 --- a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java +++ b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java @@ -18,7 +18,10 @@ package com.amazon.carbonado.info;
+import java.io.Externalizable;
import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.lang.annotation.Annotation;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
@@ -2080,6 +2083,42 @@ public class StorableIntrospector { return derivedToSet.size() > originalSize;
}
+
+ // Package-private in order to be inherited by subclasses.
+ Object writeReplace() {
+ return new NaET(mName, mEnclosingType);
+ }
+
+ // Name and Enclosing Type
+ private static class NaET implements Externalizable {
+ private static final long serialVersionUID = 1L;
+
+ private String mName;
+ private Class<? extends Storable> mEnclosingType;
+
+ // Required for Externalizable.
+ public NaET() {
+ }
+
+ NaET(String name, Class<? extends Storable> enclosingType) {
+ mName = name;
+ mEnclosingType = enclosingType;
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(mName);
+ out.writeObject(mEnclosingType);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ mName = (String) in.readObject();
+ mEnclosingType = (Class<? extends Storable>) in.readObject();
+ }
+
+ private Object readResolve() {
+ return StorableIntrospector.examine(mEnclosingType).getAllProperties().get(mName);
+ }
+ }
}
private static final class JoinProperty<S extends Storable> extends SimpleProperty<S> {
diff --git a/src/main/java/com/amazon/carbonado/info/StorableProperty.java b/src/main/java/com/amazon/carbonado/info/StorableProperty.java index 53b5098..0d77481 100644 --- a/src/main/java/com/amazon/carbonado/info/StorableProperty.java +++ b/src/main/java/com/amazon/carbonado/info/StorableProperty.java @@ -18,6 +18,7 @@ package com.amazon.carbonado.info;
+import java.io.Serializable;
import java.lang.reflect.Method;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.util.Appender;
@@ -28,7 +29,7 @@ import com.amazon.carbonado.util.Appender; * @author Brian S O'Neill
* @see StorableIntrospector
*/
-public interface StorableProperty<S extends Storable> extends Appender {
+public interface StorableProperty<S extends Storable> extends Serializable, Appender {
/**
* Returns the name of this property.
*/
|