33A simple demo application to show how to work with the default technologies of JavaEE version 8 (or higher). This conceptual
44architecture makes use of the following technologies:
55
6- - Java 11 and Java EE 8 with Wildfly 14+ and PostgreSQL 10+
7- - Hibernate 5 for JPA 2.2
6+ - Java 13+
7+ - JavaEE 8 with Thorntail 2.6
8+ - PostgreSQL 11+
9+ - Hibernate 5 and JPA 2.2
810- Weld 3.0 for CDI 2.0
9- - Mojarra for JSF 2.3 + Primefaces 7 + AdminLTE 2.4 + Bootstrap 3
10- - Apache Delta Spike JPA and Data Module for database querying and repositories management
11- - Apache Shiro 1.4 through [ ShiroEE] ( https://github.com/arthurgregorio/shiro-ee ) for Security with LDAP/AD and database
12- authentication support
11+ - Mojarra for JSF 2.3 + Primefaces 7 + [ AdminLTE] ( https://adminlte.io/ ) 2.4 + Bootstrap 3
12+ - Apache Delta Spike JPA + QueryDSL
13+ - Apache Shiro 1.4 provided by [ ShiroEE] ( https://github.com/arthurgregorio/shiro-ee ) extension
14+ - LDAP and Active Diretory integration for user authentication
1315- Maven for dependency management and build
14- - Flyway 5.2 for database migrations
16+ - Flyway 6 for database migrations
1517- Database audit with Hibernate Envers 5
16- - Hibernate Validator for Bean Validation
17- - Omnifaces 3 and PrimefacesExt for JSF utilities
18- - Jackson for JSON support
18+ - Hibernate Validator 6 for Bean Validation
19+ - Omnifaces 3 and Primefaces Extensions for JSF utilities
1920- Lombok, Google Guava and Apache Commons-lang for class level utilities
2021- Mustache for e-mail templating
2122- Webservices with JAX-RS (RestEasy)
2223
23- The demo makes use of a custom implementation of [ AdminLTE] ( https://adminlte.io/ ) integrated with Boostrap 3 and
24- Primefaces for a better UI experience, modern features and mobile support.
24+ It's not much say that if you want a ** production ready architecture** , this is the project you are looking for.
2525
26- Also, inside the application you can find (already functional) a simple CRUD of Users and User Groups with authentication,
27- permission based authorization, all integrated with LDAP/AD and/or local accounts.
26+ ### Create the database
2827
29- It's not much say, that if you want a ** production ready architecture** , this is the project you are looking for.
30-
31- ## How to: configure
32-
33- First of all, you will need to download the latest version of Wildfly application server. This is the homologated version,
34- maybe, with a little bit of changes ~~ or no~~ you can run this on Payara, Glassfish or any other JEE 7+ server.
35-
36- Download Wildfly [ here] ( http://wildfly.org/downloads/ ) and configure the datasource for the application by editing the
37- ``` standalone.xml ``` or ``` standalone-full.xml ``` (you will know which one to change) to add this lines to the
38- datasource section in the file:
39-
40- ``` xml
41- <datasource jta =" true" jndi-name =" java:/datasources/LibraryDS" pool-name =" LibraryDS" enabled =" true" use-ccm =" false" >
42- <connection-url >jdbc:postgresql://localhost:5432/library</connection-url >
43- <driver-class >org.postgresql.Driver</driver-class >
44- <driver >postgresql</driver >
45- <pool >
46- <min-pool-size >10</min-pool-size >
47- <initial-pool-size >5</initial-pool-size >
48- <max-pool-size >30</max-pool-size >
49- <prefill >true</prefill >
50- <flush-strategy >AllInvalidIdleConnections</flush-strategy >
51- </pool >
52- <security >
53- <user-name >sa_library</user-name >
54- <password >sa_library</password >
55- </security >
56- <validation >
57- <valid-connection-checker class-name =" org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker" />
58- <check-valid-connection-sql >SELECT 1</check-valid-connection-sql >
59- <background-validation >true</background-validation >
60- <use-fast-fail >true</use-fast-fail >
61- <exception-sorter class-name =" org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter" />
62- </validation >
63- </datasource >
64- ```
65-
66- > ** Quick note** : the datasource will not work if you don't have the PostgreSQL driver enabled in the wildfly modules.
67- To do this, follow [ this blog post] ( https://bok.stenusys.com/index.php/2018/02/12/how_to_setup_postgresql_datasource_with_wildfly/ ) .
68-
69-
70- If you want to send e-mails, these lines should be added to the mail subsystem (search for ``` mail-session ``` ):
71-
72- > ** Quick note** : if you are looking for a good fake/development e-mail provider, I can indicate [ mailtrap] ( https://mailtrap.io/ )
73-
74- ``` xml
75- <mail-session name =" my-email" debug =" true" jndi-name =" java:/mail/library" from =" no-reply@my-email-account.com" >
76- <smtp-server outbound-socket-binding-ref =" my-email-socket" username =" my@email-account.com" password =" my-secret" />
77- </mail-session >
78- ```
79-
80- And the e-mail socket to the ``` socket-binding-group ``` at the end of the file:
81-
82- ``` xml
83- <outbound-socket-binding name =" my-email-socket" >
84- <remote-destination host =" my-email-server.com" port =" 587" />
85- </outbound-socket-binding >
86- ```
87-
88- After this, create the database on you local instance of PostgreSQL 10+ to match the Wildfly configurations and enable
89- the deployment of the application:
28+ Before the configuration step, create the database to used by the application:
9029
9130``` sql
9231-- the user
@@ -99,7 +38,7 @@ CREATE USER sa_library WITH
9938 NOREPLICATION
10039 ENCRYPTED PASSWORD ' sa_library' ;
10140
102- -- the databse
41+ -- the database
10342 CREATE DATABASE library
10443 WITH
10544 OWNER = sa_library
@@ -112,37 +51,95 @@ CREATE USER sa_library WITH
11251
11352The tables and the initial data (default user, group and authorizations) should be created by Flyway with the migrations
11453strategy. If you want to run this application in development mode, Hibernate will create the tables, but you must create
115- the schemes by hands on PgAdmin or other similar software:
54+ the schemes manually on PgAdmin or other similar software:
11655
11756``` sql
11857CREATE SCHEMA configuration AUTHORIZATION sa_library;
11958CREATE SCHEMA registration AUTHORIZATION sa_library;
120- CREATE SCHEMA configuration_audit AUTHORIZATION sa_library;
121- CREATE SCHEMA registration_audit AUTHORIZATION sa_library;
12259```
12360
124- ## How to: run on IDE
61+ ### Configure the application
62+
63+ The application provides three profiles to build and configure the application:
64+
65+ - * ALPHA* -for development environments
66+ - * BETA* - for testing environments
67+ - * RELEASE_CANDIDATE* - for validation and final testing (approval of changes)
68+ - * RELEASE* - used in production environments
12569
126- Just import the maven project and deploy to you (already configured) Wildfly server. Remember: first configure the
127- datasource because application will not start if it is missing .
70+ Every profile has his own configurations, it means that you can have separated environments and to activate them you
71+ just need to build the application again .
12872
129- ## How to: run by hands
73+ Below we will configure the RELEASE profile and build a production artifact:
13074
131- Build the project. On the root folder run:
75+ ``` xml
76+ <profile >
77+ <id >release</id >
78+ <properties >
79+ <application .version>${project.version}-RELEASE</application .version>
80+ <application .base-url>https://localhost:8443/</application .base-url>
81+ <skip .tests>false</skip .tests>
82+ <project .stage>Production</project .stage>
83+ <mail .host>my-mail-host</mail .host>
84+ <mail .port>587</mail .port>
85+ <mail .debug>false</mail .debug>
86+ <mail .from-address>noreply@your-domain.com</mail .from-address>
87+ <mail .username>my@account.com</mail .username>
88+ <mail .password>secret</mail .password>
89+ <database .host>localhost</database .host>
90+ <database .port>5432</database .port>
91+ <database .name>library</database .name>
92+ <database .username>sa_library</database .username>
93+ <database .password>sa_library</database .password>
94+ <orm .show_sql>false</orm .show_sql>
95+ <orm .ddl_auto>none</orm .ddl_auto>
96+ <ws .base-url>https://my-webservice-server.com</ws .base-url>
97+ <ws .username>admin</ws .username>
98+ <ws .password>admin</ws .password>
99+ <ws .client-name>admin</ws .client-name>
100+ <ldap .enabled>false</ldap .enabled>
101+ <ldap .url>ldap://localhost</ldap .url>
102+ <ldap .baseDn>OU=Users,DC=arthurgregorio,DC=eti,DC=br</ldap .baseDn>
103+ <ldap .user>CN=bind-user,OU=Applications,DC=arthurgregorio,DC=eti,DC=br</ldap .user>
104+ <ldap .password>my-bind-password</ldap .password>
105+ </properties >
106+ </profile >
107+ ```
132108
133- ``` shell
134- mvn clean package -Prelease
109+ As you can see, just fill the properties with your configurations and build with the command below:
110+
111+ ``` shell script
112+ mvnw clean package -Prelease
135113```
136114
137- If no profile is used, this will tell maven to build the development version with no migrations and the database need
138- to be initialized manually like said above.
115+ > ** Quick tip** !
116+ >
117+ > If you are on Windows, used ``` mvnw.bat ``` and if you are on a linux system, use ``` ./mvnw ```
118+
119+ After the build process, a folder called ``` target ``` should appear and inside you will find the artifacts
120+ ``` library-x.x.x-RELEASE-thorntail.jar ``` and ``` library-x.x.x-RELEASE.war ``` , it means that you are ready to run the
121+ application.
122+
123+ To do that, just use:
124+
125+ ``` shell script
126+ java -jar target/library-x.x.x-RELEASE-thorntail.jar
127+ ```
128+
129+ If you have Java JDK installed, the application will start and should be available on ``` http://localhost:8080/ ``` , the
130+ username and password to access are ``` admin ``` .
131+
132+ > ** Quick tip!**
133+ >
134+ > You can run the application directly from the build process using Thorntail Maven Plugin, just use
135+ > ``` mvn clean package -Prelease thorntail:run ```
136+
137+ ### Running inside the IDE
138+
139+ We use maven to build the application and almost all the IDE on the market have a feature to import maven projects.
139140
140- The build configuration also have other profiles for you to configure according your need:
141+ By that, just import the project and you are ready to go!
141142
142- - * BETA* for beta releases, testing the software
143- - * RC* for candidate releases, feature validation/approving purpose
144- - * RELEASE* for the final, production ready, releases
143+ ### Contact
145144
146- After the build, open the wildfly admin console on the web browser and in the deployments section, upload the war file
147- created by the build in the target folder (named * library-1.0.0-(selected-profile)* ) inside the project and access it on
148- the default URL: https://localhost:8443/ , and you're done! Enjoy the demo.
145+ If you have any problem or want to contact me, send me an e-mail at: contato@arthurgregorio.eti.br
0 commit comments