Skip to content

Instantly share code, notes, and snippets.

@danveloper
Created May 29, 2013 18:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danveloper/5672710 to your computer and use it in GitHub Desktop.
Save danveloper/5672710 to your computer and use it in GitHub Desktop.
Registration - "Redefining the Service Layer with Groovy Categories"
class LocalPaymentService implements PaymentService {
static {
use (PaymentTypeHandlerRegistrationCategory) {
CreditCardPaymentType.register(CreditCardPaymentProcessor)
GiftCardPaymentType.register(GiftCardPaymentProcessor)
EmployeePaymentType.register(EmployeePaymentProcessor)
CheckPaymentType.register(CheckPaymentProcessor)
}
}
public String process(PaymentType paymentType) {
// ...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment