Play framework 2.1 with Spring - spring

I'm analyzing on using Spring framework with Play 2.1 to support DI. Apart from DI, can i also use spring's AOP interceptors, transaction, DAO and REST support with Play 2.1? I'm not sure whether it is the right approach. If not, what is the best way to handle these things with Play? Are there any inbuilt support in Play on these areas or do i need to go with separate libraries like AspectJ, Guice, Jersey etc?

Yes you can integrate Spring with the Play Framework. I did it in a project just some weeks ago. As shown in the tutorial linked by Pere Villega this can easily be achived by extending GlobalSettings. This way also works for other DI solutions like Guice (as shown here). As far as I know, there currently is no native solution for DI in Play 2.x.
Of course you can also use other features provdided by Spring, like their DAO support or transaction management (however this may require further configuration). We even used Spring Data's MongoDB support.
Just some personal note: I really like the Play Framework for building typical Java MVC webapps, but I found it quite temperamental for building an API only. So if you are also writing your web client using Play, the provided routing and templating are great and give you a head start. For a pure REST service however I ended up using JAX-RS (on Jersey), some basic Spring components and Jetty. We then wrote the web client completely in JavaScript using Backbone, Node and Airbnb's Rendr.

Play has it's own way of managing REST, transactions (depending on the JPA library used) and interceptors.
You can integrate it with Spring, see this demo in github, but I'd first think about if you really need it.

Related

Integrating Helidon with spring boot

Using rest service using Helidon
Have created app using Helidon and rest services are available from Helidon.
i want to use spring jdbc template,dao Autowire features with Helidon and searched lot didn't find any article first of all is it right way ? Please suggest docs links
Spring and Helidon are alternative frameworks indented for (mostly) the same purpose. They are two different worlds that will have problems coliding.
I don't think it's impossible to combine them, but it is at least impractical and bound to bring lots of problems like bean instantiation, classloader and so on with them.
I'd recommend you choose one of the two and stick with it.
Helidon is not Spring so does not support these features. It sounds like you want to write a Spring application instead.

Starting with Spring framework

