Spring Framework WebAsyncManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework WebAsyncManager class.

This code example shows how to use the following methods:getCallableInterceptor, hasConcurrentResult, registerCallableInterceptor, registerDeferredResultInterceptor
public class OpenEntityManagerInViewInterceptor extends EntityManagerFactoryAccessor implements AsyncWebRequestInterceptor { 
 
	/** 
	 * Suffix that gets appended to the EntityManagerFactory toString 
	 * representation for the "participate in existing entity manager 
	 * handling" request attribute. 
	 * @see #getParticipateAttributeName 
	 */ 
	public static final String PARTICIPATE_SUFFIX = ".PARTICIPATE"; 
 
 
	@Override 
	public void preHandle(WebRequest request) throws DataAccessException { 
 
		String participateAttributeName = getParticipateAttributeName(); 
 
		WebAsyncManager asyncManager = WebAsyncUtils.getAsyncManager(request); 
		if (asyncManager.hasConcurrentResult()) { 
			if (applyCallableInterceptor(asyncManager, participateAttributeName)) { 
				return; 

8
CodeRank
This code example shows how to use the following methods:getCallableInterceptor, hasConcurrentResult, registerCallableInterceptor, registerDeferredResultInterceptor
 * occur at the very beginning of request processing, to avoid clashes with already 
 * loaded instances of the same objects. 
 * 
 * @author Juergen Hoeller 
 * @since 3.1 
 * @see OpenSessionInViewFilter 
 * @see OpenSessionInterceptor 
 * @see org.springframework.orm.hibernate4.HibernateTransactionManager 
 * @see org.springframework.transaction.support.TransactionSynchronizationManager 
 * @see org.hibernate.SessionFactory#getCurrentSession() 
 */ 
public class OpenSessionInViewInterceptor implements AsyncWebRequestInterceptor { 
 
	/** 
	 * Suffix that gets appended to the {@code SessionFactory} 
	 * {@code toString()} representation for the "participate in existing 
	 * session handling" request attribute. 
	 * @see #getParticipateAttributeName 
	 */ 
	public static final String PARTICIPATE_SUFFIX = ".PARTICIPATE"; 

7
CodeRank
This code example shows how to use the following methods:hasConcurrentResult
	 * filter is currently executing within an asynchronous dispatch. 
	 * @param request the current request 
	 * @see WebAsyncManager#hasConcurrentResult() 
	 */ 
	protected boolean isAsyncDispatch(HttpServletRequest request) { 
		return WebAsyncUtils.getAsyncManager(request).hasConcurrentResult(); 
	} 
 
	/** 
	 * Whether request processing is in asynchronous mode meaning that the 
	 * response will not be committed after the current thread is exited. 
	 * @param request the current request 
	 * @see WebAsyncManager#isConcurrentHandlingStarted() 
	 */ 
	protected boolean isAsyncStarted(HttpServletRequest request) { 
		return WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted(); 
	} 
 
	/** 
	 * Return the name of the request attribute that identifies that a request 
7
CodeRank
This code example shows how to use the following methods:getCallableInterceptor, hasConcurrentResult, registerCallableInterceptor, registerDeferredResultInterceptor
 * 
 * <p>In contrast to {@link OpenSessionInViewFilter}, this interceptor is 
 * configured in a Spring application context and can thus take advantage of bean 
 * wiring. It inherits common Hibernate configuration properties from 
 * {@link org.springframework.orm.hibernate3.HibernateAccessor}, 
 * to be configured in a bean definition. 
 * 
 * <p><b>WARNING:</b> Applying this interceptor to existing logic can cause issues 
 * that have not appeared before, through the use of a single Hibernate 
 * {@code Session} for the processing of an entire request. In particular, the 
 * reassociation of persistent objects with a Hibernate {@code Session} has to 
 * occur at the very beginning of request processing, to avoid clashes with already 
 * loaded instances of the same objects. 
 * 
 * <p>Alternatively, turn this interceptor into deferred close mode, by specifying 
 * "singleSession"="false": It will not use a single session per request then, 
 * but rather let each data access operation or transaction use its own session 
 * (as would be the case without Open Session in View). Each of those sessions will 
 * be registered for deferred close though, which will actually be processed at 
 * request completion. 

7
CodeRank
See Code Examples for Spring Framework WebAsyncManager Methods: