geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1058785 - in /geronimo/sandbox/djencks/txmanager/geronimo-connector: ./ src/main/java/org/apache/geronimo/connector/ src/main/java/org/apache/geronimo/connector/outbound/ src/main/java/org/apache/geronimo/connector/work/ src/main/java/org/...
Date Thu, 13 Jan 2011 23:05:41 GMT
Author: djencks
Date: Thu Jan 13 23:05:40 2011
New Revision: 1058785

URL: http://svn.apache.org/viewvc?rev=1058785&view=rev
Log:
remove unneeded classes and set up BootstrapContext using DS

Added:
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/DSExecutor.java
  (with props)
Removed:
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/NamedRunnable.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/NullWorkExecutorPool.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/WorkExecutorPool.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/WorkExecutorPoolImpl.java
Modified:
    geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/GeronimoBootstrapContext.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/HintsContextHandler.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionContextHandler.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/ScheduleWorkExecutor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/StartWorkExecutor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/SyncWorkExecutor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml Thu Jan 13 23:05:40 2011
@@ -100,6 +100,10 @@
             
             <plugin>
                 <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
                     <instructions>

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/GeronimoBootstrapContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/GeronimoBootstrapContext.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/GeronimoBootstrapContext.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/GeronimoBootstrapContext.java
Thu Jan 13 23:05:40 2011
@@ -23,6 +23,9 @@ import javax.resource.spi.XATerminator;
 import javax.resource.spi.work.WorkManager;
 import javax.resource.spi.work.WorkContext;
 import javax.transaction.TransactionSynchronizationRegistry;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.geronimo.connector.work.GeronimoWorkManager;
 
 /**
@@ -31,25 +34,32 @@ import org.apache.geronimo.connector.wor
  *
  * @version $Rev$ $Date$
  */
