<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8408435112500136770</id><updated>2011-04-21T12:53:08.717-07:00</updated><category term='OSGi'/><category term='spring'/><category term='s2ap'/><title type='text'>Painful OSGi</title><subtitle type='html'>Your destination to sharpen your OSGi and Spring 2 Application Platform skills.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://osgipain.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8408435112500136770/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://osgipain.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>SpringFan</name><uri>http://www.blogger.com/profile/15690775852358654480</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8408435112500136770.post-3790677153461680914</id><published>2008-05-10T07:08:00.000-07:00</published><updated>2008-05-10T09:46:34.105-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='OSGi'/><category scheme='http://www.blogger.com/atom/ns#' term='s2ap'/><category scheme='http://www.blogger.com/atom/ns#' term='spring'/><title type='text'>First Look at the Spring 2 Application Platform</title><content type='html'>Hey, my name is SpringFan. I'm a Spring user since 2004. I've held various positions as senior Java architect and senior Java consultant. I've used the Spring Framework in dozens of projects, big and small.&lt;br /&gt;&lt;br /&gt;I've contributed to several open-source Java projects - including Spring. I've also co-founded a few open-source Java projects myself, some incubating, some well-known. I'm an editor at Java-related websites and author and co-author of a number of Java-related books.&lt;br /&gt;&lt;br /&gt;I know most people working for SpringSource, including its founders. I'm familiar with the frameworks in the Spring portfolio and worked extensively with most of them. I regularly submit bug reports and suggestions for improvements to the various SpringSource frameworks (about 20 tickets in the last 12 months).&lt;br /&gt;&lt;br /&gt;You could say I'm somewhat familiar with Spring. One thing I'm not familiar with though is OSGi and this is exactly the road the SpringSource guys have decided to take.&lt;br /&gt;&lt;br /&gt;SpringSource thinks OSGi is the future and they're putting their money where their mouth is. They've started work on Spring DM (Spring Dynamic Modules, previously Spring OSGi) more than two years ago with a few of their consultants working on it. Rod Johnson &lt;a href="http://java.dzone.com/news/interview-rod-johnson-springso"&gt;claimed in April 2008&lt;/a&gt; that SpringSource has been working on the new &lt;a href="http://www.springsource.com/web/guest/products/suite/applicationplatform"&gt;Spring 2 Application Platform&lt;/a&gt; (S2AP) for over one year and I know they have a lot of people working on it.&lt;br /&gt;&lt;br /&gt;And they've kept it secret. None of the SpringSource people I've talked to informally during the last year has ever mentioned S2AP. Then one day we woke up and there was S2AP in beta.&lt;br /&gt;&lt;br /&gt;I've never thought Spring DM was useful for my purposes, particularly since using OSGi in applications that are deployed in servlet containers or application servers is either tricky or impossible.&lt;br /&gt;&lt;br /&gt;At it's core OSGi is a structured ClassLoader hack. And since servlet containers and application servers also play with ClassLoaders they typically impose restrictions on the kind of ClassLoader hackery OSGi employs, making the overall experience for developers less than comfortable. (Note: some application servers use OSGi internally, but they don't offer support to use OSGi in the applications you deploy on them.)&lt;br /&gt;&lt;br /&gt;Developers typically have a hard time with application servers. If you're using the top of the line (Weblogic) you still have a fair chance at agility. Otherwise you're out of luck, especially if you're working with application server resources like JMS queues, JDBC DataSources or JCA connections in combination with distributed transactions. Add OSGi to the picture and you have take even more restrictions and limitations into account to make your applications work. S2AP seems to solve exactly this problem which makes it promising and interesting.&lt;br /&gt;&lt;br /&gt;OSGi - through its ClassLoader hackery - offers certain advantages that if you can make them work for you could return important benefits. Eclipse is obviously a powerful platform for developing plugins and it's based on OSGi. (Note: I feel strongly that developing Eclipse plugin is harder than it could and should be, but the advantage of the OSGi features is obvious.)&lt;br /&gt;&lt;br /&gt;So, which features does OSGi offer? The most important feature from where I'm standing is limited ClassLoader visibility. In a Java VM without using OSGi or similar ClassLoader hacks all public classes that are available on the class path are accessible from any other class. This is annoying, and OSGi allows you to impose restrictions on this. In fact, by default you only have access to the classes in your "&lt;span style="font-style: italic;"&gt;bundle&lt;/span&gt;".&lt;br /&gt;&lt;br /&gt;Another OSGi feature is to have multiple versions of the same classes in one Java VM. You then have to choose which version you want to use. This could be useful in theory. Yet, as far as I know Eclipse does not use this feature and I have yet to hear from a usage in practice.&lt;br /&gt;&lt;br /&gt;Lastly, OSGi gives "&lt;span style="font-style: italic;"&gt;bundles&lt;/span&gt;" a life cycle which allows "&lt;span style="font-style: italic;"&gt;bundles&lt;/span&gt;" to be loaded, unloaded, reloaded, started, stopped, ... on a live Java VM. See, OSGi has been conceived for embedded, low resource applications and environments (BMW cars use OSGi). You can work with this life cycle dynamically through the OSGi APIs or via OSGi management consoles. And it's a useful feature. Ever wished you could dynamically load and unload Spring configuration files instead of loading them when your application starts? S2AP offers this through Spring DM and OSGi.&lt;br /&gt;&lt;br /&gt;A bundle is a regular JAR file with OSGi-specific headers in its &lt;code&gt;MANIFEST.MF&lt;/code&gt; file that has to be loaded by an OSGi container (e.g. Eclipse Equinox). OSGi features (access restrictions, versioning and bundle life cycle) are only available in OSGi bundles that have been loaded by an OSGi container.&lt;br /&gt;&lt;br /&gt;So, why is S2AP promising then? Before I can even start to answer that question we have to take look under the hood. And there we find Spring DM and the Eclipse Equinox OSGi container.&lt;br /&gt;&lt;br /&gt;I've never used Spring DM in anger. But I do know it adds Spring Framework capabilities to OSGi bundles. For example, when a bundle gets loaded Spring XML files that are included in the bundle (JAR file) are automatically loaded in an ApplicationContext that is local to that bundle. When the bundle in unloaded the ApplicationContext is closed. In these Spring XML files it is possible to declaratively obtain services exposed by other bundles. You can also declaratively expose services for the benefit of other bundles.&lt;br /&gt;&lt;br /&gt;Spring DM certainly offers useful features, and a new deployment model. Unfortunately it's hard or even impossible to use Spring DM from inside applications that are deployed in application servers, which is your typical Java enterprise application ($$$).&lt;br /&gt;&lt;br /&gt;That problem could be solved, for example by starting the Eclipse Equinox OSGi container and run it next to a Weblogic application server (so not in the same Java VM). You could then use Spring DM in your bundles and access Weblogic resources remotely, like its JTA TransactionManager or JMS queues and ConnectionFactories.&lt;br /&gt;&lt;br /&gt;You could do that but it comes with some penalties. First, you now have at least two Java VMs to configure, run and monitor. Also, not all Weblogic resources can be accessed from other Java VMs, like CommonJ thread pools or schedulers.&lt;br /&gt;&lt;br /&gt;SpringSource has cleverly taken this approach and turned it upside down. With BEA bought by Oracle for its customer base and not necessarily it's Weblogic application server technology SpringSource introduces a completely new deployment model. And it may turn out to be a pretty good one.&lt;br /&gt;&lt;br /&gt;S2AP is actually an application server, but not a JEE application server like Weblogic, WebSphere or JBoss. It appears to offer some pretty advanced, for-money monitoring and logging capabilities which is something loaded enterprise customers want.&lt;br /&gt;&lt;br /&gt;They offer the OSGi-based Spring DM deployment model for applications and they also offer SPIs (Service Provider Interface) for vendors to integrate their JMS servers, transaction managers and JNDI trees. Which is clever.&lt;br /&gt;&lt;br /&gt;Because while Weblogic is the best integrated application server the features it offers are also available elsewhere and often for free. Atomikos offers an &lt;a href="http://www.atomikos.com/Main/TransactionsEssentials"&gt;open-source JTA TransactionManager&lt;/a&gt; with support for distributed transactions which can be used in combination with JMS servers like ActiveMQ, IBM MQ Series or Weblogic server.&lt;br /&gt;&lt;br /&gt;Nothing stands in the way of deploying the Atomikos JTA TransactionManger as an OSGi bundle, instantly offering distributed transaction management capabilities to other bundles. Clever. It's not hard to see how Atomikos and other vendors would be happy to work with SpringSource to make their valuable products work seamlessly on S2AP. S2AP probably offers some value in return for these vendors through its for-money advanced monitoring offering.&lt;br /&gt;&lt;br /&gt;And it doesn't stop there. S2AP also seems to have support for hot class weaving, probably on top of the OSGi bundle life cycle. Handy, and not only to integrate AspectJ (btw, I guess we will see things moving in AspectJ land soon too).&lt;br /&gt;&lt;br /&gt;Imagine Terracotta's open-source distributed memory - which requires load-weaving - available as an OSGi bundle. I'd have to look into how class weaving works in S2AP. But knowing the SpringSource guys they'll offer some powerful, stable semantics in this area. If Terracotta gets integrated into S2AP in this way it would offer powerful clustering features for the benefit of application code. This would literally be wild, since it would allow us to apply clustering with a very fine and comfortable brush.&lt;br /&gt;&lt;br /&gt;From where I stand, and given we're talking about SpringSource which is now loaded with venture capital to invest I think S2AP will become pretty successful in enterprise environments at which it is clearly targeted.&lt;br /&gt;&lt;br /&gt;The price to be payed by developers is that there's a new deployment model to learn. That's pretty daunting. Yet I believe it will happen. I don't believe it strongly yet, I first have to dive into OSGi and S2AP. But things are certainly looking promising.&lt;br /&gt;&lt;br /&gt;Also, expect to wait at least another 6 months, probably more, for S2AP 1.0. Which is good news for the community since it gives us the time it will take to acquire new skills.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8408435112500136770-3790677153461680914?l=osgipain.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://osgipain.blogspot.com/feeds/3790677153461680914/comments/default' title='Reacties plaatsen'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8408435112500136770&amp;postID=3790677153461680914' title='3 reacties'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8408435112500136770/posts/default/3790677153461680914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8408435112500136770/posts/default/3790677153461680914'/><link rel='alternate' type='text/html' href='http://osgipain.blogspot.com/2008/05/first-look-at-spring-2-application.html' title='First Look at the Spring 2 Application Platform'/><author><name>SpringFan</name><uri>http://www.blogger.com/profile/15690775852358654480</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry></feed>
