Examples of Spring applications over Karaf - spring

Are there publicly available examples of Spring applications in Karaf 2.2.x, in particular ones using #Repository and other Spring component annotations?

If you want to use Spring and Karaf you're most probably bound to Spring DM version 1.2.1 and therefore also probably also bound to Spring 2.5.6. You're probably better of switching to blueprint.

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.

Spring 4 and OSGI

I want to use Spring in an application which loads several modules using OSGi. I want to be able to inject beans exposed by bundle A into targets exposed by bundle B.
I saw blueprint which seems to require Spring 3, and eclipse gemini which supports Spring 4 but seems pretty abandoned.
What's the latests on using OSGi with Spring 4?
Thanks
BLueprint is independent from spring. For example Aries Blueprint does not need any spring dependency. I am not sure about Gemini but I think it also does not require spring. Blueprint is optimized for OSGi and works well. It does not provide all spring features though.
Spring never worked well in OSGi. Spring 4 now even is not delivered as bundles. So I would not suggest to use spring in OSGi at all.
That said Apache Karaf offers spring 4 bundles but I am not sure how well they work. In any case I doubt you will get any OSGi support from spring source.

Apache Felix + Spring

I have successfully created an osgi application with apache felix. Now I want to integrate spring 4 with it. How do I do it ? Can anyone provide me a complete example ?
Thanks
Arpan
In order to use Spring in your OSGi based java application for Spring Controllers or Dependency Injection you need to use Apache Aries Blueprint. Apache Karaf also provides a convenient distribution of the Felix OSGi Container with support for Apache Aries Blueprint. However before embarking on mixing Spring with OSGi I recommend reading the discussion on Blueprint here

Does Spring Framework come with its own beans?

This text is from the book called Core Java Server Faces:
It is a historical accident that there are two separate mechanisms,
CDI beans and JSF managed beans, for beans that can be used in JSF
pages. We suggest that you use CDI beans unless your application must
work on a plain servlet runner such as Tomcat. The source code for the
book comes in two versions, one with CDI beans (for Java EE 6
application servers) and one with JSF managed beans (for servlet
runners without CDI support).
My question is:
If I use the Spring Framework, and a Tomcat Server, will I need to use one of the beans mentioned above, or does Spring Framework come with its own bean implementations?
As far as I know, Spring Framework supports Dependency Injection. Does it support it if I run the application on Tomcat? Does it mean that I will be using neither the CDI beans nor the JSF Managed means mentioned in this book?
Thank you.
talking about container is more correct than bean implementation. Yes Spring comes with its own container. In fact you can see spring frameworks as a kind of alternative to the full Java EE stack.
Using Spring DI and CDI together has about no interest but you still can use JSF with spring on tomcat although if i would advise you to switch to a Java EE 6 web profile server instead of spring in this case.
Spring comes with is own view framework implementation named spring mvc.
All of this can run perfectly on any servlet container (jetty tomcat etc...) on condition that you provide associated dependencies ofc.

Spring can be used in Seam?

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

Resources