JSR330 DI vs. Spring DI - spring

Why are people using Spring DI vs. JSR330 DI? I see many projects still going forward at a huge speed with spring DI oblivious to the JSR330 specification. Many don't even know it exists. Was it not marketed enough and spring was?
I do see posts of Guice vs. spring, but the real argument should be JSR330 vs. spring since spring does not implement the spec yet(and hopefully one day it will). Any ideas on why such a large portion of the community seems oblivious to JSR330 and not evolving to it?
NOTE: I should make a correction here. Spring 3.0 does implement JSR330 and even has a way to override the default bindings much like guice except you have to supply an xml file instead of a Module file written in java.

I would say it is because Spring is so much more than just a simple DI container. Many teams use Spring for these other various reasons:
Transaction Management
Security
MVC
Aspects
Data Access
Batch processes
Webflow
Web Services
Many others...
They have their hands in so many things that it just makes it easy mix and match Spring technologies to do general enterprise development.

Spring 3.X supports JSR-330 out fo the box - http://blog.credera.com/topic/technology-solutions/java/springone-2gx-2011-summary/
It means that you can use the spring annotations or the JSR-330 ones.

Related

RESTful web service

I am implementing a REST service from scratch. I am using Spring + ibatis for the same.
Now, spring offers REST support using annotations. However, online, I find many tutorials to integrate Jersey with Spring.
My question: Why would one want to introduce extra dependencies by including another framework, that is Jersey JAX-RS, when Spring itself is good?
You assume that there's a problem with introducing "another" dependency, which, unless you're developing for some tiny embedded system, there isn't. The added memory footprint, complexity etc would generally be irrelevant.
The decision to use Spring or Jersey for RESTv implementation should be one of personal preference and suitability. Pick the one that satisfies your requirements and you're most comfortable with.
Also, using Spring for REST will require additional dependencies itself. If you're only using Spring for dependency injection, you won't require spring-web or spring-webmvc, whereas these will be required for REST.
Hope this helps

Why to use Spring not JSF (Advantages of spring over JSF)?

i don't know JSF very well, and i have a friend who is using only JSF
and he asked me a very open question, why do you use spring not jsf ?
and because of there are a lot of things about spring in my mind
i wasn't able to give some straight answers
so what are the advantages of spring over JSF ?
Spring and JSF are quite a different frameworks.
JSF is more of a web application framework and you can still use spring with JSF to manage the relationship and creations of the objects.
Spring is more of an entire j2ee application framework/plaform.
Spring MVC and web flow will help you to design web applications similar to JSF.
But spring with its IOC concept also brings a lot of other modules such as dependency injection, aop, DAO, ORM, integration, batch and social tools and much more.
You can also check the JSF-Spring combination - http://www.springsource.org/node/422
JSF is presentation layer, Spring business layer (roughly said), they can be used together and do not compete.
As said before, JSF is a request-driven, MVC web-framework, built around a light-weight IoC container and is designed to simplify and standardize the way UI-layer of a web-application is built.
Spring, on the other hand, is less concerned with UI-layer but its precise definition is hard to formulate. It can be said that the primary function of SF is to tie together different layers of a web application in a standardized way, at the same time abstracting away the implementation details of a particular web technology from the developer. As one of the consequences, the developer is freed from implementing "plumbing" and instead gets working module interconnections which are tested, implemented and used relatively easily. This should provide a boost to productivity and shortens development cycle.
This abstraction can be viewed through various Spring modules - Spring is heavily modularized, so you choose which components of the framework will you be using. Though it features a MVC framework (SpringMVC is mostly written as a reaction to the Jakarta Struts, whom the Spring developers deemed poorly written), Spring lacks a dedicated presentation module so you're free to use most of existing UI technologies (e.g. JSF, GWT-oids, etc.) - once you properly configure them in Spring.
In another words, the "scopes" of JSF and Spring are quite different (though not totally disjunct).

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.

What is the best way to have interceptors for POJO?

EJB 3.0 comes with the concept of Interceptors, but then again they are applicable to EJBs only. My project requires developing Interceptors for POJO classes. One option for this is to use Spring AOP. I want to know if it's worth the overhead of including the libraries such as commons-logging, spring-aop, cglib that are required for Spring AOP.
Spring is much more than Spring AOP, and you can not use Spring AOP without Spring, and I am talking not only to the Spring libs, but to the Spring programming model too!
So if you think Spring is useful for your application (believe me, it is very useful to many application), then you can use it. - But it is a complete programming model, like EJB, not only a lib or a simple framework.
But I think every modern not trivial application should have a ICO container, so Spring is one of the choices you have.
Sure, it's worth, but be aware it won't be enough if you need to have interceptors for you POJOs : You will also need a "spring agent" to be passed as an argument to your jvm ("Load-Time Weaving"), or you won't be able to intercept your pojos methods, or you will have to use "Compile-Time Weaving".
In short : POJOs have to be created via Spring for them to be "interceptable".
CTW (or LTW) makes compilation (or startup) quite slower.

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