当前位置: 首页>>代码示例>>Java>>正文


Java Request.getContext方法代码示例

本文整理汇总了Java中org.apache.catalina.connector.Request.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java Request.getContext方法的具体用法?Java Request.getContext怎么用?Java Request.getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.connector.Request的用法示例。


在下文中一共展示了Request.getContext方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Detect possible the JVMRoute change at cluster backup node..
 * 
 * @param request
 *            tomcat request being processed
 * @param response
 *            tomcat response being processed
 * @exception IOException
 *                if an input/output error has occurred
 * @exception ServletException
 *                if a servlet error has occurred
 */
@Override
public void invoke(Request request, Response response) throws IOException,
        ServletException {

     if (getEnabled() &&
             request.getContext() != null &&
             request.getContext().getDistributable() &&
             !request.isAsyncDispatching()) {
         // valve cluster can access manager - other cluster handle turnover 
         // at host level - hopefully!
         Manager manager = request.getContext().getManager();

         if (manager != null && (
                 (manager instanceof ClusterManager
                   && getCluster() != null
                   && getCluster().getManager(((ClusterManager)manager).getName()) != null)
                 ||
                 (manager instanceof PersistentManager)))
             handlePossibleTurnover(request);
    }
    // Pass this request on to the next valve in our pipeline
    getNext().invoke(request, response);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:36,代码来源:JvmRouteBinderValve.java

示例2: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Detect possible the JVMRoute change at cluster backup node..
 * 
 * @param request
 *            tomcat request being processed
 * @param response
 *            tomcat response being processed
 * @exception IOException
 *                if an input/output error has occurred
 * @exception ServletException
 *                if a servlet error has occurred
 */
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {

	if (getEnabled() && request.getContext() != null && request.getContext().getDistributable()
			&& !request.isAsyncDispatching()) {
		// valve cluster can access manager - other cluster handle turnover
		// at host level - hopefully!
		Manager manager = request.getContext().getManager();

		if (manager != null && ((manager instanceof ClusterManager && getCluster() != null
				&& getCluster().getManager(((ClusterManager) manager).getName()) != null)
				|| (manager instanceof PersistentManager)))
			handlePossibleTurnover(request);
	}
	// Pass this request on to the next valve in our pipeline
	getNext().invoke(request, response);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:30,代码来源:JvmRouteBinderValve.java

示例3: sendSessionIDClusterBackup

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Send the changed Sessionid to all clusternodes.
 * 
 * @see JvmRouteSessionIDBinderListener#messageReceived(
 *            org.apache.catalina.ha.ClusterMessage)
 * @param sessionId
 *            current failed sessionid
 * @param newSessionID
 *            new session id, bind to the new cluster node
 */
protected void sendSessionIDClusterBackup(Request request, String sessionId,
        String newSessionID) {
    CatalinaCluster c = getCluster();
    if (c != null && !(getManager(request) instanceof BackupManager)) {
        SessionIDMessage msg = new SessionIDMessage();
        msg.setOrignalSessionID(sessionId);
        msg.setBackupSessionID(newSessionID);
        Context context = request.getContext();
        msg.setContextName(context.getName());
        msg.setHost(context.getParent().getName());
        c.send(msg);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:JvmRouteBinderValve.java

示例4: denyRequest

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Reject the request that was denied by this valve.
 * <p>If <code>invalidAuthenticationWhenDeny</code> is true
 * and the context has <code>preemptiveAuthentication</code>
 * set, set an invalid authorization header to trigger basic auth.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be processed
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
protected void denyRequest(Request request, Response response)
        throws IOException, ServletException {
    if (invalidAuthenticationWhenDeny) {
        Context context = request.getContext();
        if (context != null && context.getPreemptiveAuthentication()) {
            if (request.getCoyoteRequest().getMimeHeaders().getValue("authorization") == null) {
                request.getCoyoteRequest().getMimeHeaders().addValue("authorization").setString("invalid");
            }
            getNext().invoke(request, response);
            return;
        }
    }
    response.sendError(denyStatus);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:26,代码来源:RequestFilterValve.java

示例5: sendSessionIDClusterBackup

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Send the changed Sessionid to all clusternodes.
 * 
 * @see JvmRouteSessionIDBinderListener#messageReceived(
 *      org.apache.catalina.ha.ClusterMessage)
 * @param sessionId
 *            current failed sessionid
 * @param newSessionID
 *            new session id, bind to the new cluster node
 */
protected void sendSessionIDClusterBackup(Request request, String sessionId, String newSessionID) {
	CatalinaCluster c = getCluster();
	if (c != null && !(getManager(request) instanceof BackupManager)) {
		SessionIDMessage msg = new SessionIDMessage();
		msg.setOrignalSessionID(sessionId);
		msg.setBackupSessionID(newSessionID);
		Context context = request.getContext();
		msg.setContextName(context.getName());
		msg.setHost(context.getParent().getName());
		c.send(msg);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:23,代码来源:JvmRouteBinderValve.java

示例6: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Log the interesting request parameters, invoke the next Valve in the
 * sequence, and log the interesting response parameters.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
@Override
public void invoke(Request request, Response response)
    throws IOException, ServletException
{
    long totalstart = 0;

    //this happens before the request
    if(doStatistics()) {
        totalstart = System.currentTimeMillis();
    }
    if (primaryIndicator) {
        createPrimaryIndicator(request) ;
    }
    Context context = request.getContext();
    boolean isCrossContext = context != null
            && context instanceof StandardContext
            && ((StandardContext) context).getCrossContext();
    try {
        if(isCrossContext) {
            if(log.isDebugEnabled())
                log.debug(sm.getString("ReplicationValve.crossContext.add"));
            //FIXME add Pool of Arraylists
            crossContextSessions.set(new ArrayList<DeltaSession>());
        }
        getNext().invoke(request, response);
        if(context != null && cluster != null
                && context.getManager() instanceof ClusterManager) {
            ClusterManager clusterManager = (ClusterManager) context.getManager();

            // valve cluster can access manager - other cluster handle replication 
            // at host level - hopefully!
            if(cluster.getManager(clusterManager.getName()) == null)
                return ;
            if(cluster.hasMembers()) {
                sendReplicationMessage(request, totalstart, isCrossContext, clusterManager, cluster);
            } else {
                resetReplicationRequest(request,isCrossContext);
            }        
        }
    } finally {
        // Array must be remove: Current master request send endAccess at recycle. 
        // Don't register this request session again!
        if(isCrossContext) {
            if(log.isDebugEnabled())
                log.debug(sm.getString("ReplicationValve.crossContext.remove"));
            // crossContextSessions.remove() only exist at Java 5
            // register ArrayList at a pool
            crossContextSessions.set(null);
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:62,代码来源:ReplicationValve.java

示例7: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Select the appropriate child Context to process this request,
 * based on the specified request URI.  If no matching Context can
 * be found, return an appropriate HTTP error.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 * @param valveContext Valve context used to forward to the next Valve
 *
 * @exception IOException if an input/output error occurred
 * @exception ServletException if a servlet error occurred
 */
public final void invoke(Request request, Response response)
    throws IOException, ServletException {

    // Select the Context to be used for this Request
    Context context = request.getContext();
    if (context == null) {
        response.sendError
            (HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
             sm.getString("standardHost.noContext"));
        return;
    }

    // Bind the context CL to the current thread
    if( context.getLoader() != null ) {
        // Not started - it should check for availability first
        // This should eventually move to Engine, it's generic.
        Thread.currentThread().setContextClassLoader
                (context.getLoader().getClassLoader());
    }

    // Ask this Context to process this request
    context.getPipeline().getFirst().invoke(request, response);

    // Access a session (if present) to update last accessed time, based on a
    // strict interpretation of the specification
    if (Globals.STRICT_SERVLET_COMPLIANCE) {
        request.getSession(false);
    }

    // Error page processing
    response.setSuspended(false);

    Throwable t = (Throwable) request.getAttribute(Globals.EXCEPTION_ATTR);

    if (t != null) {
        throwable(request, response, t);
    } else {
        status(request, response);
    }

    // Restore the context classloader
    Thread.currentThread().setContextClassLoader
        (StandardHostValve.class.getClassLoader());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:58,代码来源:StandardHostValve.java

示例8: invoke

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Log the interesting request parameters, invoke the next Valve in the
 * sequence, and log the interesting response parameters.
 *
 * @param request
 *            The servlet request to be processed
 * @param response
 *            The servlet response to be created
 *
 * @exception IOException
 *                if an input/output error occurs
 * @exception ServletException
 *                if a servlet error occurs
 */
@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
	long totalstart = 0;

	// this happens before the request
	if (doStatistics()) {
		totalstart = System.currentTimeMillis();
	}
	if (primaryIndicator) {
		createPrimaryIndicator(request);
	}
	Context context = request.getContext();
	boolean isCrossContext = context != null && context instanceof StandardContext
			&& ((StandardContext) context).getCrossContext();
	try {
		if (isCrossContext) {
			if (log.isDebugEnabled())
				log.debug(sm.getString("ReplicationValve.crossContext.add"));
			// FIXME add Pool of Arraylists
			crossContextSessions.set(new ArrayList<DeltaSession>());
		}
		getNext().invoke(request, response);
		if (context != null && cluster != null && context.getManager() instanceof ClusterManager) {
			ClusterManager clusterManager = (ClusterManager) context.getManager();

			// valve cluster can access manager - other cluster handle
			// replication
			// at host level - hopefully!
			if (cluster.getManager(clusterManager.getName()) == null)
				return;
			if (cluster.hasMembers()) {
				sendReplicationMessage(request, totalstart, isCrossContext, clusterManager, cluster);
			} else {
				resetReplicationRequest(request, isCrossContext);
			}
		}
	} finally {
		// Array must be remove: Current master request send endAccess at
		// recycle.
		// Don't register this request session again!
		if (isCrossContext) {
			if (log.isDebugEnabled())
				log.debug(sm.getString("ReplicationValve.crossContext.remove"));
			// crossContextSessions.remove() only exist at Java 5
			// register ArrayList at a pool
			crossContextSessions.set(null);
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:64,代码来源:ReplicationValve.java

示例9: denyRequest

import org.apache.catalina.connector.Request; //导入方法依赖的package包/类
/**
 * Reject the request that was denied by this valve.
 * <p>
 * If <code>invalidAuthenticationWhenDeny</code> is true and the context has
 * <code>preemptiveAuthentication</code> set, set an invalid authorization
 * header to trigger basic auth.
 *
 * @param request
 *            The servlet request to be processed
 * @param response
 *            The servlet response to be processed
 * @exception IOException
 *                if an input/output error occurs
 * @exception ServletException
 *                if a servlet error occurs
 */
protected void denyRequest(Request request, Response response) throws IOException, ServletException {
	if (invalidAuthenticationWhenDeny) {
		Context context = request.getContext();
		if (context != null && context.getPreemptiveAuthentication()) {
			if (request.getCoyoteRequest().getMimeHeaders().getValue("authorization") == null) {
				request.getCoyoteRequest().getMimeHeaders().addValue("authorization").setString("invalid");
			}
			getNext().invoke(request, response);
			return;
		}
	}
	response.sendError(denyStatus);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:30,代码来源:RequestFilterValve.java


注:本文中的org.apache.catalina.connector.Request.getContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。