I have a running app in vert.x. I have many missing features or I just can say missing spring.
How can I integrate vert.x and Spring MVC working on a Tomcat server?
With Vert.x 3 I would think you would want to use the Vert.x Web capabilities as described here instead of Spring MVC if you want to give Vertx a go. It provides a different approach to developing a web application using the Multi-Reactor pattern than the traditional multi-threaded Servlet model which Spring MVC is based on. With the Servlet model every request runs on its own thread. In Vert.x there is an event loop that is single threaded. All requests are run on the same thread, which requires blocking I/O code to be written in special blocks (see Core Manual).
Depends on which Vert.x version you are using. 2.x requires a module. like mod-spring-appcontext. In Vert.x 3.x just create a Spring ApplicationContext in your code, typically in the entry point of your application, like your public static void main method. I can't get into more detail. Vert.x questions rarely, if ever, get noticed here.
I would not recommend working with vert.x on a tomcat container as there philosophies are completely different. Tomcat is a servlet container which creates different thread for each incoming call whereas vert.x works on a event-loop. If you are missing spring and will like to use its bean you can integrate it in vert.x environment and run any blocking code in worker verticles.
You can see an example here : https://github.com/vert-x3/vertx-examples/tree/master/spring-examples/spring-example
Related
We have a plain java web project with some servlets, some JPAs and our logic.
We want to move to Cloud Foundry . I have learnt that Spring boot comes up with a lot of nice cloud foundry features out of the box like support for CF environment variables parsing, CF service broker API implementation.
Now i don't want to move to Spring MVC since we already have the application running with plain java web framework.
Can i still use Spring cloud foundry related projects to take advantage of Cloud Foundry related features like parsing of env variables ?
Are they internally dependent on Spring core, spring mvc projects ? Will including the Spring Cloud Foundry project bloat my total deployable war size due to all internal spring dependencies.
Best Regards,
Saurav
A lot of this depends on exactly which features you want to use. The awesomeness you get from Spring Boot requires Spring & so it won't transfer to your app unless you embrace & use Spring. The same goes for Spring Cloud.
You specifically mentioned parsing service information from environment variables (i.e. VCAP_SERVICES & VCAP_APPLICATION). This is the one exception that comes to mind. You can use Spring Cloud Connectors in a limited capacity without Spring. See this link for details. It's not as full-featured as what you'd get if you were using Spring & Spring Boot, but it will give you some help.
If you don't want to use SCC, you can always parse the environment variables yourself and use the data. It's conceptually very easy. Both VCAP_APPLICATION & VCAP_SERVICES are environment variables and the value is a JSON blob so all you need to do is parse the JSON and locate the information that you need.
Hope that helps!
I have a WebApi where I am using Windsor Castle as a IoC framework. I am using Owin library and a startup file was created to centralized the configuration of the API. Everything works as expected.
I have integration tests where I am using Owin.Testing library and the server is started using a test startup class which is inheriting the real one. The Windsor container was successfully configured for the TestServer. The integration tests are executing web requests against the running self hosted server. Everything works fine.
There are two things which are not working when using the test server:
the ModelState of the controller is all the time valid even when I am passing an invalid json body for the POST request. When hosted with IIS it works as expected. Any idea what can be wrong with the test server?
I am using VS test runner and the Owin TestServer is initialized in a [ClassInitialize] method. I do not want to create a new test server after each test as Windsor container initialization is quite expensive. There are tests where I need to mock some 3rd party services (by using Register method of the container and Moq). At the end of each test I want to rollback all the mocks from the container which were done in the scope of executed test. Is it possible somehow to do it? I have tried to register within a scope but does not work.
Thanks
I've SignalR 2.x and ASP.NET with ServiceStack framework. It makes to entry points, one per each pipeline:
Startup.Configuration(IAppBuilder app) -- for SignalR startup configuration
and
Global.Application_Start() in Global.asax.cs -- for initializing the standard ASP.NET pipeline.
I'd like to pass some object that has been created in Application_Start() into Configuration() (e.g. IOC instance). For this I'd like to be sure that Configuration() will be called after Application_Start().
I found this stackoverflow question. What bothering me is the slightly later definition. Does it mean the execution is overlapped? Is it promised that the code in Configuration() will be called after Application_Start() for sure?
Does anybody know how it is exactly working and what is this delay? Has anyone had an experience with coding these methods?
Thank you
Iv decided to confirm my previous (and incorrect) statement by experiment and indeed Application_Start() method is called before any Owin startup class which means before SignalR Configuration (assuming recommended SignalR configuration using Owin startup of course).
It is true that Owin (Microsoft.Owin.Host.SystemWeb to be precise - which is Owin host adapter for IIS) uses System.Web.PreApplicationStartMethodAttribute to hook into ASP.NET pipeline but only to register its own OwinHttpModule (and yes this registration happens before Application_Start()). But Owin startup classes are discovered and run during OwinHttpModule.Init() which happens after Application_Start(). Slightly later means exactly that - both methods are called during execution of HttpApplication.RegisterEventSubscriptionsWithIIS private method. No overlaping for sure...
Sidenote: Imho there is no reason to have startup\configuration in two different places in application and because OWIN is the next big thing in ASP.NET world (see vNext or SignalR) and offers more benefits than Application_Start() (such as switching startup configuration in web.config), I'm definitely planning to migrate all Application_Start() code to OWIN startup.
-> No reason to worry about what's happening 1st ;)
And this is also my suggestion to you!
according to this guide! I run servlet successfully, but some of actions of the servlet failed, because they need servlet-api 2.5+ support. how can I use my own servlet-api library instead of domino web server's old version.
thanks!
David Taieb (software architect at IBM) stated in a comment to a blog post:
In 8.5.2, Domino introduced support for Equinox Http Service which allows you to create lightweight servlets registered via extension points. I say lightweight because these servlets are not run within the context of a traditional J2EE Web App with web.xml support. However, the Equinox Http Service lets you associate an http context to different servlets so that they share the same http session object.
Starting in 8.5.3, Domino will start supporting the XPD Web Container which is a full fledged J2EE Web Container (although it does not support things like EJBs). With the XPD Web Container, you can transform almost any WAR into a WAB (Web Archive bundle) and run it in Domino.
You maybe also want to take a look at Servlet Sample at OpenNTF.
Otherwise, please state the version of Domino, you are currently using.
I have web app which is already developed based on Spring MVC. I need to re-implement that web app in Mule.
Can I develop the mule application based on Spring MVC?
Can I declare the Spring MVC dispatcher servlet inside a mule's servlet endpoint and take things further from there?
The web app has web.xml where it defines the DispatcherServlet, the contextparams, the listener classes and so on. How can we remodel that in a mule application?
Any examples where a mule application is developed based on SpringMVC would be great.
Thanks to its embedded Jetty container, you can deploy any JavaEE web application in Mule. So there's no need to remodel anything.
The "Boosktore" example application demonstrates running web-apps within Mule: https://github.com/mulesoft/mule/tree/mule-3.x/examples/bookstore
Mule ESB is not an MVC Framework. It is developed using enterprise integration patterns in mind.
Please go through this blog, to know when to use ESB.
spring mvc can be integrated with mule.
Define all your spring related configuration in separate xml file and include it in mule configuration file.
You can write your custom transformers ,in the custom transformations you can inject or do an autowire of your service classes and from service object you can interact with dao layers.