[weld-commits] Weld SVN: r4585 - in core/trunk/impl/src/main/java/org/jboss/weld: resources and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Mon Nov 2 19:17:53 EST 2009


Author: pete.muir at jboss.org
Date: 2009-11-02 19:17:53 -0500 (Mon, 02 Nov 2009)
New Revision: 4585

Added:
   core/trunk/impl/src/main/java/org/jboss/weld/resources/SingleThreadScheduledExecutorServiceFactory.java
Removed:
   core/trunk/impl/src/main/java/org/jboss/weld/conversation/JavaSEConversationTerminator.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java
Log:
WELD-90, WELD-92

Modified: core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java	2009-11-03 00:16:50 UTC (rev 4584)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java	2009-11-03 00:17:53 UTC (rev 4585)
@@ -41,6 +41,7 @@
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
 
 import javax.enterprise.context.Conversation;
 import javax.enterprise.inject.Any;
@@ -50,6 +51,7 @@
 import org.jboss.weld.context.ContextLifecycle;
 import org.jboss.weld.context.ConversationContext;
 import org.jboss.weld.context.api.BeanStore;
+import org.jboss.weld.resources.spi.ScheduledExecutorServiceFactory;
 import org.slf4j.cal10n.LocLogger;
 
 /**
@@ -62,10 +64,6 @@
 {
    private static final LocLogger log = loggerFactory().getLogger(CONVERSATION);
 
-   // The conversation terminator
-   @Inject
-   private ConversationTerminator conversationTerminator;
-
    // The current conversation
    @Inject @Any
    private ConversationImpl currentConversation;
@@ -203,7 +201,7 @@
    private Future<?> scheduleForTermination(String cid, long timeout)
    {
       Runnable terminationTask = new TerminationTask(cid);
-      return conversationTerminator.scheduleForTermination(terminationTask, timeout);
+      return Container.instance().deploymentServices().get(ScheduledExecutorServiceFactory.class).get().schedule(terminationTask, timeout, TimeUnit.MILLISECONDS);
    }
 
    /**

Deleted: core/trunk/impl/src/main/java/org/jboss/weld/conversation/JavaSEConversationTerminator.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/JavaSEConversationTerminator.java	2009-11-03 00:16:50 UTC (rev 4584)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/JavaSEConversationTerminator.java	2009-11-03 00:17:53 UTC (rev 4585)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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 org.jboss.weld.conversation;
-
-import java.io.Serializable;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import javax.enterprise.context.SessionScoped;
-
-/**
- * A ConversationTerminator implementation using Java SE scheduling
- *   
- * @author Nicklas Karlsson
- * @see org.jboss.weld.conversation.ConversationTerminator
- */
- at SessionScoped
-public class JavaSEConversationTerminator implements ConversationTerminator, Serializable
-{
-   private static final long serialVersionUID = 7258623232951724618L;
-
-   private transient ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
-
-   public Future<?> scheduleForTermination(Runnable terminationTask, long timeoutInMilliseconds)
-   {
-      return executor.schedule(terminationTask, timeoutInMilliseconds, TimeUnit.MILLISECONDS);
-   }
-
-}

Added: core/trunk/impl/src/main/java/org/jboss/weld/resources/SingleThreadScheduledExecutorServiceFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/resources/SingleThreadScheduledExecutorServiceFactory.java	                        (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/resources/SingleThreadScheduledExecutorServiceFactory.java	2009-11-03 00:17:53 UTC (rev 4585)
@@ -0,0 +1,29 @@
+package org.jboss.weld.resources;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+
+import org.jboss.weld.resources.spi.ScheduledExecutorServiceFactory;
+
+// TODO Expose in SPI
+public class SingleThreadScheduledExecutorServiceFactory implements ScheduledExecutorServiceFactory
+{
+
+   private final ScheduledExecutorService executorService;
+
+   public SingleThreadScheduledExecutorServiceFactory()
+   {
+      this.executorService = Executors.newScheduledThreadPool(1);
+   }
+   
+   public ScheduledExecutorService get()
+   {
+      return executorService;
+   }
+   
+   public void cleanup()
+   {
+      this.executorService.shutdown();
+   }
+   
+}


Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/resources/SingleThreadScheduledExecutorServiceFactory.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native



More information about the weld-commits mailing list