Adempiere Architecture 3 tier

From ADempiere ERP Wiki

Jump to: navigation, search

About "Currently I am doing a basic example to ADempiere use JPA , WebServices and Client GWT to show how it works this this architecture."

I believe it is better to share the process and create this basic example so we can have all the perspectives.

My Idea and answer is also to Colin:

Contents

Setup Tools

1-Tier

Overview

The current model of Compiere to manage the persistence using the class PO and all the model classes create form database. Well, to migrate all this classes to JPA I only have to do some changes into the generate Model and add some lines to generate every annotation to implement JPA.

Setup Environment

2-Tier

Overview

The current model of compiere to manage the business logic uses the classes MClass , Workflow , Process ,Callouts , Validation Rules. The purpose is that MClass can be the EJB or Web Service we can choose any option as is convenient for us.

It is convenient to say that:

In JEE 5 is very easy to create an EJB or WEB Service,we only need set the correspondent annotation , ie: (@Remote,@Stateful,@Remove,@WebService,@Remove)

Example the EJB:

 package com.sun.tutorial.javaee.ejb;
 import java.util.List;
 import javax.ejb.Remote;
 
 @Remote
 public interface Cart {
  public void initialize(String person) throws BookException;
  public void initialize(String person, String id)
    throws BookException;
  public void addBook(String title);
  public void removeBook(String title) throws BookException;
  public List<String> getContents();
  public void remove();
 }
 
 package com.sun.tutorial.javaee.ejb;
 
 import java.util.ArrayList;
 import java.util.List;
 import javax.ejb.Remove;
 import javax.ejb.Stateful;
 
 @Stateful
 public class CartBean implements Cart {
  String customerName;
  String customerId;
  List<String> contents;
 
  public void initialize(String person) throws BookException {
    if (person == null) {
      throw new BookException("Null person not allowed.");
    } else {
      customerName = person;
    }
 
    customerId = "0";
    contents = new ArrayList<String>();
  }
 
  public void initialize(String person, String id)
        throws BookException {
    if (person == null) {
      throw new BookException("Null person not allowed.");
    } else {
 
      customerName = person;
    }
 
    IdVerifier idChecker = new IdVerifier();
 
    if (idChecker.validate(id)) {
      customerId = id;
    } else {
      throw new BookException("Invalid id: " + id);
    }
 
    contents = new ArrayList<String>();
  }
 
  public void addBook(String title) {
    contents.add(title);
  }
 
  public void removeBook(String title) throws BookException {
    boolean result = contents.remove(title);
    if (result == false) {
      throw new BookException(title + " not in cart.");
    }
  }
 
  public List<String> getContents() {
    return contents;
  }
 
  @Remove
  public void remove() {
    contents = null;
  }
 }

Example web Service

 package helloservice.endpoint;
 
 import javax.jws.WebService;
 
 @WebService
 public class Hello {
 private String message = new String("Hello, ");
 
 public void Hello() {}
 
 @WebMethod
 public String sayHello(String name) {
   return message + name + ".";
 } 
} 

As we can see an ejb also will be called as web service setting the correspondent annotation, you can see to more detail http://java.sun.com/javaee/5/docs/tutorial/doc/EJBConcepts5.htmlwp80011

But, we currently have a problem with Adempiere: if we want to modify the business logic we have to create a callout or process but it is necessary to create a new java class and compile it, we need to change the business logic in hot. This is only possible with Validation Rules (limited only to SQL), Workflow , Process (limited only to PLSQL), my idea is to use a good script engine where we can create new business logic in hot, I am thinking in http://jakarta.apache.org/bsf/index.html.

I also think that add every persistent class must implement an inspector to validate any business Rule created into Application Dictionary. That is to say, you can imagine a web service or ejb (MClass) with an inspector to validate (AfterSave , BeforeSave , AfterDelete , BeforeDelete) and you can include it into a business logic from Application Dictionary in hot ( more detail http://developers.sun.com/learning/javaoneonline/2006/coreenterprise/TS-1365.pdf)

Setup Environment

3-Tier

Overview

Well to the 3-Tier we need a good client that,

  • Has a User interface focused in the easy, intuitive use , attractive and well organized.
  • Keep just one application client.
  • Keep the client really light
  • Uses an engine to build maintenance screens based on the AD
  • Just gets the information that the user is asking for
  • Captures high volume of data in a simple, multiple and mixed way.
  • Must be a universal client (any internet browser)
  • Uses Java programming language

In my analysis I searched many alternatives (JSP, Servlet, Struts, etc), but I wanted to look toward the future so I choose AJAX, so with AJAX we have many frameworks (Zimbra, DWR, ZK, Echo2, GWT)

I choose the GWT because:

The 3 tier will be in communication with 2 tier using Remote Procedure Calls.

finally you will say: all this is fine, but the forced question is does it work?

the answer is yes, it works, you can see:

Setup Environment

Personal tools