how to create/load a custom spring jar in a not spring managed web application -
I would like to create a jars liberalization using the spring and would like to import them into my web application. Since I also use spring later, I have no problem. The point is that I want to use it again in a non-spring management environment. Suppose I want to use Lib in the pure Java web app, then I can not use spring automaker and package scan features. My idea is: Create a simple pure bean and loader conferencing in its constructor:
Public Spring Springstallone {Private Client Client; Personal Annotation ConfiFication Applications Context CTX; Public Springstallon () {ctx = New Entatation Conflict Application Concert (); Ctx.getEnvironment () setActiveProfiles ("Test"). Ctx.scan ("my.package.scan"); Ctx.refresh (); Client = (Client) ctx.getBean (Client.class); Ctx.destroy (); } Sending a public null (object o) {client.send (o); }} Is this the correct way to do it? If so, how should I manage an app contact (should I bother about this?)?
Thank you in advance for your help.
Fabio
You can not do the spring app Destroy the context and hope that your client object will work.
Instead, you should provide a separate ' SpringStandalone.destroy () ' method, whose client code will not be required by your Springstallon class.
Note that the call to ctx.destroy () does not just clean the spring container, but also runs some 'business' functions, such as All Bean Methods have been annotated with @PreDestroy , Shutdown Events etc. have been published, so when you do not need the Springstallone object, then it is a good practice to call
I believe that nothing is wrong in your view
Note that it takes time to load the spring app reference, so you only want to make your SpringStallon once.
Comments
Post a Comment