Skip to content
Permalink
Browse files
GERONIMO-4360 more spec implementation, mostly about which import con…
…texts get processed when

git-svn-id: https://svn.apache.org/repos/asf/geronimo/components/txmanager/trunk@780440 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
djencks committed May 31, 2009
1 parent ca62693 commit 2e0651bee7272559e290b99222f59c9bb0352b3c
Showing 5 changed files with 58 additions and 17 deletions.
@@ -61,5 +61,28 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<!-- Do not include META-INF/maven to avoid long file problems on windows -->
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
<executions>
<execution>
<goals>
<!-- Build *test.jar files for modules -->
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>

@@ -17,9 +17,9 @@

package org.apache.geronimo.connector.work;

import java.util.concurrent.Executor;
import java.util.List;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.Executor;

import javax.resource.spi.work.ExecutionContext;
import javax.resource.spi.work.Work;
@@ -37,7 +37,7 @@
* WorkManager implementation which uses under the cover three WorkExecutorPool
* - one for each synchronization policy - in order to dispatch the submitted
* Work instances.
* <P>
* <p/>
* A WorkManager is a component of the JCA specifications, which allows a
* Resource Adapter to submit tasks to an Application Server for execution.
*
@@ -65,7 +65,7 @@ public class GeronimoWorkManager implements WorkManager {
*/
private Executor scheduledWorkExecutorPool;

private final List<InflowContextHandler> inflowContextHandlers;
private final Collection<InflowContextHandler> inflowContextHandlers;


private final WorkExecutor scheduleWorkExecutor = new ScheduleWorkExecutor();
@@ -79,11 +79,11 @@ public GeronimoWorkManager() {
this(null, null, null, null);
}

public GeronimoWorkManager(Executor sync, Executor start, Executor sched, List<InflowContextHandler> inflowContextHandlers) {
public GeronimoWorkManager(Executor sync, Executor start, Executor sched, Collection<InflowContextHandler> inflowContextHandlers) {
syncWorkExecutorPool = sync;
startWorkExecutorPool = start;
scheduledWorkExecutorPool = sched;
this.inflowContextHandlers = inflowContextHandlers == null? Collections.<InflowContextHandler>emptyList(): inflowContextHandlers;
this.inflowContextHandlers = inflowContextHandlers == null ? Collections.<InflowContextHandler>emptyList() : inflowContextHandlers;
}

public void doStart() throws Exception {
@@ -188,9 +188,8 @@ public void scheduleWork(
* Execute the specified Work.
*
* @param work Work to be executed.
*
* @exception WorkException Indicates that the Work execution has been
* unsuccessful.
* @throws WorkException Indicates that the Work execution has been
* unsuccessful.
*/
private void executeWork(WorkerContext work, WorkExecutor workExecutor, Executor pooledExecutor) throws WorkException {
work.workAccepted(this);
@@ -24,7 +24,7 @@
import javax.resource.spi.work.WorkCompletedException;

/**
* @version $Rev:$ $Date:$
* @version $Rev$ $Date$
*/
public interface InflowContextHandler<E extends InflowContext> {

@@ -34,4 +34,6 @@

Class<E> getHandledClass();

boolean required();

}
@@ -30,7 +30,7 @@
import org.apache.geronimo.transaction.manager.ImportedTransactionActiveException;

/**
* @version $Rev:$ $Date:$
* @version $Rev$ $Date$
*/
public class TransactionInflowContextHandler implements InflowContextHandler<TransactionInflowContext>{

@@ -73,4 +73,8 @@ public void after(TransactionInflowContext inflowContext) throws WorkCompletedEx
public Class<TransactionInflowContext> getHandledClass() {
return TransactionInflowContext.class;
}

public boolean required() {
return false;
}
}
@@ -21,6 +21,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Collection;
import java.util.concurrent.CountDownLatch;

import javax.resource.NotSupportedException;
@@ -131,9 +132,9 @@ public void workRejected(WorkEvent event) {
* @param work Work to be wrapped.
* @param inflowContextHandlers InflowContextHandlers supported by this work manager
*/
public WorkerContext(Work work, List<InflowContextHandler> inflowContextHandlers) {
public WorkerContext(Work work, Collection<InflowContextHandler> inflowContextHandlers) {
adaptee = work;
this.inflowContextHandlers = inflowContextHandlers;
this.inflowContextHandlers = new ArrayList<InflowContextHandler>(inflowContextHandlers);
executionContext = null;
workListener = NULL_WORK_LISTENER;
}
@@ -154,7 +155,7 @@ public WorkerContext(Work work, List<InflowContextHandler> inflowContextHandlers
public WorkerContext(Work aWork,
long aStartTimeout,
ExecutionContext execContext,
WorkListener workListener, List<InflowContextHandler> inflowContextHandlers) throws WorkRejectedException {
WorkListener workListener, Collection<InflowContextHandler> inflowContextHandlers) throws WorkRejectedException {
adaptee = aWork;
startTimeOut = aStartTimeout;
if (null == workListener) {
@@ -170,7 +171,7 @@ public WorkerContext(Work aWork,
} else {
executionContext = execContext;
}
this.inflowContextHandlers = inflowContextHandlers;
this.inflowContextHandlers = new ArrayList<InflowContextHandler>(inflowContextHandlers);
}

/* (non-Javadoc)
@@ -333,18 +334,30 @@ public void run() {
throw new WorkCompletedException("Duplicate or unhandled InflowContext: " + inflowContext);
}
}
for (Iterator<InflowContextHandler> it = inflowContextHandlers.iterator(); it.hasNext();) {
InflowContextHandler inflowContextHandler = it.next();
if (!inflowContextHandler.required()) {
it.remove();
}
}
// TODO use a InflowContextLifecycleListener

int i = 0;
for (InflowContext inflowContext : inflowContexts) {
inflowContextHandlers.get(i).before(inflowContext);
sortedHandlers.get(i++).before(inflowContext);
}
for (InflowContextHandler inflowContextHandler: inflowContextHandlers) {
inflowContextHandler.before(null);
}
try {
adaptee.run();
} finally {
int j = 0;
for (InflowContext inflowContext : inflowContexts) {
inflowContextHandlers.get(j).after(inflowContext);
sortedHandlers.get(j++).after(inflowContext);
}
for (InflowContextHandler inflowContextHandler: inflowContextHandlers) {
inflowContextHandler.after(null);
}
}

0 comments on commit 2e0651b

Please sign in to comment.