Tolerate container failure better, now that we can handle non-enhanced types.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@563705 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Patrick Linskey 2007-08-08 00:05:40 +00:00
parent 63c3748900
commit b7fe66357b
2 changed files with 20 additions and 2 deletions

View File

@ -37,6 +37,7 @@ import org.apache.openjpa.kernel.Bootstrap;
import org.apache.openjpa.kernel.BrokerFactory;
import org.apache.openjpa.lib.conf.ConfigurationProvider;
import org.apache.openjpa.lib.conf.Configurations;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.meta.MetaDataModes;
import org.apache.openjpa.meta.MetaDataRepository;
import org.apache.openjpa.util.ClassResolver;
@ -53,6 +54,9 @@ public class PersistenceProviderImpl
static final String CLASS_TRANSFORMER_OPTIONS = "ClassTransformerOptions";
private static final Localizer _loc = Localizer.forPackage(
PersistenceProviderImpl.class);
/**
* Loads the entity manager specified by <code>name</code>, applying
* the properties in <code>m</code> as overrides to the properties defined
@ -91,10 +95,16 @@ public class PersistenceProviderImpl
return null;
// add enhancer
Exception transformerException = null;
String ctOpts = (String) Configurations.getProperty
(CLASS_TRANSFORMER_OPTIONS, pui.getProperties());
try {
pui.addTransformer(new ClassTransformerImpl(cp, ctOpts,
pui.getNewTempClassLoader()));
} catch (Exception e) {
// fail gracefully
transformerException = e;
}
// if the BrokerImpl hasn't been specified, switch to the
// non-finalizing one, since anything claiming to be a container
@ -107,6 +117,11 @@ public class PersistenceProviderImpl
BrokerFactory factory = Bootstrap.newBrokerFactory(cp,
pui.getClassLoader());
if (transformerException != null)
factory.getConfiguration().getLog(
OpenJPAConfiguration.LOG_RUNTIME).warn(
_loc.get("transformer-registration-error", pui),
transformerException);
return OpenJPAPersistence.toEntityManagerFactory(factory);
} catch (Exception e) {
throw PersistenceExceptions.toPersistenceException(e);

View File

@ -125,6 +125,9 @@ no-setter-for-getter: No setter was found for method {0} in type {1} while \
searching for persistent properties. This method will be ignored. If you \
intended for this to be persistent, please add a corresponding setter, \
or switch to field access for this type hierarchy.
transformer-registration-error: An error occurred while registering a \
ClassTransformer with {0}. The error is logged along with this warning. \
Load-time class transformation will not be available.
EntityManagerFactory-name: EntityManagerFactory implementation
EntityManagerFactory-desc: Allows extension of standard \