This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes OSGi and Spring modules Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "OSGi and Spring modules" Watch "OSGi and Spring modules" New topic
Author

OSGi and Spring modules

Manassés Souza
Greenhorn

Joined: Jan 05, 2009
Posts: 9

Hi Craig and ranchers!

Wich Spring core functionality (DI, AOP, ...) better suite OSGi ? and what´s the relantionship with other Spring projects (Web flow, Security, etc.) ?

Thanks!
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
Manassés Souza wrote:Wich Spring core functionality (DI, AOP, ...) better suite OSGi ? and what´s the relantionship with other Spring projects (Web flow, Security, etc.)


That's a tough one to answer. Certainly DI and OSGi go together very well, as that's what Spring-DM is all about: wiring OSGi services and wiring the beans that make up those services. AOP is a bit tougher, because (due to OSGi's unique way of dealing with the classpath), AOP's reach is a bit constrained in OSGi.

As for the rest of the Spring portfolio...I'm not sure, but I suspect most or all of it can fit into OSGi somehow. It just kinda depends on what you want to do.

In my opinion, one such mix of Spring in OSGi that looks appealing is a mixture of Spring-DM, Spring Security, Spring Integration, and Spring-WS. I've not spent any time exploring this mix, but I've pondered it quite some bit on my drive to work and it seems like a powerful mix of Spring related technologies within OSGi.


Spring in Action - Unleash POJO power in your applications!
Modular Java - Discover the secret weapon to modularity on the Java platform!
XDoclet in Action - Your complete guide to code generation with XDoclet.
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
Craig Walls wrote:
AOP is a bit tougher, because (due to OSGi's unique way of dealing with the classpath), AOP's reach is a bit constrained in OSGi.

Could you please to explain more on this? How could using OGSi make it difficult to use Spring AOP?


SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
Kengkaj Sathianpantarit wrote:
Craig Walls wrote:
AOP is a bit tougher, because (due to OSGi's unique way of dealing with the classpath), AOP's reach is a bit constrained in OSGi.

Could you please to explain more on this? How could using OGSi make it difficult to use Spring AOP?


Well, the gist of it has to do with OSGi's way of constraining the classloader. Each bundle gets its own classloader and that bundle can only see its own contents plus the contents of the packages that it has imported. That means that a bundle with an aspect in it can only advise those things it sees and not necessarily everything in the OSGi runtime. (As opposed to non-OSGi where the classpath is one big dumping ground for classes and resources and an aspect can advise pretty much anything its pointcut specifies.)
Hong Anderson
Ranch Hand

Joined: Jul 05, 2005
Posts: 1936
I see, but I think it might be a good thing to advise only things a bundle see, what do you think?

I don't like AOP much, and I would not advise junior developers to use AOP.
I'm not quite comfortable for the fact that I might accidentally advise something I don't want or I don't even know about.
Or when I'm refactoring a class, maybe this class is being advised from an unknown aspect, and refactoring it might break some functionality.
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
Kengkaj Sathianpantarit wrote:I see, but I think it might be a good thing to advise only things a bundle see, what do you think?


Maybe, but I think that there's a certain amount of value in creating a bundle that provides an aspect that can be used across all other bundles. I can totally understand the concerns you presented, but I still kinda like the idea and can see it being useful (even if dangerous in the wrong hands).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OSGi and Spring modules
 
Similar Threads
Modular Java: Spring
Spring in Action - Spring OSGi integration?
Modular Java: flexibility
* Welcome Craig Walls
Spring Security 3 and OSgi