pmfProps.putAll(pumd.getProperties());
}
}
else
{
throw new JDOUserException(LOCALISER_JDO.msg("012004", persistenceUnitName));
}
if (omfContext.getApi().equalsIgnoreCase("JPA"))
{
pumd.clearJarFiles(); // Dont use JARs when in J2SE for JPA
}
}
catch (JPOXException jpe)
{
throw new JDOUserException(LOCALISER_JDO.msg("012005", persistenceUnitName));
}
}
}
// Append on any user properties
if (props != null)
{
pmfProps.putAll(props);
}
// Apply the properties to the PMF
try
{
setOptions(pmfProps);
}
catch (JPOXException jpe)
{
// Only throw JDOException and subclasses
throw JPOXJDOHelper.getJDOExceptionForJPOXException(jpe);
}
if (pumd != null)
{
// Initialise the MetaDataManager with all files/classes for this persistence-unit
// This is done now that all PMF properties are set (including the persistence-unit props)
try
{
omfContext.getMetaDataManager().initialise(pumd, omfContext.getClassLoaderResolver(null));
}
catch (JPOXException jpe)
{
throw new JDOException(jpe.getMessage(),jpe);
}
}
if (props != null)
{
// Process any lifecycle listeners defined in persistent properties
Iterator propsIter = props.keySet().iterator();
while (propsIter.hasNext())
{
String key = (String)propsIter.next();
if (key.startsWith("javax.jdo.listener.InstanceLifecycleListener"))
{
String listenerClsName = key.substring(45);
String listenerClasses = (String)props.get(key);
ClassLoaderResolver clr = omfContext.getClassLoaderResolver(null);
Class listenerCls = null;
try
{
listenerCls = clr.classForName(listenerClsName);
}
catch (ClassNotResolvedException cnre)
{
throw new JDOUserException(LOCALISER_JDO.msg("012022", listenerClsName));
}
InstanceLifecycleListener listener = null;
// Find method getInstance()
Method method = ClassUtils.getMethodForClass(listenerCls, "getInstance", null);
if (method != null)
{
// Create instance via getInstance()
try
{
listener = (InstanceLifecycleListener)method.invoke(null, null);
}
catch (Exception e)
{
throw new JDOUserException(LOCALISER_JDO.msg("012021", listenerClsName), e);
}
}
else
{
// Try default constructor
try
{
listener = (InstanceLifecycleListener)listenerCls.newInstance();
}
catch (Exception e)
{
throw new JDOUserException(LOCALISER_JDO.msg("012020", listenerClsName), e);
}
}
Class[] classes = null;
if (!StringUtils.isWhitespace(listenerClasses))