Thursday, 26 March 2015

Multi-module Java EE web application

The subject of the application is simple examination tool. User can configure answers to questions 'Administrate answers' and then 'Take an exam'.

Run the example application:

To implement a starter example I've chosen:

  - Java,
  - EJB,
  - JBoss,
  - Maven,
  - Struts 2 (+Conventions Plugin)

I divided an application into following modules

- exam-business-logic-api - interfaces on which depend ejb and web modules,
- exam-business-logic - ejb module with business logic implementation,
- exam-business-logic-ear - ear with business logic (intentionally deployed separately to test remote communication - in JBoss 7 each deployment unit classes are loaded using different Class Loader),
- exam-web - web application based on Struts 2 framework (whole configured with Conventions Plugin), also deployed separately as war.

Application has been implemented using Struts2 MVC framework . I configured actions with annotations solely (dependency on Struts 2 Conventions Plugin). I also followed Post-Redirect-Get web design pattern.

You can configure exam questions in business logic module:

@Stateless(mappedName = "ExamQuestionsService")
public class ExamQuestionsServiceBean implements ExamQuestionsService {
    public List<ExamQuestion> getExamQuestions() {
        ExamQuestion examQuestion1 = new ExamQuestion();
        examQuestion1.setQuestion("What is the current version of Struts?");
        ExamQuestion examQuestion2 = new ExamQuestion();
        examQuestion2.setQuestion("How many principles are in S.O.L.I.D.?");
        ExamQuestion examQuestion3 = new ExamQuestion();
        examQuestion3.setQuestion("Software design pattern in which an (..)");
        List result = new ArrayList();
        return result;

To review or clone an example please visit my exam GitHub repository. Instructions of building and deploying are attached in README file.

 GitHub repository of this starter application

I've deployed ear and war artifacts on RedHat OpenShift (examstarter application).

No comments: