List of usage examples for org.springframework.scheduling.concurrent ThreadPoolTaskExecutor setKeepAliveSeconds
public void setKeepAliveSeconds(int keepAliveSeconds)
From source file:com.sinosoft.one.mvc.web.portal.impl.PortalBeanPostProcessor.java
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (applicationContext instanceof WebApplicationContext) { WebApplicationContext webApplicationContext = (WebApplicationContext) applicationContext; if (ThreadPoolTaskExecutor.class == bean.getClass()) { ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) bean; String paramCorePoolSize = webApplicationContext.getServletContext() .getInitParameter(PORTAL_EXECUTOR_CORE_POOL_SIZE); if (StringUtils.isNotBlank(paramCorePoolSize)) { if (logger.isInfoEnabled()) { logger.info("found param " + PORTAL_EXECUTOR_CORE_POOL_SIZE + "=" + paramCorePoolSize); }/*from w w w. java 2 s . c o m*/ executor.setCorePoolSize(Integer.parseInt(paramCorePoolSize)); } else { throw new IllegalArgumentException( "please add '<context-param><param-name>portalExecutorCorePoolSize</param-name><param-value>a number here</param-value></context-param>' in your web.xml"); } String paramMaxPoolSize = webApplicationContext.getServletContext() .getInitParameter(PORTAL_EXECUTOR_MAX_POOL_SIZE); if (StringUtils.isNotBlank(paramMaxPoolSize)) { if (logger.isInfoEnabled()) { logger.info("found param " + PORTAL_EXECUTOR_MAX_POOL_SIZE + "=" + paramMaxPoolSize); } executor.setMaxPoolSize(Integer.parseInt(paramMaxPoolSize)); } String paramKeepAliveSeconds = webApplicationContext.getServletContext() .getInitParameter(PORTAL_EXECUTOR_KEEP_ALIVE_SECONDS); if (StringUtils.isNotBlank(paramKeepAliveSeconds)) { if (logger.isInfoEnabled()) { logger.info( "found param " + PORTAL_EXECUTOR_KEEP_ALIVE_SECONDS + "=" + paramKeepAliveSeconds); } executor.setKeepAliveSeconds(Integer.parseInt(paramKeepAliveSeconds)); } } else if (List.class.isInstance(bean) && "portalListenerList".equals(beanName)) { String paramListeners = webApplicationContext.getServletContext() .getInitParameter(PORTAL_LISTENERS); @SuppressWarnings("unchecked") List<WindowListener> list = (List<WindowListener>) bean; if (StringUtils.isNotBlank(paramListeners)) { String[] splits = paramListeners.split(",| "); if (logger.isInfoEnabled()) { logger.info("found portalListener config: " + Arrays.toString(splits)); } for (String className : splits) { className = className.trim(); if (className.length() > 0) { try { Class<?> clazz = Class.forName(className); WindowListener l = (WindowListener) BeanUtils.instantiateClass(clazz); list.add(l); if (logger.isInfoEnabled()) { logger.info("add portalListener: " + l); } } catch (Exception e) { logger.error("", e); } } } } } } return bean; }
From source file:com.laxser.blitz.web.portal.impl.PortalBeanPostProcessor.java
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (applicationContext instanceof WebApplicationContext) { WebApplicationContext webApplicationContext = (WebApplicationContext) applicationContext; if (ThreadPoolTaskExecutor.class == bean.getClass()) { ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) bean; String paramCorePoolSize = webApplicationContext.getServletContext() .getInitParameter(PORTAL_EXECUTOR_CORE_POOL_SIZE); if (StringUtils.isNotBlank(paramCorePoolSize)) { if (logger.isInfoEnabled()) { logger.info("found param " + PORTAL_EXECUTOR_CORE_POOL_SIZE + "=" + paramCorePoolSize); }/*from w w w . ja v a 2 s. c om*/ executor.setCorePoolSize(Integer.parseInt(paramCorePoolSize)); } else { throw new IllegalArgumentException( "please add '<context-param><param-name>portalExecutorCorePoolSize</param-name><param-value>a number here</param-value></context-param>' in your web.xml"); } String paramMaxPoolSize = webApplicationContext.getServletContext() .getInitParameter(PORTAL_EXECUTOR_MAX_POOL_SIZE); if (StringUtils.isNotBlank(paramMaxPoolSize)) { if (logger.isInfoEnabled()) { logger.info("found param " + PORTAL_EXECUTOR_MAX_POOL_SIZE + "=" + paramMaxPoolSize); } executor.setMaxPoolSize(Integer.parseInt(paramMaxPoolSize)); } String paramKeepAliveSeconds = webApplicationContext.getServletContext() .getInitParameter(PORTAL_EXECUTOR_KEEP_ALIVE_SECONDS); if (StringUtils.isNotBlank(paramKeepAliveSeconds)) { if (logger.isInfoEnabled()) { logger.info( "found param " + PORTAL_EXECUTOR_KEEP_ALIVE_SECONDS + "=" + paramKeepAliveSeconds); } executor.setKeepAliveSeconds(Integer.parseInt(paramKeepAliveSeconds)); } } else if (List.class.isInstance(bean) && "portalListenerList".equals(beanName)) { String paramListeners = webApplicationContext.getServletContext() .getInitParameter(PORTAL_LISTENERS); @SuppressWarnings("unchecked") List<WindowListener> list = (List<WindowListener>) bean; if (StringUtils.isNotBlank(paramListeners)) { String[] splits = paramListeners.split(",| "); if (logger.isInfoEnabled()) { logger.info("found portalListener config: " + Arrays.toString(splits)); } for (String className : splits) { className = className.trim(); if (className.length() > 0) { try { Class<?> clazz = Class.forName(className); WindowListener l = (WindowListener) BeanUtils.instantiateClass(clazz); list.add(l); if (logger.isInfoEnabled()) { logger.info("add portalListener: " + l); } } catch (Exception e) { logger.error("", e); } } } } } } return bean; }
From source file:org.finra.dm.service.config.ServiceSpringModuleConfig.java
/** * Returns an Async "task" executor which is also a normal "executor". This is being wired into Activity via the job executor bean. It is also being used by * the "@EnableAsync" annotation and the fact that this class implements AsyncConfigurer. That way, all methods annotated with "@Async" will be executed * asynchronously by this executor. Thus, we have a shared thread pool that handles both Async method calls as well as Activiti asynchronous job executions * (e.g. timers, messages, etc.).//from w w w . j a v a 2 s. c om * * @return the async task executor. */ @Override @Bean // This will call the "initialize" method of the ThreadPoolTaskExecutor automatically. public TaskExecutor getAsyncExecutor() { // Create a Spring thread pool "task" executor that is backed by a JDK Thread Pool Executor. // Use the environment to make the key thread pool parameters configurable although changing them would require a server restart. ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize( configurationHelper.getProperty(ConfigurationValue.THREAD_POOL_CORE_POOL_SIZE, Integer.class)); executor.setMaxPoolSize( configurationHelper.getProperty(ConfigurationValue.THREAD_POOL_MAX_POOL_SIZE, Integer.class)); executor.setKeepAliveSeconds( configurationHelper.getProperty(ConfigurationValue.THREAD_POOL_KEEP_ALIVE_SECS, Integer.class)); return executor; }
From source file:org.finra.herd.service.config.ServiceSpringModuleConfig.java
/** * Activiti's dedicated TaskExecutor bean definition. * * @return TaskExecutor//from w ww. j ava 2 s. co m */ @Bean public TaskExecutor activitiTaskExecutor() { ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); taskExecutor.setCorePoolSize(configurationHelper .getProperty(ConfigurationValue.ACTIVITI_THREAD_POOL_CORE_POOL_SIZE, Integer.class)); taskExecutor.setMaxPoolSize(configurationHelper .getProperty(ConfigurationValue.ACTIVITI_THREAD_POOL_MAX_POOL_SIZE, Integer.class)); taskExecutor.setKeepAliveSeconds(configurationHelper .getProperty(ConfigurationValue.ACTIVITI_THREAD_POOL_KEEP_ALIVE_SECS, Integer.class)); taskExecutor.setQueueCapacity(configurationHelper .getProperty(ConfigurationValue.ACTIVITI_THREAD_POOL_QUEUE_CAPACITY, Integer.class)); return taskExecutor; }