I'm planning to start learning Spring but when I open any spring tutorial, I find many modules like Spring REST, spring MVC etc.
I'm really confused on how to start with spring, from which module to start, how are these modules related to each other, should I go through all the modules??
I tried searching many sites to answer my questions but couldn't find satisfactory ans, so thought of posting here. It would be great if somebody can guide me in this regard.
Spring is a java framework which provides solutions to several problems. So i guess it really depends on what you are planning to learn. The most important to learn first is understanding what Dependency Injection and inversion of control means. When you understand this you will understand why the rest of the frameworks are designed as it is. i suppose learn Spring IoC first since this is basically the core component of Spring Framework. Link: http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/beans.html
After learning Spring IoC, you can go on learning each specific Spring frameworks which address specific problems. For example:
Are you interested in Web development? --> Spring MVC
Are you interested in storing data to database? --> Spring Data
Are you interested in developing web services / web apis --> Spring REST
http://docs.spring.io/spring-framework/docs/current/spring-framework-reference/html/overview.html
Start with Spring Core Module, which is the heart of entire Spring.
Spring Core Module helps in Injecting Dependencies (java objects) into
the Application at Runtime.
Please refer below URL for more details:
http://www.springbyexample.org/examples/core-concepts.html
A good knowledge of design patterns is essential for learning any framework in Java.
These Youtube videos can give you a good understanding of basic Spring.
As explained in the previous answers, start learning with the Spring core. You need to have a sound knowledge of servlets, JSP, Hibernate (ORM's) to understand the advanced topics.

Spring Framework, Spring Security - possible to use Spring Security without Spring Framework?

Ive been working now with the Spring Framework 3.0.5 and Spring Security 3.0.5 for several time. I know that Spring Framework uses DI and AOP. I also know that Spring Security uses DI, for example when writing custom handlers or filters. Im not sure whether Spring Security also uses AOP - so my first question is: does it?
Well, Id also like to know how Spring Security can be used for non-spring-based applications. Its written in their documentation that this is possible. Well, I wonder how - it seems like it uses DI, so how should it work in a simple java web application? I guess at least a web container which supports dependency injection is needed, correct? (Which one could that be?)
Thank you for answering :-)
[EDIT]
documentation says:
"documentation says: "Spring Security provides comprehensive security services for J2EE-based enterprise software applications. There is a particular emphasis on supporting projects built using The Spring Framework, which is the leading J2EE solution for enterprise software development. If you're not using Spring for developing enterprise applications, we warmly encourage you to take a closer look at it. Some familiarity with Spring - and in particular dependency injection principles - will help you get up to speed with Spring Security more easily.""
j2ee-based enterprise software applications......... emphasis on supporting projects using spring framework...... well this means it should be possible to work with it without Spring Framework itself!
?
AND:
Even though we use Spring to configure Spring Seurity, your application doesn't have to be Spring-based. Many people use Spring Security with web frameworks such as Struts, for example.
This is from the spring security homepage. well....
Does it use AOP ?
Yes spring-security uses AOP for its method security (you'd have to search the page to find it).
Can you use spring-security without spring ?
Generally no.
As you need to define spring beans for several spring-security elements.
But! You can use Acegi security without spring as far as I know. Which should give you close to the same functionality.
Can you secure a non-J2EE application
Definitely.
Anything that can run in a servlet container can be secured with spring-security. You just need Spring's IoC/DI.
This answer can help you on the minimal spring-security dependencies.

How to best apply Spring, Spring MVC and Hibernate frameworks

I'm an individual programmer, developer and I see a huge demand for the frameworks: Spring, Spring MVC, webflow, and Hibernate. Popular today: Spring MVC, webflow, GWT.
I've been going through the tutorials, and the technology looks awesome !
What I would like to know, is.. It's used in corporate sites, why not for smaller sites. How can I apply these frameworks in building websites ?
I can't imaging doing any kind of serious website building without a modern CMS or Portal framework (whether in Java/php-opensource), And yes, MVC gives you the validation and authentication hooks to be used.
All the demo's on Spring, cover some elementary, contrived example.
If I learn these technologies (and I'm well on my way), how do I put them into practice, and in what context (no pun intented) do I use them ?
I don't want to rebuild a CMS system, but I'd like to employ these frameworks effectively.
You should have a look at Magnolia/Blossom.
Magnolia is a Java (JCR) based Repository, and Blossom some kind of Spring integration.
I used it in one of my project, it worked. (Not all Spring 3.0 Features worked - for example I was not able to map two or more urls to one controller), but it worked) And I was not able to find any other mature Spring based CMS.
At least I belive the power of Spring MVC is more in web based applications than in simple web sites.

Is the REST support in Spring 3's MVC Framework production quality yet?

Since Spring 3 was released in December last year, I have been trying out the new REST features in the MVC framework for a small commercial project involving implementing a few RESTful Web Services which consume XML and return XML views using JiBX. I plan to use either Hibernate or JDBC Templates for the data persistence.
As a Spring 2.0 developer, I have found Spring 3's (and 2.5's) new annotations way of doing things quite a paradigm shift and have personally found some of the new MVC annotation features difficult to get up to speed with for non-trivial applications - as such, I am often having to dig for information in forums and blogs that is not apparent from going through the reference guide or from the various Spring 3 REST examples on the web.
For deadline-driven production quality and mission critical applications implementing a RESTful architecture, should I be holding off from Spring 3 and rather be using mature JSR 311 (JAX-RS) compliant frameworks like RESTlet or Jersey for the REST layer of my code (together with Spring 2 / 2.5 to tie things together)? I had no problems using RESTlet 1.x in a previous project and it was quite easy to get up to speed with (no magic tricks behind the scenes), but when starting my current project it initially looked like the new REST stuff in Spring 3's MVC Framework would make life easier.
Do any of you out there have any advice to give on this?
Does anyone know of any commercial / production-quality projects using, or having successfully delivered with, the new REST stuff in Spring 3's MVC Framework.
Many thanks
Glen
We use Spring 3's REST support in a production environment and are very happy with the results. We have about 1600 users and experience no performance issues.
We transitioned from Spring 2.5 (all XML configuration) to Spring 3.0 using Annotations to map our controllers and have been very pleased. Our initial tests show equal to better performance then our previous version and we've seen no bugs in the Spring code.
we have used the rest based implementation with Apache Wink and the results from the wink layer are very good.Our application was scalable with 2 clusters to 3000 requests per second.We did not face any performance issue with the wink layer.I felt that as spring does not provide a JAX-RS AKA JSR 311 we need to settle for another rest based implementation like Jersey or Restlet. If you are already using Spring3.0 please feel free to use JAX-WS support provided by spring's RestTemplate.

Resources