Search in sources :

Example 66 with Container

use of org.apache.catalina.Container in project Payara by payara.

the class WebContainer method updateJvmRoute.

public void updateJvmRoute(HttpService httpService, String jvmOption) {
    String jvmRoute = null;
    if (jvmOption.contains("{") && jvmOption.contains("}")) {
        // Look up system-property
        jvmOption = jvmOption.substring(jvmOption.indexOf("{") + 1, jvmOption.indexOf("}"));
        jvmRoute = server.getSystemPropertyValue(jvmOption);
        if (jvmRoute == null) {
            // Try to get it from System property if it exists
            jvmRoute = System.getProperty(jvmOption);
        }
    } else if (jvmOption.contains("=")) {
        jvmRoute = jvmOption.substring(jvmOption.indexOf("=") + 1);
    }
    engine.setJvmRoute(jvmRoute);
    for (com.sun.enterprise.config.serverbeans.VirtualServer vsBean : httpService.getVirtualServer()) {
        VirtualServer vs = (VirtualServer) engine.findChild(vsBean.getId());
        for (Container context : vs.findChildren()) {
            if (context instanceof StandardContext) {
                ((StandardContext) context).setJvmRoute(jvmRoute);
            }
        }
    }
    for (Connector connector : _embedded.getConnectors()) {
        connector.setJvmRoute(jvmRoute);
    }
    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, LogFacade.JVM_ROUTE_UPDATED, jvmRoute);
    }
}
Also used : PECoyoteConnector(com.sun.enterprise.web.connector.coyote.PECoyoteConnector) Connector(org.apache.catalina.Connector) Container(org.apache.catalina.Container) StandardContext(org.apache.catalina.core.StandardContext)

Example 67 with Container

use of org.apache.catalina.Container in project Payara by payara.

the class LoggerBase method setContainer.

/**
 * Set the Container with which this Logger has been associated.
 *
 * @param container The associated Container
 */
public void setContainer(Container container) {
    Container oldContainer = this.container;
    this.container = container;
    support.firePropertyChange("container", oldContainer, this.container);
}
Also used : Container(org.apache.catalina.Container)

Example 68 with Container

use of org.apache.catalina.Container in project Payara by payara.

the class LoggerBase method setContainer.

/**
 * Set the Container with which this Logger has been associated.
 *
 * @param container The associated Container
 */
public void setContainer(Container container) {
    Container oldContainer = this.container;
    this.container = container;
    support.firePropertyChange("container", oldContainer, this.container);
}
Also used : Container(org.apache.catalina.Container)

Example 69 with Container

use of org.apache.catalina.Container in project Payara by payara.

the class FileStore method save.

/**
 * Save the specified Session into this Store.  Any previously saved
 * information for the associated session identifier is replaced.
 *
 * @param session Session to be saved
 *
 * @exception IOException if an input/output error occurs
 */
public void save(Session session) throws IOException {
    // Open an output stream to the specified pathname, if any
    File file = file(session.getIdInternal());
    if (file == null) {
        return;
    }
    if (debug >= 1) {
        String msg = MessageFormat.format(rb.getString(LogFacade.SAVING_SESSION_TO_FILE), new Object[] { session.getIdInternal(), file.getAbsolutePath() });
        log(msg);
    }
    ObjectOutputStream oos = null;
    try (FileOutputStream fos = new FileOutputStream(file.getAbsolutePath());
        BufferedOutputStream bos = new BufferedOutputStream(fos)) {
        Container container = manager.getContainer();
        if (container != null) {
            oos = ((StandardContext) container).createObjectOutputStream(bos);
        } else {
            oos = new ObjectOutputStream(bos);
        }
        oos.writeObject(session);
    } catch (IOException e) {
        throw e;
    } finally {
        if (oos != null) {
            try {
                oos.close();
            } catch (IOException ioe) {
            // ignore
            }
        }
    }
}
Also used : Container(org.apache.catalina.Container) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 70 with Container

use of org.apache.catalina.Container in project Payara by payara.

the class FileStore method load.

/**
 * Load and return the Session associated with the specified session
 * identifier from this Store, without removing it.  If there is no
 * such stored Session, return <code>null</code>.
 *
 * @param id Session identifier of the session to load
 *
 * @exception ClassNotFoundException if a deserialization error occurs
 * @exception IOException if an input/output error occurs
 */
public Session load(String id) throws ClassNotFoundException, IOException {
    // HERCULES:addition
    // Check to see if it's in our cache first
    Session sess = sessions.get(id);
    if (sess != null) {
        return sess;
    }
    // HERCULES:addition
    // Open an input stream to the specified pathname, if any
    File file = file(id);
    if (file == null) {
        return (null);
    }
    if (!file.exists()) {
        return (null);
    }
    if (debug >= 1) {
        String msg = MessageFormat.format(rb.getString(LogFacade.LOADING_SESSION_FROM_FILE), new Object[] { id, file.getAbsolutePath() });
        log(msg);
    }
    FileInputStream fis = null;
    BufferedInputStream bis = null;
    ObjectInputStream ois = null;
    Loader loader = null;
    ClassLoader classLoader = null;
    try {
        fis = new FileInputStream(file.getAbsolutePath());
        bis = new BufferedInputStream(fis);
        Container container = manager.getContainer();
        if (container != null) {
            ois = ((StandardContext) container).createObjectInputStream(bis);
        } else {
            ois = new ObjectInputStream(bis);
        }
    // end HERCULES:mod
    } catch (FileNotFoundException e) {
        if (debug >= 1)
            log("No persisted data file found");
        return (null);
    } catch (IOException e) {
        if (bis != null) {
            try {
                bis.close();
            } catch (IOException f) {
            // Ignore
            }
        }
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException f) {
            // Ignore
            }
        }
        throw e;
    }
    try {
        StandardSession session = StandardSession.deserialize(ois, manager);
        session.setManager(manager);
        // HERCULES: addition
        // Put it in the cache
        sessions.put(session.getIdInternal(), session);
        // HERCULES: addition
        return (session);
    } finally {
        // Close the input stream
        if (ois != null) {
            try {
                ois.close();
            } catch (IOException f) {
            // Ignore
            }
        }
    }
}
Also used : Container(org.apache.catalina.Container) BufferedInputStream(java.io.BufferedInputStream) FileNotFoundException(java.io.FileNotFoundException) Loader(org.apache.catalina.Loader) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) Session(org.apache.catalina.Session) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

Container (org.apache.catalina.Container)163 Context (org.apache.catalina.Context)28 IOException (java.io.IOException)24 Host (org.apache.catalina.Host)22 StandardContext (org.apache.catalina.core.StandardContext)21 Engine (org.apache.catalina.Engine)18 LifecycleException (org.apache.catalina.LifecycleException)17 File (java.io.File)15 ObjectName (javax.management.ObjectName)15 Wrapper (org.apache.catalina.Wrapper)13 StandardHost (org.apache.catalina.core.StandardHost)13 ArrayList (java.util.ArrayList)12 ServletException (javax.servlet.ServletException)11 MalformedURLException (java.net.MalformedURLException)10 Valve (org.apache.catalina.Valve)10 StandardWrapper (org.apache.catalina.core.StandardWrapper)10 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)10 NamingException (javax.naming.NamingException)9 Lifecycle (org.apache.catalina.Lifecycle)9 Realm (org.apache.catalina.Realm)9