use of com.sun.jdo.api.persistence.support.JDOFatalUserException in project Payara by payara.
the class DBVendorType method newSpecialDBOperationInstance.
/**
* Returns new instance of class specified by specialDBOpClassName.
* The class is required to implement interface SpecialDBOperation.
* If specialDBOpClassName is null or cannot be loaded, then an instance
* of BaseSpecialDBOperation is returned.
* @param specialDBOpClassName Name of a class that implements
* SpecialDBOperation
* @param databaseMetaData DatabaseMetaData for the connection for which
* this SpecialDBOperation is created
* @param identifier Identifier of pmf used to obtain databaseMetaData.
* This can be null in non managed environment.
* @return An instance of SpecialDBOperation specified by specialDBOpClassName.
*/
private SpecialDBOperation newSpecialDBOperationInstance(final String specialDBOpClassName, DatabaseMetaData databaseMetaData, String identifier) {
SpecialDBOperation retInstance = null;
if (specialDBOpClassName != null) {
final ClassLoader loader = DBVendorType.class.getClassLoader();
Class clz = (Class) java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
public Object run() {
try {
if (loader != null) {
return Class.forName(specialDBOpClassName, true, loader);
} else {
return Class.forName(specialDBOpClassName);
}
} catch (Exception ex) {
if (logger.isLoggable()) {
logger.log(Logger.INFO, // NOI18N
"core.configuration.cantloadclass", specialDBOpClassName);
}
return null;
}
}
});
if (clz != null) {
try {
retInstance = (SpecialDBOperation) clz.newInstance();
retInstance.initialize(databaseMetaData, identifier);
} catch (Exception ex) {
throw new JDOFatalUserException(I18NHelper.getMessage(messages, // NOI18N
"sqlstore.database.dbvendor.cantinstantiateclass", specialDBOpClassName), ex);
}
}
}
return (retInstance != null) ? retInstance : DEFAULT_SPECIAL_DB_OPERATION;
}
use of com.sun.jdo.api.persistence.support.JDOFatalUserException in project Payara by payara.
the class DeploymentHelper method getConnection.
/**
* Get a Connection from the resource specified by the JNDI name
* of a CMP resource.
* This connection is aquired from a non-transactional resource which does not
* go through transaction enlistment/delistment.
* The deployment processing is required to use only those connections.
*
* @param name JNDI name of a cmp-resource for the connection.
* @return a Connection.
* @throws JDOFatalUserException if name cannot be looked up, or we
* cannot get a connection based on the name.
* @throws SQLException if can not get a Connection.
*/
public static Connection getConnection(String name) throws SQLException {
if (logger.isLoggable(logger.FINE)) {
// NOI18N
logger.fine("ejb.DeploymentHelper.getconnection", name);
}
// TODO - pass Habitat or ConnectorRuntime as an argument.
ServiceLocator habitat = Globals.getDefaultHabitat();
DataSource ds = null;
try {
ConnectorRuntime connectorRuntime = habitat.getService(ConnectorRuntime.class);
ds = DataSource.class.cast(connectorRuntime.lookupNonTxResource(name, true));
} catch (Exception e) {
throw new JDOFatalUserException(I18NHelper.getMessage(messages, "ejb.jndi.lookupfailed", // NOI18N
name));
}
return ds.getConnection();
}
use of com.sun.jdo.api.persistence.support.JDOFatalUserException 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;
}
use of com.sun.jdo.api.persistence.support.JDOFatalUserException in project Payara by payara.
the class FieldDesc method setupDesc.
//
// ------------ Initialisation methods ------------
//
void setupDesc(final Class classType, final String name) {
Field f = (Field) java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
public Object run() {
try {
return classType.getDeclaredField(name);
} catch (NoSuchFieldException e) {
throw new JDOFatalUserException(I18NHelper.getMessage(messages, // NOI18N
"core.configuration.loadfailed.field", name, classType.getName()), e);
}
}
});
setupDesc(f);
}
Aggregations