Java 类javax.servlet.Servlet 实例源码

项目:lazycat    文件:StandardWrapper.java   
/**
 * Return this previously allocated servlet to the pool of available
 * instances. If this servlet class does not implement SingleThreadModel, no
 * action is actually required.
 *
 * @param servlet
 *            The servlet to be returned
 *
 * @exception ServletException
 *                if a deallocation error occurs
 */
@Override
public void deallocate(Servlet servlet) throws ServletException {

    // If not SingleThreadModel, no action is required
    if (!singleThreadModel) {
        countAllocated.decrementAndGet();
        return;
    }

    // Unlock and free this instance
    synchronized (instancePool) {
        countAllocated.decrementAndGet();
        instancePool.push(servlet);
        instancePool.notify();
    }

}
项目:uavstack    文件:SpringBootTomcatPlusIT.java   
/**
 * onServletStop
 * 
 * @param args
 */
@Override
public void onServletStop(Object... args) {

    StandardWrapper sw = (StandardWrapper) args[0];
    Servlet servlet = (Servlet) args[1];
    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.BEFORE_SERVLET_DESTROY);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    /**
     * NOTE: spring boot rewrite the tomcat webappclassloader, makes the addURL for nothing, then we can't do
     * anything on this we may use its webappclassloader's parent as the classloader
     */
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader().getParent());

    context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath());
    iSupport.doIntercept(context);
}
项目:apache-tomcat-7.0.73-with-comment    文件:ApplicationContextFacade.java   
/**
 * @deprecated As of Java Servlet API 2.1, with no direct replacement.
 */
@Override
@Deprecated
public Servlet getServlet(String name)
    throws ServletException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            return (Servlet) invokeMethod(context, "getServlet", 
                                          new Object[]{name});
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            if (t instanceof ServletException) {
                throw (ServletException) t;
            }
            return null;
        }
    } else {
        return context.getServlet(name);
    }
}
项目:lazycat    文件:ApplicationContextFacade.java   
@Override
@SuppressWarnings("unchecked") // doPrivileged() returns the correct type
public <T extends Servlet> T createServlet(Class<T> c) throws ServletException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            return (T) invokeMethod(context, "createServlet", new Object[] { c });
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            if (t instanceof ServletException) {
                throw (ServletException) t;
            }
            return null;
        }
    } else {
        return context.createServlet(c);
    }
}
项目:tomcat7    文件:ApplicationContextFacade.java   
/**
 * @deprecated As of Java Servlet API 2.1, with no direct replacement.
 */
@Override
@Deprecated
public Servlet getServlet(String name)
    throws ServletException {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        try {
            return (Servlet) invokeMethod(context, "getServlet", 
                                          new Object[]{name});
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
            if (t instanceof ServletException) {
                throw (ServletException) t;
            }
            return null;
        }
    } else {
        return context.getServlet(name);
    }
}
项目:tomcat7    文件:StandardWrapper.java   
/**
 * Return this previously allocated servlet to the pool of available
 * instances.  If this servlet class does not implement SingleThreadModel,
 * no action is actually required.
 *
 * @param servlet The servlet to be returned
 *
 * @exception ServletException if a deallocation error occurs
 */
@Override
public void deallocate(Servlet servlet) throws ServletException {

    // If not SingleThreadModel, no action is required
    if (!singleThreadModel) {
        countAllocated.decrementAndGet();
        return;
    }

    // Unlock and free this instance
    synchronized (instancePool) {
        countAllocated.decrementAndGet();
        instancePool.push(servlet);
        instancePool.notify();
    }

}
项目:lams    文件:InstanceSupport.java   
/**
 * Notify all lifecycle event listeners that a particular event has
 * occurred for this Container.  The default implementation performs
 * this notification synchronously using the calling thread.
 *
 * @param type Event type
 * @param servlet The relevant Servlet for this event
 * @param request The servlet request we are processing
 * @param response The servlet response we are processing
 * @param exception Exception that occurred
 */
public void fireInstanceEvent(String type, Servlet servlet,
                              ServletRequest request,
                              ServletResponse response,
                              Throwable exception) {

    if (listeners.length == 0)
        return;

    InstanceEvent event = new InstanceEvent(wrapper, servlet, type,
                                            request, response, exception);
    InstanceListener interested[] = listeners;
    for (int i = 0; i < interested.length; i++)
        interested[i].instanceEvent(event);

}
项目:jerrydog    文件:InstanceEvent.java   
/**
 * Construct a new InstanceEvent with the specified parameters.  This
 * constructor is used for processing servlet lifecycle events.
 *
 * @param wrapper Wrapper managing this servlet instance
 * @param servlet Servlet instance for which this event occurred
 * @param type Event type (required)
 * @param exception Exception that occurred
 */
