use of com.sun.enterprise.util.i18n.StringManager in project Payara by payara.
the class AdminObjectConfigParserImpl method getAdminObject.
private AdminObject getAdminObject(ConnectorDescriptor desc, String adminObjectInterface, String adminObjectClass) throws ConnectorRuntimeException {
if (desc == null || adminObjectInterface == null) {
throw new ConnectorRuntimeException("Invalid arguments");
}
Set adminObjectSet = desc.getAdminObjects();
if (adminObjectSet == null || adminObjectSet.size() == 0) {
return null;
}
AdminObject adminObject = null;
Iterator iter = adminObjectSet.iterator();
Properties mergedVals = null;
boolean adminObjectFound = false;
while (iter.hasNext()) {
adminObject = (AdminObject) iter.next();
if (adminObjectInterface.equals(adminObject.getAdminObjectInterface()) && (adminObjectClass == null || adminObjectClass.equals(adminObject.getAdminObjectClass()))) {
adminObjectFound = true;
break;
}
}
if (!adminObjectFound) {
StringManager localStrings = StringManager.getManager(AdminObjectConfigParserImpl.class);
String msg = localStrings.getString("no_adminobject_interface_found_in_raxml", adminObjectInterface);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, msg);
}
throw new ConnectorRuntimeException(msg);
}
return adminObject;
}
use of com.sun.enterprise.util.i18n.StringManager in project Payara by payara.
the class DBControl method createDBLog.
/**
* create a db.log file that stdout/stderr will redirect to. dbhome is the
* h2.system.home directory where derb.log gets created. if user specified
* --dbhome options, ${db}.log will be created there.
*
* @param dbHome
* @return
* @throws java.lang.Exception
*/
private String createDBLog(final String dbHome) throws Exception {
// dbHome must exist and have write permission
final File fDBHome = new File(dbHome);
String dbLogFilePath;
final StringManager localManager = StringManager.getManager(this.getClass());
if (fDBHome.isDirectory() && fDBHome.canWrite()) {
final File fDBLog = new File(dbHome, getLogFileName());
dbLogFilePath = fDBLog.toString();
// if the file exists, check if it is writeable
if (fDBLog.exists() && !fDBLog.canWrite()) {
System.out.println(localManager.getString("UnableToAccessDatabaseLog", getLogFileName(), dbLogFilePath));
System.out.println(localManager.getString("ContinueStartingDatabase"));
// if exist but not able to write then create a temporary
// log file and persist on starting the database
dbLogFilePath = createTempLogFile();
} else if (!fDBLog.exists()) {
// Create the log file
if (!fDBLog.createNewFile()) {
System.out.println(localManager.getString("UnableToCreateDatabaseLog", getLogFileName(), dbLogFilePath));
}
}
} else {
System.out.println(localManager.getString("InvalidDBDirectory", dbHome));
System.out.println(localManager.getString("ContinueStartingDatabase"));
// if directory does not exist then create a temporary log file
// and persist on starting the database
dbLogFilePath = createTempLogFile();
}
return dbLogFilePath;
}
use of com.sun.enterprise.util.i18n.StringManager in project Payara by payara.
the class DBControl method createTempLogFile.
/**
* creates a temporary log file.
*
* @return
* @throws org.glassfish.api.admin.CommandException
*/
private String createTempLogFile() throws CommandException {
String tempFileName = "";
try {
final File fTemp = File.createTempFile("foo", null);
fTemp.deleteOnExit();
tempFileName = fTemp.toString();
} catch (IOException ioe) {
final StringManager localManager = StringManager.getManager(this.getClass());
throw new CommandException(localManager.getString("UnableToAccessDatabaseLog", tempFileName));
}
return tempFileName;
}
use of com.sun.enterprise.util.i18n.StringManager in project Payara by payara.
the class CPManagedConnectionFactory method createManagedConnection.
/**
* Creates a new physical connection to the underlying EIS resource
* manager.
*
* @param subject <code>Subject</code> instance passed by the application server
* @param cxRequestInfo <code>ConnectionRequestInfo</code> which may be created
* as a result of the invocation <code>getConnection(user, password)</code>
* on the <code>DataSource</code> object
* @return <code>ManagedConnection</code> object created
* @throws ResourceException if there is an error in instantiating the
* <code>DataSource</code> object used for the
* creation of the <code>ManagedConnection</code> object
* @throws SecurityException if there ino <code>PasswordCredential</code> object
* satisfying this request
* @throws ResourceAllocationException if there is an error in allocating the
* physical connection
*/
public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
logFine("In createManagedConnection");
PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);
javax.sql.ConnectionPoolDataSource dataSource = getDataSource();
javax.sql.PooledConnection cpConn = null;
ManagedConnectionImpl mc = null;
try {
/* For the case where the user/passwd of the connection pool is
* equal to the PasswordCredential for the connection request
* get a connection from this pool directly.
* for all other conditions go create a new connection
*/
String user = getUser();
if (user == null || isEqual(pc, user, getPassword())) {
cpConn = dataSource.getPooledConnection();
} else {
cpConn = dataSource.getPooledConnection(pc.getUserName(), new String(pc.getPassword()));
}
} catch (java.sql.SQLException sqle) {
// _logger.log(Level.SEVERE, "jdbc.exc_create_ds_conn",sqle);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "jdbc.exc_create_ds_conn", sqle);
}
StringManager sm = StringManager.getManager(DataSourceObjectBuilder.class);
String msg = sm.getString("jdbc.cannot_allocate_connection", sqle.getMessage());
ResourceAllocationException rae = new ResourceAllocationException(msg, sqle);
throw rae;
}
try {
mc = constructManagedConnection(cpConn, null, pc, this);
mc.initializeConnectionType(ManagedConnectionImpl.ISPOOLEDCONNECTION);
// GJCINT
validateAndSetIsolation(mc);
} finally {
if (mc == null) {
if (cpConn != null) {
try {
cpConn.close();
} catch (SQLException e) {
_logger.log(Level.FINEST, "Exception while closing connection : createManagedConnection" + cpConn);
}
}
}
}
return mc;
}
use of com.sun.enterprise.util.i18n.StringManager in project Payara by payara.
the class DSManagedConnectionFactory method createManagedConnection.
/**
* Creates a new physical connection to the underlying EIS resource
* manager.
*
* @param subject <code>Subject</code> instance passed by the application server
* @param cxRequestInfo <code>ConnectionRequestInfo</code> which may be created
* as a result of the invocation <code>getConnection(user, password)</code>
* on the <code>DataSource</code> object
* @return <code>ManagedConnection</code> object created
* @throws ResourceException if there is an error in instantiating the
* <code>DataSource</code> object used for the
* creation of the <code>ManagedConnection</code> object
* @throws SecurityException if there ino <code>PasswordCredential</code> object
* satisfying this request
* @throws ResourceAllocationException if there is an error in allocating the
* physical connection
*/
public javax.resource.spi.ManagedConnection createManagedConnection(javax.security.auth.Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
logFine("In createManagedConnection");
PasswordCredential pc = SecurityUtils.getPasswordCredential(this, subject, cxRequestInfo);
javax.sql.DataSource dataSource = getDataSource();
java.sql.Connection dsConn = null;
ManagedConnectionImpl mc = null;
try {
/* For the case where the user/passwd of the connection pool is
* equal to the PasswordCredential for the connection request
* get a connection from this pool directly.
* for all other conditions go create a new connection
*/
String user = getUser();
if (user == null || isEqual(pc, user, getPassword())) {
dsConn = dataSource.getConnection();
} else {
dsConn = dataSource.getConnection(pc.getUserName(), new String(pc.getPassword()));
}
} catch (java.sql.SQLException sqle) {
// _logger.log(Level.WARNING, "jdbc.exc_create_conn", sqle.getMessage());
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "jdbc.exc_create_conn", sqle.getMessage());
}
StringManager localStrings = StringManager.getManager(DataSourceObjectBuilder.class);
String msg = localStrings.getString("jdbc.cannot_allocate_connection", sqle.getMessage());
ResourceAllocationException rae = new ResourceAllocationException(msg);
rae.initCause(sqle);
throw rae;
}
try {
mc = constructManagedConnection(null, dsConn, pc, this);
// GJCINT
validateAndSetIsolation(mc);
} finally {
if (mc == null) {
if (dsConn != null) {
try {
dsConn.close();
} catch (SQLException e) {
_logger.log(Level.FINEST, "Exception while closing connection : " + "createManagedConnection" + dsConn);
}
}
}
}
return mc;
}
Aggregations