Skip to content

Commit

Permalink
jaxrs: Add handling for BlockingTransitionInternalEvent in the jaxrs …
Browse files Browse the repository at this point in the history
…completion mechanism
  • Loading branch information
sbrossie committed Feb 27, 2016
1 parent 859e932 commit 3df0b41
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
Expand Up @@ -61,6 +61,7 @@
import org.killbill.billing.entitlement.api.SubscriptionApi; import org.killbill.billing.entitlement.api.SubscriptionApi;
import org.killbill.billing.entitlement.api.SubscriptionApiException; import org.killbill.billing.entitlement.api.SubscriptionApiException;
import org.killbill.billing.entitlement.api.SubscriptionBundle; import org.killbill.billing.entitlement.api.SubscriptionBundle;
import org.killbill.billing.events.BlockingTransitionInternalEvent;
import org.killbill.billing.events.EffectiveSubscriptionInternalEvent; import org.killbill.billing.events.EffectiveSubscriptionInternalEvent;
import org.killbill.billing.events.InvoiceCreationInternalEvent; import org.killbill.billing.events.InvoiceCreationInternalEvent;
import org.killbill.billing.events.NullInvoiceInternalEvent; import org.killbill.billing.events.NullInvoiceInternalEvent;
Expand Down Expand Up @@ -526,11 +527,15 @@ public CompletionUserRequestEntitlement(final UUID userToken) {


@Override @Override
public void onSubscriptionBaseTransition(final EffectiveSubscriptionInternalEvent event) { public void onSubscriptionBaseTransition(final EffectiveSubscriptionInternalEvent event) {

log.info(String.format("Got event SubscriptionBaseTransition token = %s, type = %s, remaining = %d ", log.info(String.format("Got event SubscriptionBaseTransition token = %s, type = %s, remaining = %d ",
event.getUserToken(), event.getTransitionType(), event.getRemainingEventsForUserOperation())); event.getUserToken(), event.getTransitionType(), event.getRemainingEventsForUserOperation()));
} }


@Override
public void onBlockingState(final BlockingTransitionInternalEvent event) {
log.info(String.format("Got event BlockingTransitionInternalEvent token = %s", event.getUserToken()));
}

@Override @Override
public void onEmptyInvoice(final NullInvoiceInternalEvent event) { public void onEmptyInvoice(final NullInvoiceInternalEvent event) {
log.info(String.format("Got event EmptyInvoiceNotification token = %s ", event.getUserToken())); log.info(String.format("Got event EmptyInvoiceNotification token = %s ", event.getUserToken()));
Expand Down
Expand Up @@ -58,7 +58,7 @@ public void unregisterCompletionUserRequestWaiter(final CompletionUserRequest wa
*/ */
@AllowConcurrentEvents @AllowConcurrentEvents
@Subscribe @Subscribe
public void handleSubscriptionevents(final BusInternalEvent event) { public void handleSubscriptionEvents(final BusInternalEvent event) {
final List<CompletionUserRequestNotifier> runningWaiters = new ArrayList<CompletionUserRequestNotifier>(); final List<CompletionUserRequestNotifier> runningWaiters = new ArrayList<CompletionUserRequestNotifier>();
synchronized (activeWaiters) { synchronized (activeWaiters) {
runningWaiters.addAll(activeWaiters); runningWaiters.addAll(activeWaiters);
Expand Down
Expand Up @@ -25,6 +25,7 @@


import org.killbill.billing.events.AccountChangeInternalEvent; import org.killbill.billing.events.AccountChangeInternalEvent;
import org.killbill.billing.events.AccountCreationInternalEvent; import org.killbill.billing.events.AccountCreationInternalEvent;
import org.killbill.billing.events.BlockingTransitionInternalEvent;
import org.killbill.billing.events.BusInternalEvent; import org.killbill.billing.events.BusInternalEvent;
import org.killbill.billing.events.EffectiveSubscriptionInternalEvent; import org.killbill.billing.events.EffectiveSubscriptionInternalEvent;
import org.killbill.billing.events.InvoiceCreationInternalEvent; import org.killbill.billing.events.InvoiceCreationInternalEvent;
Expand Down Expand Up @@ -105,6 +106,9 @@ public void onBusEvent(final BusInternalEvent curEvent) {
case ACCOUNT_CHANGE: case ACCOUNT_CHANGE:
onAccountChange((AccountChangeInternalEvent) curEvent); onAccountChange((AccountChangeInternalEvent) curEvent);
break; break;
case BLOCKING_STATE:
onBlockingState((BlockingTransitionInternalEvent) curEvent);
break;
case SUBSCRIPTION_TRANSITION: case SUBSCRIPTION_TRANSITION:
// We only dispatch the event for the effective date and not the requested date since we have both // We only dispatch the event for the effective date and not the requested date since we have both
// for subscription events. // for subscription events.
Expand Down Expand Up @@ -144,6 +148,11 @@ public void onAccountChange(final AccountChangeInternalEvent curEvent) {
public void onSubscriptionBaseTransition(final EffectiveSubscriptionInternalEvent curEventEffective) { public void onSubscriptionBaseTransition(final EffectiveSubscriptionInternalEvent curEventEffective) {
} }


@Override
public void onBlockingState(final BlockingTransitionInternalEvent curEvent) {

}

@Override @Override
public void onInvoiceCreation(final InvoiceCreationInternalEvent curEvent) { public void onInvoiceCreation(final InvoiceCreationInternalEvent curEvent) {
} }
Expand Down
Expand Up @@ -21,6 +21,7 @@


import org.killbill.billing.events.AccountChangeInternalEvent; import org.killbill.billing.events.AccountChangeInternalEvent;
import org.killbill.billing.events.AccountCreationInternalEvent; import org.killbill.billing.events.AccountCreationInternalEvent;
import org.killbill.billing.events.BlockingTransitionInternalEvent;
import org.killbill.billing.events.BusInternalEvent; import org.killbill.billing.events.BusInternalEvent;
import org.killbill.billing.events.EffectiveSubscriptionInternalEvent; import org.killbill.billing.events.EffectiveSubscriptionInternalEvent;
import org.killbill.billing.events.InvoiceCreationInternalEvent; import org.killbill.billing.events.InvoiceCreationInternalEvent;
Expand All @@ -37,7 +38,9 @@ public interface CompletionUserRequestWaiter {


public void onAccountChange(final AccountChangeInternalEvent curEvent); public void onAccountChange(final AccountChangeInternalEvent curEvent);


public void onSubscriptionBaseTransition(final EffectiveSubscriptionInternalEvent curEventEffective); public void onSubscriptionBaseTransition(final EffectiveSubscriptionInternalEvent curEvent);

public void onBlockingState(final BlockingTransitionInternalEvent curEvent);


public void onInvoiceCreation(final InvoiceCreationInternalEvent curEvent); public void onInvoiceCreation(final InvoiceCreationInternalEvent curEvent);


Expand Down

1 comment on commit 3df0b41

@pierre
Copy link
Member

@pierre pierre commented on 3df0b41 Feb 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.