Java ee modular application

I need to reorganize the Java EE application because the current design is not very modular, it is actually quite a mess. There is a business facade, but since the application was developed by several people, and therefore the initial design was ignored several times. The app currently runs on tomcat with JSF, but will be ported to websphere soon. I have already done some research on various design patterns to encapsulate business logic from a view, as well as how to make a modular application so that it is easy to add more functionality because the application will be improved in the future. I read about OSGI, but I think that would be redundant.

The application is already layered. But I am far from defining an API. I already cleaned up the application a bit. Now all beans access business logic through business facade methods. But the business facade consists of about 40 methods, which, I think, are not very pleasant.

Third Party Editing

For example, I have these model classes

  • ManageLdap using methods like createAccount and deleteAccount
  • GroupManager that manages ldap groups

In the business facade, I have a createAccount method that

  • calls the ManagerLdap class to create an ldap account and
  • performs some recordings as well
  • calls GroupManager

This pseudo code

 package Model.ManageLdap public class ManageLdap { public ldapAccount createAccount() { } public ldapAccount deleteAccount() { } } public class GroupManager { public bool addAccountToGroup(var account) { } } 

And in the business facade

 package BusinessFacade.Foo public class SomeFoo { public ldapAccount createAccount() { var ldapAccount = new ManageLdap.createAccount(); Logger.log("Account created"); var accountWasAdded = GroupManager.addAccountToGroup(ldapAccount); } } 

Now, if I want to add additional features to the application, for example, create a subversion repository for the user

  • I need to implement a model class to create repositories,
  • enter some methods in the business facade and
  • Create an additional bean to access the view.

This makes the facade even larger and more confusing, but beyond that, this is not what I call modular design.

So, how can I separate business logic from presentation without a huge business facade?

+6
source share
1 answer

First, try to break the application into several layers, for example:

  • DAO
  • Devices
  • Security
  • View
  • Etc.

Then extract some API from each level (for example, dao-api, service-api, etc. Each of the api modules must have a set of interfaces).

Then create a set of modules (e.g. service-api , service-impl , dao-api , dao-impl ) and enable some build tool ( gradle or maven ) to manage them.

Do not allow one implementation module to be dependent on another implementation module (only impl β†’ api or api β†’ api).

Each jar file separated by a module.

After such refactoring in the future, it will be much more difficult to break the design of the application.

+3
source

All Articles