0

I would like write JEE app in ports and adapters architecture also known as onion, hexagonal or clean architecture. So I would like to inject dependencies by interface and not by implementation. And of course implementation is in separate maven module than interface.

The problem is that wildfly does not support this. Do you know any server that can work in that infrastructure out of the box without any plumbing configuration?

Any help apreciate.

masterdany88
  • 4,009
  • 8
  • 44
  • 114

2 Answers2

1

Ports & Adapters architecture pattern just need a mechanism to inject dependencies applying dependency inversion principle. You can do it even manually when bootstrapping the app. You dont need JEE at all. Anyway I'm not a JEE expert but I think that you could do it using Inject annotation, similar to Autowired in Spring.

choquero70
  • 3,332
  • 2
  • 24
  • 40
  • The problem is that when there comes separate maven modules /jars wildfly can't handle this without deployments descriptionś. In single jar/module it works – masterdany88 Jun 12 '18 at 10:25
  • @masterdany88 In Spring if you have different jars with different contexts, you can integrate them in a hierarchy so that you can use the beans from other contexts. Maybe you have something similar in JEE? There must be a way. If not, you can do it manually. Or if you use Java 9 modules, you can use services to achieve dependency injection without need of any framework. – choquero70 Jun 15 '18 at 01:39
0

using jee there are couple of example but but nothing that give you the Dependency Injection capability of Spring...

You can tka a look at this example that use dropwizard to glue togheter everyting: https://github.com/moifort/play-with-hexagonal-architecture

rick
  • 1,742
  • 13
  • 21
  • In this project there is no `Injection` of EJ'sB. There is only JAX-RS from JEE. But thanks. This project gived me a lot of DDD practice knowledge. – masterdany88 Jun 08 '18 at 17:26
  • The injection is managed in the main app file RestApplication.java in the "controller" you can see the constructor that expect the service that are not injected but constructed – rick Jun 08 '18 at 17:29
  • Anyway for DDD and onion architecture with Spring is reeeeeally good – rick Jun 08 '18 at 17:32
  • It must be JEE. Can you post exactly whee is the injection? @Inject or @EJB? – masterdany88 Jun 08 '18 at 19:10
  • Dependency injection is a concept not an annotation. What you want to achieve with onion/hexagonal architecture is dependency inversion principle. this is a good example https://www.codeproject.com/Articles/1090953/Dependency-Inversion-in-Java the class I told you is commented anyway(not much but enough ;)) – rick Jun 09 '18 at 07:19