Spring best practice: deploying a non-bean component

I want to create an MVC application using Spring (first timer here).

As such, I want to embed Jetty in the servlet engine. However, Jetty does not strictly adhere to the java beans pattern, so I cannot run some classes from Spring (they use overloaded setters or non-Internet init methods like addXYZ).

What is the accepted / recommended practice of structuring this project? Obviously, all my code fits nicely into the MVC model, but for Jetty:

  • Am I encapsulating all Jetty (or any other non-w810> friendly component) into my own Spring-other bean?
  • I am trying to instantiate as much as possible in Spring and just extend non-bean con-formant classes to make them act like beans correctly?
  • Is there any other option?
+3
source share
1 answer

Generally speaking, I am for the second point, i.e. I try to use spring utilities such as factory-method, init-method, <constructor-arg>and the like, in order to overcome the fact that something is not completely -druzhelyubny spring. It is rare that it is not possible to configure beans on spring. And for cases when this is not possible, create wrappers

You can also program a third-party beans program:

+3

Source: https://habr.com/ru/post/1771042/


All Articles