geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1608083 - in /geronimo/specs/trunk/geronimo-concurrent_1.0_spec: ./ src/main/java/javax/enterprise/ src/main/java/javax/enterprise/concurrent/ src/main/java/javax/util/
Date Sat, 05 Jul 2014 17:54:23 GMT
Author: rmannibucau
Date: Sat Jul  5 17:54:22 2014
New Revision: 1608083

URL: http://svn.apache.org/r1608083
Log:
final concurrent utilities for ee API

Added:
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/AbortedException.java
      - copied, changed from r1608081, geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/util/concurrent/AbortedException.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ContextService.java
      - copied, changed from r1608081, geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/util/concurrent/ContextService.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/LastExecution.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManageableThread.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutorService.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutors.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedScheduledExecutorService.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTask.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTaskListener.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedThreadFactory.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/SkippedException.java
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/Trigger.java
Removed:
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/util/
Modified:
    geronimo/specs/trunk/geronimo-concurrent_1.0_spec/pom.xml

Modified: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/pom.xml?rev=1608083&r1=1608082&r2=1608083&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/pom.xml (original)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/pom.xml Sat Jul  5 17:54:22 2014
@@ -26,30 +26,31 @@
 
     <parent>
         <groupId>org.apache.geronimo.genesis</groupId>
-        <artifactId>genesis-java5-flava</artifactId>
+        <artifactId>genesis-java6-flava</artifactId>
         <version>2.0</version>
+        <relativePath />
     </parent>
 
     <groupId>org.apache.geronimo.specs</groupId>
     <artifactId>geronimo-concurrent_1.0_spec</artifactId>
     <name>Apache Geronimo Concurrency Utilities for Java EE API</name>
     <packaging>bundle</packaging>
-    <version>1.1-EA-SNAPSHOT</version>
+    <version>1.0-SNAPSHOT</version>
 
     <description>Java EE Concurrency API</description>
 
-    <url>http://geronimo.apache.org/maven/${siteId}/${version}</url>
+    <url>http://geronimo.apache.org/maven/${siteId}/${project.version}</url>
     <distributionManagement>
         <site>
             <id>apache-website</id>
-            <url>${site.deploy.url}/maven/${siteId}/${version}</url>
+            <url>${site.deploy.url}/maven/${siteId}/${project.version}</url>
         </site>
     </distributionManagement>
 
     <properties>
-        <siteId>specs/${artifactId}</siteId>
+        <siteId>specs/${project.artifactId}</siteId>
 
-        <geronimo.osgi.export.pkg>javax.util.concurrent*</geronimo.osgi.export.pkg>
+        <geronimo.osgi.export.pkg>javax.enterprise.concurrent*</geronimo.osgi.export.pkg>
         <geronimo.osgi.export.version>1.0</geronimo.osgi.export.version>
     </properties>
 
@@ -66,7 +67,7 @@
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>
-                        <Export-Package>javax.util.concurrent*;version=1.0</Export-Package>
+                        <Export-Package>javax.enterprise.concurrent*;version=1.0</Export-Package>
                     </instructions>
                 </configuration>
             </plugin>

Copied: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/AbortedException.java
(from r1608081, geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/util/concurrent/AbortedException.java)
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/AbortedException.java?p2=geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/AbortedException.java&p1=geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/util/concurrent/AbortedException.java&r1=1608081&r2=1608083&rev=1608083&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/util/concurrent/AbortedException.java
(original)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/AbortedException.java
Sat Jul  5 17:54:22 2014
@@ -14,7 +14,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package javax.util.concurrent;
+package javax.enterprise.concurrent;
 
 import java.util.concurrent.ExecutionException;
 

Copied: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ContextService.java
(from r1608081, geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/util/concurrent/ContextService.java)
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ContextService.java?p2=geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ContextService.java&p1=geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/util/concurrent/ContextService.java&r1=1608081&r2=1608083&rev=1608083&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/util/concurrent/ContextService.java
(original)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ContextService.java
Sat Jul  5 17:54:22 2014
@@ -14,264 +14,18 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-package javax.util.concurrent;
+package javax.enterprise.concurrent;
 
 import java.util.Map;
 
-/**
- * The ContextService provides methods for creating <i>contextual dynamic proxy</i>
- * objects.
- * <p>
- *
- * The proxy objects follow the same rules as defined for the
- * {@link java.lang.reflect.Proxy} class with the following additions:
- * <ul>
- * <li>The proxy instance will retain the context of the application
- * container's thread (creator's context).
- * <li>The proxy instance will implement all of the interfaces specified on the
- * <code>createContextObject</code> methods.
- * <li>All interface method invocations on a proxy instance run in the
- * creator's context.
- * <li>Invocation of the <code>hashCode</code>, <code>equals</code>,
and
- * <code>toString</code> methods declared in <code>java.lang.Object</code>
- * on a sproxy instance will not run in the creator's context.
- * <li>The proxy instance must implement <code>java.io.Serializable</code>.
- * <li>The proxied object instance must implement
- * <code>java.io.Serializable</code> if the proxy instance is serialized.
- * <li>Context properties can be stored with the proxy instance. Custom
- * property keys must not begin with "ctxsvc.".
- * <li>Context properties are to be used for controlling how various contextual
- * information is retreived and applied to the thread. Although application
- * components can store arbitrary property keys and values, it is not
- * recommended. Java EE product providers may impose limits to the size of the
- * keys and values.
- * <li>Context property keys and values must all be of type
- * <code>java.lang.String</code>. Use of the <code>put</code> and
- * <code>putAll</code> methods on the <code>java.util.Hashtable</code>
- * superclass are discouraged.
- * </ul>
- *
- */
 public interface ContextService {
-    /**
-     * A contextual object property that disables the normal transaction
-     * suspension and UserTransaction access from the proxied methods.
-     * <p>
-     *
-     * If "false" (the default if unspecified), any transaction that is
-     * currently active on the thread will be suspended and a UserTransaction
-     * (accessible in the local JNDI namespace as "java:comp/UserTransaction")
-     * will be available. When the proxied method returns the original
-     * transaction is restored.
-     * <p>
-     *
-     * If "true", the proxied method will run within the transaction (if any) of
-     * the current thread. A UserTransaction will only be available if the the
-     * container thread (for example, a Servlet or Bean Managed Transaction
-     * EJB).
-     */
-    public String USE_PARENT_TRANSACTION = "ctxsvc.useparenttran";
+    <T> T createContextualProxy(T instance, Class<T> intf);
 
-    /**
-     * Creates a new contextual object proxy for the input object instance.
-     * <p>
-     *
-     * Each method invocation will have the context of the application component
-     * instance that created the context object.
-     * <p>
-     *
-     * The contextual object is useful when developing or using Java SE
-     * threading mechanisms spraying events to other component instances or
-     * communicating with component instances on different Java processes.
-     * <p>
-     *
-     * If the application component that created the proxy is started or
-     * deployed, all methods on reflected interfaces will throw a
-     * <code>java.lang.IllegalState</code> exception.
-     * <p>
-     *
-     * For example, to call a normal Runnable with the correct context using a
-     * Java&trade; ExecutorService:
-     * <P>
-     *
-     * <pre>
-     * public class MyRunnable implements Runnable {
-     *     public void run() {
-     *         System.out.println(&quot;MyRunnable.run with J2EE Context available.&quot;);
-     *     }
-     * }
-     *
-     * InitialContext ctx = new InitialContext();
-     *
-     * ThreadFactory threadFactory = (ThreadFactory) ctx
-     *         .lookup(&quot;java:comp/env/concurrent/ThreadFactory&quot;);
-     *
-     * ContextService ctxService = (ContextService) ctx
-     *         .lookup(&quot;java:comp/env/concurrent/ContextService&quot;);
-     *
-     * Object rProxy = ctxService.createContextObject(myRunnableInstance,
-     *         new Class[] { Runnable.class });
-     *
-     * ExecutorService exSvc = Executors.newThreadPool(10, threadFactory);
-     *
-     * Future f = exSvc.submit((Runnable) rProxy);
-     * </pre>
-     *
-     * @param instance
-     *            the instance of the object to proxy.
-     * @param interfaces
-     *            the interfaces that the proxy should implement.
-     * @return a proxy for the input object that implements all of the specified
-     *         interfaces.
-     * @throws IllegalArgumentException
-     *             if the Class does not have an interface or there is not an
-     *             accessible default constructor.
-     */
-    public Object createContextObject(Object instance, Class<?>[] interfaces);
+    Object createContextualProxy(Object instance, Class<?>... interfaces);
 
-    /**
-     * Creates a new contextual object proxy for the input object instance.
-     * <p>
-     *
-     * The contextual object is useful when developing or using Java SE
-     * threading mechanisms spraying events to other component instances or
-     * communicating with component instances on different Java processes.
-     * <p>
-     *
-     * If the application component that created the proxy is started or
-     * deployed, all methods on reflected interfaces will throw a
-     * <code>java.lang.IllegalState</code> exception.
-     * <p>
-     *
-     * This method accepts a {@link Properties} object which allows the
-     * contextual object creator to define what contexts or behaviors to capture
-     * when creating the contextual object. The specified properties will remain
-     * with the contextual object until the properties are updated or removed
-     * using the {@link #setProperties(Object, Properties)} method.
-     * <p>
-     *
-     * For example, to call a Message Driven Bean (MDB) with the sender's
-     * context, but within the MDB's transaction:
-     * <P>
-     *
-     * <pre>
-     *      public class MyServlet ... {
-     *        public void doPost() throws NamingException, JMSException {
-     *            InitialContext ctx = new InitialContext();
-     *
-     *            // Get the ContextService that only propagates
-     *            // security context.
-     *            ContextService ctxSvc = (ContextService)
-     *                ctx.lookup(&quot;java:comp/env/SecurityContext&quot;);
-     *
-     *            // Set any custom context data.
-     *            Properties ctxProps = new Properties();
-     *            ctxProps.setProperty(&quot;vendor_a.security.tokenexpiration&quot;,
&quot;15000&quot;);
-     *
-     *            ProcessMessage msgProcessor =
-     *                (ProcessMessage) ctxSvc.createContextObject(new MessageProcessor(),
-     *                new Class[]{ProcessMessage.class},
-     *                ctxProps);
-     *
-     *            ConnectionFactory cf = (ConnectionFactory)
-     *                 ctx.lookup(&quot;java:comp/env/MyTopicConnectionFactory&quot;);
-     *            Destination dest = (Destination) ctx.lookup(&quot;java:comp/env/MyTopic&quot;);
-     *            Connection con = cf.createConnection();
-     *
-     *            Session session = con.createSession(true, Session.AUTO_ACKNOWLEDGE);
-     *            MessageProducer producer = session.createProducer(dest);
-     *
-     *            Message msg = session.createObjectMessage((Serializable)msgProcessor);
-     *            producer.send(dest, msg);
-     *            ...
-     *
-     *        }
-     *
-     *      public class MyMDB ... {
-     *        public void onMessage(Message msg) {
-     *            // Get the ProcessMessage context object from the message.
-     *            ObjectMessage omsg = (ObjectMessage)msg;
-     *            ProcessMessage msgProcessor = (ProcessMessage)omsg.getObject();
-     *
-     *            // Update the context object and verify that the processMessage()
-     *            // method runs inside the current transaction.  If we have a failure,
-     *            // we don't want to consume the message.
-     *            InitialContext ctx = new InitialContext();
-     *            ContextService ctxSvc = (ContextService)
-     *                ctx.lookup(&quot;java:comp/env/SecurityContext&quot;);
-     *            Properties ctxProps = ctxSvc.getProperties(msgProcessor);
-     *            ctxProps.setProperty(ContextService.USE_PARENT_TRANSACTION, &quot;true&quot;);
-     *            ctxSvc.setProperties(msgProcessor, ctxProps);
-     *
-     *            // Process the message in the specified context.
-     *            msgProcessor.processMessage(msg);
-     *        }
-     *      }
-     *
-     *      public interface  ProcessMessage {
-     *          public void processMessage(Message msg);
-     *      }
-     *
-     *      public class MessageProcessor implements ProcessMessage, Serializable {
-     *          public void processMessage(Message msg) {
-     *              // Process the message with the application container
-     *              // context that sent the message.
-     *
-     *          }
-     *      }
-     * </pre>
-     *
-     * @param instance
-     *            the instance of the object to proxy.
-     * @param interfaces
-     *            the interfaces that the proxy should implement.
-     * @param contextProperties
-     *            the properties to use when creating and running the context
-     *            object.
-     * @return a proxy for the input object that implements all of the specified
-     *         interfaces.
-     * @throws IllegalArgumentException
-     *             if the Class does not have an interface or there is not an
-     *             accessible default constructor.
-     * @throws ClassCastException
-     *             thrown if one of the keys or values in the specified
-     *             Properties object are not of type String.
-     */
-    public Object createContextObject(Object instance, Class<?>[] interfaces,
-            Map<String, String> contextProperties);
+    <T> T createContextualProxy(T instance, Map<String, String> executionProperties,
Class<T> intf);
 
-    /**
-     * Sets the properties on the context proxy instance.
-     * <p>
-     *
-     * All property keys and values must be strings. Storing other class types
-     * may result in a <code>java.lang.ClassCastException</code>.
-     *
-     * @param contextObject
-     *            the contextual proxy instance to set the properties.
-     * @param contextProperties
-     *            the properties to use when running the context object. Specify
-     *            an empty Properties object to erase all current properties.
-     * @throws IllegalArgumentException
-     *             thrown if the input contextObject is not a valid contextual
-     *             object proxy created with the
-     *             <code>createContextObject</code> method.
-     * @throws ClassCastException
-     *             thrown if one of the keys or values in the specified
-     *             Properties object are not of type String.
-     */
-    public void setProperties(Object contextObject, Map<String, String> contextProperties);
+    Object createContextualProxy(Object instance, Map<String, String> executionProperties,
Class<?>... interfaces);
 
-    /**
-     * Gets the current properties on the context proxy instance.
-     *
-     * @param contextObject
-     *            the contextual proxy instance to set the properties.
-     * @return the current context object properties
-     * @throws IllegalArgumentException
-     *             thrown if the input contextObject is not a valid contextual
-     *             object proxy created with the
-     *             <code>createContextObject</code> method.
-     */
-    public Map<String, String> getProperties(Object contextObject);
+    Map<String, String> getExecutionProperties(Object contextualProxy);
 }

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/LastExecution.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/LastExecution.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/LastExecution.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/LastExecution.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,27 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.enterprise.concurrent;
+
+import java.util.Date;
+
+public interface LastExecution {
+    String getIdentityName();
+    Object getResult();
+    Date getScheduledStart();
+    Date getRunStart();
+    Date getRunEnd();
+}

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManageableThread.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManageableThread.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManageableThread.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManageableThread.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,21 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.enterprise.concurrent;
+
+public interface ManageableThread {
+    boolean isShutdown();
+}

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutorService.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutorService.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutorService.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutorService.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,22 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.enterprise.concurrent;
+
+import java.util.concurrent.ExecutorService;
+
+public interface ManagedExecutorService extends ExecutorService {
+}

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutors.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutors.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutors.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedExecutors.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,147 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.enterprise.concurrent;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+public class ManagedExecutors {
+    public static final String NULL_TASK_ERROR_MSG = "Task cannot be null";
+
+    public static boolean isCurrentThreadShutdown() {
+        final Thread currThread = Thread.currentThread();
+        return currThread instanceof ManageableThread && ManageableThread.class.cast(currThread).isShutdown();
+    }
+
+    public static Runnable managedTask(final Runnable task, final ManagedTaskListener taskListener)
+            throws IllegalArgumentException {
+        return managedTask(task, null, taskListener);
+    }
+
+    public static Runnable managedTask(final Runnable task, final Map<String, String>
executionProperties,
+                                       final ManagedTaskListener taskListener) throws IllegalArgumentException
{
+        if (task == null) {
+            throw new IllegalArgumentException(NULL_TASK_ERROR_MSG);
+        }
+        return new RunnableAdapter(task, executionProperties, taskListener);
+    }
+
+    public static <V> Callable<V> managedTask(final Callable<V> task, final
ManagedTaskListener taskListener)
+            throws IllegalArgumentException {
+        return managedTask(task, null, taskListener);
+    }
+
+    public static <V> Callable<V> managedTask(final Callable<V> task,
+                                              final Map<String, String> executionProperties,
+                                              final ManagedTaskListener taskListener) throws
IllegalArgumentException {
+        if (task == null) {
+            throw new IllegalArgumentException(NULL_TASK_ERROR_MSG);
+        }
+        return new CallableAdapter<V>(task, executionProperties, taskListener);
+    }
+
+    private static final class RunnableAdapter extends Adapter implements Runnable {
+        private final Runnable task;
+
+        public RunnableAdapter(final Runnable task, final Map<String, String> executionProperties,
+                               final ManagedTaskListener taskListener) {
+            super(taskListener, executionProperties, ManagedTask.class.isInstance(task) ?
ManagedTask.class.cast(task) : null);
+            this.task = task;
+        }
+
+        @Override
+        public void run() {
+            task.run();
+        }
+
+    }
+
+    /**
+     * Adapter for Callable to include ManagedTask interface methods
+     */
+    private static final class CallableAdapter<V> extends Adapter implements Callable<V>
{
+        private final Callable<V> task;
+
+        public CallableAdapter(final Callable<V> task, final Map<String, String>
executionProperties,
+                               final ManagedTaskListener taskListener) {
+            super(taskListener, executionProperties, ManagedTask.class.isInstance(task) ?
ManagedTask.class.cast(task) : null);
+            this.task = task;
+        }
+
+        @Override
+        public V call() throws Exception {
+            return task.call();
+        }
+
+    }
+
+    private static class Adapter implements ManagedTask {
+        protected final ManagedTaskListener taskListener;
+        protected final Map<String, String> executionProperties;
+        protected final ManagedTask managedTask;
+
+        public Adapter(ManagedTaskListener taskListener, Map<String, String> executionProperties,
ManagedTask managedTask) {
+            this.taskListener = taskListener;
+            this.managedTask = managedTask;
+            this.executionProperties =
+                    initExecutionProperties(managedTask == null? null: managedTask.getExecutionProperties(),
+                            executionProperties);
+        }
+
+        @Override
+        public ManagedTaskListener getManagedTaskListener() {
+            if (taskListener != null) {
+                return taskListener;
+            }
+            if (managedTask != null) {
+                return managedTask.getManagedTaskListener();
+            }
+            return null;
+        }
+
+        @Override
+        public Map<String, String> getExecutionProperties() {
+            if (executionProperties != null) {
+                return executionProperties;
+            }
+            return null;
+        }
+
+        private static Map<String, String> initExecutionProperties(final Map<String,
String> base,
+                                                            final Map<String, String>
override) {
+            if (base == null && override == null) {
+                return null;
+            }
+
+            final Map<String, String> props = new HashMap<String, String>();
+            if (base != null) {
+                props.putAll(base);
+            }
+            if (override != null) {
+                props.putAll(override);
+            }
+            return props;
+        }
+
+    }
+
+    private ManagedExecutors() {
+        // no-op
+    }
+}
+

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedScheduledExecutorService.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedScheduledExecutorService.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedScheduledExecutorService.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedScheduledExecutorService.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,28 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.enterprise.concurrent;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+
+public interface ManagedScheduledExecutorService extends ManagedExecutorService, ScheduledExecutorService
{
+    ScheduledFuture<?> schedule(Runnable command, Trigger trigger);
+
+    <V> ScheduledFuture<V> schedule(Callable<V> callable, Trigger trigger);
+}
+

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTask.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTask.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTask.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTask.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,32 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.enterprise.concurrent;
+
+import java.util.Map;
+
+public interface ManagedTask {
+    String LONGRUNNING_HINT = "javax.enterprise.concurrent.LONGRUNNING_HINT";
+    String TRANSACTION = "javax.enterprise.concurrent.TRANSACTION";
+    String SUSPEND = "SUSPEND";
+    String USE_TRANSACTION_OF_EXECUTION_THREAD = "USE_TRANSACTION_OF_EXECUTION_THREAD";
+    String IDENTITY_NAME = "javax.enterprise.concurrent.IDENTITY_NAME";
+
+    ManagedTaskListener getManagedTaskListener();
+
+    Map<String, String> getExecutionProperties();
+}
+

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTaskListener.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTaskListener.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTaskListener.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedTaskListener.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,30 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.enterprise.concurrent;
+
+import java.util.concurrent.Future;
+
+public interface ManagedTaskListener {
+    void taskSubmitted(Future<?> future, ManagedExecutorService executor, Object task);
+
+    void taskAborted(Future<?> future, ManagedExecutorService executor, Object task,
Throwable exception);
+
+    void taskDone(Future<?> future, ManagedExecutorService executor, Object task, Throwable
exception);
+
+    void taskStarting(Future<?> future, ManagedExecutorService executor, Object task);
+}
+

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedThreadFactory.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedThreadFactory.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedThreadFactory.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/ManagedThreadFactory.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,22 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.enterprise.concurrent;
+
+import java.util.concurrent.ThreadFactory;
+
+public interface ManagedThreadFactory extends ThreadFactory {
+}

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/SkippedException.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/SkippedException.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/SkippedException.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/SkippedException.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,42 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package javax.enterprise.concurrent;
+
+import java.io.Serializable;
+import java.util.concurrent.ExecutionException;
+
+public class SkippedException extends ExecutionException implements Serializable {
+    private static final long serialVersionUID = 6296866815328432550L;
+
+    public SkippedException() {
+        super();
+    }
+
+    public SkippedException(java.lang.String message) {
+        super(message);
+    }
+
+    public SkippedException(java.lang.String message,
+                            java.lang.Throwable cause) {
+        super(message, cause);
+    }
+
+    public SkippedException(java.lang.Throwable cause) {
+        super(cause);
+    }
+}
+

Added: geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/Trigger.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/Trigger.java?rev=1608083&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/Trigger.java
(added)
+++ geronimo/specs/trunk/geronimo-concurrent_1.0_spec/src/main/java/javax/enterprise/concurrent/Trigger.java
Sat Jul  5 17:54:22 2014
@@ -0,0 +1,9 @@
+package javax.enterprise.concurrent;
+
+import java.util.Date;
+
+public interface Trigger {
+    Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime);
+
+    boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime);
+}



Mime
View raw message