Spring can be used in Seam? - spring

I understand that Spring has really nice features, such as dependency injection. I am new to Spring. I have understood that I can use Spring alongside with struts and other frameworks too, in order to use its capabilities.
In my project I am going to use Seam 2.0, I am using JNDI to lookup for the EJBs. I am wondering if I can integrate Spring with Seam and use its ApplicationContext in order to get beans from that directly and not use JNDI lookup anymore?

There is a whole chapter in the Seam reference dedicated to this:
27. Spring Framework integration

Related

Use of Spring 5.3 with Servlet 3.0

I'm working on application which uses Spring Core in version 4.3.14 and Spring Web in version 4.2.13. We don't use Spring MVC. Also, from Spring Web we use just very limited set of classes:
XmlWebApplicationContext (so classes from org.springframework.web.context)
RestTemplate (so classes from org.springframework.web.client, here i expect some problems)
some util classes which probably can be refactored to use something else
My question is:
We want to migrate to Spring 5.x. Is such a migration really possible? Or should i expect some severe problems with application startup (class incompatibilites etc). This source for example: https://github.com/spring-projects/spring-framework/wiki/What%27s-New-in-Spring-Framework-5.x#whats-new-in-version-50 says that Servlet 3.1 is required
From the other side, here https://spring.io/blog/2015/06/10/feedback-welcome-spring-5-system-requirements JUERGEN HOELLER wrote that migration to Spring 5 will be a soft one. So i assume that if Application uses only features from JEE6 + Servlet 3.0, then it can be that it will also work on Spring 5.x with JEE6-compatible appserver
Does anyone have an experience in that?
As always, Spring Framework upgrades its baseline with new major versions. In this case, we're requiring JDK8+ and Java EE7+.
In practice, this means that the compiled code depends on those APIs and doesn't use reflection anymore to adapt to them. In your case, this is not only about Servlet, but also JPA, JMS, bean validation and other specs.
Your application might work fine with the arrangement you're mentioning, but the Spring team will not guarantee support for this setup.

Guice + Jersey + Spring data

I am planning to use Guice(for DI) and Jersey( for rest). They integrate very well but I also want to leverage what spring-data provides. But it seems like we need to integrate spring first to use Spring data*. Is there any way i can integrate spring-data* without using spring ioc container.
Yes. I did it. it seems spring data related beans should be manually wired.

Java EE or Spring for PrimeFaces project - any difference?

I'm planning a project which will use Primefaces to generate its UI.
I understand that PrimeFaces as JSF library is somewhat more at home with Java EE than Spring, although there seems to be a lot of examples of using it together with Spring.
Are there any notable disadvantages of using Spring instead of Java EE for the DAO and service layer in a PrimeFaces project?
It complicates the things, Java EE is complex enough for application developers(you need time to open dark parts and see the lights or i hope it:)) so my opinion if you don't have a requirement about it, don't use Spring and JSF together to better understand your bean lifecycle. You can find good dicussion in this source. I prefer to use HTML+Bootstrap and Spring MVC or use Seam Framework for JSF or no framework just use pure Java EE support with primafaces(JSF) can be good.

Spring Hibernate Connection through AOP standalone application

I am trying to develop Annotation based Spring Hibernate standalone application to connect to DB. I've gone through the some blogs and wondered like we should not make use of hibernateTemplate becoz coupling your application tightly to the spring framework. For this reason, Spring recommends that HibernateTemplate no longer be used.Further more my requirement is changed to Spring Hibernate with AOP using Declarative Transaction management.I am new to AOP concepts. Can any one please give an example on Spring Hibernate Connection through AOP. That would be a great help to me.
Thanks in advance.
If you are looking for exemples of project structures, you may want to use maven archetypes which provide you an already working Spring + Hibernate or Spring + JPA configuration.
They may provide you also a web layer (or not) but you can remove it if you want.
To try that, install maven and type:
mvn archetype:generate
By the way, I don't think using HibernateTemplate is a big deal. Many people still use it. But you'd better inject the Hibernate session factory and use contextual sessions with getCurrentSession()
I'd use JPA instead of plain Hibernate. You can of course use Hibernate as a provider. I guess that you know how to run Spring container in standalone application. Just follow the steps from documentation here. Use LocalContainerEntityManagerFactoryBean. Then read about transaction management.
There is a new feature that lets you start JPA without persistence.xml file. Read here.
If you still want to use plain Hibernate follow the docs.

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.

Resources