Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Spring MVC - Register New Controllers programatically
Spring MVC - Register New Controllers programatically [message #987410] Mon, 26 November 2012 14:04 Go to next message
Eduardo Frazão is currently offline Eduardo Frazão
Messages: 118
Registered: January 2012
Senior Member
Hi all. Im working on a project that I will need to deploy new webservices endpoints dinamically, and also, redeploy this webservices in version updates, etc.

I'm thinking in deploy this webservices (Simple controllers acting as restful) as bundles. So, my idea is write a central Web Bundle, and the endpoints that will only have controllers, will consume services from the OSGi context, ant will be attached to this web bundle context.

Can I do something like that? How can I register and unregister the controllers programatically under the Spring front servlet controller (org.springframework.web.servlet.DispatcherServlet) that will be created on the WebBundle?

Any ideas?
Thanks!
Re: Spring MVC - Register New Controllers programatically [message #987729 is a reply to message #987410] Tue, 27 November 2012 19:05 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 272
Registered: January 2010
Senior Member
You might be better off with snaps. Where each snap is a mini web-app that shares host servlet context and session. Snaps can be deployed and undeployed without impacting host application. Otherwise you are looking a some custom coding.

[Updated on: Tue, 27 November 2012 19:06]

Report message to a moderator

Re: Spring MVC - Register New Controllers programatically [message #987743 is a reply to message #987729] Tue, 27 November 2012 21:11 Go to previous messageGo to next message
Eduardo Frazão is currently offline Eduardo Frazão
Messages: 118
Registered: January 2012
Senior Member
Hi Dmitry! Thanks by your help!

How can snaps run with Spring MVC? In that case, I can only have one Dispatcher Servlet right?
My major problem, is that I need to register and unregister controllers.

The only way I found to implement it, is adding the controllers to the WebBundle application context, and Subclass DefaultAnnotationHandlerMapping, to invoke a protected method that searches for Controllers on the Context.

To unregister, I need to unregister the Controllers from context, refresh.

I dont like this approach Smile.

Is Virgo Snaps aware of SpringMVC, and can it automate discovery of new controllers to the main Dispatcher servlet? Or I can create one dispatcher per snap, as totally independent application?

Sorry by the ammount of questions Smile!

Re: Spring MVC - Register New Controllers programatically [message #987871 is a reply to message #987743] Wed, 28 November 2012 13:15 Go to previous messageGo to next message
Markus Schmailzl is currently offline Markus Schmailzl
Messages: 6
Registered: November 2012
Junior Member
How can snaps run with Spring MVC? 

You can assign a WebapplicationContext to the dispatcher servlet in the host and in each snap

In that case, I can only have one Dispatcher Servlet right?

No, you can use many Dispatcher Servlets (at least withtin the snaps)

Or I can create one dispatcher per snap, as totally independent application?

That you can. In each snap you can use Spring MVC to implement the services. When deploying a snap the services are available under
a suburl of the host-url. The suburl is provided with the manifest of the bundle.
Re: Spring MVC - Register New Controllers programatically [message #987892 is a reply to message #987871] Wed, 28 November 2012 14:59 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 272
Registered: January 2010
Senior Member
What Markus said.

Snap can be viewed as a stand alone web-app and host as a proxy to that web-app.
As a full web-app, snap can do all the spring-mvc stuff. There are few limitations, i.e. https://bugs.eclipse.org/bugs/show_bug.cgi?id=371379
Re: Spring MVC - Register New Controllers programatically [message #987895 is a reply to message #987871] Wed, 28 November 2012 14:59 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry Sklyut
Messages: 272
Registered: January 2010
Senior Member
What Markus said.

Snap can be viewed as a stand alone web-app and host as a proxy to that web-app.
As a full web-app, snap can do all the spring-mvc stuff. There are few limitations, i.e. https://bugs.eclipse.org/bugs/show_bug.cgi?id=371379

Each snap has an independent lifecycle, that is it can be deployed and undeployed independent of host app. This is where you get the dynamics that you are looking for.

[Updated on: Wed, 28 November 2012 15:24]

Report message to a moderator

Re: Spring MVC - Register New Controllers programatically [message #988208 is a reply to message #987895] Wed, 28 November 2012 19:46 Go to previous message
Eduardo Frazão is currently offline Eduardo Frazão
Messages: 118
Registered: January 2012
Senior Member
Dmitry and Markus. Thanks by your help! Virgo Snaps is really the best choice. Its working fine now. Restful services is working. Now I will try to mix some SOAP Smile
Previous Topic:Virgo 3.6.0.M04
Next Topic:Spring security on Virgo
Goto Forum:
  


Current Time: Wed Sep 17 11:42:45 GMT 2014

Powered by FUDForum. Page generated in 0.07789 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software