本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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());
}
示例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);
}
}
}
示例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);
}