use of org.apache.catalina.Container in project Payara by payara.
the class JDBCStore method getName.
/**
* Return the name for this instance (built from container name)
*/
public String getName() {
if (name == null) {
Container container = manager.getContainer();
String contextName = container.getName();
String hostName = "";
String engineName = "";
if (container.getParent() != null) {
Container host = container.getParent();
hostName = host.getName();
if (host.getParent() != null) {
engineName = host.getParent().getName();
}
}
name = "/" + engineName + "/" + hostName + contextName;
}
return name;
}
use of org.apache.catalina.Container in project Payara by payara.
the class JDBCStore method load.
/**
* Load the Session associated with the id <code>id</code>.
* If no such session is found <code>null</code> is returned.
*
* @param id a value of type <code>String</code>
* @return the stored <code>Session</code>
* @exception ClassNotFoundException if an error occurs
* @exception IOException if an input/output error occurred
*/
public Session load(String id) throws ClassNotFoundException, IOException {
ResultSet rst = null;
StandardSession _session = null;
Loader loader = null;
ClassLoader classLoader = null;
ObjectInputStream ois = null;
BufferedInputStream bis = null;
Container container = manager.getContainer();
String loadSql = "SELECT " + sessionIdCol + ", " + sessionDataCol + " FROM " + sessionTable + " WHERE " + sessionIdCol + " = ? AND " + sessionAppCol + " = ?";
synchronized (this) {
Connection _conn = getConnection();
if (_conn == null) {
return (null);
}
try {
if (preparedLoadSql == null) {
preparedLoadSql = _conn.prepareStatement(loadSql);
}
preparedLoadSql.setString(1, id);
preparedLoadSql.setString(2, getName());
rst = preparedLoadSql.executeQuery();
if (rst.next()) {
bis = new BufferedInputStream(rst.getBinaryStream(2));
if (container != null) {
loader = container.getLoader();
}
if (loader != null) {
classLoader = loader.getClassLoader();
}
if (classLoader != null) {
ois = new CustomObjectInputStream(bis, classLoader);
} else {
ois = new ObjectInputStream(bis);
}
if (debug > 0) {
String msg = MessageFormat.format(rb.getString(LogFacade.LOADING_SESSION_FROM_DATABASE), new Object[] { id, sessionTable });
log(msg);
}
_session = StandardSession.deserialize(ois, manager);
_session.setManager(manager);
} else if (debug > 0) {
log(getStoreName() + ": No persisted data object found");
}
} catch (SQLException e) {
String msg = MessageFormat.format(rb.getString(LogFacade.SQL_ERROR), e);
log(msg);
} finally {
try {
if (rst != null) {
rst.close();
}
} catch (SQLException e) {
// Ignore
}
if (ois != null) {
try {
ois.close();
} catch (IOException e) {
// Ignore
}
}
release(_conn);
}
}
return (_session);
}
use of org.apache.catalina.Container in project Payara by payara.
the class ContainerBase method setParent.
/**
* Set the parent Container to which this Container is being added as a
* child. This Container may refuse to become attached to the specified
* Container by throwing an exception.
*
* @param container Container to which this Container is being added
* as a child
*
* @exception IllegalArgumentException if this Container refuses to become
* attached to the specified Container
*/
public void setParent(Container container) {
Container oldParent = this.parent;
this.parent = container;
support.firePropertyChange("parent", oldParent, this.parent);
}
use of org.apache.catalina.Container in project Payara by payara.
the class StandardContext method postWorkDirectory.
/**
* Set the appropriate context attribute for our work directory.
*/
private void postWorkDirectory() {
// Acquire (or calculate) the work directory path
String workDir = getWorkDir();
if (workDir == null || workDir.length() == 0) {
// Retrieve our parent (normally a host) name
String hostName = null;
String engineName = null;
String hostWorkDir = null;
Container parentHost = getParent();
if (parentHost != null) {
hostName = parentHost.getName();
if (parentHost instanceof StandardHost) {
hostWorkDir = ((StandardHost) parentHost).getWorkDir();
}
Container parentEngine = parentHost.getParent();
if (parentEngine != null) {
engineName = parentEngine.getName();
}
}
if ((hostName == null) || (hostName.length() < 1))
hostName = "_";
if ((engineName == null) || (engineName.length() < 1))
engineName = "_";
String temp = getPath();
if (temp.startsWith("/"))
temp = temp.substring(1);
temp = temp.replace('/', '_');
temp = temp.replace('\\', '_');
if (temp.length() < 1)
temp = "_";
if (hostWorkDir != null) {
workDir = hostWorkDir + File.separator + temp;
} else {
workDir = "work" + File.separator + engineName + File.separator + hostName + File.separator + temp;
}
setWorkDir(workDir);
}
// Create this directory if necessary
File dir = new File(workDir);
if (!dir.isAbsolute()) {
File catalinaHome = engineBase();
String catalinaHomePath = null;
try {
catalinaHomePath = catalinaHome.getCanonicalPath();
dir = new File(catalinaHomePath, workDir);
} catch (IOException e) {
}
}
if (!dir.mkdirs() && !dir.isDirectory()) {
log.log(Level.SEVERE, LogFacade.CREATE_WORK_DIR_EXCEPTION, dir.getAbsolutePath());
}
// Set the appropriate servlet context attribute
getServletContext().setAttribute(ServletContext.TEMPDIR, dir);
context.setAttributeReadOnly(ServletContext.TEMPDIR);
}
use of org.apache.catalina.Container in project Payara by payara.
the class StandardContext method getVirtualServerName.
@Override
public String getVirtualServerName() {
String virtualServerName = null;
Container parent = getParent();
if (parent != null) {
virtualServerName = parent.getName();
}
return virtualServerName;
}
Aggregations