mirror of
https://github.com/apache/openjpa.git
synced 2025-02-20 17:05:15 +00:00
OPENJPA-849, OPENJPA-1251: property management, hidden values
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@805565 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0e4769e43b
commit
814341420d
@ -77,10 +77,10 @@ class AutoDetachValue
|
||||
return _flags;
|
||||
}
|
||||
|
||||
protected List getAliasList() {
|
||||
protected List<String> getAliasList() {
|
||||
// We do not document the numeric values and they are not
|
||||
// helpful to someone trying to understand the error message
|
||||
ArrayList list = new ArrayList();
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (int x = 0; x < ALIASES.length; x += 2)
|
||||
list.add(ALIASES[x]);
|
||||
return list;
|
||||
|
@ -41,6 +41,7 @@ import org.apache.openjpa.kernel.FinderCache;
|
||||
import org.apache.openjpa.kernel.InverseManager;
|
||||
import org.apache.openjpa.kernel.LockLevels;
|
||||
import org.apache.openjpa.kernel.LockManager;
|
||||
import org.apache.openjpa.kernel.MixedLockLevels;
|
||||
import org.apache.openjpa.kernel.PreparedQueryCache;
|
||||
import org.apache.openjpa.kernel.QueryFlushModes;
|
||||
import org.apache.openjpa.kernel.RestoreState;
|
||||
@ -86,8 +87,7 @@ public class OpenJPAConfigurationImpl
|
||||
extends ConfigurationImpl
|
||||
implements OpenJPAConfiguration {
|
||||
|
||||
private static final Localizer _loc =
|
||||
Localizer.forPackage(OpenJPAConfigurationImpl.class);
|
||||
private static final Localizer _loc = Localizer.forPackage(OpenJPAConfigurationImpl.class);
|
||||
|
||||
// cached state; some of this is created in getter methods, so make
|
||||
// protected in case subclasses want to access without creating
|
||||
@ -172,6 +172,7 @@ public class OpenJPAConfigurationImpl
|
||||
public ObjectValue writeBehindCachePlugin;
|
||||
public ObjectValue writeBehindCacheManagerPlugin;
|
||||
public ObjectValue writeBehindCallbackPlugin;
|
||||
public BooleanValue dynamicEnhancementAgent;
|
||||
|
||||
// custom values
|
||||
public BrokerFactoryValue brokerFactoryPlugin;
|
||||
@ -179,12 +180,9 @@ public class OpenJPAConfigurationImpl
|
||||
public AutoDetachValue autoDetach;
|
||||
|
||||
private Collection<String> supportedOptions = new HashSet<String>(33);
|
||||
private final StoreFacadeTypeRegistry _storeFacadeRegistry =
|
||||
new StoreFacadeTypeRegistry();
|
||||
private BrokerFactoryEventManager _brokerFactoryEventManager =
|
||||
new BrokerFactoryEventManager(this);
|
||||
private final StoreFacadeTypeRegistry _storeFacadeRegistry = new StoreFacadeTypeRegistry();
|
||||
private BrokerFactoryEventManager _brokerFactoryEventManager = new BrokerFactoryEventManager(this);
|
||||
|
||||
public BooleanValue dynamicEnhancementAgent;
|
||||
|
||||
/**
|
||||
* Default constructor. Attempts to load global properties.
|
||||
@ -213,9 +211,8 @@ public class OpenJPAConfigurationImpl
|
||||
String[] aliases;
|
||||
|
||||
classResolverPlugin = addPlugin("ClassResolver", true);
|
||||
aliases =
|
||||
new String[] { "default",
|
||||
"org.apache.openjpa.util.ClassResolverImpl",
|
||||
aliases = new String[] {
|
||||
"default", "org.apache.openjpa.util.ClassResolverImpl",
|
||||
// deprecated alias
|
||||
"spec", "org.apache.openjpa.util.ClassResolverImpl", };
|
||||
classResolverPlugin.setAliases(aliases);
|
||||
@ -273,41 +270,38 @@ public class OpenJPAConfigurationImpl
|
||||
|
||||
lockManagerPlugin = addPlugin("LockManager", false);
|
||||
aliases =
|
||||
new String[] { "none", "org.apache.openjpa.kernel.NoneLockManager",
|
||||
new String[] {
|
||||
"none", "org.apache.openjpa.kernel.NoneLockManager",
|
||||
"version", "org.apache.openjpa.kernel.VersionLockManager", };
|
||||
lockManagerPlugin.setAliases(aliases);
|
||||
lockManagerPlugin.setDefault(aliases[0]);
|
||||
lockManagerPlugin.setString(aliases[0]);
|
||||
|
||||
inverseManagerPlugin = addPlugin("InverseManager", false);
|
||||
aliases =
|
||||
new String[] { "false", null, "true",
|
||||
"org.apache.openjpa.kernel.InverseManager", };
|
||||
aliases = new String[] {
|
||||
"false", null,
|
||||
"true", "org.apache.openjpa.kernel.InverseManager", };
|
||||
inverseManagerPlugin.setAliases(aliases);
|
||||
inverseManagerPlugin.setDefault(aliases[0]);
|
||||
inverseManagerPlugin.setString(aliases[0]);
|
||||
|
||||
savepointManagerPlugin = addPlugin("SavepointManager", true);
|
||||
aliases =
|
||||
new String[] { "in-mem",
|
||||
"org.apache.openjpa.kernel.InMemorySavepointManager", };
|
||||
aliases = new String[] {
|
||||
"in-mem", "org.apache.openjpa.kernel.InMemorySavepointManager", };
|
||||
savepointManagerPlugin.setAliases(aliases);
|
||||
savepointManagerPlugin.setDefault(aliases[0]);
|
||||
savepointManagerPlugin.setString(aliases[0]);
|
||||
savepointManagerPlugin
|
||||
.setInstantiatingGetter("getSavepointManagerInstance");
|
||||
savepointManagerPlugin.setInstantiatingGetter("getSavepointManagerInstance");
|
||||
|
||||
orphanedKeyPlugin = addPlugin("OrphanedKeyAction", true);
|
||||
aliases =
|
||||
new String[] { "log",
|
||||
"org.apache.openjpa.event.LogOrphanedKeyAction", "exception",
|
||||
"org.apache.openjpa.event.ExceptionOrphanedKeyAction", "none",
|
||||
"org.apache.openjpa.event.NoneOrphanedKeyAction", };
|
||||
aliases = new String[] {
|
||||
"log", "org.apache.openjpa.event.LogOrphanedKeyAction",
|
||||
"exception", "org.apache.openjpa.event.ExceptionOrphanedKeyAction",
|
||||
"none", "org.apache.openjpa.event.NoneOrphanedKeyAction", };
|
||||
orphanedKeyPlugin.setAliases(aliases);
|
||||
orphanedKeyPlugin.setDefault(aliases[0]);
|
||||
orphanedKeyPlugin.setString(aliases[0]);
|
||||
orphanedKeyPlugin
|
||||
.setInstantiatingGetter("getOrphanedKeyActionInstance");
|
||||
orphanedKeyPlugin.setInstantiatingGetter("getOrphanedKeyActionInstance");
|
||||
|
||||
remoteProviderPlugin = new RemoteCommitProviderValue();
|
||||
addValue(remoteProviderPlugin);
|
||||
@ -318,11 +312,10 @@ public class OpenJPAConfigurationImpl
|
||||
transactionMode.setDefault(aliases[0]);
|
||||
|
||||
managedRuntimePlugin = addPlugin("ManagedRuntime", true);
|
||||
aliases =
|
||||
new String[] { "auto",
|
||||
"org.apache.openjpa.ee.AutomaticManagedRuntime", "jndi",
|
||||
"org.apache.openjpa.ee.JNDIManagedRuntime", "invocation",
|
||||
"org.apache.openjpa.ee.InvocationManagedRuntime", };
|
||||
aliases = new String[] {
|
||||
"auto", "org.apache.openjpa.ee.AutomaticManagedRuntime",
|
||||
"jndi", "org.apache.openjpa.ee.JNDIManagedRuntime",
|
||||
"invocation", "org.apache.openjpa.ee.InvocationManagedRuntime", };
|
||||
managedRuntimePlugin.setAliases(aliases);
|
||||
managedRuntimePlugin.setDefault(aliases[0]);
|
||||
managedRuntimePlugin.setString(aliases[0]);
|
||||
@ -330,9 +323,8 @@ public class OpenJPAConfigurationImpl
|
||||
.setInstantiatingGetter("getManagedRuntimeInstance");
|
||||
|
||||
proxyManagerPlugin = addPlugin("ProxyManager", true);
|
||||
aliases =
|
||||
new String[] { "default",
|
||||
"org.apache.openjpa.util.ProxyManagerImpl" };
|
||||
aliases = new String[] {
|
||||
"default", "org.apache.openjpa.util.ProxyManagerImpl" };
|
||||
proxyManagerPlugin.setAliases(aliases);
|
||||
proxyManagerPlugin.setDefault(aliases[0]);
|
||||
proxyManagerPlugin.setString(aliases[0]);
|
||||
@ -380,8 +372,7 @@ public class OpenJPAConfigurationImpl
|
||||
connection2URL = addString("Connection2URL");
|
||||
connection2DriverName = addString("Connection2DriverName");
|
||||
connection2Properties = addString("Connection2Properties");
|
||||
connectionFactory2Properties =
|
||||
addString("ConnectionFactory2Properties");
|
||||
connectionFactory2Properties = addString("ConnectionFactory2Properties");
|
||||
connectionFactory2Name = addString("ConnectionFactory2Name");
|
||||
|
||||
connectionFactoryMode = addBoolean("ConnectionFactoryMode");
|
||||
@ -408,13 +399,13 @@ public class OpenJPAConfigurationImpl
|
||||
retainState.set(true);
|
||||
|
||||
restoreState = addInt("RestoreState");
|
||||
aliases =
|
||||
new String[] { "none", String.valueOf(RestoreState.RESTORE_NONE),
|
||||
"false", String.valueOf(RestoreState.RESTORE_NONE),
|
||||
aliases = new String[] {
|
||||
"none", String.valueOf(RestoreState.RESTORE_NONE),
|
||||
"false", String.valueOf(RestoreState.RESTORE_NONE),
|
||||
"immutable", String.valueOf(RestoreState.RESTORE_IMMUTABLE),
|
||||
// "true" for compat with jdo RestoreValues
|
||||
"true", String.valueOf(RestoreState.RESTORE_IMMUTABLE), "all",
|
||||
String.valueOf(RestoreState.RESTORE_ALL), };
|
||||
"true", String.valueOf(RestoreState.RESTORE_IMMUTABLE),
|
||||
"all", String.valueOf(RestoreState.RESTORE_ALL), };
|
||||
restoreState.setAliases(aliases);
|
||||
restoreState.setDefault(aliases[0]);
|
||||
restoreState.set(RestoreState.RESTORE_IMMUTABLE);
|
||||
@ -425,10 +416,10 @@ public class OpenJPAConfigurationImpl
|
||||
|
||||
detachStatePlugin = addPlugin("DetachState", true);
|
||||
aliases = new String[] {
|
||||
"loaded", DetachOptions.Loaded.class.getName(),
|
||||
"fgs", DetachOptions.FetchGroups.class.getName(),
|
||||
"loaded", DetachOptions.Loaded.class.getName(),
|
||||
"fgs", DetachOptions.FetchGroups.class.getName(),
|
||||
"fetch-groups", DetachOptions.FetchGroups.class.getName(),
|
||||
"all", DetachOptions.All.class.getName(),
|
||||
"all", DetachOptions.All.class.getName(),
|
||||
};
|
||||
detachStatePlugin.setAliases(aliases);
|
||||
detachStatePlugin.setDefault(aliases[0]);
|
||||
@ -458,11 +449,11 @@ public class OpenJPAConfigurationImpl
|
||||
fetchGroups.set(new String[] { "default" });
|
||||
|
||||
flushBeforeQueries = addInt("FlushBeforeQueries");
|
||||
aliases =
|
||||
new String[] { "true", String.valueOf(QueryFlushModes.FLUSH_TRUE),
|
||||
"false", String.valueOf(QueryFlushModes.FLUSH_FALSE),
|
||||
"with-connection",
|
||||
String.valueOf(QueryFlushModes.FLUSH_WITH_CONNECTION), };
|
||||
aliases = new String[] {
|
||||
"true", String.valueOf(QueryFlushModes.FLUSH_TRUE),
|
||||
"false", String.valueOf(QueryFlushModes.FLUSH_FALSE),
|
||||
"with-connection", String.valueOf(QueryFlushModes.FLUSH_WITH_CONNECTION),
|
||||
};
|
||||
flushBeforeQueries.setAliases(aliases);
|
||||
flushBeforeQueries.setDefault(aliases[0]);
|
||||
flushBeforeQueries.set(QueryFlushModes.FLUSH_TRUE);
|
||||
@ -474,8 +465,7 @@ public class OpenJPAConfigurationImpl
|
||||
lockTimeout.setDynamic(true);
|
||||
|
||||
readLockLevel = addInt("ReadLockLevel");
|
||||
aliases =
|
||||
new String[] {
|
||||
aliases = new String[] {
|
||||
"read", String.valueOf(LockLevels.LOCK_READ),
|
||||
"write", String.valueOf(LockLevels.LOCK_WRITE),
|
||||
"none", String.valueOf(LockLevels.LOCK_NONE),
|
||||
@ -486,8 +476,7 @@ public class OpenJPAConfigurationImpl
|
||||
readLockLevel.setAliasListComprehensive(true);
|
||||
|
||||
writeLockLevel = addInt("WriteLockLevel");
|
||||
aliases =
|
||||
new String[] {
|
||||
aliases = new String[] {
|
||||
"read", String.valueOf(LockLevels.LOCK_READ),
|
||||
"write", String.valueOf(LockLevels.LOCK_WRITE),
|
||||
"none", String.valueOf(LockLevels.LOCK_NONE),
|
||||
@ -502,17 +491,12 @@ public class OpenJPAConfigurationImpl
|
||||
addValue(seqPlugin);
|
||||
|
||||
connectionRetainMode = addInt("ConnectionRetainMode");
|
||||
aliases =
|
||||
new String[] {
|
||||
"on-demand",
|
||||
String.valueOf(ConnectionRetainModes.CONN_RETAIN_DEMAND),
|
||||
"transaction",
|
||||
String.valueOf(ConnectionRetainModes.CONN_RETAIN_TRANS),
|
||||
"always",
|
||||
String.valueOf(ConnectionRetainModes.CONN_RETAIN_ALWAYS),
|
||||
aliases = new String[] {
|
||||
"on-demand", String.valueOf(ConnectionRetainModes.CONN_RETAIN_DEMAND),
|
||||
"transaction", String.valueOf(ConnectionRetainModes.CONN_RETAIN_TRANS),
|
||||
"always", String.valueOf(ConnectionRetainModes.CONN_RETAIN_ALWAYS),
|
||||
// deprecated
|
||||
"persistence-manager",
|
||||
String.valueOf(ConnectionRetainModes.CONN_RETAIN_ALWAYS),
|
||||
"persistence-manager", String.valueOf(ConnectionRetainModes.CONN_RETAIN_ALWAYS),
|
||||
};
|
||||
connectionRetainMode.setAliases(aliases);
|
||||
connectionRetainMode.setDefault(aliases[0]);
|
||||
@ -520,12 +504,10 @@ public class OpenJPAConfigurationImpl
|
||||
connectionRetainMode.set(ConnectionRetainModes.CONN_RETAIN_DEMAND);
|
||||
|
||||
filterListenerPlugins = addPluginList("FilterListeners");
|
||||
filterListenerPlugins
|
||||
.setInstantiatingGetter("getFilterListenerInstances");
|
||||
filterListenerPlugins.setInstantiatingGetter("getFilterListenerInstances");
|
||||
|
||||
aggregateListenerPlugins = addPluginList("AggregateListeners");
|
||||
aggregateListenerPlugins
|
||||
.setInstantiatingGetter("getAggregateListenerInstances");
|
||||
aggregateListenerPlugins.setInstantiatingGetter("getAggregateListenerInstances");
|
||||
|
||||
retryClassRegistration = addBoolean("RetryClassRegistration");
|
||||
|
||||
@ -543,27 +525,21 @@ public class OpenJPAConfigurationImpl
|
||||
callbackPlugin.setString(aliases[0]);
|
||||
callbackPlugin.setInstantiatingGetter("getCallbackOptionsInstance");
|
||||
|
||||
queryCompilationCachePlugin = new QueryCompilationCacheValue(
|
||||
"QueryCompilationCache");
|
||||
queryCompilationCachePlugin.setInstantiatingGetter(
|
||||
"getQueryCompilationCacheInstance");
|
||||
queryCompilationCachePlugin = new QueryCompilationCacheValue("QueryCompilationCache");
|
||||
queryCompilationCachePlugin.setInstantiatingGetter("getQueryCompilationCacheInstance");
|
||||
addValue(queryCompilationCachePlugin);
|
||||
|
||||
runtimeUnenhancedClasses = addInt("RuntimeUnenhancedClasses");
|
||||
runtimeUnenhancedClasses.setAliases(new String[] {
|
||||
"supported", String.valueOf(
|
||||
RuntimeUnenhancedClassesModes.SUPPORTED),
|
||||
"unsupported", String.valueOf(
|
||||
RuntimeUnenhancedClassesModes.UNSUPPORTED),
|
||||
"warn", String.valueOf(
|
||||
RuntimeUnenhancedClassesModes.WARN),
|
||||
"supported", String.valueOf(RuntimeUnenhancedClassesModes.SUPPORTED),
|
||||
"unsupported", String.valueOf(RuntimeUnenhancedClassesModes.UNSUPPORTED),
|
||||
"warn", String.valueOf(RuntimeUnenhancedClassesModes.WARN),
|
||||
});
|
||||
runtimeUnenhancedClasses.setDefault("unsupported");
|
||||
runtimeUnenhancedClasses.setString("unsupported");
|
||||
runtimeUnenhancedClasses.setAliasListComprehensive(true);
|
||||
|
||||
cacheMarshallerPlugins = (CacheMarshallersValue)
|
||||
addValue(new CacheMarshallersValue(this));
|
||||
cacheMarshallerPlugins = (CacheMarshallersValue) addValue(new CacheMarshallersValue(this));
|
||||
|
||||
eagerInitialization = addBoolean("InitializeEagerly");
|
||||
|
||||
@ -581,26 +557,22 @@ public class OpenJPAConfigurationImpl
|
||||
validationMode.setDynamic(true);
|
||||
|
||||
String defValidationGroup = "javax.validation.groups.Default";
|
||||
validationGroupPrePersist =
|
||||
addString("javax.persistence.validation.group.pre-persist");
|
||||
validationGroupPrePersist = addString("javax.persistence.validation.group.pre-persist");
|
||||
validationGroupPrePersist.setString(defValidationGroup);
|
||||
validationGroupPrePersist.setDefault("");
|
||||
validationGroupPrePersist.setDynamic(true);
|
||||
|
||||
validationGroupPreUpdate =
|
||||
addString("javax.persistence.validation.group.pre-update");
|
||||
validationGroupPreUpdate = addString("javax.persistence.validation.group.pre-update");
|
||||
validationGroupPreUpdate.setString(defValidationGroup);
|
||||
validationGroupPreUpdate.setDefault("");
|
||||
validationGroupPreUpdate.setDynamic(true);
|
||||
|
||||
validationGroupPreRemove =
|
||||
addString("javax.persistence.validation.group.pre-remove");
|
||||
validationGroupPreRemove = addString("javax.persistence.validation.group.pre-remove");
|
||||
validationGroupPreRemove.setDefault("");
|
||||
validationGroupPreRemove.setDynamic(true);
|
||||
|
||||
validationFactory = addObject("javax.persistence.validation.factory");
|
||||
validationFactory.setInstantiatingGetter(
|
||||
"getValidationFactoryInstance");
|
||||
validationFactory.setInstantiatingGetter("getValidationFactoryInstance");
|
||||
validationFactory.setDynamic(true);
|
||||
|
||||
validator = addObject("Validator");
|
||||
@ -615,8 +587,7 @@ public class OpenJPAConfigurationImpl
|
||||
lifecycleEventManager.setAliases(aliases);
|
||||
lifecycleEventManager.setDefault(aliases[0]);
|
||||
lifecycleEventManager.setString(aliases[0]);
|
||||
lifecycleEventManager.setInstantiatingGetter(
|
||||
"getLifecycleEventManagerInstance");
|
||||
lifecycleEventManager.setInstantiatingGetter("getLifecycleEventManagerInstance");
|
||||
|
||||
dynamicEnhancementAgent = addBoolean("DynamicEnhancementAgent");
|
||||
dynamicEnhancementAgent.setDefault("true");
|
||||
@ -648,8 +619,8 @@ public class OpenJPAConfigurationImpl
|
||||
|
||||
writeBehindCachePlugin = addPlugin("WriteBehindCache", false);
|
||||
aliases = new String[] {
|
||||
"false", null,
|
||||
"true", SimpleWriteBehindCache.class.getName(),
|
||||
"false", null,
|
||||
"true", SimpleWriteBehindCache.class.getName(),
|
||||
"simple", SimpleWriteBehindCache.class.getName() };
|
||||
writeBehindCachePlugin.setAliases(aliases);
|
||||
writeBehindCachePlugin.setDefault(aliases[0]);
|
||||
@ -657,8 +628,8 @@ public class OpenJPAConfigurationImpl
|
||||
|
||||
writeBehindCallbackPlugin = addPlugin("WriteBehindCallback", true);
|
||||
aliases = new String[] {
|
||||
"false", null,
|
||||
"true", SimpleWriteBehindCallback.class.getName(),
|
||||
"false", null,
|
||||
"true", SimpleWriteBehindCallback.class.getName(),
|
||||
"simple", SimpleWriteBehindCallback.class.getName() };
|
||||
writeBehindCallbackPlugin.setAliases(aliases);
|
||||
writeBehindCallbackPlugin.setDefault(aliases[0]);
|
||||
@ -737,8 +708,7 @@ public class OpenJPAConfigurationImpl
|
||||
}
|
||||
|
||||
public BrokerImpl newBrokerInstance(String user, String pass) {
|
||||
BrokerImpl broker =
|
||||
(BrokerImpl) brokerPlugin.instantiate(BrokerImpl.class, this);
|
||||
BrokerImpl broker = (BrokerImpl) brokerPlugin.instantiate(BrokerImpl.class, this);
|
||||
if (broker != null)
|
||||
broker.setAuthentication(user, pass);
|
||||
return broker;
|
||||
@ -761,9 +731,7 @@ public class OpenJPAConfigurationImpl
|
||||
public DataCacheManager getDataCacheManagerInstance() {
|
||||
DataCacheManager dcm = (DataCacheManager) dataCacheManagerPlugin.get();
|
||||
if (dcm == null) {
|
||||
dcm =
|
||||
(DataCacheManager) dataCacheManagerPlugin.instantiate(
|
||||
DataCacheManager.class, this);
|
||||
dcm = (DataCacheManager) dataCacheManagerPlugin.instantiate(DataCacheManager.class, this);
|
||||
dcm.initialize(this, dataCachePlugin, queryCachePlugin);
|
||||
}
|
||||
return dcm;
|
||||
@ -849,8 +817,7 @@ public class OpenJPAConfigurationImpl
|
||||
}
|
||||
|
||||
public InverseManager newInverseManagerInstance() {
|
||||
return (InverseManager) inverseManagerPlugin.instantiate(
|
||||
InverseManager.class, this);
|
||||
return (InverseManager) inverseManagerPlugin.instantiate(InverseManager.class, this);
|
||||
}
|
||||
|
||||
public void setSavepointManager(String savepointManager) {
|
||||
|
@ -43,15 +43,7 @@ public interface BrokerFactory
|
||||
/**
|
||||
* Return properties describing this runtime.
|
||||
*/
|
||||
public Properties getProperties();
|
||||
|
||||
/**
|
||||
* Return all of the configured properties plus those returned in
|
||||
* @see #getProperties().
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public Map<String, String> getAllProperties();
|
||||
public Map<String,Object> getProperties();
|
||||
|
||||
/**
|
||||
* Return all of the supported properties as a set of keys. If a property
|
||||
|
@ -26,6 +26,7 @@ import java.lang.reflect.Modifier;
|
||||
import java.security.AccessController;
|
||||
import java.util.AbstractCollection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -53,13 +54,13 @@ import org.apache.openjpa.datacache.DataCache;
|
||||
import org.apache.openjpa.ee.ManagedRuntime;
|
||||
import org.apache.openjpa.enhance.PCRegistry;
|
||||
import org.apache.openjpa.enhance.PersistenceCapable;
|
||||
import org.apache.openjpa.enhance.Reflection;
|
||||
import org.apache.openjpa.event.LifecycleEvent;
|
||||
import org.apache.openjpa.event.LifecycleEventManager;
|
||||
import org.apache.openjpa.event.RemoteCommitEventManager;
|
||||
import org.apache.openjpa.event.TransactionEvent;
|
||||
import org.apache.openjpa.event.TransactionEventManager;
|
||||
import org.apache.openjpa.kernel.exps.ExpressionParser;
|
||||
import org.apache.openjpa.lib.conf.Value;
|
||||
import org.apache.openjpa.lib.log.Log;
|
||||
import org.apache.openjpa.lib.util.J2DoPrivHelper;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
@ -98,6 +99,7 @@ import org.apache.openjpa.util.WrappedException;
|
||||
*
|
||||
* @author Abe White
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class BrokerImpl
|
||||
implements Broker, FindCallbacks, Cloneable, Serializable {
|
||||
|
||||
@ -229,8 +231,8 @@ public class BrokerImpl
|
||||
|
||||
|
||||
// Map of properties whose values have been changed
|
||||
private Map<String, String> _changedProperties =
|
||||
new HashMap<String, String>();
|
||||
// private Map<String, String> _changedProperties =
|
||||
// new HashMap<String, String>();
|
||||
|
||||
// status
|
||||
private int _flags = 0;
|
||||
@ -251,8 +253,30 @@ public class BrokerImpl
|
||||
private transient boolean _initializeWasInvoked = false;
|
||||
private LinkedList _fcs;
|
||||
|
||||
// Set of supported properties
|
||||
private Set<String> _supportedPropertyNames;
|
||||
// Set of supported property keys. The keys in this set correspond to bean-style setter methods
|
||||
// that can be set by reflection. The keys are not qualified by any prefix.
|
||||
private static Set<String> _supportedPropertyNames;
|
||||
static {
|
||||
_supportedPropertyNames = new HashSet<String>();
|
||||
_supportedPropertyNames.addAll(Arrays.asList(new String[] {
|
||||
"AutoClear",
|
||||
"AutoDetach",
|
||||
"CacheFinderQuery",
|
||||
"CachePreparedQuery",
|
||||
"DetachedNew",
|
||||
"DetachState",
|
||||
"EvictFromDataCache",
|
||||
"IgnoreChanges",
|
||||
"LifecycleListenerCallbackMode",
|
||||
"Multithreaded",
|
||||
"NontransactionalRead",
|
||||
"NontransactionalWrite",
|
||||
"Optimistic",
|
||||
"PopulateDataCache",
|
||||
"RestoreState",
|
||||
"RetainState",
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the persistence manager's authentication. This is the first
|
||||
@ -472,8 +496,6 @@ public class BrokerImpl
|
||||
public void setIgnoreChanges(boolean val) {
|
||||
assertOpen();
|
||||
_ignoreChanges = val;
|
||||
_changedProperties.put("IgnoreChanges", String
|
||||
.valueOf(_ignoreChanges));
|
||||
}
|
||||
|
||||
public boolean getNontransactionalRead() {
|
||||
@ -492,8 +514,6 @@ public class BrokerImpl
|
||||
("nontrans-read-not-supported"));
|
||||
|
||||
_nontransRead = val;
|
||||
_changedProperties.put("NontransactionalRead", String
|
||||
.valueOf(_nontransRead));
|
||||
}
|
||||
|
||||
public boolean getNontransactionalWrite() {
|
||||
@ -506,8 +526,6 @@ public class BrokerImpl
|
||||
throw new UserException(_loc.get("illegal-op-in-prestore"));
|
||||
|
||||
_nontransWrite = val;
|
||||
_changedProperties.put("NontransactionalWrite", String
|
||||
.valueOf(_nontransWrite));
|
||||
}
|
||||
|
||||
public boolean getOptimistic() {
|
||||
@ -526,8 +544,6 @@ public class BrokerImpl
|
||||
("optimistic-not-supported"));
|
||||
|
||||
_optimistic = val;
|
||||
_changedProperties.put("Optimistic", String
|
||||
.valueOf(_optimistic));
|
||||
}
|
||||
|
||||
public int getRestoreState() {
|
||||
@ -541,8 +557,6 @@ public class BrokerImpl
|
||||
"Restore"));
|
||||
|
||||
_restoreState = val;
|
||||
_changedProperties.put("RestoreState", String
|
||||
.valueOf(_restoreState));
|
||||
}
|
||||
|
||||
public boolean getRetainState() {
|
||||
@ -554,8 +568,6 @@ public class BrokerImpl
|
||||
if ((_flags & FLAG_PRESTORING) != 0)
|
||||
throw new UserException(_loc.get("illegal-op-in-prestore"));
|
||||
_retainState = val;
|
||||
_changedProperties.put("RetainState", String
|
||||
.valueOf(_retainState));
|
||||
}
|
||||
|
||||
public int getAutoClear() {
|
||||
@ -565,7 +577,6 @@ public class BrokerImpl
|
||||
public void setAutoClear(int val) {
|
||||
assertOpen();
|
||||
_autoClear = val;
|
||||
_changedProperties.put("AutoClear", String.valueOf(_autoClear));
|
||||
}
|
||||
|
||||
public int getAutoDetach() {
|
||||
@ -575,8 +586,6 @@ public class BrokerImpl
|
||||
public void setAutoDetach(int detachFlags) {
|
||||
assertOpen();
|
||||
_autoDetach = detachFlags;
|
||||
_changedProperties.put("AutoDetach", String
|
||||
.valueOf(_autoDetach));
|
||||
}
|
||||
|
||||
public void setAutoDetach(int detachFlag, boolean on) {
|
||||
@ -585,8 +594,6 @@ public class BrokerImpl
|
||||
_autoDetach |= detachFlag;
|
||||
else
|
||||
_autoDetach &= ~detachFlag;
|
||||
_changedProperties.put("AutoDetach", String
|
||||
.valueOf(_autoDetach));
|
||||
}
|
||||
|
||||
public int getDetachState() {
|
||||
@ -596,8 +603,6 @@ public class BrokerImpl
|
||||
public void setDetachState(int mode) {
|
||||
assertOpen();
|
||||
_detachState = mode;
|
||||
_changedProperties.put("DetachState", String
|
||||
.valueOf(_detachState));
|
||||
}
|
||||
|
||||
public boolean isDetachedNew() {
|
||||
@ -668,65 +673,29 @@ public class BrokerImpl
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
Map<String, String> currentProperties = _conf.getAllProperties();
|
||||
|
||||
// Update the properties from the config with properties that may
|
||||
// have changed for this broker
|
||||
if (!_changedProperties.isEmpty()) {
|
||||
Set<String> changedKeys = _changedProperties.keySet();
|
||||
for (String changedKey : changedKeys) {
|
||||
Value value = _conf.getValue(changedKey);
|
||||
String valueKey = value.getLoadKey();
|
||||
if (valueKey == null) {
|
||||
valueKey = "openjpa." + value.getProperty();
|
||||
}
|
||||
|
||||
if (currentProperties.containsKey(valueKey)) {
|
||||
currentProperties.put(valueKey, _changedProperties
|
||||
.get(changedKey));
|
||||
}
|
||||
else {
|
||||
Set<String> equivalentKeys = value.getEquivalentKeys();
|
||||
if (!equivalentKeys.isEmpty()) {
|
||||
for (String equivalentKey : equivalentKeys) {
|
||||
if (currentProperties.containsKey(equivalentKey)) {
|
||||
currentProperties.put(equivalentKey,
|
||||
_changedProperties.get(changedKey));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get current configuration property values used by this instance.
|
||||
* This values are combination of the current configuration values
|
||||
* overwritten by values maintained by this instance such as
|
||||
* Optimistic flag.
|
||||
*/
|
||||
public Map<String, Object> getProperties() {
|
||||
Map props = _conf.toProperties(true);
|
||||
for (String s : _supportedPropertyNames) {
|
||||
props.put("openjpa." + s, Reflection.getValue(this, s, true));
|
||||
}
|
||||
|
||||
return currentProperties;
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the property names that can be used to corresponding setter methods of this receiver
|
||||
* to set its value.
|
||||
*/
|
||||
public Set<String> getSupportedProperties() {
|
||||
if (_supportedPropertyNames == null) {
|
||||
_supportedPropertyNames = new TreeSet<String>();
|
||||
_supportedPropertyNames.add("AutoClear");
|
||||
_supportedPropertyNames.add("AutoDetach");
|
||||
_supportedPropertyNames.add("DetachState");
|
||||
_supportedPropertyNames.add("IgnoreChanges");
|
||||
_supportedPropertyNames.add("LockTimeout");
|
||||
_supportedPropertyNames.add("Multithreaded");
|
||||
_supportedPropertyNames.add("NontransactionalRead");
|
||||
_supportedPropertyNames.add("NontransactionalWrite");
|
||||
_supportedPropertyNames.add("Optimistic");
|
||||
_supportedPropertyNames.add("RestoreState");
|
||||
_supportedPropertyNames.add("RetainState");
|
||||
}
|
||||
Set<String> supportedProperties = new LinkedHashSet<String>();
|
||||
for (String propertyName : _supportedPropertyNames) {
|
||||
supportedProperties.addAll(_conf.getPropertyKeys(propertyName));
|
||||
}
|
||||
supportedProperties.add("javax.persistence.query.timeout");
|
||||
supportedProperties.add("javax.persistence.lock.timeout");
|
||||
|
||||
return supportedProperties;
|
||||
Set<String> keys = _conf.getPropertyKeys();
|
||||
for (String s : _supportedPropertyNames)
|
||||
keys.add("openjpa." + s);
|
||||
return keys;
|
||||
}
|
||||
|
||||
// ////////
|
||||
|
@ -180,7 +180,7 @@ public class DelegatingBroker
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, String> getProperties() {
|
||||
public Map<String,Object> getProperties() {
|
||||
try {
|
||||
return _broker.getProperties();
|
||||
} catch (RuntimeException re) {
|
||||
|
@ -50,7 +50,7 @@ public class BooleanValue extends Value {
|
||||
/**
|
||||
* The internal value.
|
||||
*/
|
||||
public boolean get() {
|
||||
public Boolean get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ public class DoubleValue extends Value {
|
||||
/**
|
||||
* The internal value.
|
||||
*/
|
||||
public double get() {
|
||||
public Double get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,7 @@ public abstract class Value implements Cloneable {
|
||||
|
||||
private static final String[] EMPTY_ALIASES = new String[0];
|
||||
private static final Localizer s_loc = Localizer.forPackage(Value.class);
|
||||
public static final String INVISIBLE = "******";
|
||||
|
||||
private String prop = null;
|
||||
private String loadKey = null;
|
||||
@ -53,7 +54,7 @@ public abstract class Value implements Cloneable {
|
||||
private String originalValue = null;
|
||||
private Set<String> otherNames = null;
|
||||
private boolean visible = true;
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
@ -285,7 +286,7 @@ public abstract class Value implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* The default value for the propert as a string.
|
||||
* The default value for the property as a string.
|
||||
*/
|
||||
public void setDefault(String def) {
|
||||
this.def = def;
|
||||
@ -411,7 +412,7 @@ public abstract class Value implements Cloneable {
|
||||
/**
|
||||
* Returns the type of the property that this Value represents.
|
||||
*/
|
||||
public abstract Class getValueType();
|
||||
public abstract Class<?> getValueType();
|
||||
|
||||
/**
|
||||
* Return the internal string form of this value.
|
||||
@ -559,4 +560,13 @@ public abstract class Value implements Cloneable {
|
||||
public void setVisible(boolean visible) {
|
||||
this.visible = visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the actual data stored in this value.
|
||||
*/
|
||||
public abstract Object get();
|
||||
|
||||
public String toString() {
|
||||
return getProperty()+ ":" + get() + "[" + getValueType().getName() + "]";
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import java.io.ObjectOutput;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamClass;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.Connection;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -53,6 +54,7 @@ import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.ee.ManagedRuntime;
|
||||
import org.apache.openjpa.enhance.PCEnhancer;
|
||||
import org.apache.openjpa.enhance.PCRegistry;
|
||||
import org.apache.openjpa.enhance.Reflection;
|
||||
import org.apache.openjpa.kernel.AbstractBrokerFactory;
|
||||
import org.apache.openjpa.kernel.Broker;
|
||||
import org.apache.openjpa.kernel.DelegatingBroker;
|
||||
@ -66,6 +68,7 @@ import org.apache.openjpa.kernel.QueryFlushModes;
|
||||
import org.apache.openjpa.kernel.QueryLanguages;
|
||||
import org.apache.openjpa.kernel.Seq;
|
||||
import org.apache.openjpa.kernel.jpql.JPQLParser;
|
||||
import org.apache.openjpa.lib.log.Log;
|
||||
import org.apache.openjpa.lib.util.Closeable;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
import org.apache.openjpa.meta.ClassMetaData;
|
||||
@ -81,6 +84,8 @@ import org.apache.openjpa.util.RuntimeExceptionTranslator;
|
||||
import org.apache.openjpa.util.UserException;
|
||||
import org.apache.openjpa.util.WrappedException;
|
||||
|
||||
import serp.util.Strings;
|
||||
|
||||
/**
|
||||
* Implementation of {@link EntityManager} interface.
|
||||
*
|
||||
@ -92,17 +97,14 @@ public class EntityManagerImpl
|
||||
implements OpenJPAEntityManagerSPI, Externalizable,
|
||||
FindCallbacks, OpCallbacks, Closeable, OpenJPAEntityTransaction {
|
||||
|
||||
private static final Localizer _loc = Localizer.forPackage
|
||||
(EntityManagerImpl.class);
|
||||
private static final Localizer _loc = Localizer.forPackage(EntityManagerImpl.class);
|
||||
private static final Object[] EMPTY_OBJECTS = new Object[0];
|
||||
|
||||
private DelegatingBroker _broker;
|
||||
private EntityManagerFactoryImpl _emf;
|
||||
private Map<FetchConfiguration,FetchPlan> _plans =
|
||||
new IdentityHashMap<FetchConfiguration,FetchPlan>(1);
|
||||
private Map<FetchConfiguration,FetchPlan> _plans = new IdentityHashMap<FetchConfiguration,FetchPlan>(1);
|
||||
|
||||
private RuntimeExceptionTranslator _ret =
|
||||
PersistenceExceptions.getRollbackTranslator(this);
|
||||
private RuntimeExceptionTranslator _ret = PersistenceExceptions.getRollbackTranslator(this);
|
||||
|
||||
public EntityManagerImpl() {
|
||||
// for Externalizable
|
||||
@ -111,8 +113,7 @@ public class EntityManagerImpl
|
||||
/**
|
||||
* Constructor; supply factory and delegate.
|
||||
*/
|
||||
public EntityManagerImpl(EntityManagerFactoryImpl factory,
|
||||
Broker broker) {
|
||||
public EntityManagerImpl(EntityManagerFactoryImpl factory, Broker broker) {
|
||||
initialize(factory, broker);
|
||||
}
|
||||
|
||||
@ -1551,19 +1552,14 @@ public class EntityManagerImpl
|
||||
return createQuery(jpql);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see javax.persistence.EntityManager#getProperties()
|
||||
*
|
||||
* This does not return the password property.
|
||||
*/
|
||||
public Map<String, Object> getProperties() {
|
||||
Map<String, String> currentProperties = _broker.getProperties();
|
||||
|
||||
// Convert the <String, String> map into a <String, Object> map
|
||||
Map<String, Object> finalMap =
|
||||
new HashMap<String, Object>(currentProperties);
|
||||
|
||||
return finalMap;
|
||||
Map props = _broker.getProperties();
|
||||
for (String s : _broker.getSupportedProperties()) {
|
||||
Method getter = Reflection.findGetter(this.getClass(), getPropertyName(s), false);
|
||||
if (getter != null)
|
||||
props.put(s, Reflection.get(this, getter));
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
public CriteriaBuilder getQueryBuilder() {
|
||||
@ -1614,8 +1610,29 @@ public class EntityManagerImpl
|
||||
return _emf.getMetamodel();
|
||||
}
|
||||
|
||||
public void setProperty(String arg0, Object arg1) {
|
||||
throw new UnsupportedOperationException(
|
||||
"JPA 2.0 - Method not yet implemented");
|
||||
public void setProperty(String prop, Object value) {
|
||||
String beanProp = getPropertyName(prop);
|
||||
try {
|
||||
Method setter = Reflection.findSetter(this.getClass(), beanProp, false);
|
||||
if (setter != null) {
|
||||
if (value instanceof String) {
|
||||
if ("null".equals(value)) {
|
||||
value = null;
|
||||
} else {
|
||||
value = Strings.parse((String) value, setter.getParameterTypes()[0]);
|
||||
}
|
||||
}
|
||||
Reflection.set(this, setter, value);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Log log = getConfiguration().getLog(OpenJPAConfiguration.LOG_RUNTIME);
|
||||
if (log.isWarnEnabled())
|
||||
log.warn(_loc.get("bad-em-prop", prop, value));
|
||||
}
|
||||
}
|
||||
|
||||
String getPropertyName(String s) {
|
||||
int dot = s.lastIndexOf('.');
|
||||
return dot == -1 ? s : s.substring(dot+1);
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,11 @@ public class PersistenceProductDerivation
|
||||
public int getType() {
|
||||
return TYPE_SPEC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConfigurationPrefix() {
|
||||
return "javax.persistence";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate()
|
||||
@ -174,8 +179,7 @@ public class PersistenceProductDerivation
|
||||
conf.lockManagerPlugin.setString("mixed");
|
||||
conf.nontransactionalWrite.setDefault("true");
|
||||
conf.nontransactionalWrite.set(true);
|
||||
int specVersion = ((OpenJPAConfiguration) c).getSpecificationInstance()
|
||||
.getVersion();
|
||||
int specVersion = ((OpenJPAConfiguration) c).getSpecificationInstance().getVersion();
|
||||
if (specVersion < 2) {
|
||||
Compatibility compatibility = conf.getCompatibilityInstance();
|
||||
compatibility.setFlushBeforeDetach(true);
|
||||
@ -354,7 +358,7 @@ public class PersistenceProductDerivation
|
||||
*/
|
||||
public boolean checkPuNameCollisions(Log logger,String puName){
|
||||
PUNameCollision p = _puNameCollisions.get(puName);
|
||||
if(p!=null){
|
||||
if (p != null){
|
||||
p.logCollision(logger);
|
||||
return true;
|
||||
}
|
||||
@ -365,13 +369,10 @@ public class PersistenceProductDerivation
|
||||
throws IOException {
|
||||
Enumeration<URL> urls = null;
|
||||
try {
|
||||
urls = AccessController.doPrivileged(
|
||||
J2DoPrivHelper.getResourcesAction(loader, rsrc));
|
||||
urls = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(loader, rsrc));
|
||||
if (!urls.hasMoreElements()) {
|
||||
if (!rsrc.startsWith("META-INF"))
|
||||
urls = AccessController.doPrivileged(
|
||||
J2DoPrivHelper.getResourcesAction(
|
||||
loader, "META-INF/" + rsrc));
|
||||
urls = AccessController.doPrivileged(J2DoPrivHelper.getResourcesAction(loader, "META-INF/" + rsrc));
|
||||
if (!urls.hasMoreElements())
|
||||
return null;
|
||||
}
|
||||
@ -396,22 +397,19 @@ public class PersistenceProductDerivation
|
||||
String name, Map m, ClassLoader loader, boolean explicit)
|
||||
throws IOException {
|
||||
if (loader == null)
|
||||
loader = AccessController.doPrivileged(
|
||||
J2DoPrivHelper.getContextClassLoaderAction());
|
||||
loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
|
||||
|
||||
List<URL> urls = getResourceURLs(rsrc, loader);
|
||||
if (urls == null || urls.size() == 0)
|
||||
return null;
|
||||
|
||||
ConfigurationParser parser = new ConfigurationParser(m);
|
||||
PersistenceUnitInfoImpl pinfo = parseResources(parser, urls, name,
|
||||
loader);
|
||||
PersistenceUnitInfoImpl pinfo = parseResources(parser, urls, name, loader);
|
||||
if (pinfo == null) {
|
||||
if (!explicit)
|
||||
return Boolean.FALSE;
|
||||
throw new MissingResourceException(_loc.get("missing-xml-config",
|
||||
rsrc, String.valueOf(name)).getMessage(), getClass().getName(),
|
||||
rsrc);
|
||||
rsrc, String.valueOf(name)).getMessage(), getClass().getName(), rsrc);
|
||||
} else if (!isOpenJPAPersistenceProvider(pinfo, loader)) {
|
||||
if (!explicit) {
|
||||
warnUnknownProvider(pinfo);
|
||||
@ -434,8 +432,7 @@ public class PersistenceProductDerivation
|
||||
private PersistenceUnitInfoImpl parseResources(ConfigurationParser parser,
|
||||
List<URL> urls, String name, ClassLoader loader)
|
||||
throws IOException {
|
||||
List<PersistenceUnitInfoImpl> pinfos =
|
||||
new ArrayList<PersistenceUnitInfoImpl>();
|
||||
List<PersistenceUnitInfoImpl> pinfos = new ArrayList<PersistenceUnitInfoImpl>();
|
||||
for (URL url : urls) {
|
||||
parser.parse(url);
|
||||
pinfos.addAll((List<PersistenceUnitInfoImpl>) parser.getResults());
|
||||
@ -455,16 +452,13 @@ public class PersistenceProductDerivation
|
||||
// found named unit?
|
||||
if (name != null) {
|
||||
if (name.equals(pinfo.getPersistenceUnitName())){
|
||||
|
||||
if(result!=null){
|
||||
this.addPuNameCollision(name,
|
||||
result.getPersistenceXmlFileUrl().toString(),
|
||||
if (result != null){
|
||||
this.addPuNameCollision(name, result.getPersistenceXmlFileUrl().toString(),
|
||||
pinfo.getPersistenceXmlFileUrl().toString());
|
||||
|
||||
}else{
|
||||
} else {
|
||||
// Grab a ref to the pinfo that matches the name we're
|
||||
// looking for. Keep going to look for duplicate pu
|
||||
// names.
|
||||
// looking for. Keep going to look for duplicate pu names.
|
||||
result = pinfo;
|
||||
}
|
||||
}
|
||||
@ -473,8 +467,7 @@ public class PersistenceProductDerivation
|
||||
|
||||
if (isOpenJPAPersistenceProvider(pinfo, loader)) {
|
||||
// if no name given and found unnamed unit, return it.
|
||||
// otherwise record as default unit unless we find a
|
||||
// better match later
|
||||
// otherwise record as default unit unless we find a better match later
|
||||
if (StringUtils.isEmpty(pinfo.getPersistenceUnitName()))
|
||||
return pinfo;
|
||||
if (ojpa == null)
|
||||
@ -493,16 +486,13 @@ public class PersistenceProductDerivation
|
||||
private static boolean isOpenJPAPersistenceProvider
|
||||
(PersistenceUnitInfo pinfo, ClassLoader loader) {
|
||||
String provider = pinfo.getPersistenceProviderClassName();
|
||||
if (StringUtils.isEmpty(provider)
|
||||
|| PersistenceProviderImpl.class.getName().equals(provider))
|
||||
if (StringUtils.isEmpty(provider) || PersistenceProviderImpl.class.getName().equals(provider))
|
||||
return true;
|
||||
|
||||
if (loader == null)
|
||||
loader = AccessController.doPrivileged(
|
||||
J2DoPrivHelper.getContextClassLoaderAction());
|
||||
loader = AccessController.doPrivileged(J2DoPrivHelper.getContextClassLoaderAction());
|
||||
try {
|
||||
if (PersistenceProviderImpl.class.isAssignableFrom
|
||||
(Class.forName(provider, false, loader)))
|
||||
if (PersistenceProviderImpl.class.isAssignableFrom(Class.forName(provider, false, loader)))
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
log(_loc.get("unloadable-provider", provider, t).getMessage());
|
||||
@ -516,8 +506,7 @@ public class PersistenceProductDerivation
|
||||
* provider.
|
||||
*/
|
||||
private static void warnUnknownProvider(PersistenceUnitInfo pinfo) {
|
||||
log(_loc.get("unrecognized-provider",
|
||||
pinfo.getPersistenceProviderClassName()).getMessage());
|
||||
log(_loc.get("unrecognized-provider", pinfo.getPersistenceProviderClassName()).getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -530,13 +519,11 @@ public class PersistenceProductDerivation
|
||||
|
||||
private void addPuNameCollision(String puName, String file1, String file2){
|
||||
PUNameCollision pun = _puNameCollisions.get(puName);
|
||||
if(pun!=null){
|
||||
if (pun != null){
|
||||
pun.addCollision(file1, file2);
|
||||
}else{
|
||||
_puNameCollisions.put(puName,
|
||||
new PUNameCollision(puName, file1, file2));
|
||||
} else {
|
||||
_puNameCollisions.put(puName, new PUNameCollision(puName, file1, file2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -565,17 +552,13 @@ public class PersistenceProductDerivation
|
||||
public void setInto(Configuration conf) {
|
||||
if (conf instanceof OpenJPAConfiguration) {
|
||||
OpenJPAConfiguration oconf = (OpenJPAConfiguration) conf;
|
||||
Object persistenceVersion =
|
||||
getProperties().get(
|
||||
PersistenceUnitInfoImpl.PERSISTENCE_VERSION);
|
||||
Object persistenceVersion = getProperties().get(PersistenceUnitInfoImpl.PERSISTENCE_VERSION);
|
||||
if (persistenceVersion == null) {
|
||||
oconf.setSpecification(SPEC_JPA);
|
||||
} else {
|
||||
// Set the spec level based on the persistence version
|
||||
oconf.setSpecification("jpa " +
|
||||
persistenceVersion.toString());
|
||||
getProperties().remove(
|
||||
PersistenceUnitInfoImpl.PERSISTENCE_VERSION);
|
||||
oconf.setSpecification("jpa " + persistenceVersion.toString());
|
||||
getProperties().remove(PersistenceUnitInfoImpl.PERSISTENCE_VERSION);
|
||||
}
|
||||
|
||||
|
||||
@ -586,12 +569,10 @@ public class PersistenceProductDerivation
|
||||
// the global value with our settings
|
||||
String orig = oconf.getMetaDataFactory();
|
||||
if (!StringUtils.isEmpty(orig)) {
|
||||
String key = ProductDerivations.getConfigurationKey
|
||||
("MetaDataFactory", getProperties());
|
||||
String key = ProductDerivations.getConfigurationKey("MetaDataFactory", getProperties());
|
||||
Object override = getProperties().get(key);
|
||||
if (override instanceof String)
|
||||
addProperty(key, Configurations.combinePlugins(orig,
|
||||
(String) override));
|
||||
addProperty(key, Configurations.combinePlugins(orig, (String) override));
|
||||
}
|
||||
}
|
||||
|
||||
@ -674,16 +655,14 @@ public class PersistenceProductDerivation
|
||||
protected Object getSchemaSource() {
|
||||
// use the version 1 schema by default. non-versioned docs will
|
||||
// continue to parse with the old xml if they do not contain a
|
||||
// persistence-unit. that is currently the only signficant change
|
||||
// persistence-unit. that is currently the only significant change
|
||||
// to the schema. if more significant changes are made in the
|
||||
// future, the 2.0 schema may be preferable.
|
||||
String persistencexsd = "persistence-xsd.rsrc";
|
||||
// if the version and/or schema location is for 1.0, use the 1.0
|
||||
// schema
|
||||
if (_persistenceVersion != null &&
|
||||
_persistenceVersion.equals(XMLVersionParser.VERSION_2_0) ||
|
||||
(_schemaLocation != null &&
|
||||
_schemaLocation.indexOf(PERSISTENCE_XSD_2_0) != -1)) {
|
||||
if (_persistenceVersion != null && _persistenceVersion.equals(XMLVersionParser.VERSION_2_0)
|
||||
|| (_schemaLocation != null && _schemaLocation.indexOf(PERSISTENCE_XSD_2_0) != -1)) {
|
||||
persistencexsd = "persistence_2_0-xsd.rsrc";
|
||||
}
|
||||
return getClass().getResourceAsStream(persistencexsd);
|
||||
@ -701,8 +680,7 @@ public class PersistenceProductDerivation
|
||||
if (currentDepth() == 1)
|
||||
startPersistenceUnit(attrs);
|
||||
else if (currentDepth() == 3 && "property".equals(name))
|
||||
_info.setProperty(attrs.getValue("name"),
|
||||
attrs.getValue("value"));
|
||||
_info.setProperty(attrs.getValue("name"), attrs.getValue("value"));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -772,16 +750,15 @@ public class PersistenceProductDerivation
|
||||
// transaction type to local
|
||||
String val = attrs.getValue("transaction-type");
|
||||
if (val == null)
|
||||
_info.setTransactionType
|
||||
(PersistenceUnitTransactionType.RESOURCE_LOCAL);
|
||||
_info.setTransactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL);
|
||||
else
|
||||
_info.setTransactionType(Enum.valueOf
|
||||
(PersistenceUnitTransactionType.class, val));
|
||||
_info.setTransactionType(Enum.valueOf(PersistenceUnitTransactionType.class, val));
|
||||
|
||||
if (_source != null)
|
||||
_info.setPersistenceXmlFileUrl(_source);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This private class is used to hold onto information regarding
|
||||
* PersistentUnit name collisions.
|
||||
@ -797,13 +774,14 @@ public class PersistenceProductDerivation
|
||||
|
||||
_puName=puName;
|
||||
}
|
||||
|
||||
void logCollision(Log logger){
|
||||
if(logger.isWarnEnabled()){
|
||||
logger.warn(_loc.getFatal("dup-pu",
|
||||
new Object[]{_puName,_resources.toString(),
|
||||
_resources.iterator().next()}));
|
||||
logger.warn(_loc.getFatal("dup-pu", new Object[]{_puName,_resources.toString(),
|
||||
_resources.iterator().next()}));
|
||||
}
|
||||
}
|
||||
|
||||
void addCollision(String file1, String file2){
|
||||
_resources.add(file1);
|
||||
_resources.add(file2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user