made a number of configuration-related classes serializable to facilitate alternate means of configuration population; moved away from a couple more usages of commons collections LinkedMap; added new lifecycle callback to ProductDerivation interface

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@475059 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2006-11-14 23:42:42 +00:00
parent db2128fe02
commit 301580c069
39 changed files with 348 additions and 165 deletions

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.jdbc.kernel;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
@ -69,8 +70,8 @@ public class TableJDBCSeq
private static final Localizer _loc = Localizer.forPackage
(TableJDBCSeq.class);
private JDBCConfiguration _conf = null;
private Log _log = null;
private transient JDBCConfiguration _conf = null;
private transient Log _log = null;
private int _alloc = 50;
private final Status _stat = new Status();
@ -624,7 +625,8 @@ public class TableJDBCSeq
/**
* Helper struct to hold status information.
*/
protected static class Status {
protected static class Status
implements Serializable {
public long seq = 1L;
public long max = 0L;

View File

@ -21,13 +21,12 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.set.ListOrderedSet;
import org.apache.openjpa.enhance.PersistenceCapable;
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
import org.apache.openjpa.jdbc.kernel.JDBCStore;
@ -621,8 +620,7 @@ public class ClassMapping
_assignMaps = subs;
} else {
int size = (int) (subs.length * 1.33 + 2);
Set independent = ListOrderedSet.decorate(new HashSet(size),
new ArrayList(subs.length + 1));
Set independent = new LinkedHashSet(size);
if (isMapped())
independent.add(this);
independent.addAll(Arrays.asList(subs));

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.jdbc.meta;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.openjpa.jdbc.kernel.JDBCStore;
@ -38,7 +39,8 @@ import org.apache.openjpa.kernel.OpenJPAStateManager;
*
* @author Abe White
*/
public interface Joinable {
public interface Joinable
extends Serializable {
/**
* Return the field index of this joinable, or -1 if not a field.

View File

@ -44,7 +44,7 @@ import serp.util.Strings;
public class MappingDefaultsImpl
implements MappingDefaults, Configurable {
protected DBDictionary dict = null;
protected transient DBDictionary dict = null;
private String _baseClassStrategy = null;
private String _subclassStrategy = null;
private String _versionStrategy = null;

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.jdbc.meta;
import java.io.Serializable;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collections;
@ -47,7 +48,8 @@ import serp.util.Strings;
*
* @author Abe White
*/
public abstract class MappingInfo {
public abstract class MappingInfo
implements Serializable {
public static final int JOIN_NONE = 0;
public static final int JOIN_FORWARD = 1;

View File

@ -65,6 +65,7 @@ import org.apache.openjpa.jdbc.schema.Column;
import org.apache.openjpa.jdbc.schema.SchemaGroup;
import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
import org.apache.openjpa.lib.conf.Configurable;
import org.apache.openjpa.lib.conf.Configurations;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.meta.ClassMetaData;
@ -94,8 +95,9 @@ public class MappingRepository
"org.apache.openjpa.jdbc.meta.strats.EnumValueHandler");
}
private DBDictionary _dict = null;
private MappingDefaults _defaults = null;
private transient DBDictionary _dict = null;
private transient MappingDefaults _defaults = null;
private Map _results = new HashMap(); // object->queryresultmapping
private SchemaGroup _schema = null;
private StrategyInstaller _installer = null;
@ -1167,5 +1169,10 @@ public class MappingRepository
_dict = conf.getDBDictionaryInstance();
if (_defaults == null)
_defaults = conf.getMappingDefaultsInstance();
if (_schema != null && _schema instanceof Configurable) {
((Configurable) _schema).setConfiguration(conf);
((Configurable) _schema).startConfiguration();
((Configurable) _schema).endConfiguration();
}
}
}

View File

@ -21,6 +21,7 @@ import org.apache.openjpa.jdbc.schema.Index;
import org.apache.openjpa.jdbc.schema.Schema;
import org.apache.openjpa.jdbc.schema.Table;
import org.apache.openjpa.jdbc.schema.Unique;
import serp.util.Strings;
/**

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.jdbc.meta;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.openjpa.jdbc.kernel.JDBCStore;
@ -28,7 +29,8 @@ import org.apache.openjpa.util.MetaDataException;
* @author Abe White
* @since 0.4.0
*/
public interface Strategy {
public interface Strategy
extends Serializable {
/**
* Return the alias of this strategy. For custom strategies, return the

View File

@ -15,7 +15,7 @@
*/
package org.apache.openjpa.jdbc.meta;
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
import java.io.Serializable;
/**
* Installs mapping strategies.
@ -24,9 +24,9 @@ import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
* @nojavadoc
* @since 0.4.0
*/
public abstract class StrategyInstaller {
public abstract class StrategyInstaller
implements Serializable {
protected final JDBCConfiguration conf;
protected final MappingRepository repos;
/**
@ -34,7 +34,6 @@ public abstract class StrategyInstaller {
*/
public StrategyInstaller(MappingRepository repos) {
this.repos = repos;
this.conf = (JDBCConfiguration) repos.getConfiguration();
}
/**

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.jdbc.meta;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
@ -30,7 +31,8 @@ import org.apache.openjpa.kernel.OpenJPAStateManager;
* @author Abe White
* @since 0.4.0
*/
public interface ValueHandler {
public interface ValueHandler
extends Serializable {
/**
* Map the given value and return all mapped columns, or simply return an

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.jdbc.meta;
import java.io.Serializable;
import java.sql.SQLException;
import org.apache.openjpa.jdbc.schema.Column;
@ -34,7 +35,7 @@ import org.apache.openjpa.meta.ValueMetaData;
* @since 0.4.0
*/
public interface ValueMapping
extends ValueMetaData, MetaDataContext {
extends ValueMetaData, MetaDataContext, Serializable {
/**
* Standard forward join.

View File

@ -48,7 +48,7 @@ public class ValueMappingImpl
private static final Localizer _loc = Localizer.forPackage
(ValueMappingImpl.class);
private final ValueMappingInfo _info;
private ValueMappingInfo _info;
private ValueHandler _handler = null;
private ClassMapping[] _typeArr = null;
@ -72,6 +72,13 @@ public class ValueMappingImpl
getMappingDefaults().useClassCriteria());
}
/**
* Constructor for deserialization.
*/
protected ValueMappingImpl() {
super();
}
public ValueMappingInfo getValueInfo() {
return _info;
}

View File

@ -15,6 +15,8 @@
*/
package org.apache.openjpa.jdbc.schema;
import java.io.Serializable;
/**
* Metadata about column I/O in a specific context. In the context of
* a foreign key, the standard foreign key columns are indexed first, then
@ -22,7 +24,8 @@ package org.apache.openjpa.jdbc.schema;
*
* @author Abe White
*/
public class ColumnIO {
public class ColumnIO
implements Serializable {
public static final ColumnIO UNRESTRICTED = new ColumnIO() {
public void setInsertable(int col, boolean insertable) {

View File

@ -35,7 +35,7 @@ public class DynamicSchemaFactory
extends SchemaGroup
implements SchemaFactory, Configurable {
private DBDictionary _dict = null;
private transient DBDictionary _dict = null;
private String _schema = null;
public void setConfiguration(Configuration conf) {

View File

@ -19,8 +19,8 @@ import java.sql.DatabaseMetaData;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.LinkedHashMap;
import org.apache.commons.collections.map.LinkedMap;
import org.apache.commons.lang.ObjectUtils;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.lib.util.StringDistance;
@ -65,17 +65,18 @@ public class ForeignKey
*/
public static final int ACTION_DEFAULT = 5;
private static Localizer _loc = Localizer.forPackage(ForeignKey.class);
private static final Localizer _loc =
Localizer.forPackage(ForeignKey.class);
private String _pkTableName = null;
private String _pkSchemaName = null;
private String _pkColumnName = null;
private int _seq = 0;
private LinkedMap _joins = null;
private LinkedMap _joinsPK = null;
private LinkedMap _consts = null;
public LinkedMap _constsPK = null;
private LinkedHashMap _joins = null;
private LinkedHashMap _joinsPK = null;
private LinkedHashMap _consts = null;
private LinkedHashMap _constsPK = null;
private int _delAction = ACTION_NONE;
private int _upAction = ACTION_NONE;
private int _index = 0;
@ -525,10 +526,10 @@ public class ForeignKey
_pkTable = pkTable;
if (_joins == null)
_joins = new LinkedMap();
_joins = new LinkedHashMap();
_joins.put(local, toPK);
if (_joinsPK == null)
_joinsPK = new LinkedMap();
_joinsPK = new LinkedHashMap();
_joinsPK.put(toPK, local);
// force re-cache
@ -550,7 +551,7 @@ public class ForeignKey
_pkTable = pkTable;
if (_constsPK == null)
_constsPK = new LinkedMap();
_constsPK = new LinkedHashMap();
_constsPK.put(toPK, val);
// force re-cache
@ -564,7 +565,7 @@ public class ForeignKey
*/
public void joinConstant(Column col, Object val) {
if (_consts == null)
_consts = new LinkedMap();
_consts = new LinkedHashMap();
_consts.put(col, val);
// force re-cache

View File

@ -36,10 +36,11 @@ public class LazySchemaFactory
extends SchemaGroup
implements SchemaFactory, Configurable {
private JDBCConfiguration _conf = null;
private SchemaGenerator _gen = null;
private Connection _conn = null;
private DatabaseMetaData _meta = null;
private transient JDBCConfiguration _conf = null;
private transient Connection _conn = null;
private transient DatabaseMetaData _meta = null;
private transient SchemaGenerator _gen = null;
private boolean _indexes = false;
private boolean _pks = false;
private boolean _fks = false;

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.jdbc.schema;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
@ -28,7 +29,8 @@ import org.apache.openjpa.lib.util.Localizer;
*
* @author Abe White
*/
public class NameSet {
public class NameSet
implements Serializable {
private static final Localizer _loc = Localizer.forPackage(NameSet.class);

View File

@ -15,13 +15,16 @@
*/
package org.apache.openjpa.jdbc.schema;
import java.io.Serializable;
/**
* Some schema components count references so that unused components
* can be detected.
*
* @author Abe White
*/
class ReferenceCounter {
class ReferenceCounter
implements Serializable {
private int _count = 0;

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.jdbc.schema;
import java.io.Serializable;
import java.util.Map;
import java.util.TreeMap;
@ -26,7 +27,7 @@ import org.apache.commons.lang.StringUtils;
* @author Abe White
*/
public class Schema
implements Comparable {
implements Comparable, Serializable {
private String _name = null;
private SchemaGroup _group = null;

View File

@ -21,8 +21,8 @@ import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
import java.util.LinkedHashMap;
import org.apache.commons.collections.map.LinkedMap;
import org.apache.commons.lang.StringUtils;
import org.apache.openjpa.lib.meta.SourceTracker;
@ -269,7 +269,7 @@ public class Table
else
col = new Column(name, this);
if (_colMap == null)
_colMap = new LinkedMap();
_colMap = new LinkedHashMap();
_colMap.put(name.toUpperCase(), col);
_cols = null;
return col;

View File

@ -15,6 +15,9 @@
*/
package org.apache.openjpa.event;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.Method;
import org.apache.openjpa.lib.util.Localizer;
@ -31,7 +34,7 @@ public class BeanLifecycleCallbacks
private static final Localizer _loc = Localizer.forPackage
(BeanLifecycleCallbacks.class);
private Object _listener;
private transient Object _listener;
/**
* Constructor. Make the callback on an instance of the given type.
@ -49,8 +52,12 @@ public class BeanLifecycleCallbacks
*/
public BeanLifecycleCallbacks(Class cls, Method method, boolean arg) {
super(method, arg);
_listener = newListener(cls);
}
private Object newListener(Class cls) {
try {
_listener = cls.newInstance();
return cls.newInstance();
} catch (Throwable t) {
throw new UserException(_loc.get("bean-constructor",
cls.getName()), t);
@ -67,4 +74,17 @@ public class BeanLifecycleCallbacks
else
callback.invoke(_listener, new Object[]{ obj });
}
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
super.readExternal(in);
Class cls = (Class) in.readObject();
_listener = newListener(cls);
}
public void writeExternal(ObjectOutput out)
throws IOException {
super.writeExternal(out);
out.writeObject(_listener.getClass());
}
}

View File

@ -15,12 +15,15 @@
*/
package org.apache.openjpa.event;
import java.io.Serializable;
/**
* A lifecycle listener that responds to callbacks rather than events.
*
* @author Steve Kim
*/
public interface LifecycleCallbacks {
public interface LifecycleCallbacks
extends Serializable {
/**
* Return whether the given instance has a callback for the given

View File

@ -15,6 +15,10 @@
*/
package org.apache.openjpa.event;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.Method;
import java.util.Arrays;
@ -27,12 +31,12 @@ import org.apache.openjpa.util.UserException;
* @author Steve Kim
*/
public class MethodLifecycleCallbacks
implements LifecycleCallbacks {
implements LifecycleCallbacks, Externalizable {
private static final Localizer _loc = Localizer.forPackage
(MethodLifecycleCallbacks.class);
private Method _callback;
private transient Method _callback;
private boolean _arg;
/**
@ -138,4 +142,21 @@ public class MethodLifecycleCallbacks
return true;
}
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
Class cls = (Class) in.readObject();
String methName = (String) in.readObject();
_arg = in.readBoolean();
Class[] args = _arg ? new Class[]{ Object.class } : null;
_callback = getMethod(cls, methName, args);
}
public void writeExternal(ObjectOutput out)
throws IOException {
out.writeObject(_callback.getClass());
out.writeObject(_callback.getName());
out.writeBoolean(_arg);
}
}

View File

@ -38,12 +38,13 @@ public abstract class AbstractMetaDataFactory
implements MetaDataFactory {
protected MetaDataRepository repos = null;
protected Log log = null;
protected transient Log log = null;
protected File dir = null;
protected int store = STORE_DEFAULT;
protected boolean strict = false;
protected Set types = null;
/**
* Set of persistent type names supplied by user.
*/

View File

@ -111,11 +111,11 @@ public class ClassMetaData
private static final Localizer _loc = Localizer.forPackage
(ClassMetaData.class);
// the repository this class belongs to, if any, and source file
private final MetaDataRepository _repos;
private MetaDataRepository _repos;
private transient ClassLoader _loader = null;
private final ValueMetaData _owner;
private final LifecycleMetaData _lifeMeta = new LifecycleMetaData(this);
private ClassLoader _loader = null;
private File _srcFile = null;
private int _srcType = SRC_OTHER;
private String[] _comments = null;
@ -537,7 +537,7 @@ public class ClassMetaData
* The datastore identity sequence name, or null for none.
*/
public String getIdentitySequenceName() {
if (_seqName == DEFAULT_STRING) {
if (DEFAULT_STRING.equals(_seqName)) {
if (_super != null)
_seqName = getPCSuperclassMetaData().getIdentitySequenceName();
else
@ -1279,7 +1279,7 @@ public class ClassMetaData
* The name of the datacache to use for this class, or null if none.
*/
public String getDataCacheName() {
if (_cacheName == DEFAULT_STRING) {
if (DEFAULT_STRING.equals(_cacheName)) {
if (_super != null)
_cacheName = getPCSuperclassMetaData().getDataCacheName();
else
@ -1353,7 +1353,7 @@ public class ClassMetaData
* The name of the detach state field, or null if none.
*/
public String getDetachedState() {
if (_detachState == DEFAULT_STRING) {
if (DEFAULT_STRING.equals(_detachState)) {
ClassMetaData sup = getPCSuperclassMetaData();
if (sup != null && sup.isDetachable() == isDetachable())
_detachState = sup.getDetachedState();
@ -2246,13 +2246,13 @@ public class ClassMetaData
// only copy this information if it wasn't set explicitly for this
// instance
if (_cacheName == DEFAULT_STRING)
if (DEFAULT_STRING.equals(_cacheName))
_cacheName = meta.getDataCacheName();
if (_cacheTimeout == Integer.MIN_VALUE)
_cacheTimeout = meta.getDataCacheTimeout();
if (_detachable == null)
_detachable = meta._detachable;
if (_detachState == DEFAULT_STRING)
if (DEFAULT_STRING.equals(_detachState))
_detachState = meta.getDetachedState();
// synch field information; first remove extra fields

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.meta;
import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
@ -35,7 +36,8 @@ import serp.util.Strings;
*
* @author Abe White
*/
public abstract class Extensions {
public abstract class Extensions
implements Serializable {
public static final String OPENJPA = "openjpa";
@ -412,7 +414,8 @@ public abstract class Extensions {
/**
* Key class.
*/
private static class HashKey {
private static class HashKey
implements Serializable {
public final String vendor;
public final String key;

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.meta;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -30,7 +31,8 @@ import serp.util.Numbers;
/**
* Captures fetch group metadata.
*/
public class FetchGroup {
public class FetchGroup
implements Serializable {
/**
* Name of the default fetch group.

View File

@ -15,6 +15,10 @@
*/
package org.apache.openjpa.meta;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
@ -156,13 +160,19 @@ public class FieldMetaData
private String _lfg = null;
private Boolean _lrs = null;
private String _extName = null;
private Method _extMethod = DEFAULT_METHOD;
private String _factName = null;
private Member _factMethod = DEFAULT_METHOD;
private String _extString = null;
private Map _extValues = Collections.EMPTY_MAP;
private Map _fieldValues = Collections.EMPTY_MAP;
private Member _backingMember = null;
// Members aren't serializable. Use a proxy that can provide a Member
// to avoid writing the full Externalizable implementation.
private transient MemberProvider _backingMember = null;
// Members aren't serializable. Initializing _extMethod and _factMethod to
// DEFAULT_METHOD is sufficient to trigger lazy population of these fields.
private transient Method _extMethod = DEFAULT_METHOD;
private transient Member _factMethod = DEFAULT_METHOD;
// intermediate and impl data
private boolean _intermediate = true;
@ -213,7 +223,7 @@ public class FieldMetaData
if (Modifier.isTransient(member.getModifiers()))
_transient = true;
_backingMember = member;
_backingMember = new MemberProvider(member);
Class type;
Class[] types;
@ -245,7 +255,7 @@ public class FieldMetaData
* Return the backing member supplied in {@link #backingMember}.
*/
public Member getBackingMember() {
return _backingMember;
return _backingMember.getMember();
}
/**
@ -782,7 +792,7 @@ public class FieldMetaData
* Logical inverse field.
*/
public String getInverse() {
if (_inverse == ClassMetaData.DEFAULT_STRING)
if (ClassMetaData.DEFAULT_STRING.equals(_inverse))
_inverse = null;
return _inverse;
}
@ -906,7 +916,7 @@ public class FieldMetaData
* The value sequence name, or null for none.
*/
public String getValueSequenceName() {
if (_seqName == ClassMetaData.DEFAULT_STRING)
if (ClassMetaData.DEFAULT_STRING.equals(_seqName))
_seqName = null;
return _seqName;
}
@ -1487,10 +1497,6 @@ public class FieldMetaData
return StoreContext.class.getName().equals(type.getName());
}
public int hashCode() {
return getFullName(true).hashCode();
}
public boolean equals(Object other) {
if (other == this)
return true;
@ -1713,7 +1719,7 @@ public class FieldMetaData
_extValues = Collections.EMPTY_MAP;
_fieldValues = Collections.EMPTY_MAP;
_primKey = field.isPrimaryKey();
_backingMember = field.getBackingMember();
_backingMember = field._backingMember;
// embedded fields can't be versions
if (_owner.getEmbeddingMetaData() == null && _version == null)
@ -1735,11 +1741,11 @@ public class FieldMetaData
_valStrategy = field.getValueStrategy();
if (_upStrategy == -1)
_upStrategy = field.getUpdateStrategy();
if (_seqName == ClassMetaData.DEFAULT_STRING) {
if (ClassMetaData.DEFAULT_STRING.equals(_seqName)) {
_seqName = field.getValueSequenceName();
_seqMeta = null;
}
if (_inverse == ClassMetaData.DEFAULT_STRING)
if (ClassMetaData.DEFAULT_STRING.equals(_inverse))
_inverse = field.getInverse();
// copy value metadata
@ -1919,4 +1925,62 @@ public class FieldMetaData
{
_val.copy (vmd);
}
/**
* Serializable wrapper around a {@link Method} or {@link Field}. For
* space considerations, this does not support {@link Constructor}s.
*/
private static class MemberProvider
implements Externalizable {
private transient Member _member;
private MemberProvider(Member member) {
if (_member instanceof Constructor)
throw new IllegalArgumentException();
_member = member;
}
public Member getMember() {
return _member;
}
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
boolean isField = in.readBoolean();
Class cls = _member.getDeclaringClass();
String memberName = (String) in.readObject();
try {
if (isField)
_member = cls.getDeclaredField(memberName);
else {
Class[] parameterTypes = (Class[]) in.readObject();
_member = cls.getDeclaredMethod(memberName, parameterTypes);
}
} catch (SecurityException e) {
IOException ioe = new IOException(e.getMessage());
ioe.initCause(e);
throw ioe;
} catch (NoSuchFieldException e) {
IOException ioe = new IOException(e.getMessage());
ioe.initCause(e);
throw ioe;
} catch (NoSuchMethodException e) {
IOException ioe = new IOException(e.getMessage());
ioe.initCause(e);
throw ioe;
}
}
public void writeExternal(ObjectOutput out)
throws IOException {
boolean isField = _member instanceof Field;
out.writeBoolean(isField);
out.writeObject(_member.getDeclaringClass());
out.writeObject(_member.getName());
if (!isField)
out.writeObject(((Method) _member).getParameterTypes());
}
}
}

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.meta;
import java.io.Serializable;
import java.util.Comparator;
/**
@ -24,7 +25,7 @@ import java.util.Comparator;
* @nojavadoc
*/
public class InheritanceComparator
implements Comparator {
implements Comparator, Serializable {
private Class _base = Object.class;

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.meta;
import java.io.Serializable;
import java.util.Arrays;
import org.apache.openjpa.event.LifecycleCallbacks;
@ -28,7 +29,8 @@ import org.apache.openjpa.util.InternalException;
* @author Steve Kim
* @author Abe White
*/
public class LifecycleMetaData {
public class LifecycleMetaData
implements Serializable {
public static final int IGNORE_NONE = 0;
public static final int IGNORE_HIGH = 2 << 0;

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.meta;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -53,7 +54,7 @@ import serp.util.Strings;
*/
public class MetaDataRepository
implements PCRegistry.RegisterClassListener, Configurable, Closeable,
MetaDataModes {
MetaDataModes, Serializable {
/**
* Constant to not validate any metadata.
@ -109,10 +110,11 @@ public class MetaDataRepository
// map of classes to lists of their subclasses
private final Map _subs = Collections.synchronizedMap(new HashMap());
private OpenJPAConfiguration _conf = null;
private Log _log = null;
private MetaDataFactory _factory = null;
private InterfaceImplGenerator _implGen = null;
private transient OpenJPAConfiguration _conf = null;
private transient Log _log = null;
private transient InterfaceImplGenerator _implGen = null;
private transient MetaDataFactory _factory = null;
private int _resMode = MODE_META | MODE_MAPPING;
private int _sourceMode = MODE_META | MODE_MAPPING | MODE_QUERY;
private int _validate = VALIDATE_META | VALIDATE_UNENHANCED;
@ -1458,6 +1460,10 @@ public class MetaDataRepository
}
public void endConfiguration() {
initializeMetaDataFactory();
}
private void initializeMetaDataFactory() {
if (_factory == null) {
MetaDataFactory mdf = _conf.newMetaDataFactoryInstance();
if (mdf == null)
@ -1789,7 +1795,8 @@ public class MetaDataRepository
/**
* Query key struct.
*/
private static class QueryKey {
private static class QueryKey
implements Serializable {
public String clsName;
public String name;

View File

@ -15,6 +15,7 @@
*/
package org.apache.openjpa.meta;
import java.io.Serializable;
import java.util.Comparator;
/**
@ -22,7 +23,8 @@ import java.util.Comparator;
*
* @author Abe White
*/
public interface Order {
public interface Order
extends Serializable {
/**
* Token denoting to order by the element value.

View File

@ -16,6 +16,7 @@
package org.apache.openjpa.meta;
import java.io.File;
import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
@ -32,7 +33,7 @@ import org.apache.openjpa.lib.xml.Commentable;
* @author Steve Kim
*/
public class QueryMetaData
implements MetaDataModes, SourceTracker, Commentable {
implements MetaDataModes, SourceTracker, Commentable, Serializable {
private static final String[] EMPTY_KEYS = new String[0];
private static final Object[] EMPTY_VALS = new Object[0];

View File

@ -16,6 +16,7 @@
package org.apache.openjpa.meta;
import java.io.File;
import java.io.Serializable;
import org.apache.commons.lang.StringUtils;
import org.apache.openjpa.conf.SeqValue;
@ -36,7 +37,8 @@ import org.apache.openjpa.util.OpenJPAException;
* @since 0.4.0
*/
public class SequenceMetaData
implements SourceTracker, MetaDataContext, Closeable, Commentable {
implements SourceTracker, MetaDataContext, Closeable, Commentable,
Serializable {
/**
* Sequence name that means to use the system default sequence.
@ -63,11 +65,12 @@ public class SequenceMetaData
private static final Localizer _loc = Localizer.forPackage
(SequenceMetaData.class);
private final MetaDataRepository _repos;
private MetaDataRepository _repos;
private SequenceFactory _factory = null;
private final String _name;
private int _type = Seq.TYPE_DEFAULT;
private String _plugin = IMPL_NATIVE;
private SequenceFactory _factory = null;
private File _source = null;
private Object _scope = null;
private int _srcType = SRC_OTHER;
@ -78,7 +81,7 @@ public class SequenceMetaData
private int _initial = -1;
// instantiated lazily
private Seq _instance = null;
private transient Seq _instance = null;
/**
* Constructor; supply sequence name.
@ -346,7 +349,8 @@ public class SequenceMetaData
* Allow facades to supply adapters from a spec sequence type to the
* OpenJPA sequence type.
*/
public static interface SequenceFactory {
public static interface SequenceFactory
extends Serializable {
/**
* Transform the given class named in metadata into a sequence.

View File

@ -15,6 +15,8 @@
*/
package org.apache.openjpa.meta;
import java.io.Serializable;
/**
* Holds metadata on a value; this could be a field value, key value, or
* element value.
@ -23,7 +25,7 @@ package org.apache.openjpa.meta;
* @author Abe White
*/
public interface ValueMetaData
extends MetaDataContext, MetaDataModes {
extends MetaDataContext, MetaDataModes, Serializable {
/**
* The operation is not cascaded to this field.

View File

@ -36,7 +36,7 @@ public class ValueMetaDataImpl
// embedded metadata, make sure to add it to the copy() method
///////////////////////////////////////////////////////////////
private final FieldMetaData _owner;
private FieldMetaData _owner;
private Class _decType = Object.class;
private int _decCode = JavaTypes.OBJECT;
private ClassMetaData _decTypeMeta = null;
@ -59,6 +59,12 @@ public class ValueMetaDataImpl
_owner = owner;
}
/**
* Constructor for serialization.
*/
protected ValueMetaDataImpl() {
}
public FieldMetaData getFieldMetaData() {
return _owner;
}

View File

@ -66,4 +66,7 @@ public abstract class AbstractProductDerivation
public boolean afterSpecificationSet(Configuration conf) {
return false;
}
public void beforeConfigurationClose(Configuration conf) {
}
}

View File

@ -112,4 +112,11 @@ public interface ProductDerivation {
* @return true if given Configuration has been mutated.
*/
public boolean afterSpecificationSet(Configuration conf);
/**
* Called before the given Configuration is closed.
*
* @since 0.9.7
*/
public void beforeConfigurationClose(Configuration conf);
}