The payment-cdi-event quickstart demonstrates how to use CDI Events in Red Hat JBoss Enterprise Application Platform.
The JSF front-end client allows you to create both credit and debit operation events.
To test this quickstart, enter an amount, choose either a Credit or Debit operation, and then click on Pay to create the event.
A Session scoped (@SessionScoped) payment event handler catches the operation and produces (@Produces) a named list of all operations performed during this session. The event is logged in the JBoss EAP server log and the event list is displayed in a table at the bottom of the form.
The payment-cdi-event quickstart defines the following classes:
A session scoped bean that stores the payment form information:
operation type: debit or credit
It contains the following utilities methods:
public String pay(): Process the operation when the user clicks on submit. We have only one JSP page, so the method does not return anything and the flow of control doesn't change.
public void reset(): Clear the payment form data.
PaymentEvent: We have only one Event. It handles both credit and debit operations. Qualifiers help us to make the difference at injection point.
PaymentTypeEnum: A typesafe enum is used to represent the operation payment type. It contains utility methods to convert between String and Enum.
The qualifiers package contains the Credit and Debit classes. The annotation determines the operation of injecting Event.
The handler package containss Interfaces and implementations of PaymentEvent Observers.
ICreditEventObserver: Interface to listen to CREDIT Event Only (@Observes @Credit).
IDebitEventObserver: Interface to listen to DEBIT Event (@Observes @Debit).
The concrete implementation of the payment handler, it implements both IcreditEventObserver and IDebitEventObserver.
The payment handler exposes the list of events caught during a session ( @Named name=payments).
The application this project produces is designed to be run on Red Hat JBoss Enterprise Application Platform 7 or later.
All you need to build this project is Java 8.0 (Java SDK 1.8) or later and Maven 3.1.1 or later. See Configure Maven for JBoss EAP 7 to make sure you are configured correctly for testing the quickstarts.
If you want to debug the source code of any library in the project, run the following command to pull the source into your local repository. The IDE should then detect it.
Aug 20, 2015(Sande Gilda):JBEAP 577 Replace links to shared resources for JBoss EAP 7 material
Aug 6, 2015(Sande Gilda):JBEAP 613 Replace s JBoss console JBoss EAP server log
Aug 4, 2015(Sande Gilda):JBEAP 578 Update Maven version in README files
Aug 3, 2015(Sande Gilda):JBEAP 564 Clarify Maven instructions
Jul 23, 2015(Sande Gilda):Replace CONFIGURE_MAVEN link with CONFIGURE_MAVEN_JBOSS_EAP7 link
Jun 24, 2015(Sande Gilda):JDF833 Plugin commands have changed from jboss as prefix to wildfly prefix. jboss as deploy is now wildfly deploy and jboss as undeploy is now wildfly undeploy. Same replacement for port and hostname
Jun 17, 2015(Sande Gilda):Update the quickstart README files to remove instructions related to the Maven settings
Jun 2, 2015(Sande Gilda):Update quickstart files to remove JBoss EAP version and update to Java EE 7 and SDK 1.8. Replace references to WFK and Sandbox with EAP
Mar 4, 2015(Sande Gilda):Bz1198744 Update README JBDS instructions to be more clear
Feb 3, 2015(Sande Gilda):Update the quickstart README files to point to the new shared EAP_HOME and Build and Deploy instructions