public InstanceEvent(Wrapper wrapper, Servlet servlet, String type,
                     Throwable exception) {

  super(wrapper);
  this.wrapper = wrapper;
  this.filter = null;
  this.servlet = servlet;
  this.type = type;
  this.exception = exception;

}
项目:lams    文件:ServletInfo.java   
public ServletInfo(final String name, final Class<? extends Servlet> servletClass) {
    if (name == null) {
        throw UndertowServletMessages.MESSAGES.paramCannotBeNull("name");
    }
    if (servletClass == null) {
        throw UndertowServletMessages.MESSAGES.paramCannotBeNull("servletClass", "Servlet", name);
    }
    if (!Servlet.class.isAssignableFrom(servletClass)) {
        throw UndertowServletMessages.MESSAGES.servletMustImplementServlet(name, servletClass);
    }
    try {
        final Constructor<? extends Servlet> ctor = servletClass.getDeclaredConstructor();
        ctor.setAccessible(true);
        this.instanceFactory = new ConstructorInstanceFactory(ctor);
        this.name = name;
        this.servletClass = servletClass;
    } catch (NoSuchMethodException e) {
        throw UndertowServletMessages.MESSAGES.componentMustHaveDefaultConstructor("Servlet", servletClass);
    }
}
项目:yacy_grid_mcp    文件:APIServer.java   
public static void addService(Class<? extends Servlet> service) {
    try {
        APIHandler handler = (APIHandler) service.newInstance();
        services.add(service);
        serviceMap.put(handler.getAPIName(), handler);
    } catch (InstantiationException | IllegalAccessException e) {
        Data.logger.warn("", e);
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:ApplicationContextFacade.java   
@Override
public ServletRegistration.Dynamic addServlet(String servletName,
        Class<? extends Servlet> servletClass) {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        return (ServletRegistration.Dynamic) doPrivileged("addServlet",
                new Class[]{String.class, Class.class},
                new Object[]{servletName, servletClass});
    } else {
        return context.addServlet(servletName, servletClass);
    }
}
项目:high    文件:Application.java   
@Bean
Servlet thrift(ThriftCodecManager thriftCodecManager, TProtocolFactory protocolFactory, TCalculatorService calculatorService) {
    ThriftServiceProcessor processor = new ThriftServiceProcessor(thriftCodecManager, Arrays.<ThriftEventHandler>asList(), calculatorService);

    return new TServlet(
            NiftyProcessorAdapters.processorToTProcessor(processor),
            protocolFactory,
            protocolFactory
    );
}
项目:apache-tomcat-7.0.73-with-comment    文件:InstanceEvent.java   
/**
 * Construct a new InstanceEvent with the specified parameters.  This
 * constructor is used for processing servlet processing events.
 *
 * @param wrapper Wrapper managing this servlet instance
 * @param servlet Servlet instance for which this event occurred
 * @param type Event type (required)
 * @param request Servlet request we are processing
 * @param response Servlet response we are processing
 * @param exception Exception that occurred
 */
public InstanceEvent(Wrapper wrapper, Servlet servlet, String type,
                     ServletRequest request, ServletResponse response,
                     Throwable exception) {

  super(wrapper);
  this.filter = null;
  this.servlet = servlet;
  this.type = type;
  this.request = request;
  this.response = response;
  this.exception = exception;

}
项目:apache-tomcat-7.0.73-with-comment    文件:JspFactoryImpl.java   
private PageContext internalGetPageContext(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL, boolean needsSession,
        int bufferSize, boolean autoflush) {
    try {
        PageContext pc;
        if (USE_POOL) {
            PageContextPool pool = localPool.get();
            if (pool == null) {
                pool = new PageContextPool();
                localPool.set(pool);
            }
            pc = pool.get();
            if (pc == null) {
                pc = new PageContextImpl();
            }
        } else {
            pc = new PageContextImpl();
        }
        pc.initialize(servlet, request, response, errorPageURL, 
                needsSession, bufferSize, autoflush);
        return pc;
    } catch (Throwable ex) {
        ExceptionUtils.handleThrowable(ex);
        if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        }
        log.fatal("Exception initializing page context", ex);
        return null;
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:SecurityUtil.java   
/**
 * Perform work as a particular </code>Subject</code>. Here the work
 * will be granted to a <code>null</code> subject.
 *
 * @param methodName the method to apply the security restriction
 * @param targetObject the <code>Servlet</code> on which the method will
 * be called.
 * @param targetParameterTypes <code>Class</code> array used to instantiate a
 * <code>Method</code> object.
 * @param targetArguments <code>Object</code> array contains the
 * runtime parameters instance.
 * @param principal the <code>Principal</code> to which the security
 * privilege apply..
 */
public static void doAsPrivilege(final String methodName,
                                 final Servlet targetObject,
                                 final Class<?>[] targetParameterTypes,
                                 final Object[] targetArguments,
                                 Principal principal)
    throws java.lang.Exception{

    // CometProcessor instances must not be cached as Servlet or
    // NoSuchMethodException will be thrown.
    Class<? extends Servlet> targetType =
            targetObject instanceof CometProcessor ? CometProcessor.class : Servlet.class;

    Method method = null;
    Method[] methodsCache = classCache.get(Servlet.class);
    if(methodsCache == null) {
        method = createMethodAndCacheIt(methodsCache,
                                        targetType,
                                        methodName,
                                        targetParameterTypes);
    } else {
        method = findMethod(methodsCache, methodName);
        if (method == null) {
            method = createMethodAndCacheIt(methodsCache,
                                            targetType,
                                            methodName,
                                            targetParameterTypes);
        }
    }

    execute(method, targetObject, targetArguments, principal);
}
项目:apache-tomcat-7.0.73-with-comment    文件:Tomcat.java   
@SuppressWarnings("deprecation")
public ExistingStandardWrapper( Servlet existing ) {
    this.existing = existing;
    if (existing instanceof javax.servlet.SingleThreadModel) {
        singleThreadModel = true;
        instancePool = new Stack<Servlet>();
    }
}
项目:tomcat7    文件:InstanceEvent.java   
/**
 * Construct a new InstanceEvent with the specified parameters.  This
 * constructor is used for processing servlet processing events.
 *
 * @param wrapper Wrapper managing this servlet instance
 * @param servlet Servlet instance for which this event occurred
 * @param type Event type (required)
 * @param request Servlet request we are processing
 * @param response Servlet response we are processing
 */
public InstanceEvent(Wrapper wrapper, Servlet servlet, String type,
                     ServletRequest request, ServletResponse response) {

  super(wrapper);
  this.filter = null;
  this.servlet = servlet;
  this.type = type;
  this.request = request;
  this.response = response;

}
项目:marathon-auth-plugin    文件:ServletContextHandler.java   
/**
 * @since servlet-api-3.0
 */
@Override
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
{
    if (!isStarting())
        throw new IllegalStateException();

    if (servletName == null || "".equals(servletName.trim()))
        throw new IllegalStateException("Missing servlet name");

    if (!_enabled)
        throw new UnsupportedOperationException();

    final ServletHandler handler = ServletContextHandler.this.getServletHandler();
    ServletHolder holder = handler.getServlet(servletName);
    if (holder == null)
    {
        holder = handler.newServletHolder(Source.JAVAX_API);
        holder.setName(servletName);
        holder.setServlet(servlet);
        handler.addServlet(holder);
        return dynamicHolderAdded(holder);
    }

    //complete a partial registration
    if (holder.getClassName()==null && holder.getHeldClass()==null)
    {
        holder.setServlet(servlet);
        return holder.getRegistration();
    }
    else
        return null; //existing completed registration for servlet name
}
项目:lams    文件:DefaultInstanceManager.java   
private void checkAccess(Class<?> clazz) {
    if (privileged) return;
    if (Filter.class.isAssignableFrom(clazz)) {
        checkAccess(clazz, restrictedFilters);
    } else if (Servlet.class.isAssignableFrom(clazz)) {
        checkAccess(clazz, restrictedServlets);
    } else {
        checkAccess(clazz, restrictedListeners);
    }
}
项目:tomcat7    文件:InstanceSupport.java   
/**
 * Notify all lifecycle event listeners that a particular event has
 * occurred for this Container.  The default implementation performs
 * this notification synchronously using the calling thread.
 *
 * @param type Event type
 * @param servlet The relevant Servlet for this event
 * @param exception Exception that occurred
 */
public void fireInstanceEvent(String type, Servlet servlet,
                              Throwable exception) {

    if (listeners.length == 0)
        return;

    InstanceEvent event = new InstanceEvent(wrapper, servlet, type,
                                            exception);
    InstanceListener interested[] = listeners;
    for (int i = 0; i < interested.length; i++)
        interested[i].instanceEvent(event);

}
项目:tomcat7    文件:InstanceSupport.java   
/**
 * Notify all lifecycle event listeners that a particular event has
 * occurred for this Container.  The default implementation performs
 * this notification synchronously using the calling thread.
 *
 * @param type Event type
 * @param servlet The relevant Servlet for this event
 * @param request The servlet request we are processing
 * @param response The servlet response we are processing
 */
public void fireInstanceEvent(String type, Servlet servlet,
                              ServletRequest request,
                              ServletResponse response) {

    if (listeners.length == 0)
        return;

    InstanceEvent event = new InstanceEvent(wrapper, servlet, type,
                                            request, response);
    InstanceListener interested[] = listeners;
    for (int i = 0; i < interested.length; i++)
        interested[i].instanceEvent(event);

}
项目:lazycat    文件:JspFactoryImpl.java   
private PageContext internalGetPageContext(Servlet servlet, ServletRequest request, ServletResponse response,
        String errorPageURL, boolean needsSession, int bufferSize, boolean autoflush) {
    try {
        PageContext pc;
        if (USE_POOL) {
            PageContextPool pool = localPool.get();
            if (pool == null) {
                pool = new PageContextPool();
                localPool.set(pool);
            }
            pc = pool.get();
            if (pc == null) {
                pc = new PageContextImpl();
            }
        } else {
            pc = new PageContextImpl();
        }
        pc.initialize(servlet, request, response, errorPageURL, needsSession, bufferSize, autoflush);
        return pc;
    } catch (Throwable ex) {
        ExceptionUtils.handleThrowable(ex);
        if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        }
        log.fatal("Exception initializing page context", ex);
        return null;
    }
}
项目:tomcat7    文件:ApplicationContextFacade.java   
/**
 * @deprecated As of Java Servlet API 2.1, with no direct replacement.
 */
@Override
@SuppressWarnings("unchecked") // doPrivileged() returns the correct type
@Deprecated
public Enumeration<Servlet> getServlets() {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        return (Enumeration<Servlet>) doPrivileged("getServlets", null);
    } else {
        return context.getServlets();
    }
}
项目:tomcat7    文件:ApplicationContextFacade.java   
@Override
public ServletRegistration.Dynamic addServlet(String servletName,
        Class<? extends Servlet> servletClass) {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        return (ServletRegistration.Dynamic) doPrivileged("addServlet",
                new Class[]{String.class, Class.class},
                new Object[]{servletName, servletClass});
    } else {
        return context.addServlet(servletName, servletClass);
    }
}
项目:uavstack    文件:TomcatPlusIT.java   
/**
 * onServletStart
 * 
 * @param args
 */
public void onServletStart(Object... args) {

    StandardWrapper sw = (StandardWrapper) args[0];
    Servlet servlet = (Servlet) args[1];

    InterceptSupport iSupport = InterceptSupport.instance();
    InterceptContext context = iSupport.createInterceptContext(Event.AFTER_SERVET_INIT);
    context.put(InterceptConstants.SERVLET_INSTANCE, servlet);
    context.put(InterceptConstants.WEBAPPLOADER, Thread.currentThread().getContextClassLoader());

    context.put(InterceptConstants.CONTEXTPATH, sw.getServletContext().getContextPath());

    iSupport.doIntercept(context);
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestAsyncContextImpl.java   
@Test
public void testAsyncContextListenerClearing() throws Exception {
    resetTracker();

    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    Servlet stage1 = new DispatchingServletTracking("/stage2", true);
    Wrapper wrapper1 = Tomcat.addServlet(ctx, "stage1", stage1);
    wrapper1.setAsyncSupported(true);
    ctx.addServletMapping("/stage1", "stage1");

    Servlet stage2 = new DispatchingServletTracking("/stage3", false);
    Wrapper wrapper2 = Tomcat.addServlet(ctx, "stage2", stage2);
    wrapper2.setAsyncSupported(true);
    ctx.addServletMapping("/stage2", "stage2");

    Servlet stage3 = new NonAsyncServlet();
    Tomcat.addServlet(ctx, "stage3", stage3);
    ctx.addServletMapping("/stage3", "stage3");

    TesterAccessLogValve alv = new TesterAccessLogValve();
    ctx.getPipeline().addValve(alv);

    tomcat.start();

    getUrl("http://localhost:" + getPort()+ "/stage1");

    assertEquals("doGet-startAsync-doGet-startAsync-onStartAsync-NonAsyncServletGet-onComplete-", getTrack());

    // Check the access log
    alv.validateAccessLog(1, 200, 0, REQUEST_TIME);
}
项目:lazycat    文件:ApplicationContext.java   
/**
 * @deprecated As of Java Servlet API 2.1, with no direct replacement.
 */
@Override
@Deprecated
public Servlet getServlet(String name) {

    return (null);

}
项目:tomcat7    文件:StandardContext.java   
/**
 * hook to register that we need to scan for security annotations.
 * @param wrapper   The wrapper for the Servlet that was added
 */
public ServletRegistration.Dynamic dynamicServletAdded(Wrapper wrapper) {
    Servlet s = wrapper.getServlet();
    if (s != null && createdServlets.contains(s)) {
        // Mark the wrapper to indicate annotations need to be scanned
        wrapper.setServletSecurityAnnotationScanRequired(true);
    }
    return new ApplicationServletRegistration(wrapper, this);
}
项目:lazycat    文件:ApplicationContextFacade.java   
@Override
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet) {
    if (SecurityUtil.isPackageProtectionEnabled()) {
        return (ServletRegistration.Dynamic) doPrivileged("addServlet", new Class[] { String.class, Servlet.class },
                new Object[] { servletName, servlet });
    } else {
        return context.addServlet(servletName, servlet);
    }
}
项目:jerrydog    文件:InstanceEvent.java   
/**
 * Construct a new InstanceEvent with the specified parameters.  This
 * constructor is used for processing servlet lifecycle events.
 *
 * @param wrapper Wrapper managing this servlet instance
 * @param servlet Servlet instance for which this event occurred
 * @param type Event type (required)
 */
