[jboss-cvs] JBossAS SVN: r86487 - projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 30 16:55:48 EDT 2009
Author: david.lloyd at jboss.com
Date: 2009-03-30 16:55:48 -0400 (Mon, 30 Mar 2009)
New Revision: 86487
Added:
projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ScheduledThreadPoolExecutorMetaData.java
Modified:
projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ThreadsMetaData.java
Log:
JBTHR-4 - finish support for scheduled executor service
Added: projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ScheduledThreadPoolExecutorMetaData.java
===================================================================
--- projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ScheduledThreadPoolExecutorMetaData.java (rev 0)
+++ projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ScheduledThreadPoolExecutorMetaData.java 2009-03-30 20:55:48 UTC (rev 86487)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.threads.metadata;
+
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+ at XmlType(name = "scheduled-thread-pool-executor")
+public final class ScheduledThreadPoolExecutorMetaData {
+ private String name;
+ private String threadFactory;
+ private PoolSizeMetaData poolSize;
+
+ public String getName() {
+ return name;
+ }
+
+ @XmlAttribute(required = true)
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public String getThreadFactory() {
+ return threadFactory;
+ }
+
+ @XmlAttribute(name = "thread-factory", required = true)
+ public void setThreadFactory(final String threadFactory) {
+ this.threadFactory = threadFactory;
+ }
+
+ public PoolSizeMetaData getPoolSize() {
+ return poolSize;
+ }
+
+ @XmlElement(name = "pool-size")
+ public void setPoolSize(final PoolSizeMetaData poolSize) {
+ this.poolSize = poolSize;
+ }
+}
Modified: projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ThreadsMetaData.java
===================================================================
--- projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ThreadsMetaData.java 2009-03-30 20:28:21 UTC (rev 86486)
+++ projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ThreadsMetaData.java 2009-03-30 20:55:48 UTC (rev 86487)
@@ -37,6 +37,8 @@
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
import static java.lang.Math.max;
import org.jboss.xb.annotations.JBossXmlSchema;
import org.jboss.beans.metadata.spi.BeanMetaData;
@@ -118,6 +120,7 @@
private List<ThreadPoolExecutorMetaData> threadPoolExecutors = new ArrayList<ThreadPoolExecutorMetaData>();
private List<DirectExecutorMetaData> directExecutors = new ArrayList<DirectExecutorMetaData>();
private List<NotatingExecutorMetaData> notatingExecutors = new ArrayList<NotatingExecutorMetaData>();
+ private List<ScheduledThreadPoolExecutorMetaData> scheduledThreadPoolExecutors = new ArrayList<ScheduledThreadPoolExecutorMetaData>();
public List<ThreadGroupMetaData> getThreadGroups() {
return threadGroups;
@@ -164,6 +167,15 @@
this.notatingExecutors = notatingExecutors;
}
+ public List<ScheduledThreadPoolExecutorMetaData> getScheduledThreadPoolExecutors() {
+ return scheduledThreadPoolExecutors;
+ }
+
+ @XmlElement(name = "scheduled-thread-pool-executor")
+ public void setScheduledThreadPoolExecutors(final List<ScheduledThreadPoolExecutorMetaData> scheduledThreadPoolExecutors) {
+ this.scheduledThreadPoolExecutors = scheduledThreadPoolExecutors;
+ }
+
@XmlTransient
public List<BeanMetaData> getBeans() {
List<BeanMetaData> beanMetaDataList = new ArrayList<BeanMetaData>();
@@ -368,6 +380,24 @@
builder.addConstructorParameter(String.class.getName(), metaData.getNote());
beanMetaDataList.add(builder.getBeanMetaData());
}
+ for (ScheduledThreadPoolExecutorMetaData metaData : scheduledThreadPoolExecutors) {
+ final String name = metaData.getName();
+ final BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(name, ScheduledThreadPoolExecutor.class.getName());
+ builder.setMode(ControllerMode.ON_DEMAND);
+ final PoolSizeMetaData poolSizeMetaData = metaData.getPoolSize();
+ final int size;
+ if (poolSizeMetaData != null) {
+ size = max(1, calcPoolSize(poolSizeMetaData));
+ } else {
+ size = 1;
+ }
+ builder.addConstructorParameter("int", Integer.valueOf(size));
+ final String threadFactoryName = metaData.getThreadFactory();
+ if (threadFactoryName != null) {
+ builder.addConstructorParameter(ThreadFactory.class.getName(), builder.createInject(threadFactoryName));
+ }
+ beanMetaDataList.add(builder.getBeanMetaData());
+ }
return beanMetaDataList;
}
More information about the jboss-cvs-commits
mailing list