Details
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/janitor/IncompletePaymentAttemptTask.java b/payment/src/main/java/org/killbill/billing/payment/core/janitor/IncompletePaymentAttemptTask.java
index e7f2318..9851afb 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/janitor/IncompletePaymentAttemptTask.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/janitor/IncompletePaymentAttemptTask.java
@@ -70,11 +70,16 @@ public class IncompletePaymentAttemptTask extends CompletionTaskBase<PaymentAtte
private final PluginControlPaymentAutomatonRunner pluginControlledPaymentAutomatonRunner;
@Inject
- public IncompletePaymentAttemptTask(final InternalCallContextFactory internalCallContextFactory, final PaymentConfig paymentConfig,
- final PaymentDao paymentDao, final Clock clock, final PaymentStateMachineHelper paymentStateMachineHelper,
- final PaymentControlStateMachineHelper retrySMHelper, final AccountInternalApi accountInternalApi,
+ public IncompletePaymentAttemptTask(final InternalCallContextFactory internalCallContextFactory,
+ final PaymentConfig paymentConfig,
+ final PaymentDao paymentDao,
+ final Clock clock,
+ final PaymentStateMachineHelper paymentStateMachineHelper,
+ final PaymentControlStateMachineHelper retrySMHelper,
+ final AccountInternalApi accountInternalApi,
final PluginControlPaymentAutomatonRunner pluginControlledPaymentAutomatonRunner,
- final OSGIServiceRegistration<PaymentPluginApi> pluginRegistry, final GlobalLocker locker) {
+ final OSGIServiceRegistration<PaymentPluginApi> pluginRegistry,
+ final GlobalLocker locker) {
super(internalCallContextFactory, paymentConfig, paymentDao, clock, paymentStateMachineHelper, retrySMHelper, accountInternalApi, pluginRegistry, locker);
this.pluginControlledPaymentAutomatonRunner = pluginControlledPaymentAutomatonRunner;
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/core/janitor/Janitor.java b/payment/src/main/java/org/killbill/billing/payment/core/janitor/Janitor.java
index 2c21d9c..fbac8e0 100644
--- a/payment/src/main/java/org/killbill/billing/payment/core/janitor/Janitor.java
+++ b/payment/src/main/java/org/killbill/billing/payment/core/janitor/Janitor.java
@@ -24,10 +24,20 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import org.joda.time.DateTime;
+import org.killbill.billing.account.api.AccountInternalApi;
import org.killbill.billing.events.PaymentInternalEvent;
+import org.killbill.billing.osgi.api.OSGIServiceRegistration;
import org.killbill.billing.payment.core.PaymentExecutors;
+import org.killbill.billing.payment.core.sm.PaymentControlStateMachineHelper;
+import org.killbill.billing.payment.core.sm.PaymentStateMachineHelper;
+import org.killbill.billing.payment.core.sm.PluginControlPaymentAutomatonRunner;
+import org.killbill.billing.payment.dao.PaymentDao;
import org.killbill.billing.payment.glue.DefaultPaymentService;
+import org.killbill.billing.payment.plugin.api.PaymentPluginApi;
+import org.killbill.billing.util.callcontext.InternalCallContextFactory;
import org.killbill.billing.util.config.PaymentConfig;
+import org.killbill.clock.Clock;
+import org.killbill.commons.locker.GlobalLocker;
import org.killbill.notificationq.api.NotificationEvent;
import org.killbill.notificationq.api.NotificationQueue;
import org.killbill.notificationq.api.NotificationQueueService;
@@ -49,29 +59,75 @@ public class Janitor {
private final NotificationQueueService notificationQueueService;
private final PaymentConfig paymentConfig;
- private final IncompletePaymentAttemptTask incompletePaymentAttemptTask;
- private final IncompletePaymentTransactionTask incompletePaymentTransactionTask;
private final PaymentExecutors paymentExecutors;
+ private final Clock clock;
+ private final PaymentDao paymentDao;
+ private final InternalCallContextFactory internalCallContextFactory;
+ private final PaymentStateMachineHelper paymentStateMachineHelper;
+ private final PaymentControlStateMachineHelper retrySMHelper;
+ private final AccountInternalApi accountInternalApi;
+ private final OSGIServiceRegistration<PaymentPluginApi> pluginRegistry;
+ private final GlobalLocker locker;
+ private final PluginControlPaymentAutomatonRunner pluginControlledPaymentAutomatonRunner;
+
+
+
+ private IncompletePaymentAttemptTask incompletePaymentAttemptTask;
+ private IncompletePaymentTransactionTask incompletePaymentTransactionTask;
private NotificationQueue janitorQueue;
private ScheduledExecutorService janitorExecutor;
private volatile boolean isStopped;
@Inject
- public Janitor(final PaymentConfig paymentConfig,
+ public Janitor(final InternalCallContextFactory internalCallContextFactory,
+ final PaymentDao paymentDao,
+ final Clock clock,
+ final PaymentStateMachineHelper paymentStateMachineHelper,
+ final PaymentControlStateMachineHelper retrySMHelper,
+ final AccountInternalApi accountInternalApi,
+ final PluginControlPaymentAutomatonRunner pluginControlledPaymentAutomatonRunner,
+ final OSGIServiceRegistration<PaymentPluginApi> pluginRegistry,
+ final GlobalLocker locker,
+ final PaymentConfig paymentConfig,
final NotificationQueueService notificationQueueService,
- final PaymentExecutors paymentExecutors,
- final IncompletePaymentAttemptTask incompletePaymentAttemptTask,
- final IncompletePaymentTransactionTask incompletePaymentTransactionTask) {
+ final PaymentExecutors paymentExecutors) {
this.notificationQueueService = notificationQueueService;
this.paymentExecutors = paymentExecutors;
this.paymentConfig = paymentConfig;
- this.incompletePaymentAttemptTask = incompletePaymentAttemptTask;
- this.incompletePaymentTransactionTask = incompletePaymentTransactionTask;
+ this.internalCallContextFactory = internalCallContextFactory;
+ this.paymentDao = paymentDao;
+ this.clock = clock;
+ this.pluginControlledPaymentAutomatonRunner = pluginControlledPaymentAutomatonRunner;
+ this.paymentStateMachineHelper = paymentStateMachineHelper;
+ this.retrySMHelper = retrySMHelper;
+ this.accountInternalApi = accountInternalApi;
+ this.pluginRegistry = pluginRegistry;
+ this.locker = locker;
}
+ /*
+ public IncompletePaymentAttemptTask(final InternalCallContextFactory internalCallContextFactory,
+ final PaymentConfig paymentConfig,
+ final PaymentDao paymentDao,
+ final Clock clock,
+ final PaymentStateMachineHelper paymentStateMachineHelper,
+ final PaymentControlStateMachineHelper retrySMHelper,
+ final AccountInternalApi accountInternalApi,
+ final PluginControlPaymentAutomatonRunner pluginControlledPaymentAutomatonRunner,
+ final OSGIServiceRegistration<PaymentPluginApi> pluginRegistry,
+ final GlobalLocker locker) {
+
+
+ public IncompletePaymentTransactionTask(final InternalCallContextFactory internalCallContextFactory, final PaymentConfig paymentConfig,
+ final PaymentDao paymentDao, final Clock clock,
+ final PaymentStateMachineHelper paymentStateMachineHelper, final PaymentControlStateMachineHelper retrySMHelper, final AccountInternalApi accountInternalApi,
+ final OSGIServiceRegistration<PaymentPluginApi> pluginRegistry, final GlobalLocker locker) {
+
+ */
+
public void initialize() throws NotificationQueueAlreadyExists {
janitorQueue = notificationQueueService.createNotificationQueue(DefaultPaymentService.SERVICE_NAME,
QUEUE_NAME,
@@ -90,6 +146,29 @@ public class Janitor {
}
}
);
+
+ this.incompletePaymentAttemptTask = new IncompletePaymentAttemptTask(internalCallContextFactory,
+ paymentConfig,
+ paymentDao,
+ clock,
+ paymentStateMachineHelper,
+ retrySMHelper,
+ accountInternalApi,
+ pluginControlledPaymentAutomatonRunner,
+ pluginRegistry,
+ locker);
+
+ this.incompletePaymentTransactionTask = new IncompletePaymentTransactionTask(internalCallContextFactory,
+ paymentConfig,
+ paymentDao,
+ clock,
+ paymentStateMachineHelper,
+ retrySMHelper,
+ accountInternalApi,
+ pluginRegistry,
+ locker);
+
+
incompletePaymentTransactionTask.attachJanitorQueue(janitorQueue);
incompletePaymentAttemptTask.attachJanitorQueue(janitorQueue);
}
diff --git a/payment/src/main/java/org/killbill/billing/payment/glue/PaymentModule.java b/payment/src/main/java/org/killbill/billing/payment/glue/PaymentModule.java
index b249c8b..c9a0c74 100644
--- a/payment/src/main/java/org/killbill/billing/payment/glue/PaymentModule.java
+++ b/payment/src/main/java/org/killbill/billing/payment/glue/PaymentModule.java
@@ -92,8 +92,6 @@ public class PaymentModule extends KillBillModule {
}
protected void installJanitor() {
- bind(IncompletePaymentTransactionTask.class).asEagerSingleton();
- bind(IncompletePaymentAttemptTask.class).asEagerSingleton();
bind(Janitor.class).asEagerSingleton();
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/dispatcher/TestPluginDispatcher.java b/payment/src/test/java/org/killbill/billing/payment/dispatcher/TestPluginDispatcher.java
index 86365e5..835df39 100644
--- a/payment/src/test/java/org/killbill/billing/payment/dispatcher/TestPluginDispatcher.java
+++ b/payment/src/test/java/org/killbill/billing/payment/dispatcher/TestPluginDispatcher.java
@@ -26,16 +26,27 @@ import org.killbill.billing.ErrorCode;
import org.killbill.billing.payment.PaymentTestSuiteNoDB;
import org.killbill.billing.payment.api.PaymentApiException;
import org.killbill.billing.payment.dispatcher.PluginDispatcher.PluginDispatcherReturnType;
+import org.killbill.commons.profiling.Profiling;
import org.killbill.commons.request.Request;
import org.killbill.commons.request.RequestData;
import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestPluginDispatcher extends PaymentTestSuiteNoDB {
- private final PluginDispatcher<Void> voidPluginDispatcher = new PluginDispatcher<Void>(10, paymentExecutors);
+ private PluginDispatcher<Void> voidPluginDispatcher;
+
+ private PluginDispatcher<String> stringPluginDispatcher;
+
+ @BeforeMethod(groups = "fast")
+ public void beforeMethod() throws Exception {
+ super.beforeMethod();
+ eventBus.start();
+ voidPluginDispatcher = new PluginDispatcher<Void>(10, paymentExecutors);
+ stringPluginDispatcher = new PluginDispatcher<String>(1, paymentExecutors);
+ }
- private final PluginDispatcher<String> stringPluginDispatcher = new PluginDispatcher<String>(1, paymentExecutors);
@Test(groups = "fast")
public void testDispatchWithTimeout() throws TimeoutException, PaymentApiException {
diff --git a/payment/src/test/java/org/killbill/billing/payment/PaymentTestSuiteNoDB.java b/payment/src/test/java/org/killbill/billing/payment/PaymentTestSuiteNoDB.java
index 8c45a5a..9af2ee5 100644
--- a/payment/src/test/java/org/killbill/billing/payment/PaymentTestSuiteNoDB.java
+++ b/payment/src/test/java/org/killbill/billing/payment/PaymentTestSuiteNoDB.java
@@ -103,11 +103,13 @@ public abstract class PaymentTestSuiteNoDB extends GuicyKillbillTestSuiteNoDB {
@BeforeMethod(groups = "fast")
public void beforeMethod() throws Exception {
eventBus.start();
+ paymentExecutors.initialize();
Profiling.resetPerThreadProfilingData();
}
@AfterMethod(groups = "fast")
public void afterMethod() throws Exception {
+ paymentExecutors.stop();
eventBus.stop();
}
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/PaymentTestSuiteWithEmbeddedDB.java b/payment/src/test/java/org/killbill/billing/payment/PaymentTestSuiteWithEmbeddedDB.java
index aefb209..14072c3 100644
--- a/payment/src/test/java/org/killbill/billing/payment/PaymentTestSuiteWithEmbeddedDB.java
+++ b/payment/src/test/java/org/killbill/billing/payment/PaymentTestSuiteWithEmbeddedDB.java
@@ -90,6 +90,7 @@ public abstract class PaymentTestSuiteWithEmbeddedDB extends GuicyKillbillTestSu
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
+ paymentExecutors.initialize();
eventBus.start();
Profiling.resetPerThreadProfilingData();
clock.resetDeltaFromReality();
@@ -99,5 +100,6 @@ public abstract class PaymentTestSuiteWithEmbeddedDB extends GuicyKillbillTestSu
@AfterMethod(groups = "slow")
public void afterMethod() throws Exception {
eventBus.stop();
+ paymentExecutors.stop();
}
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java b/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java
index 8303dc6..1753af8 100644
--- a/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java
+++ b/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java
@@ -114,20 +114,17 @@ public class TestJanitor extends PaymentTestSuiteWithEmbeddedDB {
protected void beforeClass() throws Exception {
super.beforeClass();
mockPaymentProviderPlugin = (MockPaymentProviderPlugin) registry.getServiceForName(MockPaymentProviderPlugin.PLUGIN_NAME);
- paymentExecutors.initialize();
- janitor.initialize();
- janitor.start();
}
@AfterClass(groups = "slow")
protected void afterClass() throws Exception {
- janitor.stop();
- paymentExecutors.stop();
}
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
+ janitor.initialize();
+ janitor.start();
eventBus.register(handler);
testListener.reset();
eventBus.register(testListener);
@@ -137,6 +134,7 @@ public class TestJanitor extends PaymentTestSuiteWithEmbeddedDB {
@AfterMethod(groups = "slow")
public void afterMethod() throws Exception {
+ janitor.stop();
eventBus.unregister(handler);
eventBus.unregister(testListener);
super.afterMethod();