This project provides a Web interface portal for end-users to work with the loan approval process of the fictitious WestBank. Besides, for testing purpose it also includes the Web services that provide necessary business functions used by the loan approval process.
- SOAP/Web Services (WSDL/XML/SOAP/HTTP) implemented using JAX-WS / Apache CXF on top of Spring Framework
- Spring MVC
- JPA / Hibernate on top of an RDBMS with HikariCP for JDBC connection pooling.
- H2, Apache Derby, HyperSQL, MySQL, PostgreSQL have been included and tested but any RDBMS can be also used with extra configuration effort
- Logback and Simple Logging Facade for Java (SLF4J) for efficient logging
- Apache Maven for dependency management, building, packaging, and deployment
The portal can be deployed as an application (*.war) in a Web application server such as Apache Tomcat, Eclipse Jetty, JBoss Wildfly AS, etc. Nevertheless, we can directly run it at the command line.
Go to the project folder and proceed with the following command.
mvn jetty:runThen open a Web browser to http://localhost:9999/portal for the portal main page.
Some other pages for development/testing
-
Verifying the underlying database (see
com.westbank.web.DevController) : http://localhost:9999/portal/dev.html -
Checking the list of running Web services: http://localhost:9999/portal/services
-
To login as a staff (manager, supervisor, clerk, or broker), go to page: http://localhost:9999/portal/staff/login.html
-
Note: ID and password for staff are temporarily listed in page http://localhost:9999/portal/dev.html
mvn -DskipTests clean packageAs switching to XML-less configurations with Servlet 3.0+, the main web application configuration is PortalWebApplicationInitializer instead of the traditional WEB-INF/web.xml.
PortalWebApplicationInitializerfirst loads the root context and registers two configurationsPersistenceConfiguration(for data access) andServiceConfiguration(for publishing Web/SOAP services)- Then it registers a child context with
AnnotationConfigWebApplicationContextfor the SpringDispatcherServletAnnotationConfigWebApplicationContextregisters the MVC configuration inWebMvcConfigurationDispatcherServletwill serve all*.htmland/portal/*
PortalWebApplicationInitializerwill also load another servletCXFServletto serve the Web/SOAP services at/services/*
The configuration for Spring MVC is in WebMvcConfiguration:
-
It implements
WebMvcConfigurerand is annotated with@EnableWebMvc(equivalent to<mvc:annotation-driven />in Spring XML) -
It enables default servlet handling
-
It adds ResourceHandlers to serve
/resources/ -
It configures view resolvers to serve JSP/JSTL at
/WEB-INF/view/and for.jsp -
It configures
MessageSourceto serve multiple languages ati18n/messages-XXX.properties
-
Other resources like CSSs, images, and JavasSripts are in the folders
src/main/webapp/[css | images | js ]. -
src/main/resources/i18n/messages.propertiesfor the information displayed to the customers such as success and error notifications. -
src/main/resources/logback.xmlfor Logback
-
Data manipulation and persistence are done using Spring JPA / Hibernate configured via
PersistenceConfiguration.- Annotated with
@Configuration@EnableJpaRepositories,@EnableTransactionManagement,@ComponentScan - Defines
javax.sql.DataSourcewith the underlyling implementationHikariDataSourceof HikariCP - Defines
entityManagerFactorywithLocalContainerEntityManagerFactoryBean - Defines JPA TransactionManager / Java Transaction API (JTA) with
JpaTransactionManager - Defines a
DataSourceInitializerto set up some data using the scriptload-user-and-role.sql
- Annotated with
-
Domain entities are annotated with JPA conventions in
com.westbank.domain -
Data repositories are in
com.westbank.repositoryfor manipulating the underlying data/objects usingEntityManager -
Data services (including some business logic) are in
com.westbank.serviceworking on top of the repositories -
The currently used RDBMS is in-memory H2 for minimal memory footprint. Nevertheless, any other RDBMS can be used as well. In order to use other RDBMSs instead, just please note the following points:
- Create a database name
WESTBANKDB - Create a user
westbankwith passwordsecretand assign that user to the database or use your preferred values and updatehibernate.propertiesaccordingly - Add necessary Maven dependencies for the new RDBMS in
pom.xml. - Issue the command
mvn jetty:runto check if the Web application works. - In case of problems, tune the verbosity in
logback.xmlfor debugging.
- Create a database name
This project also includes some Web services using JAX-WS / Apache CXF to provide the business functions needed by the loan approval process. These Web service interfaces (*.wsdl) are in the folder WEB-INF/wsdl.
- Business services -- functions provided by the underlying IT infrastructure.
| +-- BankInformation.wsdl +-- BankPrivilege.wsdl +-- CreditWorthiness.wsdl +-- LoanApprovalClosing.wsdl +-- LoanFile.wsdl +-- LoanContract.wsdl +-- LoanContractSigning.wsdl +-- LoanRisk.wsdl +-- LoanSettlement.wsdl +-- TaskDispatch.wsdl - Call back services -- called back by the loan approval process when it wants to notifies the customers or finishes
|
+-- CallbackLoanContract.wsdl
+-- CallbackLoanApproval.wsdl
Apache CXF's cxf-codegen-plugin Maven plugin is used to generate Java code from the aforementioned services (i.e. contract-first service development). The generated Java sources are under the base package com.westbank.ws.
The m2eclipse plugin that supports Maven in Eclipse will invoke the Apache CXF
cxf-codegen-pluginwhenever you import this project into Eclipse,the existing generated stuffs will be unnecessarily overwritten. Thus, the plugin is currently disabled. Whenever any WSDL is modified, please enable this plugin and execute the commandmvn generate-sourcesto re-generate the Java code.
The actual implementation of the business logic of each Web service is in the corresponding Java class named com.westbank.ws.impl.XXXImpl in which 'XXX' is the name of that Web service. In order to alter these services, have a look into the folder WEB-INF/wsdl. After modifying the WSDLs, just run mvn clean generate-sources to re-generate Java code.
The configuration for publishing Web services using Apache CXF and Spring is provided in ServiceConfiguration loaded by the root application context. It in turn loads the service bean definitions in ServiceBeans.
As the Web application is running, open a Web browser at http://localhost:9999/portal/services to see a list of running Web services.
For further testing and demonstration purposes, some special values are hard-coded in the Web services logics:
- If the borrower's last name is "Power", the privilege is ok, i.e., the number of incidents is 0, the number of banks is 0 (see
com.westbank.ws.impl.BankPrivilegeImpl) - The monthly payment is calculated according to a provided formula (see
com.westbank.ws.impl.BankInformationImpl) - If choosing the EstateType as HOUSE, then the return risk evaluation is HIGH (see
com.westbank.ws.impl.LoanRiskImpl) - If the loan amount < 1 million, then the role will be CLERK, otherwise, SUPERVISOR (see
com.westbank.ws.impl.TaskDispatchImpl) - If the borrower's first name is "Alice", the CreditWorthinessOK is
true, otherwise,false(seecom.westbank.ws.impl.CreditWorthinessImpl)