public InstanceEvent(Wrapper wrapper, Servlet servlet, String type) {

  super(wrapper);
  this.wrapper = wrapper;
  this.filter = null;
  this.servlet = servlet;
  this.type = type;

}
项目:tomcat7    文件:StandardWrapper.java   
/**
 * Gets the names of the methods supported by the underlying servlet.
 *
 * This is the same set of methods included in the Allow response header
 * in response to an OPTIONS request method processed by the underlying
 * servlet.
 *
 * @return Array of names of the methods supported by the underlying
 * servlet
 */
@Override
public String[] getServletMethods() throws ServletException {

    instance = loadServlet();

    Class<? extends Servlet> servletClazz = instance.getClass();
    if (!javax.servlet.http.HttpServlet.class.isAssignableFrom(
                                                    servletClazz)) {
        return DEFAULT_SERVLET_METHODS;
    }

    HashSet<String> allow = new HashSet<String>();
    allow.add("TRACE");
    allow.add("OPTIONS");

    Method[] methods = getAllDeclaredMethods(servletClazz);
    for (int i=0; methods != null && i<methods.length; i++) {
        Method m = methods[i];

        if (m.getName().equals("doGet")) {
            allow.add("GET");
            allow.add("HEAD");
        } else if (m.getName().equals("doPost")) {
            allow.add("POST");
        } else if (m.getName().equals("doPut")) {
            allow.add("PUT");
        } else if (m.getName().equals("doDelete")) {
            allow.add("DELETE");
        }
    }

    String[] methodNames = new String[allow.size()];
    return allow.toArray(methodNames);

}
项目:lams    文件:InstanceEvent.java   
/**
 * Construct a new InstanceEvent with the specified parameters.  This
 * constructor is used for processing servlet processing events.
 *
 * @param wrapper Wrapper managing this servlet instance
 * @param servlet Servlet instance for which this event occurred
 * @param type Event type (required)
 * @param request Servlet request we are processing
 * @param response Servlet response we are processing
 * @param exception Exception that occurred
 */
