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.
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.
PortalWebApplicationInitializer first loads the root context and registers two configurations PersistenceConfiguration (for data access) and ServiceConfiguration (for publishing Web/SOAP services)AnnotationConfigWebApplicationContext for the Spring DispatcherServlet
AnnotationConfigWebApplicationContext registers the MVC configuration in WebMvcConfiguration
DispatcherServlet will serve all *.html and /portal/*
PortalWebApplicationInitializer will also load another servlet CXFServlet to serve the Web/SOAP services at /services/*
The configuration for Spring MVC is in WebMvcConfiguration:
It implements WebMvcConfigurer and 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 MessageSource to serve multiple languages at i18n/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.properties for the information displayed to the customers such as success and error notifications.
src/main/resources/logback.xml for Logback
Data manipulation and persistence are done using Spring JPA / Hibernate configured via PersistenceConfiguration.
@Configuration @EnableJpaRepositories, @EnableTransactionManagement, @ComponentScan
javax.sql.DataSource with the underlyling implementation HikariDataSource of HikariCPentityManagerFactory with LocalContainerEntityManagerFactoryBean
JpaTransactionManager
DataSourceInitializer to set up some data using the script load-user-and-role.sql
Domain entities are annotated with JPA conventions in com.westbank.domain
Data repositories are in com.westbank.repository for manipulating the underlying data/objects using EntityManager
Data services (including some business logic) are in com.westbank.service working 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:
WESTBANKDB
westbank with password secret and assign that user to the database or use your preferred values and update hibernate.properties accordinglypom.xml.mvn jetty:run to check if the Web application works.logback.xml for debugging.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.
|
+-- BankInformation.wsdl
+-- BankPrivilege.wsdl
+-- CreditWorthiness.wsdl
+-- LoanApprovalClosing.wsdl
+-- LoanFile.wsdl
+-- LoanContract.wsdl
+-- LoanContractSigning.wsdl
+-- LoanRisk.wsdl
+-- LoanSettlement.wsdl
+-- TaskDispatch.wsdl
|
+-- 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:
com.westbank.ws.impl.BankPrivilegeImpl)com.westbank.ws.impl.BankInformationImpl)com.westbank.ws.impl.LoanRiskImpl)com.westbank.ws.impl.TaskDispatchImpl)true, otherwise, false (see com.westbank.ws.impl.CreditWorthinessImpl)