Search in sources :

Example 61 with StandardContext

use of org.apache.catalina.core.StandardContext in project Payara by payara.

the class BaseHASession method sync.

public void sync() {
    HttpSessionBindingEvent event = null;
    event = new HttpSessionBindingEvent((HttpSession) this, null, null);
    // Notify special event listeners on sync()
    Manager manager = this.getManager();
    StandardContext stdContext = (StandardContext) manager.getContainer();
    // fire container event
    stdContext.fireContainerEvent("sessionSync", event);
}
Also used : HttpSessionBindingEvent(javax.servlet.http.HttpSessionBindingEvent) HttpSession(javax.servlet.http.HttpSession) StandardContext(org.apache.catalina.core.StandardContext) Manager(org.apache.catalina.Manager)

Example 62 with StandardContext

use of org.apache.catalina.core.StandardContext in project Payara by payara.

the class LoggerBase method createObjectName.

public ObjectName createObjectName() {
    if (log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "createObjectName with {0}", container);
    }
    // register
    try {
        StandardEngine engine = null;
        String suffix = "";
        if (container instanceof StandardEngine) {
            engine = (StandardEngine) container;
        } else if (container instanceof StandardHost) {
            engine = (StandardEngine) container.getParent();
            suffix = ",host=" + container.getName();
        } else if (container instanceof StandardContext) {
            String path = ((StandardContext) container).getPath();
            // add "/" to avoid MalformedObjectName Exception
            if (path.equals("")) {
                path = "/";
            }
            engine = (StandardEngine) container.getParent().getParent();
            suffix = ",path=" + path + ",host=" + container.getParent().getName();
        } else {
            log.log(Level.SEVERE, LogFacade.UNKNOWN_CONTAINER_EXCEPTION);
        }
        if (engine != null) {
            oname = new ObjectName(engine.getDomain() + ":type=Logger" + suffix);
        } else {
            log.log(Level.SEVERE, LogFacade.NULL_ENGINE_EXCEPTION, container);
        }
    } catch (Throwable e) {
        log.log(Level.WARNING, LogFacade.UNABLE_CREATE_OBJECT_NAME_FOR_LOGGER_EXCEPTION, e);
    }
    return oname;
}
Also used : StandardEngine(org.apache.catalina.core.StandardEngine) StandardHost(org.apache.catalina.core.StandardHost) StandardContext(org.apache.catalina.core.StandardContext) ObjectName(javax.management.ObjectName)

Example 63 with StandardContext

use of org.apache.catalina.core.StandardContext in project Payara by payara.

the class ManagerBase method init.

public void init() {
    if (initialized)
        return;
    initialized = true;
    if (oname == null) {
        try {
            StandardContext ctx = (StandardContext) this.getContainer();
            domain = ctx.getEngineName();
            distributable = ctx.getDistributable();
            StandardHost hst = (StandardHost) ctx.getParent();
            String path = ctx.getEncodedPath();
            if (path.equals("")) {
                path = "/";
            }
            oname = new ObjectName(domain + ":type=Manager,path=" + path + ",host=" + hst.getName());
        } catch (Exception e) {
            log.log(Level.SEVERE, LogFacade.ERROR_REGISTERING_EXCEPTION_SEVERE, e);
        }
    }
    if (log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "Registering {0}", oname);
    }
}
Also used : StandardHost(org.apache.catalina.core.StandardHost) StandardContext(org.apache.catalina.core.StandardContext) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ObjectName(javax.management.ObjectName)

Example 64 with StandardContext

use of org.apache.catalina.core.StandardContext in project Payara by payara.

the class HASessionStoreValve method invoke.

/**
 * invoke call-back; nothing to do on the way in
 * @param request
 * @param response
 */
public int invoke(org.apache.catalina.Request request, org.apache.catalina.Response response) throws java.io.IOException, javax.servlet.ServletException {
    // FIXME this is for 7.0PE style valves
    // left here if the same optimization is done to the valve architecture
    String sessionId = null;
    ReplicationWebEventPersistentManager manager;
    StandardContext context;
    HttpServletRequest httpServletrequest = (HttpServletRequest) request.getRequest();
    HttpSession session = httpServletrequest.getSession(false);
    if (session != null) {
        sessionId = session.getId();
        if (sessionId != null) {
            context = (StandardContext) request.getContext();
            manager = (ReplicationWebEventPersistentManager) context.getManager();
            String oldJreplicaValue = null;
            Cookie[] cookies = httpServletrequest.getCookies();
            if (cookies != null) {
                for (Cookie cookie : cookies) {
                    if (cookie.getName().equalsIgnoreCase(Globals.JREPLICA_COOKIE_NAME)) {
                        oldJreplicaValue = cookie.getValue();
                    }
                }
                String replica = manager.getReplicaFromPredictor(sessionId, oldJreplicaValue);
                if (replica != null) {
                    Session sess = request.getSessionInternal(false);
                    if (sess != null) {
                        sess.setNote(Globals.JREPLICA_SESSION_NOTE, replica);
                    }
                }
            }
        }
    }
    return INVOKE_NEXT;
// return 0;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Cookie(javax.servlet.http.Cookie) HttpSession(javax.servlet.http.HttpSession) StandardContext(org.apache.catalina.core.StandardContext) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.catalina.Session)

Example 65 with StandardContext

use of org.apache.catalina.core.StandardContext in project Payara by payara.

the class HASessionStoreValve method doPostInvoke.

/**
 * A post-request processing implementation that does the valveSave.
 * @param request
 * @param response
 */
private void doPostInvoke(Request request, Response response) throws IOException, ServletException {
    if (_logger.isLoggable(Level.FINEST)) {
        _logger.finest("IN HASessionStoreValve>>postInvoke()");
    }
    String sessionId = null;
    Session session;
    StandardContext context;
    Manager manager;
    HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
    HttpSession hsess = hreq.getSession(false);
    if (hsess != null) {
        sessionId = hsess.getId();
        if (_logger.isLoggable(Level.FINEST)) {
            _logger.finest("IN HASessionStoreValve:postInvoke:sessionId=" + sessionId);
        }
    }
    if (sessionId != null) {
        context = (StandardContext) request.getContext();
        manager = context.getManager();
        session = manager.findSession(sessionId);
        if (_logger.isLoggable(Level.FINEST)) {
            _logger.finest("IN HASessionStoreValve:postInvoke:session=" + session);
        }
        if (session != null) {
            WebEventPersistentManager pMgr = (WebEventPersistentManager) manager;
            pMgr.doValveSave(session);
        }
    }
    HACookieManager.reset();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpSession(javax.servlet.http.HttpSession) StandardContext(org.apache.catalina.core.StandardContext) HACookieManager(org.glassfish.ha.common.HACookieManager) Manager(org.apache.catalina.Manager) HttpSession(javax.servlet.http.HttpSession) Session(org.apache.catalina.Session)

Aggregations

StandardContext (org.apache.catalina.core.StandardContext)181 File (java.io.File)72 Tomcat (org.apache.catalina.startup.Tomcat)64 Test (org.junit.Test)52 TomcatBaseTest (org.apache.catalina.startup.TomcatBaseTest)41 Context (org.apache.catalina.Context)32 ByteChunk (org.apache.tomcat.util.buf.ByteChunk)31 StandardHost (org.apache.catalina.core.StandardHost)25 IOException (java.io.IOException)22 Host (org.apache.catalina.Host)18 MalformedURLException (java.net.MalformedURLException)16 JarFile (java.util.jar.JarFile)16 ServletContext (javax.servlet.ServletContext)16 StandardRoot (org.apache.catalina.webresources.StandardRoot)16 URL (java.net.URL)13 InterceptSupport (com.creditease.monitor.interceptframework.InterceptSupport)12 InterceptContext (com.creditease.monitor.interceptframework.spi.InterceptContext)12 HashMap (java.util.HashMap)12 List (java.util.List)12 Container (org.apache.catalina.Container)12