Jeremy,

I have removed the dependency on Geronimo work manager (connector and transaction jars). Please find the patch attached. I have also removed the org.apache.tuscany.core.services.workmanager.DefaultWorkManager class and the associated test cases from core. All tests are passing with a clean build.

Ta
Meeraj

_________________________________________________________________
Windows LiveĀ™ Messenger has arrived. Click here to download it for free! http://imagine-msn.com/messenger/launch80/?locale=en-gb Index: sca/core/src/test/java/org/apache/tuscany/core/policy/async/AsyncInterceptorTestCase.java
===================================================================
--- sca/core/src/test/java/org/apache/tuscany/core/policy/async/AsyncInterceptorTestCase.java (revision 428921) +++ sca/core/src/test/java/org/apache/tuscany/core/policy/async/AsyncInterceptorTestCase.java (working copy)
@@ -6,14 +6,15 @@
import org.apache.tuscany.spi.wire.Message;
import org.apache.tuscany.spi.wire.MessageImpl;

-import org.apache.geronimo.connector.work.GeronimoWorkManager;
-import org.apache.geronimo.transaction.context.TransactionContextManager;
import org.apache.tuscany.core.monitor.NullMonitorFactory;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
import org.jmock.core.Invocation;
import org.jmock.core.Stub;

+import org.apache.tuscany.core.services.work.jsr237.workmanager.ThreadPoolWorkManager;
+import org.apache.tuscany.core.services.work.jsr237.Jsr237WorkScheduler;
+import org.apache.tuscany.spi.services.work.WorkScheduler;
/**
 * Verfies basic async invocations
 *
@@ -21,12 +22,13 @@
 */
public class AsyncInterceptorTestCase extends MockObjectTestCase {

-    private GeronimoWorkManager workManager;
+       private WorkScheduler workScheduler;
+    private ThreadPoolWorkManager workManager;

    @SuppressWarnings("unchecked")
    public void testInvocation() throws Exception {
        AsyncInterceptor asyncInterceptor =
- new AsyncInterceptor(workManager, new NullMonitorFactory().getMonitor(AsyncMonitor.class)); + new AsyncInterceptor(workScheduler, new NullMonitorFactory().getMonitor(AsyncMonitor.class));
        Message msg = new MessageImpl();
        msg.setBody("foo");
        final CountDownLatch startSignal = new CountDownLatch(1);
@@ -51,13 +53,12 @@

    protected void setUp() throws Exception {
        super.setUp();
- TransactionContextManager transactionContextManager = new TransactionContextManager(); - workManager = new GeronimoWorkManager(2, transactionContextManager);
-        workManager.doStart();
+        workManager = new ThreadPoolWorkManager(2);
+        workScheduler = new Jsr237WorkScheduler(workManager);
    }

    protected void tearDown() throws Exception {
        super.tearDown();
-        workManager.doStop();
+        workManager.destroy();
    }
}
Index: sca/core/src/main/java/org/apache/tuscany/core/policy/async/AsyncPolicyBuilder.java
===================================================================
--- sca/core/src/main/java/org/apache/tuscany/core/policy/async/AsyncPolicyBuilder.java (revision 428921) +++ sca/core/src/main/java/org/apache/tuscany/core/policy/async/AsyncPolicyBuilder.java (working copy)
@@ -1,6 +1,6 @@
package org.apache.tuscany.core.policy.async;

-import javax.resource.spi.work.WorkManager;
+import org.apache.tuscany.spi.services.work.WorkScheduler;

import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.OneWay;
@@ -25,7 +25,7 @@
public class AsyncPolicyBuilder implements TargetPolicyBuilder {

    private PolicyBuilderRegistry builderRegistry;
-    private WorkManager workManager;
+    private WorkScheduler workScheduler;
    private AsyncMonitor monitor;

    public AsyncPolicyBuilder() {
@@ -50,15 +50,15 @@
    }