public InstanceEvent(Wrapper wrapper, Servlet servlet, String type,
                     ServletRequest request, ServletResponse response,
                     Throwable exception) {

  super(wrapper);
  this.wrapper = wrapper;
  this.filter = null;
  this.servlet = servlet;
  this.type = type;
  this.request = request;
  this.response = response;
  this.exception = exception;

}
项目:tomcat7    文件:JspCServletContext.java   
/**
 * Return a null reference for the specified servlet name.
 *
 * @param name Name of the requested servlet
 *
 * @deprecated This method has been deprecated with no replacement
 */
@Override
@Deprecated
public Servlet getServlet(String name) throws ServletException {

    return (null);

}
项目:apache-tomcat-7.0.73-with-comment    文件:SecurityUtil.java   
/**
 * Perform work as a particular </code>Subject</code>. Here the work
 * will be granted to a <code>null</code> subject.
 *
 * @param methodName the method to apply the security restriction
 * @param targetObject the <code>Servlet</code> on which the method will
 * be called.
 * @param targetType <code>Class</code> array used to instantiate a
 * <code>Method</code> object.
 * @param targetArguments <code>Object</code> array contains the runtime
 * parameters instance.
 */
public static void doAsPrivilege(final String methodName,
                                 final Servlet targetObject,
                                 final Class<?>[] targetType,
                                 final Object[] targetArguments)
    throws java.lang.Exception{

     doAsPrivilege(methodName,
                   targetObject,
                   targetType,
                   targetArguments,
                   null);
}
项目:apache-tomcat-7.0.73-with-comment    文件:InstanceEvent.java   
/**
 * Construct a new InstanceEvent with the specified parameters.  This
 * constructor is used for processing servlet lifecycle events.
 *
 * @param wrapper Wrapper managing this servlet instance
 * @param servlet Servlet instance for which this event occurred
 * @param type Event type (required)
 */
