mirror of
https://github.com/apache/openjpa.git
synced 2025-03-02 14:39:05 +00:00
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:
parent
db2128fe02
commit
301580c069
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.kernel;
|
package org.apache.openjpa.jdbc.kernel;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -69,8 +70,8 @@ public class TableJDBCSeq
|
|||||||
private static final Localizer _loc = Localizer.forPackage
|
private static final Localizer _loc = Localizer.forPackage
|
||||||
(TableJDBCSeq.class);
|
(TableJDBCSeq.class);
|
||||||
|
|
||||||
private JDBCConfiguration _conf = null;
|
private transient JDBCConfiguration _conf = null;
|
||||||
private Log _log = null;
|
private transient Log _log = null;
|
||||||
private int _alloc = 50;
|
private int _alloc = 50;
|
||||||
private final Status _stat = new Status();
|
private final Status _stat = new Status();
|
||||||
|
|
||||||
@ -624,7 +625,8 @@ public class TableJDBCSeq
|
|||||||
/**
|
/**
|
||||||
* Helper struct to hold status information.
|
* Helper struct to hold status information.
|
||||||
*/
|
*/
|
||||||
protected static class Status {
|
protected static class Status
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
public long seq = 1L;
|
public long seq = 1L;
|
||||||
public long max = 0L;
|
public long max = 0L;
|
||||||
|
@ -21,13 +21,12 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.collections.set.ListOrderedSet;
|
|
||||||
import org.apache.openjpa.enhance.PersistenceCapable;
|
import org.apache.openjpa.enhance.PersistenceCapable;
|
||||||
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
||||||
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
||||||
@ -621,8 +620,7 @@ public class ClassMapping
|
|||||||
_assignMaps = subs;
|
_assignMaps = subs;
|
||||||
} else {
|
} else {
|
||||||
int size = (int) (subs.length * 1.33 + 2);
|
int size = (int) (subs.length * 1.33 + 2);
|
||||||
Set independent = ListOrderedSet.decorate(new HashSet(size),
|
Set independent = new LinkedHashSet(size);
|
||||||
new ArrayList(subs.length + 1));
|
|
||||||
if (isMapped())
|
if (isMapped())
|
||||||
independent.add(this);
|
independent.add(this);
|
||||||
independent.addAll(Arrays.asList(subs));
|
independent.addAll(Arrays.asList(subs));
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.meta;
|
package org.apache.openjpa.jdbc.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
||||||
@ -38,7 +39,8 @@ import org.apache.openjpa.kernel.OpenJPAStateManager;
|
|||||||
*
|
*
|
||||||
* @author Abe White
|
* @author Abe White
|
||||||
*/
|
*/
|
||||||
public interface Joinable {
|
public interface Joinable
|
||||||
|
extends Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the field index of this joinable, or -1 if not a field.
|
* Return the field index of this joinable, or -1 if not a field.
|
||||||
|
@ -44,7 +44,7 @@ import serp.util.Strings;
|
|||||||
public class MappingDefaultsImpl
|
public class MappingDefaultsImpl
|
||||||
implements MappingDefaults, Configurable {
|
implements MappingDefaults, Configurable {
|
||||||
|
|
||||||
protected DBDictionary dict = null;
|
protected transient DBDictionary dict = null;
|
||||||
private String _baseClassStrategy = null;
|
private String _baseClassStrategy = null;
|
||||||
private String _subclassStrategy = null;
|
private String _subclassStrategy = null;
|
||||||
private String _versionStrategy = null;
|
private String _versionStrategy = null;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.meta;
|
package org.apache.openjpa.jdbc.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -47,7 +48,8 @@ import serp.util.Strings;
|
|||||||
*
|
*
|
||||||
* @author Abe White
|
* @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_NONE = 0;
|
||||||
public static final int JOIN_FORWARD = 1;
|
public static final int JOIN_FORWARD = 1;
|
||||||
|
@ -65,6 +65,7 @@ import org.apache.openjpa.jdbc.schema.Column;
|
|||||||
import org.apache.openjpa.jdbc.schema.SchemaGroup;
|
import org.apache.openjpa.jdbc.schema.SchemaGroup;
|
||||||
import org.apache.openjpa.jdbc.sql.DBDictionary;
|
import org.apache.openjpa.jdbc.sql.DBDictionary;
|
||||||
import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
|
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.conf.Configurations;
|
||||||
import org.apache.openjpa.lib.util.Localizer;
|
import org.apache.openjpa.lib.util.Localizer;
|
||||||
import org.apache.openjpa.meta.ClassMetaData;
|
import org.apache.openjpa.meta.ClassMetaData;
|
||||||
@ -94,8 +95,9 @@ public class MappingRepository
|
|||||||
"org.apache.openjpa.jdbc.meta.strats.EnumValueHandler");
|
"org.apache.openjpa.jdbc.meta.strats.EnumValueHandler");
|
||||||
}
|
}
|
||||||
|
|
||||||
private DBDictionary _dict = null;
|
private transient DBDictionary _dict = null;
|
||||||
private MappingDefaults _defaults = null;
|
private transient MappingDefaults _defaults = null;
|
||||||
|
|
||||||
private Map _results = new HashMap(); // object->queryresultmapping
|
private Map _results = new HashMap(); // object->queryresultmapping
|
||||||
private SchemaGroup _schema = null;
|
private SchemaGroup _schema = null;
|
||||||
private StrategyInstaller _installer = null;
|
private StrategyInstaller _installer = null;
|
||||||
@ -1167,5 +1169,10 @@ public class MappingRepository
|
|||||||
_dict = conf.getDBDictionaryInstance();
|
_dict = conf.getDBDictionaryInstance();
|
||||||
if (_defaults == null)
|
if (_defaults == null)
|
||||||
_defaults = conf.getMappingDefaultsInstance();
|
_defaults = conf.getMappingDefaultsInstance();
|
||||||
|
if (_schema != null && _schema instanceof Configurable) {
|
||||||
|
((Configurable) _schema).setConfiguration(conf);
|
||||||
|
((Configurable) _schema).startConfiguration();
|
||||||
|
((Configurable) _schema).endConfiguration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,6 +21,7 @@ import org.apache.openjpa.jdbc.schema.Index;
|
|||||||
import org.apache.openjpa.jdbc.schema.Schema;
|
import org.apache.openjpa.jdbc.schema.Schema;
|
||||||
import org.apache.openjpa.jdbc.schema.Table;
|
import org.apache.openjpa.jdbc.schema.Table;
|
||||||
import org.apache.openjpa.jdbc.schema.Unique;
|
import org.apache.openjpa.jdbc.schema.Unique;
|
||||||
|
|
||||||
import serp.util.Strings;
|
import serp.util.Strings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.meta;
|
package org.apache.openjpa.jdbc.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
import org.apache.openjpa.jdbc.kernel.JDBCStore;
|
||||||
@ -28,7 +29,8 @@ import org.apache.openjpa.util.MetaDataException;
|
|||||||
* @author Abe White
|
* @author Abe White
|
||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
public interface Strategy {
|
public interface Strategy
|
||||||
|
extends Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the alias of this strategy. For custom strategies, return the
|
* Return the alias of this strategy. For custom strategies, return the
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.meta;
|
package org.apache.openjpa.jdbc.meta;
|
||||||
|
|
||||||
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installs mapping strategies.
|
* Installs mapping strategies.
|
||||||
@ -24,9 +24,9 @@ import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
|
|||||||
* @nojavadoc
|
* @nojavadoc
|
||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
public abstract class StrategyInstaller {
|
public abstract class StrategyInstaller
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
protected final JDBCConfiguration conf;
|
|
||||||
protected final MappingRepository repos;
|
protected final MappingRepository repos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +34,6 @@ public abstract class StrategyInstaller {
|
|||||||
*/
|
*/
|
||||||
public StrategyInstaller(MappingRepository repos) {
|
public StrategyInstaller(MappingRepository repos) {
|
||||||
this.repos = repos;
|
this.repos = repos;
|
||||||
this.conf = (JDBCConfiguration) repos.getConfiguration();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.meta;
|
package org.apache.openjpa.jdbc.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
|
||||||
@ -30,7 +31,8 @@ import org.apache.openjpa.kernel.OpenJPAStateManager;
|
|||||||
* @author Abe White
|
* @author Abe White
|
||||||
* @since 0.4.0
|
* @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
|
* Map the given value and return all mapped columns, or simply return an
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.meta;
|
package org.apache.openjpa.jdbc.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import org.apache.openjpa.jdbc.schema.Column;
|
import org.apache.openjpa.jdbc.schema.Column;
|
||||||
@ -34,7 +35,7 @@ import org.apache.openjpa.meta.ValueMetaData;
|
|||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
public interface ValueMapping
|
public interface ValueMapping
|
||||||
extends ValueMetaData, MetaDataContext {
|
extends ValueMetaData, MetaDataContext, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard forward join.
|
* Standard forward join.
|
||||||
|
@ -48,7 +48,7 @@ public class ValueMappingImpl
|
|||||||
private static final Localizer _loc = Localizer.forPackage
|
private static final Localizer _loc = Localizer.forPackage
|
||||||
(ValueMappingImpl.class);
|
(ValueMappingImpl.class);
|
||||||
|
|
||||||
private final ValueMappingInfo _info;
|
private ValueMappingInfo _info;
|
||||||
private ValueHandler _handler = null;
|
private ValueHandler _handler = null;
|
||||||
private ClassMapping[] _typeArr = null;
|
private ClassMapping[] _typeArr = null;
|
||||||
|
|
||||||
@ -72,6 +72,13 @@ public class ValueMappingImpl
|
|||||||
getMappingDefaults().useClassCriteria());
|
getMappingDefaults().useClassCriteria());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for deserialization.
|
||||||
|
*/
|
||||||
|
protected ValueMappingImpl() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
public ValueMappingInfo getValueInfo() {
|
public ValueMappingInfo getValueInfo() {
|
||||||
return _info;
|
return _info;
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.schema;
|
package org.apache.openjpa.jdbc.schema;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata about column I/O in a specific context. In the context of
|
* 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
|
* 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
|
* @author Abe White
|
||||||
*/
|
*/
|
||||||
public class ColumnIO {
|
public class ColumnIO
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
public static final ColumnIO UNRESTRICTED = new ColumnIO() {
|
public static final ColumnIO UNRESTRICTED = new ColumnIO() {
|
||||||
public void setInsertable(int col, boolean insertable) {
|
public void setInsertable(int col, boolean insertable) {
|
||||||
|
@ -35,7 +35,7 @@ public class DynamicSchemaFactory
|
|||||||
extends SchemaGroup
|
extends SchemaGroup
|
||||||
implements SchemaFactory, Configurable {
|
implements SchemaFactory, Configurable {
|
||||||
|
|
||||||
private DBDictionary _dict = null;
|
private transient DBDictionary _dict = null;
|
||||||
private String _schema = null;
|
private String _schema = null;
|
||||||
|
|
||||||
public void setConfiguration(Configuration conf) {
|
public void setConfiguration(Configuration conf) {
|
||||||
|
@ -19,8 +19,8 @@ import java.sql.DatabaseMetaData;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
import org.apache.commons.collections.map.LinkedMap;
|
|
||||||
import org.apache.commons.lang.ObjectUtils;
|
import org.apache.commons.lang.ObjectUtils;
|
||||||
import org.apache.openjpa.lib.util.Localizer;
|
import org.apache.openjpa.lib.util.Localizer;
|
||||||
import org.apache.openjpa.lib.util.StringDistance;
|
import org.apache.openjpa.lib.util.StringDistance;
|
||||||
@ -65,17 +65,18 @@ public class ForeignKey
|
|||||||
*/
|
*/
|
||||||
public static final int ACTION_DEFAULT = 5;
|
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 _pkTableName = null;
|
||||||
private String _pkSchemaName = null;
|
private String _pkSchemaName = null;
|
||||||
private String _pkColumnName = null;
|
private String _pkColumnName = null;
|
||||||
private int _seq = 0;
|
private int _seq = 0;
|
||||||
|
|
||||||
private LinkedMap _joins = null;
|
private LinkedHashMap _joins = null;
|
||||||
private LinkedMap _joinsPK = null;
|
private LinkedHashMap _joinsPK = null;
|
||||||
private LinkedMap _consts = null;
|
private LinkedHashMap _consts = null;
|
||||||
public LinkedMap _constsPK = null;
|
private LinkedHashMap _constsPK = null;
|
||||||
private int _delAction = ACTION_NONE;
|
private int _delAction = ACTION_NONE;
|
||||||
private int _upAction = ACTION_NONE;
|
private int _upAction = ACTION_NONE;
|
||||||
private int _index = 0;
|
private int _index = 0;
|
||||||
@ -525,10 +526,10 @@ public class ForeignKey
|
|||||||
|
|
||||||
_pkTable = pkTable;
|
_pkTable = pkTable;
|
||||||
if (_joins == null)
|
if (_joins == null)
|
||||||
_joins = new LinkedMap();
|
_joins = new LinkedHashMap();
|
||||||
_joins.put(local, toPK);
|
_joins.put(local, toPK);
|
||||||
if (_joinsPK == null)
|
if (_joinsPK == null)
|
||||||
_joinsPK = new LinkedMap();
|
_joinsPK = new LinkedHashMap();
|
||||||
_joinsPK.put(toPK, local);
|
_joinsPK.put(toPK, local);
|
||||||
|
|
||||||
// force re-cache
|
// force re-cache
|
||||||
@ -550,7 +551,7 @@ public class ForeignKey
|
|||||||
|
|
||||||
_pkTable = pkTable;
|
_pkTable = pkTable;
|
||||||
if (_constsPK == null)
|
if (_constsPK == null)
|
||||||
_constsPK = new LinkedMap();
|
_constsPK = new LinkedHashMap();
|
||||||
_constsPK.put(toPK, val);
|
_constsPK.put(toPK, val);
|
||||||
|
|
||||||
// force re-cache
|
// force re-cache
|
||||||
@ -564,7 +565,7 @@ public class ForeignKey
|
|||||||
*/
|
*/
|
||||||
public void joinConstant(Column col, Object val) {
|
public void joinConstant(Column col, Object val) {
|
||||||
if (_consts == null)
|
if (_consts == null)
|
||||||
_consts = new LinkedMap();
|
_consts = new LinkedHashMap();
|
||||||
_consts.put(col, val);
|
_consts.put(col, val);
|
||||||
|
|
||||||
// force re-cache
|
// force re-cache
|
||||||
|
@ -36,10 +36,11 @@ public class LazySchemaFactory
|
|||||||
extends SchemaGroup
|
extends SchemaGroup
|
||||||
implements SchemaFactory, Configurable {
|
implements SchemaFactory, Configurable {
|
||||||
|
|
||||||
private JDBCConfiguration _conf = null;
|
private transient JDBCConfiguration _conf = null;
|
||||||
private SchemaGenerator _gen = null;
|
private transient Connection _conn = null;
|
||||||
private Connection _conn = null;
|
private transient DatabaseMetaData _meta = null;
|
||||||
private DatabaseMetaData _meta = null;
|
private transient SchemaGenerator _gen = null;
|
||||||
|
|
||||||
private boolean _indexes = false;
|
private boolean _indexes = false;
|
||||||
private boolean _pks = false;
|
private boolean _pks = false;
|
||||||
private boolean _fks = false;
|
private boolean _fks = false;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.schema;
|
package org.apache.openjpa.jdbc.schema;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -28,7 +29,8 @@ import org.apache.openjpa.lib.util.Localizer;
|
|||||||
*
|
*
|
||||||
* @author Abe White
|
* @author Abe White
|
||||||
*/
|
*/
|
||||||
public class NameSet {
|
public class NameSet
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
private static final Localizer _loc = Localizer.forPackage(NameSet.class);
|
private static final Localizer _loc = Localizer.forPackage(NameSet.class);
|
||||||
|
|
||||||
|
@ -15,13 +15,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.schema;
|
package org.apache.openjpa.jdbc.schema;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some schema components count references so that unused components
|
* Some schema components count references so that unused components
|
||||||
* can be detected.
|
* can be detected.
|
||||||
*
|
*
|
||||||
* @author Abe White
|
* @author Abe White
|
||||||
*/
|
*/
|
||||||
class ReferenceCounter {
|
class ReferenceCounter
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
private int _count = 0;
|
private int _count = 0;
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.jdbc.schema;
|
package org.apache.openjpa.jdbc.schema;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
@ -26,7 +27,7 @@ import org.apache.commons.lang.StringUtils;
|
|||||||
* @author Abe White
|
* @author Abe White
|
||||||
*/
|
*/
|
||||||
public class Schema
|
public class Schema
|
||||||
implements Comparable {
|
implements Comparable, Serializable {
|
||||||
|
|
||||||
private String _name = null;
|
private String _name = null;
|
||||||
private SchemaGroup _group = null;
|
private SchemaGroup _group = null;
|
||||||
|
@ -21,8 +21,8 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
|
||||||
import org.apache.commons.collections.map.LinkedMap;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.openjpa.lib.meta.SourceTracker;
|
import org.apache.openjpa.lib.meta.SourceTracker;
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ public class Table
|
|||||||
else
|
else
|
||||||
col = new Column(name, this);
|
col = new Column(name, this);
|
||||||
if (_colMap == null)
|
if (_colMap == null)
|
||||||
_colMap = new LinkedMap();
|
_colMap = new LinkedHashMap();
|
||||||
_colMap.put(name.toUpperCase(), col);
|
_colMap.put(name.toUpperCase(), col);
|
||||||
_cols = null;
|
_cols = null;
|
||||||
return col;
|
return col;
|
||||||
|
@ -15,6 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.event;
|
package org.apache.openjpa.event;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInput;
|
||||||
|
import java.io.ObjectOutput;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import org.apache.openjpa.lib.util.Localizer;
|
import org.apache.openjpa.lib.util.Localizer;
|
||||||
@ -31,7 +34,7 @@ public class BeanLifecycleCallbacks
|
|||||||
private static final Localizer _loc = Localizer.forPackage
|
private static final Localizer _loc = Localizer.forPackage
|
||||||
(BeanLifecycleCallbacks.class);
|
(BeanLifecycleCallbacks.class);
|
||||||
|
|
||||||
private Object _listener;
|
private transient Object _listener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Make the callback on an instance of the given type.
|
* 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) {
|
public BeanLifecycleCallbacks(Class cls, Method method, boolean arg) {
|
||||||
super(method, arg);
|
super(method, arg);
|
||||||
|
_listener = newListener(cls);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object newListener(Class cls) {
|
||||||
try {
|
try {
|
||||||
_listener = cls.newInstance();
|
return cls.newInstance();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
throw new UserException(_loc.get("bean-constructor",
|
throw new UserException(_loc.get("bean-constructor",
|
||||||
cls.getName()), t);
|
cls.getName()), t);
|
||||||
@ -67,4 +74,17 @@ public class BeanLifecycleCallbacks
|
|||||||
else
|
else
|
||||||
callback.invoke(_listener, new Object[]{ obj });
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.event;
|
package org.apache.openjpa.event;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A lifecycle listener that responds to callbacks rather than events.
|
* A lifecycle listener that responds to callbacks rather than events.
|
||||||
*
|
*
|
||||||
* @author Steve Kim
|
* @author Steve Kim
|
||||||
*/
|
*/
|
||||||
public interface LifecycleCallbacks {
|
public interface LifecycleCallbacks
|
||||||
|
extends Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the given instance has a callback for the given
|
* Return whether the given instance has a callback for the given
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.event;
|
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.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@ -27,12 +31,12 @@ import org.apache.openjpa.util.UserException;
|
|||||||
* @author Steve Kim
|
* @author Steve Kim
|
||||||
*/
|
*/
|
||||||
public class MethodLifecycleCallbacks
|
public class MethodLifecycleCallbacks
|
||||||
implements LifecycleCallbacks {
|
implements LifecycleCallbacks, Externalizable {
|
||||||
|
|
||||||
private static final Localizer _loc = Localizer.forPackage
|
private static final Localizer _loc = Localizer.forPackage
|
||||||
(MethodLifecycleCallbacks.class);
|
(MethodLifecycleCallbacks.class);
|
||||||
|
|
||||||
private Method _callback;
|
private transient Method _callback;
|
||||||
private boolean _arg;
|
private boolean _arg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,4 +142,21 @@ public class MethodLifecycleCallbacks
|
|||||||
|
|
||||||
return true;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,12 +38,13 @@ public abstract class AbstractMetaDataFactory
|
|||||||
implements MetaDataFactory {
|
implements MetaDataFactory {
|
||||||
|
|
||||||
protected MetaDataRepository repos = null;
|
protected MetaDataRepository repos = null;
|
||||||
protected Log log = null;
|
protected transient Log log = null;
|
||||||
protected File dir = null;
|
protected File dir = null;
|
||||||
protected int store = STORE_DEFAULT;
|
protected int store = STORE_DEFAULT;
|
||||||
protected boolean strict = false;
|
protected boolean strict = false;
|
||||||
protected Set types = null;
|
protected Set types = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set of persistent type names supplied by user.
|
* Set of persistent type names supplied by user.
|
||||||
*/
|
*/
|
||||||
|
@ -111,11 +111,11 @@ public class ClassMetaData
|
|||||||
private static final Localizer _loc = Localizer.forPackage
|
private static final Localizer _loc = Localizer.forPackage
|
||||||
(ClassMetaData.class);
|
(ClassMetaData.class);
|
||||||
|
|
||||||
// the repository this class belongs to, if any, and source file
|
private MetaDataRepository _repos;
|
||||||
private final MetaDataRepository _repos;
|
private transient ClassLoader _loader = null;
|
||||||
|
|
||||||
private final ValueMetaData _owner;
|
private final ValueMetaData _owner;
|
||||||
private final LifecycleMetaData _lifeMeta = new LifecycleMetaData(this);
|
private final LifecycleMetaData _lifeMeta = new LifecycleMetaData(this);
|
||||||
private ClassLoader _loader = null;
|
|
||||||
private File _srcFile = null;
|
private File _srcFile = null;
|
||||||
private int _srcType = SRC_OTHER;
|
private int _srcType = SRC_OTHER;
|
||||||
private String[] _comments = null;
|
private String[] _comments = null;
|
||||||
@ -537,7 +537,7 @@ public class ClassMetaData
|
|||||||
* The datastore identity sequence name, or null for none.
|
* The datastore identity sequence name, or null for none.
|
||||||
*/
|
*/
|
||||||
public String getIdentitySequenceName() {
|
public String getIdentitySequenceName() {
|
||||||
if (_seqName == DEFAULT_STRING) {
|
if (DEFAULT_STRING.equals(_seqName)) {
|
||||||
if (_super != null)
|
if (_super != null)
|
||||||
_seqName = getPCSuperclassMetaData().getIdentitySequenceName();
|
_seqName = getPCSuperclassMetaData().getIdentitySequenceName();
|
||||||
else
|
else
|
||||||
@ -1279,7 +1279,7 @@ public class ClassMetaData
|
|||||||
* The name of the datacache to use for this class, or null if none.
|
* The name of the datacache to use for this class, or null if none.
|
||||||
*/
|
*/
|
||||||
public String getDataCacheName() {
|
public String getDataCacheName() {
|
||||||
if (_cacheName == DEFAULT_STRING) {
|
if (DEFAULT_STRING.equals(_cacheName)) {
|
||||||
if (_super != null)
|
if (_super != null)
|
||||||
_cacheName = getPCSuperclassMetaData().getDataCacheName();
|
_cacheName = getPCSuperclassMetaData().getDataCacheName();
|
||||||
else
|
else
|
||||||
@ -1353,7 +1353,7 @@ public class ClassMetaData
|
|||||||
* The name of the detach state field, or null if none.
|
* The name of the detach state field, or null if none.
|
||||||
*/
|
*/
|
||||||
public String getDetachedState() {
|
public String getDetachedState() {
|
||||||
if (_detachState == DEFAULT_STRING) {
|
if (DEFAULT_STRING.equals(_detachState)) {
|
||||||
ClassMetaData sup = getPCSuperclassMetaData();
|
ClassMetaData sup = getPCSuperclassMetaData();
|
||||||
if (sup != null && sup.isDetachable() == isDetachable())
|
if (sup != null && sup.isDetachable() == isDetachable())
|
||||||
_detachState = sup.getDetachedState();
|
_detachState = sup.getDetachedState();
|
||||||
@ -2246,13 +2246,13 @@ public class ClassMetaData
|
|||||||
|
|
||||||
// only copy this information if it wasn't set explicitly for this
|
// only copy this information if it wasn't set explicitly for this
|
||||||
// instance
|
// instance
|
||||||
if (_cacheName == DEFAULT_STRING)
|
if (DEFAULT_STRING.equals(_cacheName))
|
||||||
_cacheName = meta.getDataCacheName();
|
_cacheName = meta.getDataCacheName();
|
||||||
if (_cacheTimeout == Integer.MIN_VALUE)
|
if (_cacheTimeout == Integer.MIN_VALUE)
|
||||||
_cacheTimeout = meta.getDataCacheTimeout();
|
_cacheTimeout = meta.getDataCacheTimeout();
|
||||||
if (_detachable == null)
|
if (_detachable == null)
|
||||||
_detachable = meta._detachable;
|
_detachable = meta._detachable;
|
||||||
if (_detachState == DEFAULT_STRING)
|
if (DEFAULT_STRING.equals(_detachState))
|
||||||
_detachState = meta.getDetachedState();
|
_detachState = meta.getDetachedState();
|
||||||
|
|
||||||
// synch field information; first remove extra fields
|
// synch field information; first remove extra fields
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -35,7 +36,8 @@ import serp.util.Strings;
|
|||||||
*
|
*
|
||||||
* @author Abe White
|
* @author Abe White
|
||||||
*/
|
*/
|
||||||
public abstract class Extensions {
|
public abstract class Extensions
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
public static final String OPENJPA = "openjpa";
|
public static final String OPENJPA = "openjpa";
|
||||||
|
|
||||||
@ -412,7 +414,8 @@ public abstract class Extensions {
|
|||||||
/**
|
/**
|
||||||
* Key class.
|
* Key class.
|
||||||
*/
|
*/
|
||||||
private static class HashKey {
|
private static class HashKey
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
public final String vendor;
|
public final String vendor;
|
||||||
public final String key;
|
public final String key;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -30,7 +31,8 @@ import serp.util.Numbers;
|
|||||||
/**
|
/**
|
||||||
* Captures fetch group metadata.
|
* Captures fetch group metadata.
|
||||||
*/
|
*/
|
||||||
public class FetchGroup {
|
public class FetchGroup
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the default fetch group.
|
* Name of the default fetch group.
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.meta;
|
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.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -156,13 +160,19 @@ public class FieldMetaData
|
|||||||
private String _lfg = null;
|
private String _lfg = null;
|
||||||
private Boolean _lrs = null;
|
private Boolean _lrs = null;
|
||||||
private String _extName = null;
|
private String _extName = null;
|
||||||
private Method _extMethod = DEFAULT_METHOD;
|
|
||||||
private String _factName = null;
|
private String _factName = null;
|
||||||
private Member _factMethod = DEFAULT_METHOD;
|
|
||||||
private String _extString = null;
|
private String _extString = null;
|
||||||
private Map _extValues = Collections.EMPTY_MAP;
|
private Map _extValues = Collections.EMPTY_MAP;
|
||||||
private Map _fieldValues = 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
|
// intermediate and impl data
|
||||||
private boolean _intermediate = true;
|
private boolean _intermediate = true;
|
||||||
@ -213,7 +223,7 @@ public class FieldMetaData
|
|||||||
if (Modifier.isTransient(member.getModifiers()))
|
if (Modifier.isTransient(member.getModifiers()))
|
||||||
_transient = true;
|
_transient = true;
|
||||||
|
|
||||||
_backingMember = member;
|
_backingMember = new MemberProvider(member);
|
||||||
|
|
||||||
Class type;
|
Class type;
|
||||||
Class[] types;
|
Class[] types;
|
||||||
@ -245,7 +255,7 @@ public class FieldMetaData
|
|||||||
* Return the backing member supplied in {@link #backingMember}.
|
* Return the backing member supplied in {@link #backingMember}.
|
||||||
*/
|
*/
|
||||||
public Member getBackingMember() {
|
public Member getBackingMember() {
|
||||||
return _backingMember;
|
return _backingMember.getMember();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -782,7 +792,7 @@ public class FieldMetaData
|
|||||||
* Logical inverse field.
|
* Logical inverse field.
|
||||||
*/
|
*/
|
||||||
public String getInverse() {
|
public String getInverse() {
|
||||||
if (_inverse == ClassMetaData.DEFAULT_STRING)
|
if (ClassMetaData.DEFAULT_STRING.equals(_inverse))
|
||||||
_inverse = null;
|
_inverse = null;
|
||||||
return _inverse;
|
return _inverse;
|
||||||
}
|
}
|
||||||
@ -906,7 +916,7 @@ public class FieldMetaData
|
|||||||
* The value sequence name, or null for none.
|
* The value sequence name, or null for none.
|
||||||
*/
|
*/
|
||||||
public String getValueSequenceName() {
|
public String getValueSequenceName() {
|
||||||
if (_seqName == ClassMetaData.DEFAULT_STRING)
|
if (ClassMetaData.DEFAULT_STRING.equals(_seqName))
|
||||||
_seqName = null;
|
_seqName = null;
|
||||||
return _seqName;
|
return _seqName;
|
||||||
}
|
}
|
||||||
@ -1487,10 +1497,6 @@ public class FieldMetaData
|
|||||||
return StoreContext.class.getName().equals(type.getName());
|
return StoreContext.class.getName().equals(type.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode() {
|
|
||||||
return getFullName(true).hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (other == this)
|
if (other == this)
|
||||||
return true;
|
return true;
|
||||||
@ -1713,7 +1719,7 @@ public class FieldMetaData
|
|||||||
_extValues = Collections.EMPTY_MAP;
|
_extValues = Collections.EMPTY_MAP;
|
||||||
_fieldValues = Collections.EMPTY_MAP;
|
_fieldValues = Collections.EMPTY_MAP;
|
||||||
_primKey = field.isPrimaryKey();
|
_primKey = field.isPrimaryKey();
|
||||||
_backingMember = field.getBackingMember();
|
_backingMember = field._backingMember;
|
||||||
|
|
||||||
// embedded fields can't be versions
|
// embedded fields can't be versions
|
||||||
if (_owner.getEmbeddingMetaData() == null && _version == null)
|
if (_owner.getEmbeddingMetaData() == null && _version == null)
|
||||||
@ -1735,11 +1741,11 @@ public class FieldMetaData
|
|||||||
_valStrategy = field.getValueStrategy();
|
_valStrategy = field.getValueStrategy();
|
||||||
if (_upStrategy == -1)
|
if (_upStrategy == -1)
|
||||||
_upStrategy = field.getUpdateStrategy();
|
_upStrategy = field.getUpdateStrategy();
|
||||||
if (_seqName == ClassMetaData.DEFAULT_STRING) {
|
if (ClassMetaData.DEFAULT_STRING.equals(_seqName)) {
|
||||||
_seqName = field.getValueSequenceName();
|
_seqName = field.getValueSequenceName();
|
||||||
_seqMeta = null;
|
_seqMeta = null;
|
||||||
}
|
}
|
||||||
if (_inverse == ClassMetaData.DEFAULT_STRING)
|
if (ClassMetaData.DEFAULT_STRING.equals(_inverse))
|
||||||
_inverse = field.getInverse();
|
_inverse = field.getInverse();
|
||||||
|
|
||||||
// copy value metadata
|
// copy value metadata
|
||||||
@ -1919,4 +1925,62 @@ public class FieldMetaData
|
|||||||
{
|
{
|
||||||
_val.copy (vmd);
|
_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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +25,7 @@ import java.util.Comparator;
|
|||||||
* @nojavadoc
|
* @nojavadoc
|
||||||
*/
|
*/
|
||||||
public class InheritanceComparator
|
public class InheritanceComparator
|
||||||
implements Comparator {
|
implements Comparator, Serializable {
|
||||||
|
|
||||||
private Class _base = Object.class;
|
private Class _base = Object.class;
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.apache.openjpa.event.LifecycleCallbacks;
|
import org.apache.openjpa.event.LifecycleCallbacks;
|
||||||
@ -28,7 +29,8 @@ import org.apache.openjpa.util.InternalException;
|
|||||||
* @author Steve Kim
|
* @author Steve Kim
|
||||||
* @author Abe White
|
* @author Abe White
|
||||||
*/
|
*/
|
||||||
public class LifecycleMetaData {
|
public class LifecycleMetaData
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
public static final int IGNORE_NONE = 0;
|
public static final int IGNORE_NONE = 0;
|
||||||
public static final int IGNORE_HIGH = 2 << 0;
|
public static final int IGNORE_HIGH = 2 << 0;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -53,7 +54,7 @@ import serp.util.Strings;
|
|||||||
*/
|
*/
|
||||||
public class MetaDataRepository
|
public class MetaDataRepository
|
||||||
implements PCRegistry.RegisterClassListener, Configurable, Closeable,
|
implements PCRegistry.RegisterClassListener, Configurable, Closeable,
|
||||||
MetaDataModes {
|
MetaDataModes, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant to not validate any metadata.
|
* Constant to not validate any metadata.
|
||||||
@ -109,10 +110,11 @@ public class MetaDataRepository
|
|||||||
// map of classes to lists of their subclasses
|
// map of classes to lists of their subclasses
|
||||||
private final Map _subs = Collections.synchronizedMap(new HashMap());
|
private final Map _subs = Collections.synchronizedMap(new HashMap());
|
||||||
|
|
||||||
private OpenJPAConfiguration _conf = null;
|
private transient OpenJPAConfiguration _conf = null;
|
||||||
private Log _log = null;
|
private transient Log _log = null;
|
||||||
private MetaDataFactory _factory = null;
|
private transient InterfaceImplGenerator _implGen = null;
|
||||||
private InterfaceImplGenerator _implGen = null;
|
private transient MetaDataFactory _factory = null;
|
||||||
|
|
||||||
private int _resMode = MODE_META | MODE_MAPPING;
|
private int _resMode = MODE_META | MODE_MAPPING;
|
||||||
private int _sourceMode = MODE_META | MODE_MAPPING | MODE_QUERY;
|
private int _sourceMode = MODE_META | MODE_MAPPING | MODE_QUERY;
|
||||||
private int _validate = VALIDATE_META | VALIDATE_UNENHANCED;
|
private int _validate = VALIDATE_META | VALIDATE_UNENHANCED;
|
||||||
@ -1458,6 +1460,10 @@ public class MetaDataRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void endConfiguration() {
|
public void endConfiguration() {
|
||||||
|
initializeMetaDataFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeMetaDataFactory() {
|
||||||
if (_factory == null) {
|
if (_factory == null) {
|
||||||
MetaDataFactory mdf = _conf.newMetaDataFactoryInstance();
|
MetaDataFactory mdf = _conf.newMetaDataFactoryInstance();
|
||||||
if (mdf == null)
|
if (mdf == null)
|
||||||
@ -1789,7 +1795,8 @@ public class MetaDataRepository
|
|||||||
/**
|
/**
|
||||||
* Query key struct.
|
* Query key struct.
|
||||||
*/
|
*/
|
||||||
private static class QueryKey {
|
private static class QueryKey
|
||||||
|
implements Serializable {
|
||||||
|
|
||||||
public String clsName;
|
public String clsName;
|
||||||
public String name;
|
public String name;
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -22,7 +23,8 @@ import java.util.Comparator;
|
|||||||
*
|
*
|
||||||
* @author Abe White
|
* @author Abe White
|
||||||
*/
|
*/
|
||||||
public interface Order {
|
public interface Order
|
||||||
|
extends Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Token denoting to order by the element value.
|
* Token denoting to order by the element value.
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ import org.apache.openjpa.lib.xml.Commentable;
|
|||||||
* @author Steve Kim
|
* @author Steve Kim
|
||||||
*/
|
*/
|
||||||
public class QueryMetaData
|
public class QueryMetaData
|
||||||
implements MetaDataModes, SourceTracker, Commentable {
|
implements MetaDataModes, SourceTracker, Commentable, Serializable {
|
||||||
|
|
||||||
private static final String[] EMPTY_KEYS = new String[0];
|
private static final String[] EMPTY_KEYS = new String[0];
|
||||||
private static final Object[] EMPTY_VALS = new Object[0];
|
private static final Object[] EMPTY_VALS = new Object[0];
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.openjpa.conf.SeqValue;
|
import org.apache.openjpa.conf.SeqValue;
|
||||||
@ -36,7 +37,8 @@ import org.apache.openjpa.util.OpenJPAException;
|
|||||||
* @since 0.4.0
|
* @since 0.4.0
|
||||||
*/
|
*/
|
||||||
public class SequenceMetaData
|
public class SequenceMetaData
|
||||||
implements SourceTracker, MetaDataContext, Closeable, Commentable {
|
implements SourceTracker, MetaDataContext, Closeable, Commentable,
|
||||||
|
Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sequence name that means to use the system default sequence.
|
* Sequence name that means to use the system default sequence.
|
||||||
@ -63,11 +65,12 @@ public class SequenceMetaData
|
|||||||
private static final Localizer _loc = Localizer.forPackage
|
private static final Localizer _loc = Localizer.forPackage
|
||||||
(SequenceMetaData.class);
|
(SequenceMetaData.class);
|
||||||
|
|
||||||
private final MetaDataRepository _repos;
|
private MetaDataRepository _repos;
|
||||||
|
private SequenceFactory _factory = null;
|
||||||
|
|
||||||
private final String _name;
|
private final String _name;
|
||||||
private int _type = Seq.TYPE_DEFAULT;
|
private int _type = Seq.TYPE_DEFAULT;
|
||||||
private String _plugin = IMPL_NATIVE;
|
private String _plugin = IMPL_NATIVE;
|
||||||
private SequenceFactory _factory = null;
|
|
||||||
private File _source = null;
|
private File _source = null;
|
||||||
private Object _scope = null;
|
private Object _scope = null;
|
||||||
private int _srcType = SRC_OTHER;
|
private int _srcType = SRC_OTHER;
|
||||||
@ -78,7 +81,7 @@ public class SequenceMetaData
|
|||||||
private int _initial = -1;
|
private int _initial = -1;
|
||||||
|
|
||||||
// instantiated lazily
|
// instantiated lazily
|
||||||
private Seq _instance = null;
|
private transient Seq _instance = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor; supply sequence name.
|
* Constructor; supply sequence name.
|
||||||
@ -346,7 +349,8 @@ public class SequenceMetaData
|
|||||||
* Allow facades to supply adapters from a spec sequence type to the
|
* Allow facades to supply adapters from a spec sequence type to the
|
||||||
* OpenJPA sequence type.
|
* OpenJPA sequence type.
|
||||||
*/
|
*/
|
||||||
public static interface SequenceFactory {
|
public static interface SequenceFactory
|
||||||
|
extends Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the given class named in metadata into a sequence.
|
* Transform the given class named in metadata into a sequence.
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds metadata on a value; this could be a field value, key value, or
|
* Holds metadata on a value; this could be a field value, key value, or
|
||||||
* element value.
|
* element value.
|
||||||
@ -23,7 +25,7 @@ package org.apache.openjpa.meta;
|
|||||||
* @author Abe White
|
* @author Abe White
|
||||||
*/
|
*/
|
||||||
public interface ValueMetaData
|
public interface ValueMetaData
|
||||||
extends MetaDataContext, MetaDataModes {
|
extends MetaDataContext, MetaDataModes, Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The operation is not cascaded to this field.
|
* The operation is not cascaded to this field.
|
||||||
|
@ -36,7 +36,7 @@ public class ValueMetaDataImpl
|
|||||||
// embedded metadata, make sure to add it to the copy() method
|
// embedded metadata, make sure to add it to the copy() method
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private final FieldMetaData _owner;
|
private FieldMetaData _owner;
|
||||||
private Class _decType = Object.class;
|
private Class _decType = Object.class;
|
||||||
private int _decCode = JavaTypes.OBJECT;
|
private int _decCode = JavaTypes.OBJECT;
|
||||||
private ClassMetaData _decTypeMeta = null;
|
private ClassMetaData _decTypeMeta = null;
|
||||||
@ -59,6 +59,12 @@ public class ValueMetaDataImpl
|
|||||||
_owner = owner;
|
_owner = owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for serialization.
|
||||||
|
*/
|
||||||
|
protected ValueMetaDataImpl() {
|
||||||
|
}
|
||||||
|
|
||||||
public FieldMetaData getFieldMetaData() {
|
public FieldMetaData getFieldMetaData() {
|
||||||
return _owner;
|
return _owner;
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,7 @@ public abstract class AbstractProductDerivation
|
|||||||
public boolean afterSpecificationSet(Configuration conf) {
|
public boolean afterSpecificationSet(Configuration conf) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void beforeConfigurationClose(Configuration conf) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,4 +112,11 @@ public interface ProductDerivation {
|
|||||||
* @return true if given Configuration has been mutated.
|
* @return true if given Configuration has been mutated.
|
||||||
*/
|
*/
|
||||||
public boolean afterSpecificationSet(Configuration conf);
|
public boolean afterSpecificationSet(Configuration conf);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before the given Configuration is closed.
|
||||||
|
*
|
||||||
|
* @since 0.9.7
|
||||||
|
*/
|
||||||
|
public void beforeConfigurationClose(Configuration conf);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user