use of com.sun.jdo.spi.persistence.support.sqlstore.impl.PersistenceManagerFactoryImpl in project Payara by payara.
the class SunContainerHelper method getPersistenceManagerFactory.
/**
* Called in a CMP environment to lookup PersistenceManagerFactory
* referenced by this Container instance as the CMP resource.
*
* This is SunContainerHelper specific code.
*
* @see getContainer(Object)
* @param container a Container instance for the request.
*/
public PersistenceManagerFactory getPersistenceManagerFactory(Object container) {
Object rc = null;
PersistenceManagerFactoryImpl pmf = null;
ResourceReferenceDescriptor cmpResource = ((Container) container).getEjbDescriptor().getEjbBundleDescriptor().getCMPResourceReference();
String name = cmpResource.getJndiName();
try {
InitialContext ic = new InitialContext();
rc = ic.lookup(name);
if (rc instanceof PersistenceManagerFactoryImpl) {
pmf = (PersistenceManagerFactoryImpl) rc;
} else if (rc instanceof javax.sql.DataSource) {
pmf = new PersistenceManagerFactoryImpl();
pmf.setConnectionFactoryName(ConnectorsUtil.getPMJndiName(name));
Iterator it = cmpResource.getProperties();
if (it != null) {
while (it.hasNext()) {
NameValuePairDescriptor prop = (NameValuePairDescriptor) it.next();
String n = prop.getName();
// Any value that is not "true" is treated as "false":
boolean value = Boolean.valueOf(prop.getValue()).booleanValue();
pmf.setBooleanProperty(n, value);
}
}
} else {
RuntimeException e = new JDOFatalUserException(I18NHelper.getMessage(// NOI18N
messages, // NOI18N
"ejb.jndi.unexpectedinstance", name, rc.getClass().getName()));
logger.severe(e.toString());
throw e;
}
} catch (javax.naming.NamingException ex) {
RuntimeException e = new JDOFatalUserException(I18NHelper.getMessage(messages, "ejb.jndi.lookupfailed", name), // NOI18N
ex);
logger.severe(e.toString());
throw e;
}
return pmf;
}
Aggregations