+@Component
+@Service
 public class GeronimoBootstrapContext implements javax.resource.spi.BootstrapContext {
-    private final GeronimoWorkManager workManager;
-    private final XATerminator xATerminator;
-    private final TransactionSynchronizationRegistry transactionSynchronizationRegistry;
+
+    @Reference
+    private GeronimoWorkManager workManager;
+
+    @Reference
+    private XATerminator xATerminator;
+
+    @Reference
+    private TransactionSynchronizationRegistry transactionSynchronizationRegistry;
 
     /**
      * Default constructor for use as a GBean Endpoint.
      */
     public GeronimoBootstrapContext() {
-        workManager = null;
-        xATerminator = null;
-        transactionSynchronizationRegistry = null;
     }
 
     /**
      * Normal constructor for use as a GBean.
+     *
      * @param workManager
      * @param xaTerminator
      * @param transactionSynchronizationRegistry
+     *
      */
     public GeronimoBootstrapContext(GeronimoWorkManager workManager, XATerminator xaTerminator,
TransactionSynchronizationRegistry transactionSynchronizationRegistry) {
         this.workManager = workManager;
@@ -57,6 +67,29 @@ public class GeronimoBootstrapContext im
         this.transactionSynchronizationRegistry = transactionSynchronizationRegistry;
     }
 
+    public void bindTransactionSynchronizationRegistry(TransactionSynchronizationRegistry
transactionSynchronizationRegistry) {
+        this.transactionSynchronizationRegistry = transactionSynchronizationRegistry;
+    }
+
+    public void unbindTransactionSynchronizationRegistry(TransactionSynchronizationRegistry
transactionSynchronizationRegistry) {
+        this.transactionSynchronizationRegistry = null;
+    }
+
+    public void bindWorkManager(GeronimoWorkManager workManager) {
+        this.workManager = workManager;
+    }
+
+    public void unbindWorkManager(GeronimoWorkManager workManager) {
+        this.workManager = null;
+    }
+
+    public void bindxATerminator(XATerminator xATerminator) {
+        this.xATerminator = xATerminator;
+    }
+
+    public void unbindxATerminator(XATerminator xATerminator) {
+        this.xATerminator = null;
+    }
 
     /**
      * @see javax.resource.spi.BootstrapContext#getWorkManager()

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
Thu Jan 13 23:05:40 2011
@@ -375,7 +375,7 @@ public abstract class AbstractSinglePool
                 interceptor.getExpiredManagedConnectionInfos(threshold, killList);
                 for (ManagedConnectionInfo managedConnectionInfo : killList) {
                     ConnectionInfo killInfo = new ConnectionInfo(managedConnectionInfo);
-                    interceptor.internalReturn(killInfo, ConnectionReturnAction.DESTROY);
+                    parent.next.returnConnection(killInfo, ConnectionReturnAction.DESTROY);
                 }
             } catch (Throwable t) {
                 log.error("Error occurred during execution of ExpirationMonitor TimerTask",
t);

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SinglePoolConnectionInterceptor.java
Thu Jan 13 23:05:40 2011
@@ -19,6 +19,7 @@ package org.apache.geronimo.connector.ou
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 import javax.resource.ResourceException;
@@ -160,9 +161,12 @@ public class SinglePoolConnectionInterce
 
     protected void getExpiredManagedConnectionInfos(long threshold, List<ManagedConnectionInfo>
killList) {
         synchronized (pool) {
-            for (ManagedConnectionInfo mci : pool) {
+            for (Iterator<ManagedConnectionInfo> mcis = pool.iterator(); mcis.hasNext();
) {
+                ManagedConnectionInfo mci = mcis.next();
                 if (mci.getLastUsed() < threshold) {
+                    mcis.remove();
                     killList.add(mci);
+                    connectionCount--;
                 }
             }
         }

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/DSExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/DSExecutor.java?rev=1058785&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/DSExecutor.java
(added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/DSExecutor.java
Thu Jan 13 23:05:40 2011
@@ -0,0 +1,45 @@
+/*
+ * 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 org.apache.geronimo.connector.work;
+
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+
+/**
+ * Basic executor that can be used if nothing else is available.
+ *
+ * @version $Rev$ $Date$
+ */
+
+@Component
+@Service
+@Property(name = "service.ranking", intValue = 0)
+public class DSExecutor extends ThreadPoolExecutor {
+    public DSExecutor() {
+        super(5, 10, 5000, TimeUnit.MILLISECONDS, new SynchronousQueue<Runnable>());
+        setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
+    }
+}

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/DSExecutor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/DSExecutor.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/DSExecutor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java
Thu Jan 13 23:05:40 2011
@@ -29,13 +29,20 @@ import javax.resource.spi.work.WorkExcep
 import javax.resource.spi.work.WorkListener;
 import javax.resource.spi.work.WorkManager;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.geronimo.connector.work.pool.ScheduleWorkExecutor;
 import org.apache.geronimo.connector.work.pool.StartWorkExecutor;
 import org.apache.geronimo.connector.work.pool.SyncWorkExecutor;
 import org.apache.geronimo.connector.work.pool.WorkExecutor;
 
 /**
- * WorkManager implementation which uses under the cover three WorkExecutorPool
+ * WorkManager implementation which uses under the cover three WorkExecutors
  * - one for each synchronization policy - in order to dispatch the submitted
  * Work instances.
  * <p/>
@@ -44,29 +51,41 @@ import org.apache.geronimo.connector.wor
  *
  * @version $Rev$ $Date$
  */
+@Component(metatype = true)
+@Service
+@Properties({@Property(name = "startExecutor.target",
+                value = "(service.ranking>=0)"),
+        @Property(name = "syncExecutor.target",
+                value = "(service.ranking>=0)"),
+        @Property(name = "scheduleExecutor.target",
+                value = "(service.ranking>=0)")})
 public class GeronimoWorkManager implements WorkManager {
 
-//    private final static int DEFAULT_POOL_SIZE = 10;
-
     /**
      * Pool of threads used by this WorkManager in order to process
      * the Work instances submitted via the doWork methods.
      */
-    private Executor syncWorkExecutorPool;
+    @Reference(target = "(service.ranking>=0)")
+    private Executor syncExecutor;
 
     /**
      * Pool of threads used by this WorkManager in order to process
      * the Work instances submitted via the startWork methods.
      */
-    private Executor startWorkExecutorPool;
+    @Reference(target = "(service.ranking>=0)")
+    private Executor startExecutor;
 
     /**
      * Pool of threads used by this WorkManager in order to process
      * the Work instances submitted via the scheduleWork methods.
      */
-    private Executor scheduledWorkExecutorPool;
+    @Reference(target = "(service.ranking>=0)")
+    private Executor scheduleExecutor;
 
-    private final Collection<WorkContextHandler> workContextHandlers;
+    @Reference(referenceInterface = WorkContextHandler.class,
+            cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
+            policy = ReferencePolicy.DYNAMIC)
+    private final Collection<WorkContextHandler<? extends WorkContext>> workContextHandlers;
 
 
     private final WorkExecutor scheduleWorkExecutor = new ScheduleWorkExecutor();
@@ -80,44 +99,52 @@ public class GeronimoWorkManager impleme
         this(null, null, null, null);
     }
 
-    public GeronimoWorkManager(Executor sync, Executor start, Executor sched, Collection<WorkContextHandler>
workContextHandlers) {
-        syncWorkExecutorPool = sync;
-        startWorkExecutorPool = start;
-        scheduledWorkExecutorPool = sched;
-        this.workContextHandlers = workContextHandlers == null ? Collections.<WorkContextHandler>emptyList()
: workContextHandlers;
+    public GeronimoWorkManager(Executor sync, Executor start, Executor sched, Collection<WorkContextHandler<?
extends WorkContext>> workContextHandlers) {
+        syncExecutor = sync;
+        startExecutor = start;
+        scheduleExecutor = sched;
+        this.workContextHandlers = workContextHandlers == null ? Collections.<WorkContextHandler<?
extends WorkContext>>emptyList() : workContextHandlers;
     }
 
-    public void doStart() throws Exception {
+
+    protected void bindStartExecutor(Executor startExecutor) {
+        this.startExecutor = startExecutor;
     }
 
-    public void doStop() throws Exception {
+    protected void unbindStartExecutor(Executor startExecutor) {
+        this.startExecutor = null;
     }
 
-    public void doFail() {
-        try {
-            doStop();
-        } catch (Exception e) {
-            //TODO what to do?
-        }
+    protected void bindSyncExecutor(Executor syncExecutor) {
+        this.syncExecutor = syncExecutor;
     }
 
-    public Executor getSyncWorkExecutorPool() {
-        return syncWorkExecutorPool;
+    protected void unbindSyncExecutor(Executor syncExecutor) {
+        this.syncExecutor = null;
     }
 
-    public Executor getStartWorkExecutorPool() {
-        return startWorkExecutorPool;
+    protected void bindScheduleExecutor(Executor scheduleExecutor) {
+        this.scheduleExecutor = scheduleExecutor;
     }
 
-    public Executor getScheduledWorkExecutorPool() {
-        return scheduledWorkExecutorPool;
+    protected void unbindScheduleExecutor(Executor scheduleExecutor) {
+        this.scheduleExecutor = null;
     }
 
+    protected void bindWorkContextHandler(WorkContextHandler<? extends WorkContext>
workContextHandler) {
+        workContextHandlers.add(workContextHandler);
+    }
+
+    protected void unbindWorkContextHandler(WorkContextHandler<? extends WorkContext>
workContextHandler) {
+        workContextHandlers.remove(workContextHandler);
+    }
+
+
     /* (non-Javadoc)
     * @see javax.resource.spi.work.WorkManager#doWork(javax.resource.spi.work.Work)
     */
     public void doWork(Work work) throws WorkException {
-        executeWork(new WorkerContext(work, workContextHandlers), syncWorkExecutor, syncWorkExecutorPool);
+        executeWork(new WorkerContext(work, workContextHandlers), syncWorkExecutor, syncExecutor);
     }
 
     /* (non-Javadoc)
@@ -132,7 +159,7 @@ public class GeronimoWorkManager impleme
         WorkerContext workWrapper =
                 new WorkerContext(work, startTimeout, execContext, workListener, workContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
-        executeWork(workWrapper, syncWorkExecutor, syncWorkExecutorPool);
+        executeWork(workWrapper, syncWorkExecutor, syncExecutor);
     }
 
     /* (non-Javadoc)
@@ -141,7 +168,7 @@ public class GeronimoWorkManager impleme
     public long startWork(Work work) throws WorkException {
         WorkerContext workWrapper = new WorkerContext(work, workContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
-        executeWork(workWrapper, startWorkExecutor, startWorkExecutorPool);
+        executeWork(workWrapper, startWorkExecutor, startExecutor);
         return System.currentTimeMillis() - workWrapper.getAcceptedTime();
     }
 
@@ -157,7 +184,7 @@ public class GeronimoWorkManager impleme
         WorkerContext workWrapper =
                 new WorkerContext(work, startTimeout, execContext, workListener, workContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
-        executeWork(workWrapper, startWorkExecutor, startWorkExecutorPool);
+        executeWork(workWrapper, startWorkExecutor, startExecutor);
         return System.currentTimeMillis() - workWrapper.getAcceptedTime();
     }
 
@@ -167,7 +194,7 @@ public class GeronimoWorkManager impleme
     public void scheduleWork(Work work) throws WorkException {
         WorkerContext workWrapper = new WorkerContext(work, workContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
-        executeWork(workWrapper, scheduleWorkExecutor, scheduledWorkExecutorPool);
+        executeWork(workWrapper, scheduleWorkExecutor, scheduleExecutor);
     }
 
     /* (non-Javadoc)
@@ -182,7 +209,7 @@ public class GeronimoWorkManager impleme
         WorkerContext workWrapper =
                 new WorkerContext(work, startTimeout, execContext, workListener, workContextHandlers);
         workWrapper.setThreadPriority(Thread.currentThread().getPriority());
-        executeWork(workWrapper, scheduleWorkExecutor, scheduledWorkExecutorPool);
+        executeWork(workWrapper, scheduleWorkExecutor, scheduleExecutor);
     }
 
     /**

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/HintsContextHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/HintsContextHandler.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/HintsContextHandler.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/HintsContextHandler.java
Thu Jan 13 23:05:40 2011
@@ -23,10 +23,15 @@ package org.apache.geronimo.connector.wo
 import javax.resource.spi.work.HintsContext;
 import javax.resource.spi.work.WorkCompletedException;
 import javax.resource.spi.work.WorkContext;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
 
 /**
  * @version $Rev$ $Date$
  */
+
+@Component
+@Service
 public class HintsContextHandler implements WorkContextHandler<HintsContext> {
 
     public void before(HintsContext workContext) throws WorkCompletedException {

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionContextHandler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionContextHandler.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionContextHandler.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/TransactionContextHandler.java
Thu Jan 13 23:05:40 2011
@@ -27,20 +27,38 @@ import javax.transaction.xa.XAException;
 import javax.transaction.InvalidTransactionException;
 import javax.transaction.SystemException;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.geronimo.transaction.manager.XAWork;
 import org.apache.geronimo.transaction.manager.ImportedTransactionActiveException;
 
 /**
  * @version $Rev$ $Date$
  */
+
+@Component
+@Service
 public class TransactionContextHandler implements WorkContextHandler<TransactionContext>{
 
-    private final XAWork xaWork;
+    @Reference
+    private XAWork xaWork;
+
+    public TransactionContextHandler() {
+    }
 
     public TransactionContextHandler(XAWork xaWork) {
         this.xaWork = xaWork;
     }
 
+    public void bindXaWork(XAWork xaWork) {
+        this.xaWork = xaWork;
+    }
+
+    public void unbindXaWork(XAWork xaWork) {
+        this.xaWork = null;
+    }
+
     public void before(TransactionContext workContext) throws WorkCompletedException {
         if (workContext.getXid() != null) {
             try {

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/WorkerContext.java
Thu Jan 13 23:05:40 2011
@@ -124,7 +124,7 @@ public class WorkerContext implements Wo
      */
     private final ExecutionContext executionContext;
 
-    private final List<WorkContextHandler> workContextHandlers;
+    private final List<WorkContextHandler<? extends WorkContext>> workContextHandlers;
 
 
     /**
@@ -133,9 +133,9 @@ public class WorkerContext implements Wo
      * @param work   Work to be wrapped.
      * @param workContextHandlers WorkContextHandlers supported by this work manager
      */
-    public WorkerContext(Work work, Collection<WorkContextHandler> workContextHandlers)
{
+    public WorkerContext(Work work, Collection<WorkContextHandler<? extends WorkContext>>
workContextHandlers) {
         adaptee = work;
-        this.workContextHandlers = new ArrayList<WorkContextHandler>(workContextHandlers);
+        this.workContextHandlers = new ArrayList<WorkContextHandler<? extends WorkContext>>(workContextHandlers);
         executionContext = null;
         workListener = NULL_WORK_LISTENER;
     }
@@ -156,7 +156,7 @@ public class WorkerContext implements Wo
     public WorkerContext(Work aWork,
                          long aStartTimeout,
                          ExecutionContext execContext,
-                         WorkListener workListener, Collection<WorkContextHandler>
workContextHandlers) throws WorkRejectedException {
+                         WorkListener workListener, Collection<WorkContextHandler<?
extends WorkContext>> workContextHandlers) throws WorkRejectedException {
         adaptee = aWork;
         startTimeOut = aStartTimeout;
         if (null == workListener) {
@@ -172,7 +172,7 @@ public class WorkerContext implements Wo
         } else {
             executionContext = execContext;
         }
-        this.workContextHandlers = new ArrayList<WorkContextHandler>(workContextHandlers);
+        this.workContextHandlers = new ArrayList<WorkContextHandler<? extends WorkContext>>(workContextHandlers);
     }
 
     /* (non-Javadoc)
@@ -323,7 +323,7 @@ public class WorkerContext implements Wo
             List<WorkContextHandler> sortedHandlers = new ArrayList<WorkContextHandler>(workContexts.size());
             for (WorkContext workContext : workContexts) {
                 boolean found = false;
-                for (Iterator<WorkContextHandler> it = workContextHandlers.iterator();
it.hasNext();) {
+                for (Iterator<WorkContextHandler<? extends WorkContext>> it =
workContextHandlers.iterator(); it.hasNext();) {
                     WorkContextHandler workContextHandler = it.next();
                     log.info("sorting WorkContextHandler: " + workContextHandler + " for
work context: " + workContext);
                     if (workContextHandler.supports(workContext.getClass())) {
@@ -343,7 +343,7 @@ public class WorkerContext implements Wo
                     throw new WorkCompletedException("Unhandled WorkContext: " + workContext,
WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE);
                 }
             }
-            for (Iterator<WorkContextHandler> it = workContextHandlers.iterator();
it.hasNext();) {
+            for (Iterator<WorkContextHandler<? extends WorkContext>> it = workContextHandlers.iterator();
it.hasNext();) {
                 WorkContextHandler workContextHandler = it.next();
                 if (!workContextHandler.required()) {
                     log.info("Removing non-required WorkContextHandler with no context: "
+ workContextHandler);

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/ScheduleWorkExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/ScheduleWorkExecutor.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/ScheduleWorkExecutor.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/ScheduleWorkExecutor.java
Thu Jan 13 23:05:40 2011
@@ -33,6 +33,6 @@ public class ScheduleWorkExecutor implem
 
     public void doExecute(WorkerContext work, Executor executor)
             throws WorkException, InterruptedException {
-        executor.execute(new NamedRunnable("A J2EE Connector", work));
+        executor.execute(work);
     }
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/StartWorkExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/StartWorkExecutor.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/StartWorkExecutor.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/StartWorkExecutor.java
Thu Jan 13 23:05:40 2011
@@ -35,7 +35,7 @@ public class StartWorkExecutor implement
     public void doExecute(WorkerContext work, Executor executor)
             throws WorkException, InterruptedException {
         CountDownLatch latch = work.provideStartLatch();
-        executor.execute(new NamedRunnable("A J2EE Connector", work));
+        executor.execute(work);
         latch.await();
     }
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/SyncWorkExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/SyncWorkExecutor.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/SyncWorkExecutor.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/pool/SyncWorkExecutor.java
Thu Jan 13 23:05:40 2011
@@ -35,7 +35,7 @@ public class SyncWorkExecutor implements
     public void doExecute(WorkerContext work, Executor executor)
             throws WorkException, InterruptedException {
         CountDownLatch latch = work.provideEndLatch();
-        executor.execute(new NamedRunnable("A J2EE Connector", work));
+        executor.execute(work);
         latch.await();
     }
 

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/BootstrapContextTest.java
Thu Jan 13 23:05:40 2011
@@ -27,6 +27,7 @@ import java.util.concurrent.ThreadPoolEx
 import java.util.concurrent.TimeUnit;
 
 import javax.resource.spi.XATerminator;
+import javax.resource.spi.work.WorkContext;
 import javax.resource.spi.work.WorkManager;
 
 import junit.framework.TestCase;
@@ -98,7 +99,7 @@ public class BootstrapContextTest extend
     public void testGetSetWorkManager() throws Exception {
         GeronimoTransactionManager transactionManager = new GeronimoTransactionManager();
         TransactionContextHandler txWorkContextHandler = new TransactionContextHandler(transactionManager);
-        GeronimoWorkManager manager = new GeronimoWorkManager(pool, pool, pool, Collections.<WorkContextHandler>singletonList(txWorkContextHandler));
+        GeronimoWorkManager manager = new GeronimoWorkManager(pool, pool, pool, Collections.<WorkContextHandler<?
extends WorkContext>>singletonList(txWorkContextHandler));
         GeronimoBootstrapContext context = new GeronimoBootstrapContext(manager, transactionManager,
transactionManager);
         WorkManager wm = context.getWorkManager();
 
@@ -111,7 +112,7 @@ public class BootstrapContextTest extend
     public void testGetSetXATerminator() throws Exception {
         GeronimoTransactionManager transactionManager = new GeronimoTransactionManager();
         TransactionContextHandler txWorkContextHandler = new TransactionContextHandler(transactionManager);
-        GeronimoWorkManager manager = new GeronimoWorkManager(pool, pool, pool, Collections.<WorkContextHandler>singletonList(txWorkContextHandler));
+        GeronimoWorkManager manager = new GeronimoWorkManager(pool, pool, pool, Collections.<WorkContextHandler<?
extends WorkContext>>singletonList(txWorkContextHandler));
         GeronimoBootstrapContext context = new GeronimoBootstrapContext(manager, transactionManager,
transactionManager);
         XATerminator xat = context.getXATerminator();
 

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java?rev=1058785&r1=1058784&r2=1058785&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java
(original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/work/PooledWorkManagerTest.java
Thu Jan 13 23:05:40 2011
@@ -28,6 +28,7 @@ import java.util.Collections;
 
 import javax.resource.spi.work.ExecutionContext;
 import javax.resource.spi.work.Work;
+import javax.resource.spi.work.WorkContext;
 import javax.resource.spi.work.WorkEvent;
 import javax.resource.spi.work.WorkException;
 import javax.resource.spi.work.WorkListener;
@@ -65,8 +66,7 @@ public class PooledWorkManagerTest exten
         pool.setThreadFactory(new ThreadPoolThreadFactory("Connector Test", getClass().getClassLoader()));
 
 
-        workManager = new GeronimoWorkManager(pool, pool, pool, Collections.<WorkContextHandler>singletonList(txWorkContextHandler));
-        workManager.doStart();
+        workManager = new GeronimoWorkManager(pool, pool, pool, Collections.<WorkContextHandler<?
extends WorkContext>>singletonList(txWorkContextHandler));
     }
 
     private static class WaitWhenBlockedPolicy
@@ -161,8 +161,6 @@ public class PooledWorkManagerTest exten
 
     public void testLifecycle() throws Exception {
         testDoWork();
-        workManager.doStop();
-        workManager.doStart();
         testDoWork();
     }
 



Mime
View raw message