    @Autowire
-    public void setWorkManager(WorkManager workManager) {
-        this.workManager = workManager;
+    public void setWorkScheduler(WorkScheduler workScheduler) {
+        this.workScheduler = workScheduler;
    }

public void build(ServiceDefinition serviceDefinition, InboundWire<?> wire) throws BuilderException { for (InboundInvocationChain chain : wire.getInvocationChains().values()) { // TODO fix this - it should be represented by the model and not through an annotation
            if (chain.getMethod().getAnnotation(OneWay.class) != null) {
- chain.addInterceptor(new AsyncInterceptor(workManager, monitor)); + chain.addInterceptor(new AsyncInterceptor(workScheduler, monitor));
            }
        }
    }
Index: sca/core/src/main/java/org/apache/tuscany/core/policy/async/AsyncInterceptor.java
===================================================================
--- sca/core/src/main/java/org/apache/tuscany/core/policy/async/AsyncInterceptor.java (revision 428921) +++ sca/core/src/main/java/org/apache/tuscany/core/policy/async/AsyncInterceptor.java (working copy)
@@ -1,8 +1,6 @@
package org.apache.tuscany.core.policy.async;

-import javax.resource.spi.work.Work;
-import javax.resource.spi.work.WorkException;
-import javax.resource.spi.work.WorkManager;
+import org.apache.tuscany.spi.services.work.WorkScheduler;

import org.osoa.sca.CompositeContext;
import org.osoa.sca.CurrentCompositeContext;
@@ -24,39 +22,31 @@
    private static final ContextBinder BINDER = new ContextBinder();
    private static final Message RESPONSE = new ImmutableMessage();

-    private WorkManager workManager;
+    private WorkScheduler workScheduler;
    private Interceptor next;
    private AsyncMonitor monitor;

- public AsyncInterceptor(WorkManager workManager, AsyncMonitor monitor) {
-        this.workManager = workManager;
+ public AsyncInterceptor(WorkScheduler workScheduler, AsyncMonitor monitor) {
+        this.workScheduler = workScheduler;
        this.monitor = monitor;
    }

    public Message invoke(final Message message) {
final CompositeContext currentContext = CurrentCompositeContext.getContext(); // Schedule the invocation of the next interceptor in a new Work instance
-        try {
-            workManager.scheduleWork(new Work() {
-                public void run() {
- CompositeContext oldContext = CurrentCompositeContext.getContext();
-                    try {
-                        AsyncInterceptor.BINDER.setContext(currentContext);
- next.invoke(message); // Invoke the next interceptor
-                    } catch (Exception e) {
-                        monitor.executionError(e);
-                    } finally {
-                        AsyncInterceptor.BINDER.setContext(oldContext);
-                    }
+        workScheduler.scheduleWork(new Runnable() {
+            public void run() {
+ CompositeContext oldContext = CurrentCompositeContext.getContext();
+                try {
+                    AsyncInterceptor.BINDER.setContext(currentContext);
+                    next.invoke(message); // Invoke the next interceptor
+                } catch (Exception e) {
+                    monitor.executionError(e);
+                } finally {
+                    AsyncInterceptor.BINDER.setContext(oldContext);
                }
-
-                public void release() {
-                }
-
-            });
-        } catch (WorkException e) {
-            throw new ServiceRuntimeException(e);
-        }
+            }
+        });
        return RESPONSE; // No return on a OneWay invocation.
    }

Index: sca/core/pom.xml
===================================================================
--- sca/core/pom.xml    (revision 428921)
+++ sca/core/pom.xml    (working copy)
@@ -73,20 +73,8 @@
            <groupId>org.apache.geronimo.specs</groupId>
            <artifactId>geronimo-j2ee-connector_1.5_spec</artifactId>
        </dependency>
-
+
        <dependency>
-            <groupId>org.apache.geronimo</groupId>
-            <artifactId>geronimo-connector</artifactId>
-            <version>1.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.geronimo</groupId>
-            <artifactId>geronimo-transaction</artifactId>
-            <version>1.0</version>
-            <scope>compile</scope>
-        </dependency>
-        <dependency>
            <groupId>concurrent</groupId>
            <artifactId>concurrent</artifactId>
            <version>1.3.4</version>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to