/**
  * Executes the given task, within a concurrency throttle if configured (through the superclass's
  * settings).
  *
  * <p>Executes urgent tasks (with 'immediate' timeout) directly, bypassing the concurrency
  * throttle (if active). All other tasks are subject to throttling.
  *
  * @see #TIMEOUT_IMMEDIATE
  * @see #doExecute(Runnable)
  */
 @Override
 public void execute(Runnable task, long startTimeout) {
   Assert.notNull(task, "Runnable must not be null");
   if (isThrottleActive() && startTimeout > TIMEOUT_IMMEDIATE) {
     this.concurrencyThrottle.beforeAccess();
     doExecute(new ConcurrencyThrottlingRunnable(task));
   } else {
     doExecute(task);
   }
 }
Пример #2
0
	public MultipartHttpServletRequest resolveMultipart(final HttpServletRequest request) throws MultipartException {
		Assert.notNull(request, "Request must not be null");
		if (this.resolveLazily) {
			return new DefaultMultipartHttpServletRequest(request) {
				protected void initializeMultipart() {
					MultipartParsingResult parsingResult = parseRequest(request);
					setMultipartFiles(parsingResult.getMultipartFiles());
					setMultipartParameters(parsingResult.getMultipartParameters());
				}
			};
		}
		else {
			MultipartParsingResult parsingResult = parseRequest(request);
			return new DefaultMultipartHttpServletRequest(
					request, parsingResult.getMultipartFiles(), parsingResult.getMultipartParameters());
		}
	}
Пример #3
0
 /**
  * Find a custom WebApplicationContext for this web application.
  *
  * @param sc ServletContext to find the web application context for
  * @param attrName the name of the ServletContext attribute to look for
  * @return the desired WebApplicationContext for this web app, or <code>null</code> if none
  */
 public static WebApplicationContext getWebApplicationContext(ServletContext sc, String attrName) {
   Assert.notNull(sc, "ServletContext must not be null");
   Object attr = sc.getAttribute(attrName);
   if (attr == null) {
     return DispatchServlet.webApplicationContext;
   }
   if (attr instanceof RuntimeException) {
     throw (RuntimeException) attr;
   }
   if (attr instanceof Error) {
     throw (Error) attr;
   }
   if (attr instanceof Exception) {
     IllegalStateException ex = new IllegalStateException();
     ex.initCause((Exception) attr);
     throw ex;
   }
   if (!(attr instanceof WebApplicationContext)) {
     throw new IllegalStateException(
         "Context attribute is not of type WebApplicationContext: " + attr);
   }
   return (WebApplicationContext) attr;
 }
	/**
	 * Set the {@link JRExporter} implementation <code>Class</code> to use. Throws
	 * {@link IllegalArgumentException} if the <code>Class</code> doesn't implement
	 * {@link JRExporter}. Required setting, as it does not have a default.
	 */
	public void setExporterClass(Class<? extends JRExporter> exporterClass) {
		Assert.isAssignable(JRExporter.class, exporterClass);
		this.exporterClass = exporterClass;
	}