@Test public void testInitService_FixedThreadPool_TypeAttributeIsMissing() throws Exception { qbeanConfigPw.println("<QThreadPoolExecutor />"); qbeanConfigPw.flush(); setQBeanConfig(qbeanConfigBos.toByteArray()); try { qbean.initService(); fail("ConfigurationException was expected"); } catch (ConfigurationException e) { assertThat(e.getMessage().contains( QThreadPoolExecutor.XML_CONFIG_ATTR__EXEC_SRV_TYPE)); } }
@Override protected void initService() throws Exception { Element rootElt = this.getPersist(); Attribute execSrvTypeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TYPE, true, "(thread pool executor type among {fixed|cached|scheduled|single})"); execSrvType = execSrvTypeAttr.getValue().trim(); if ("fixed".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else if ("cached".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, false, "(number of threads in the pool)"); if (null != corePoolSizeAttr) { initialCorePoolSize = corePoolSizeAttr.getIntValue(); } } else if ("scheduled".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else { throw new ConfigurationException( "Invalid thread pool executor type '%s' (valid types={fixed|cached|scheduled} )"); } Attribute terminationTimerAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER, false, "(termination timer in seconds)"); if (null != terminationTimerAttr) { terminationTimer = terminationTimerAttr.getIntValue(); } }
QThreadPoolExecutor extends QBeanSupport implements
        QThreadPoolExecutorMBean { @Override protected void initService() throws Exception { Element rootElt = this.getPersist(); Attribute execSrvTypeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TYPE, true, "(thread pool executor type among {fixed|cached|scheduled|single})"); execSrvType = execSrvTypeAttr.getValue().trim(); if ("fixed".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else if ("cached".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, false, "(number of threads in the pool)"); if (null != corePoolSizeAttr) { initialCorePoolSize = corePoolSizeAttr.getIntValue(); } } else if ("scheduled".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else { throw new ConfigurationException( "Invalid thread pool executor type '%s' (valid types={fixed|cached|scheduled} )"); } Attribute terminationTimerAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER, false, "(termination timer in seconds)"); if (null != terminationTimerAttr) { terminationTimer = terminationTimerAttr.getIntValue(); } } }
QThreadPoolExecutor extends QBeanSupport implements
        QThreadPoolExecutorMBean { @Override protected void initService() throws Exception { Element rootElt = this.getPersist(); Attribute execSrvTypeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TYPE, true, "(thread pool executor type among {fixed|cached|scheduled|single})"); execSrvType = execSrvTypeAttr.getValue().trim(); if ("fixed".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else if ("cached".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, false, "(number of threads in the pool)"); if (null != corePoolSizeAttr) { initialCorePoolSize = corePoolSizeAttr.getIntValue(); } } else if ("scheduled".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else { throw new ConfigurationException( "Invalid thread pool executor type '%s' (valid types={fixed|cached|scheduled} )"); } Attribute terminationTimerAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER, false, "(termination timer in seconds)"); if (null != terminationTimerAttr) { terminationTimer = terminationTimerAttr.getIntValue(); } }  }
QThreadPoolExecutor extends QBeanSupport implements
        QThreadPoolExecutorMBean { @Override protected void initService() throws Exception { Element rootElt = this.getPersist(); Attribute execSrvTypeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TYPE, true, "(thread pool executor type among {fixed|cached|scheduled|single})"); execSrvType = execSrvTypeAttr.getValue().trim(); if ("fixed".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else if ("cached".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, false, "(number of threads in the pool)"); if (null != corePoolSizeAttr) { initialCorePoolSize = corePoolSizeAttr.getIntValue(); } } else if ("scheduled".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else { throw new ConfigurationException( "Invalid thread pool executor type '%s' (valid types={fixed|cached|scheduled} )"); } Attribute terminationTimerAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER, false, "(termination timer in seconds)"); if (null != terminationTimerAttr) { terminationTimer = terminationTimerAttr.getIntValue(); } }  static ThreadPoolExecutor getThreadPoolExecutor(java.lang.String name); @SuppressWarnings("unchecked") static T getThreadPoolExecutor(
            java.lang.String name, Class<T> clazz); String getExecSrvType(); int getTerminationTimer(); int getActiveCount(); long getCompletedTaskCount(); int getCorePoolSize(); long getKeepAliveTimeMS(); int getLargestPoolSize(); int getMaximumPoolSize(); int getPoolSize(); long getTaskCount(); boolean isShutdown(); boolean isTerminated(); boolean isTerminating(); int getInitialCorePoolSize(); }
QThreadPoolExecutor extends QBeanSupport implements
        QThreadPoolExecutorMBean { @Override protected void initService() throws Exception { Element rootElt = this.getPersist(); Attribute execSrvTypeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TYPE, true, "(thread pool executor type among {fixed|cached|scheduled|single})"); execSrvType = execSrvTypeAttr.getValue().trim(); if ("fixed".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else if ("cached".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, false, "(number of threads in the pool)"); if (null != corePoolSizeAttr) { initialCorePoolSize = corePoolSizeAttr.getIntValue(); } } else if ("scheduled".equals(execSrvType)) { Attribute corePoolSizeAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE, true, "(number of threads in the pool)"); initialCorePoolSize = corePoolSizeAttr.getIntValue(); } else { throw new ConfigurationException( "Invalid thread pool executor type '%s' (valid types={fixed|cached|scheduled} )"); } Attribute terminationTimerAttr = getAttribute(rootElt, XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER, false, "(termination timer in seconds)"); if (null != terminationTimerAttr) { terminationTimer = terminationTimerAttr.getIntValue(); } }  static ThreadPoolExecutor getThreadPoolExecutor(java.lang.String name); @SuppressWarnings("unchecked") static T getThreadPoolExecutor(
            java.lang.String name, Class<T> clazz); String getExecSrvType(); int getTerminationTimer(); int getActiveCount(); long getCompletedTaskCount(); int getCorePoolSize(); long getKeepAliveTimeMS(); int getLargestPoolSize(); int getMaximumPoolSize(); int getPoolSize(); long getTaskCount(); boolean isShutdown(); boolean isTerminated(); boolean isTerminating(); int getInitialCorePoolSize(); static final String THREAD_POOL_EXECUTOR__QBEAN_PREFIX; static final String XML_CONFIG_ATTR__EXEC_SRV_TYPE; static final String XML_CONFIG_ATTR__EXEC_SRV_COREPOOLSIZE; static final String XML_CONFIG_ATTR__EXEC_SRV_TERMINATION_TIMER; static final int DEFAULT_TERMINATION_TIMER; }