mirror of https://github.com/apache/openjpa.git
OPENJPA-2057: Change classloading scheme
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1194953 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2bee63d702
commit
31e00f7d76
|
@ -21,6 +21,7 @@ package org.apache.openjpa.abstractstore;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
|
||||
import org.apache.openjpa.kernel.AbstractBrokerFactory;
|
||||
import org.apache.openjpa.kernel.Bootstrap;
|
||||
import org.apache.openjpa.kernel.BrokerFactory;
|
||||
|
@ -48,6 +49,7 @@ import org.apache.openjpa.util.UserException;
|
|||
* and bootstrapping from a {@link Map} object (the strategy used by
|
||||
* {@link Bootstrap} to create a factory in a vendor-neutral manner).
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class AbstractStoreBrokerFactory
|
||||
extends AbstractBrokerFactory {
|
||||
|
||||
|
@ -55,11 +57,9 @@ public class AbstractStoreBrokerFactory
|
|||
* The property name under which to name the concrete store manager
|
||||
* class for this runtime.
|
||||
*/
|
||||
private static final String PROP_ABSTRACT_STORE =
|
||||
"abstractstore.AbstractStoreManager";
|
||||
private static final String PROP_ABSTRACT_STORE = "abstractstore.AbstractStoreManager";
|
||||
|
||||
private static final Localizer s_loc = Localizer.forPackage
|
||||
(AbstractStoreBrokerFactory.class);
|
||||
private static final Localizer s_loc = Localizer.forPackage(AbstractStoreBrokerFactory.class);
|
||||
|
||||
private String _storeCls = null;
|
||||
private String _storeProps = null;
|
||||
|
@ -71,8 +71,7 @@ public class AbstractStoreBrokerFactory
|
|||
*/
|
||||
public static AbstractStoreBrokerFactory getInstance(ConfigurationProvider cp) {
|
||||
Object key = toPoolKey(cp.getProperties());
|
||||
AbstractStoreBrokerFactory factory = (AbstractStoreBrokerFactory)
|
||||
getPooledFactoryForKey(key);
|
||||
AbstractStoreBrokerFactory factory = (AbstractStoreBrokerFactory)getPooledFactoryForKey(key);
|
||||
if (factory != null)
|
||||
return factory;
|
||||
|
||||
|
@ -89,11 +88,12 @@ public class AbstractStoreBrokerFactory
|
|||
// use a tmp store manager to get metadata about the capabilities of
|
||||
// this runtime
|
||||
Map map = cp.getProperties();
|
||||
String storePlugin = (String) map.get(ProductDerivations
|
||||
.getConfigurationKey(PROP_ABSTRACT_STORE, map));
|
||||
OpenJPAConfiguration tmp = new OpenJPAConfigurationImpl();
|
||||
cp.setInto(tmp);
|
||||
String storePlugin = (String) map.get(ProductDerivations.getConfigurationKey(PROP_ABSTRACT_STORE, map));
|
||||
String storeCls = Configurations.getClassName(storePlugin);
|
||||
String storeProps = Configurations.getProperties(storePlugin);
|
||||
AbstractStoreManager store = createStoreManager(storeCls, storeProps);
|
||||
AbstractStoreManager store = createStoreManager(storeCls, tmp, storeProps);
|
||||
|
||||
// populate configuration
|
||||
OpenJPAConfiguration conf = store.newConfiguration();
|
||||
|
@ -101,8 +101,7 @@ public class AbstractStoreBrokerFactory
|
|||
conf.supportedOptions().removeAll(store.getUnsupportedOptions());
|
||||
|
||||
// create and pool a new factory
|
||||
return new AbstractStoreBrokerFactory(conf, storeCls, storeProps,
|
||||
store.getPlatform());
|
||||
return new AbstractStoreBrokerFactory(conf, storeCls, storeProps, store.getPlatform());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,12 +122,12 @@ public class AbstractStoreBrokerFactory
|
|||
}
|
||||
|
||||
protected StoreManager newStoreManager() {
|
||||
return createStoreManager(_storeCls, _storeProps);
|
||||
return createStoreManager(_storeCls, new OpenJPAConfigurationImpl(), _storeProps);
|
||||
}
|
||||
|
||||
private static AbstractStoreManager createStoreManager(String cls, String props) {
|
||||
private static AbstractStoreManager createStoreManager(String cls, OpenJPAConfiguration conf, String props) {
|
||||
AbstractStoreManager store =
|
||||
(AbstractStoreManager) Configurations.newInstance(cls, (Configuration)null, props);
|
||||
(AbstractStoreManager) Configurations.newInstance(cls, conf, props);
|
||||
Configurations.configureInstance(store, null, props, PROP_ABSTRACT_STORE);
|
||||
if (store == null)
|
||||
throw new UserException(s_loc.get("no-store-manager",
|
||||
|
|
|
@ -93,7 +93,7 @@ public class ManagedClassSubclasser {
|
|||
if (!PersistenceCapable.class.isAssignableFrom(cls))
|
||||
unenhanced.add(cls);
|
||||
if (unenhanced.size() > 0) {
|
||||
if (PCEnhancerAgent.getLoadSuccessful() == true) {
|
||||
if (PCEnhancerAgent.getLoadSuccessful()) {
|
||||
// This means that the enhancer has been ran but we
|
||||
// have some unenhanced classes. This can happen if an
|
||||
// entity is loaded by the JVM before the EntityManger
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.apache.openjpa.kernel;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.security.AccessController;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -40,7 +39,6 @@ import javax.transaction.TransactionManager;
|
|||
|
||||
import org.apache.commons.collections.set.MapBackedSet;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.openjpa.kernel.AuditManager;
|
||||
import org.apache.openjpa.audit.Auditor;
|
||||
import org.apache.openjpa.conf.BrokerValue;
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.apache.openjpa.kernel.ConnectionRetainModes;
|
|||
import org.apache.openjpa.lib.conf.Configuration;
|
||||
import org.apache.openjpa.lib.conf.ConfigurationProvider;
|
||||
import org.apache.openjpa.lib.conf.Configurations;
|
||||
import org.apache.openjpa.lib.conf.ProductDerivation;
|
||||
import org.apache.openjpa.lib.conf.ProductDerivations;
|
||||
import org.apache.openjpa.lib.log.Log;
|
||||
import org.apache.openjpa.lib.util.Localizer;
|
||||
|
@ -51,9 +50,7 @@ import org.apache.openjpa.meta.AbstractCFMetaDataFactory;
|
|||
import org.apache.openjpa.meta.MetaDataModes;
|
||||
import org.apache.openjpa.meta.MetaDataRepository;
|
||||
import org.apache.openjpa.persistence.osgi.BundleUtils;
|
||||
import org.apache.openjpa.persistence.osgi.OSGiDerivation;
|
||||
import org.apache.openjpa.persistence.validation.ValidationUtils;
|
||||
import org.apache.openjpa.util.ClassResolver;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIESOR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.apache.openjpa.persistence.osgi;
|
||||
|
||||
import org.apache.openjpa.lib.conf.ConfigurationProvider;
|
||||
import org.apache.openjpa.persistence.PersistenceProductDerivation;
|
||||
|
||||
/**
|
||||
* Derives for OSGi environment. Adds bundle class loader in class loading scheme.
|
||||
*
|
||||
* @author Pinaki Poddar
|
||||
*
|
||||
*/
|
||||
public class OSGiDerivation extends PersistenceProductDerivation {
|
||||
|
||||
@Override
|
||||
public void validate() throws Exception {
|
||||
if (!BundleUtils.runningUnderOSGi()) {
|
||||
throw new RuntimeException("Not running in OSGi environment");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beforeConfigurationConstruct(ConfigurationProvider cp) {
|
||||
cp.getClassLoader().addClassLoader(BundleUtils.getBundleClassLoader());
|
||||
super.beforeConfigurationConstruct(cp);
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue