GithubHelp home page GithubHelp logo

vicenthy / library Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arthurgregorio/library

0.0 1.0 0.0 1.19 MB

Simple app to show how to work with Jee standard frameworks

License: Apache License 2.0

Java 54.52% TSQL 8.01% HTML 34.55% CSS 2.34% JavaScript 0.58%

library's Introduction

Library

A simple demo application to show how to work with the default technologies of JavaEE version 8 (or higher). This conceptual architecture makes use of the following technologies:

  • Java 11 and Java EE 8 with Wildfly 14+ and PostgreSQL 10+
  • Hibernate 5 for JPA 2.2
  • Weld 3.0 for CDI 2.0
  • Mojarra for JSF 2.3 + Primefaces 7 + AdminLTE 2.4 + Bootstrap 3
  • Apache Delta Spike JPA and Data Module for database querying and repositories management
  • Apache Shiro 1.4 through ShiroEE for Security with LDAP/AD and database authentication support
  • Maven for dependency management and build
  • Flyway 5.2 for database migrations
  • Database audit with Hibernate Envers 5
  • Hibernate Validator for Bean Validation
  • Omnifaces 3 and PrimefacesExt for JSF utilities
  • Jackson for JSON support
  • Lombok, Google Guava and Apache Commons-lang for class level utilities
  • Mustache for e-mail templating
  • Webservices with JAX-RS (RestEasy)

The demo makes use of a custom implementation of AdminLTE integrated with Boostrap 3 and Primefaces for a better UI experience, modern features and mobile support.

Also, inside the application you can find (already functional) a simple CRUD of Users and User Groups with authentication, permission based authorization, all integrated with LDAP/AD and/or local accounts.

It's not much say, that if you want a production ready architecture, this is the project you are looking for.

How to: configure

First of all, you will need to download the latest version of Wildfly application server. This is the homologated version, maybe, with a little bit of changes or no you can run this on Payara, Glassfish or any other JEE 7+ server.

Download Wildfly here and configure the datasource for the application by editing the standalone.xml or standalone-full.xml (you will know which one to change) to add this lines to the datasource section in the file:

<datasource jta="true" jndi-name="java:/datasources/LibraryDS" pool-name="LibraryDS" enabled="true" use-ccm="false">
    <connection-url>jdbc:postgresql://localhost:5432/library</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <driver>postgresql</driver>
    <pool>
        <min-pool-size>10</min-pool-size>
        <initial-pool-size>5</initial-pool-size>
        <max-pool-size>30</max-pool-size>
        <prefill>true</prefill>
        <flush-strategy>AllInvalidIdleConnections</flush-strategy>
    </pool>
    <security>
        <user-name>sa_library</user-name>
        <password>sa_library</password>
    </security>
    <validation>
        <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
        <check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
        <background-validation>true</background-validation>
        <use-fast-fail>true</use-fast-fail>
        <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
    </validation>
</datasource>

Quick note: the datasource will not work if you don't have the PostgreSQL driver enabled in the wildfly modules. To do this, follow this blog post.

If you want to send e-mails, these lines should be added to the mail subsystem (search for mail-session):

Quick note: if you are looking for a good fake/development e-mail provider, I can indicate mailtrap

<mail-session name="my-email" debug="true" jndi-name="java:/mail/library" from="[email protected]">
    <smtp-server outbound-socket-binding-ref="my-email-socket" username="[email protected]" password="my-secret"/>
</mail-session>

And the e-mail socket to the socket-binding-group at the end of the file:

<outbound-socket-binding name="my-email-socket">
    <remote-destination host="my-email-server.com" port="587"/>
</outbound-socket-binding>

After this, create the database on you local instance of PostgreSQL 10+ to match the Wildfly configurations and enable the deployment of the application:

-- the user
CREATE USER sa_library WITH
  LOGIN
  NOSUPERUSER
  INHERIT
  NOCREATEDB
  NOCREATEROLE
  NOREPLICATION
  ENCRYPTED PASSWORD 'sa_library';
 
 -- the databse
 CREATE DATABASE library
    WITH 
    OWNER = sa_library
    ENCODING = 'UTF8'
    LC_COLLATE = 'en_US.utf8'
    LC_CTYPE = 'en_US.utf8'
    TABLESPACE = pg_default
    CONNECTION LIMIT = -1;

The tables and the initial data (default user, group and authorizations) should be created by Flyway with the migrations strategy. If you want to run this application in development mode, Hibernate will create the tables, but you must create the schemes by hands on PgAdmin or other similar software:

CREATE SCHEMA configuration AUTHORIZATION sa_library;
CREATE SCHEMA registration AUTHORIZATION sa_library;
CREATE SCHEMA configuration_audit AUTHORIZATION sa_library;
CREATE SCHEMA registration_audit AUTHORIZATION sa_library;

How to: run on IDE

Just import the maven project and deploy to you (already configured) Wildfly server. Remember: first configure the datasource because application will not start if it is missing.

How to: run by hands

Build the project. On the root folder run:

mvn clean package -Prelease

If no profile is used, this will tell maven to build the development version with no migrations and the database need to be initialized manually like said above.

The build configuration also have other profiles for you to configure according your need:

  • BETA for beta releases, testing the software
  • RC for candidate releases, feature validation/approving purpose
  • RELEASE for the final, production ready, releases

After the build, open the wildfly admin console on the web browser and in the deployments section, upload the war file created by the build in the target folder (named library-1.0.0-(selected-profile)) inside the project and access it on the default URL: https://localhost:8443/, and you're done! Enjoy the demo.

library's People

Contributors

arthurgregorio avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.