public InstanceEvent(Wrapper wrapper, Servlet servlet, String type) {

  super(wrapper);
  this.filter = null;
  this.servlet = servlet;
  this.type = type;

}
项目:lams    文件:JspFactoryImpl.java   
public PageContext getPageContext(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL, boolean needsSession,
        int bufferSize, boolean autoflush) {

    if( Constants.IS_SECURITY_ENABLED ) {
        PrivilegedGetPageContext dp = new PrivilegedGetPageContext(
                (JspFactoryImpl)this, servlet, request, response, errorPageURL,
                needsSession, bufferSize, autoflush);
        return (PageContext)AccessController.doPrivileged(dp);
    } else {
        return internalGetPageContext(servlet, request, response,
                errorPageURL, needsSession,
                bufferSize, autoflush);
    }
}
项目:tomcat7    文件:JspFactoryImpl.java   
private PageContext internalGetPageContext(Servlet servlet, ServletRequest request,
        ServletResponse response, String errorPageURL, boolean needsSession,
        int bufferSize, boolean autoflush) {
    try {
        PageContext pc;
        if (USE_POOL) {
            PageContextPool pool = localPool.get();
            if (pool == null) {
                pool = new PageContextPool();
                localPool.set(pool);
            }
            pc = pool.get();
            if (pc == null) {
                pc = new PageContextImpl();
            }
        } else {
            pc = new PageContextImpl();
        }
        pc.initialize(servlet, request, response, errorPageURL, 
                needsSession, bufferSize, autoflush);
        return pc;
    } catch (Throwable ex) {
        ExceptionUtils.handleThrowable(ex);
        if (ex instanceof RuntimeException) {
            throw (RuntimeException) ex;
        }
        log.fatal("Exception initializing page context", ex);
        return null;
    }
}
项目:tomcat7    文件:JspFactoryImpl.java   
PrivilegedGetPageContext(JspFactoryImpl factory, Servlet servlet,
        ServletRequest request, ServletResponse response, String errorPageURL,
        boolean needsSession, int bufferSize, boolean autoflush) {
    this.factory = factory;
    this.servlet = servlet;
    this.request = request;
    this.response = response;
    this.errorPageURL = errorPageURL;
    this.needsSession = needsSession;
    this.bufferSize = bufferSize;
    this.autoflush = autoflush;
}
项目:lemon    文件:ServletFilter.java   
public void setServletMap(Map<String, Servlet> urlPatternMap) {
    servletMap = new LinkedHashMap<UrlPatternMatcher, Servlet>();

    for (Map.Entry<String, Servlet> entry : urlPatternMap.entrySet()) {
        UrlPatternMatcher urlPatternMatcher = UrlPatternMatcher
                .create(entry.getKey());
        servletMap.put(urlPatternMatcher, entry.getValue());
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:StandardContext.java   
/**
 * hook to register that we need to scan for security annotations.
 * @param wrapper   The wrapper for the Servlet that was added
 */
public ServletRegistration.Dynamic dynamicServletAdded(Wrapper wrapper) {
    Servlet s = wrapper.getServlet();
    if (s != null && createdServlets.contains(s)) {
        // Mark the wrapper to indicate annotations need to be scanned
        wrapper.setServletSecurityAnnotationScanRequired(true);
    }
    return new ApplicationServletRegistration(wrapper, this);
}