Monday, July 28, 2008

ObjektForumNord about OSGi with Peter Kriens

I am pretty exited that Peter Kriens will join us for the ObjektForumNord (website in German, sorry), a series of talks in Germany. This time the session is in Hamburg (my hometown) and Peter is going to give a tutorial and a talk about OSGi. During the afternoon of September 9th, he will give an introductory tutorial about OSGi together with my colleague Matthias Lübken. The evening is filled with Peters talk on "Why Modularity is Important". I am really looking forward to it. Don't miss it.

Sunday, July 27, 2008

News from Equinox Aspects

Some people might have noticed already that some changes are going on inside the Equinox Aspects incubator. Heiko posted the details to the mailing list: http://dev.eclipse.org/mhonarc/lists/equinox-dev/msg04653.html.

I am pretty exited that we are moving towards being a better citizen of the Eclipse world. We have re-arranged our development process and aligned it with the process of the other projects at Eclipse. Take a look at our milestone planning and details on what keeps us busy at the Equinox Aspects Plan wiki page.

The first milestone is targeted at the 8th of August, less than two weeks from now. And on the way from milestone to milestone you can watch and test the progress by using the development builds from our download page.

Friday, July 25, 2008

Episode on Plugin Architectures at SE-Radio

Last weekend SE-Radio published an episode about plugin-based architectures. Within this episode I talk with Klaus Marquardt about different kinds of plugins and different kinds of systems build with or out of plugins.

This episode was actually my first episode as host and we recorded it a long long time ago. But listening to it today disappoints me somehow. The episode contains a larger number of repetitions from my side and I didn't achieve to make it a condensed episode. Just to be clear: This was not the fault of Klaus, whom I interviewed in this episode - not at all. Again it reveals that recording podcast episodes is a learning process - just like software engineering is.

"Silver Medal" for Equinox Aspects Talk

The attendees session ranking from Java-Forum-Stuttgart 2008 is now online and I am more than happy to see that my talk about Equinox Aspects (slides, code examples) won the silver medal. How cool is that? And its great to see that more and more people are interested in Equinox Aspects. Wonderful...

Saturday, July 12, 2008

Dependency Injection for Extensions, Third Edition

As you might have read from my previous posting I created an example that demonstrates the usage of Equinox Aspects as the load-time weaving engine for Spring Dynamic Modules. Now its time to describe this in more detail. :-)

My first idea behind this combination was to use the @Configurable annotation to use Spring's dependency injection mechanism for arbitrary objects which you typically don't create via the application context of spring. The default examples for this are plain domain objects, extensions are another example (they are typically created by the extension registry of Eclipse). Spring realizes the dependency injection for those objects by weaving an aspect into their classes. This aspect takes care of injecting the dependencies after each object creation. And this is the point where Equinox Aspects comes into play.

Fortunately Spring ships as a set of OSGi bundles. This is also true for "spring-aspects.jar", the JAR archive that contains the aspect that is responsible for making the @Configurable annotation work. And you can use Equinox Aspects to weave this aspect into your bundles wherever you would like to use the @Configurable extension. Sounds good, eh?

Ok, what do you need to do? Let’s go through the example step by step. First you need a target platform that contains the following:
Now you have a class that would like to use @Configurable. In my example it is a view for an RCP application that looks somewhat like this:

@Configurable
public class View extends ViewPart {

private Service service;

public void setService(Service service) {
this.service = service;
}

public void createPartControl(Composite parent) {
...


Then you define in the spring context of the same bundle the view as a spring bean, including the "service" property (the dependency that should be injected):

<bean class="org.eclipse.example.springdm.rcpview.View" scope="prototype">
<property name="service" ref="myservice"/>
</bean>

<bean id="myservice" class="org.eclipse.example.springdm.rcpview.Service"/>


Take care to define the bean for the view as of scope "prototype". This is necessary to tell spring that this bean definition should be used as prototype for various instances.
Now we need to tell your bundle to be woven with the spring aspect. Therefore you just define the aspect bundle as required bundle:

Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.springframework.bundle.spring.aspects


Now Equinox Aspects (if started correctly) weaves the aspect into your bundle wherever the @Configurable annotation is used. The next step is to tell the spring context that it should use load-time weaving and annotation configuration (plain old spring configuration for load-time weaving, nothing special here):

<context:spring-configured>
<context:annotation-config>
<context:load-time-weaver class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver">


This also requires some more import package statements within your manifest:

Import-Package: org.aspectj.lang,
org.aspectj.runtime.reflect,
org.springframework.instrument.classloading,
org.springframework.beans.factory.annotation


The first two import statements are necessary because they are needed if an aspect gets woven into one of your classes. A more elegant solution for this would be to reexport those packages from the spring-aspects bundle, but they didn’t define the reexport in their manifest. Therefore you need to import them manually.
The last step is to take care of the startup sequence of your bundle. If the extension is created, your bundle should be activated to get the spring context created. This creation of the spring context should happen synchronously to ensure that the context is created when your extension object is created – otherwise the dependency injection would not work. Therefore I declare in the manifest:

Eclipse-LazyStart: true
Spring-Context: *;create-asynchronously:=false


If you would like to take a look at the complete example that I used, you can download it here:



Feedback and questions are always welcome!

Code Examples from "Aspect Weaving for OSGi" Talk

As promised, here are the projects of my live demos from "Aspect Weaving for OSGi" at last weeks Java-Forum-Stuttgart 2008.

Eclipse Monitor Demo

This demo features the relatively old Eclipse Monitor application that Chris Laffra wrote a while ago. It visualizes plugin activities within your Eclipse application and you can analyze what is going on. This monitor uses Equinox Aspects to weave an aspect into all your bundles at load-time to gather the information of what is going on at runtime. It uses AspectJ advises for all methods and object creations. While this is a pretty heavy use of load-time weaving (you will notice a huge performance impact at first startup) it demos nicely the caching feature of Equinox Aspects. The second startup of your monitored app will perform very similar to a startup without any aspect weaving.

To run the example: Within your development environment you should have AJDT installed to work with AspectJ. In your target environment you should have included your favorite IDE (as example RCP app to monitor), the matching AJDT version, and the latest Equinox Aspects development build from here: http://www.eclipse.org/equinox/incubator/aspects/equinox-aspects-downloads.php. Notive: You need to install the latest dev build, not one of the archived builds. Once you have this you should be ready to run the example. Just import the projects in your workspace and use the included launch configuration.

Dependency Injection with Spring Dynamic Modules and Equinox Aspects

Spring provides this nice mechanism to inject dependencies in domain objects via the @Configurable annotation (see more here: http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-atconfigurable).
The main difference to general spring beans is that the creation of those domain objects is not done by the application context of Spring. Therefore Spring uses an aspect to call the application context after object creation to inject all necessary dependencies. In plain old Spring applications this aspect is woven into the system using load-time weaving.
Wouldn't that be a nice mechanism to inject dependencies into Eclipse extensions (like views or editors)? Just annotate your extension with @Configurable and define the dependencies to be injected inside the application context of your bundle (using the Spring Dynamic Modules stuff)?

One way of doing this is to use Equinox Aspects together with Spring Dynamic Modules. Just use the spring-aspects.jar from your spring distro (its already an OSGi bundle) and enable Equinox Aspects weaving - and you are done. It just works! :-)

To run the example: You don't need any special support within your development environment. Instead your target platform should be configured carefully. For the example projects I used Eclipse 3.3.2 as target platform, added AJDT, added the latest dev build of Equinox Aspects, Spring 2.5.4 bundles and Spring Dynamic Modules 1.1.0 bundles. Import the example projects from the zip file into your workspace and use the included launch config to run the demo. The example injects a spring bean into the view extension.

I will give more detailed information on how this Equinox Aspects weaving can be used together with Spring Dynamic Modules in an upcoming post.

If you observe any problems or if I forgot something in this description, please let me know.

Have fun with the examples!

Thursday, July 03, 2008

Slides from "Aspect Weaving for OSGi" Talk

This morning I gave a presentation at the Java-Forum-Stuttgart conference on Aspect Weaving for OSGi. The slides of this talk are now available for download:
The code for all live demos from the presentation will follow shortly.

Tuesday, June 24, 2008

Reminder: Equinox Aspects at Java-Forum-Stuttgart 2008

This is just a friendly reminder that you have the chance to see Equinox Aspects live and in action at the upcoming Java-Forum-Stuttgart 2008 next week at the 3rd of July. I will give a talk at this nice conference in Stuttgart, Germany, about Aspect Weaving for OSGi. And the talk will be fully packed with a number of live demos including:
  • Monitoring Eclipse with aspects
  • Installing, updating and uninstalling aspects at runtime (dynamics for aspects)
  • Using Equinox Aspects together with Spring Dynamic Modules
It will be really really cool, don't miss it! :-)

Sunday, June 22, 2008

Slides and Examples from Spring-Dynamic-Modules-Talk at the OSGi Community Event 2008

Already more than a week ago I gave a talk at the OSGi Community Event 2008 in Berlin about the Spring Dynamic Modules project. Giving the talk was fun, I used a number of live demos to showcase Spring DM in action. The slides are now online:
The code for all the demos can be found at the JAX blog entry of my colleque Gerd Wütherich, who prepared most of this talk. Thanks again for the great work, Gerd!

For those who are new to Spring Dynamic Modules: This project of the Spring portfolio basically allows you to use the Spring framework within an OSGi environment in a very nice and easy way. You can find more information on the Spring Dynamic Modules homepage.

Thursday, June 19, 2008

Report from Eclipse Demo Camp in Hamburg

Last Monday the Ganymede Eclipse Demo Camp took place in Hamburg. More than 40 attendees showed up and enjoyed a number of great presentations. Peter Friese wrote up a nice summary of the demo camp. I enjoyed the event a lot and I am looking forward to organizing the next Eclipse Demo Camp again together with Peter. Was a lot of fun! Thanks Peter!

Also many many thanks to Arne Roock for his great support in organizing the event and finding this cool location! His support is absolutely priceless!!!

Tuesday, June 10, 2008

Eclipse Demo Camp in Hamburg is Approaching Fast

Don't forget to register for the Eclipse Demo Camp in Hamburg - it is approaching fast. Starting next Monday at the EM-2008-friendly time of 6pm we will see some interesting demos, have free drinks and food (thanks to our sponsors: Eclipse Foundation, itemis and it-agile) and a lot of fun, I assume... :-) The demo camp takes place at the former coffee exchange - a really cool location:


So, have fun at the demo camp and many thanks to my colleague Arne Roock for his organizational support. Absolutely priceless.

Sunday, June 08, 2008

Equinox Aspects at Allianz

Some days ago I got a copy of the latest German Eclipse-Magazine (Vol. 15, 3/2008) and I found an experience report article about using Equinox Aspects. Cool! Great to read that people are using Equinox Aspects in large strategic projects. This report is about using Equinox Aspects for advanced performance tracing in a large production system at Allianz, a major insurance company in Germany. So if you are happy reading articles in German, take a look at it!

Thursday, June 05, 2008

SE-Radio Live at the OSGi Community Event 2008

The OSGi Community Event 2008 starts next week in Berlin, Germany. And there will be a special event taking place after the reception on Tuesday evening: We will host a live SE-Radio recording session. Isn't this cool? We are going to have a panel like discussion session with some interesting people and hopefully questions from the audience - all going into the se-radio recording and becoming part of that episode. So if you are going to the OSGi Community Event make sure you don't miss the SE-Radio live session - from 8pm to 9pm in the main room.
And many many thanks to Peter Kriens for making this possible and helping so much in organizing this!!!

Wednesday, June 04, 2008

Open XP-Days Germany 2008

The XP-Days conference series is a nice event series throughout Europe for people interested in agile software development (not reduced to Extreme Programming) and related topics. This years XP-Days Germany will take place in Hamburg from November 27th to 29th.
In opposite to the past XP-Days this years conference has an open review process in parallel to the submission process. This idea has two great advantages: everybody can review and comment on submissions via the submission system and people who submit sessions can benefit from those reviews and feedbacks by improving their submissions before the program committee decide. Sounds good, eh? I am used to this kind of open submissions from the EclipseCon conference and I must say: I like it a lot.
So don't forget to submit a proposal or give feedback on existing proposals - or simply join the conference this November!!!

Wednesday, May 28, 2008

Dependency Injection for Extensions, Second Edition

At this years EclipseCon I implemented an extension factory utility that could be used to delegate the creation of an extension object to a spring context (if you are using Spring Dynamic Modules). The result was that you were able to define your extensions as spring beans including all the nice spring features (dependency injection, aop, dessert topping, whatever...). That first implementation was nice, but had a number of stupid limitations (worked only for active bundles, for example). The good news is: A new version is available that includes some nice improvements... :-)

Firstofall, here is the new version of the Spring-Extension-Factory:

The new features are:
  • Ability to declare the bean-id explicitly within the extension definition

  • Automatic start of non-active bundles (and application context creation via Spring Dynamic Modules) when an extension is being created

How can I use this extension factory? Lets look at some examples. Lets assume you implement an RCP application and you would like to define a view as spring bean to inject some dependencies. First, you declare your spring bean inside the spring context:
<bean id="myview"
class="org.eclipse.example.springdm.rcpview.View"
scope="prototype">
<property name="myService" ref="serviceBean"/>
</bean>


Okay, this defines the spring bean called "myview" and injects a bean with the id "serviceBean" as a dependency into my view. The class of the view is the normal view implementation that you are familiar with. Don't forget to declare the bean as of scope "prototype". Otherwise spring would return always the same object every time an extension should be created (which is not the contract of the extension mechansim).

Now we define the extension in the plugin.xml file:
<extension point="org.eclipse.ui.views">
<view name="Message"
allowmultiple="true"
icon="icons/sample2.gif"
class="org.eclipse.springframework.
util.SpringExtensionFactory:myview
"
id="org.eclipse.example.springdm.rcpview.view">
</view>
</extension>


The class that is now referenced in the extension instead of the view itself is the spring extension factory followed by a colon and the id of our bean from the spring context. The rest of the extension definition looks exactly as before (without the extension factory).

The Spring Extension Factory includes two additional options to refer to the bean id within the extension definition. This is the strategy that I implemented into the extension factory:

  1. If a bean-id is explicitly defined (like in the example above), use this id to lookup the bean.

  2. If not, search for an id attribute within the contribution element of the extension and use it as the bean-id.

  3. If no id attribute is found inside the contribution element, try to use the id of the extension itself as bean-id.


The first option is the most explicit one. The second option works just for those extension definitions where the corresponding extension point schema defines an id attribute as part of the specific extension (this is the case for views, but obviously not for all extension points). The third option can be used for all extension points but is less explicit that the first one. In the end its a matter of taste which option you prefer.

Comments, feedback and improvements, of course, highly welcome.

Have fun with it!!!

Equinox Aspects and Spring-DM at the OSGi-Community-Event 2008

The OSGi-Community-Event 2008 in Berlin is less than two weeks ahead and I am pretty excited to give a talk on Spring Dynamic Modules there as well as some live demos on Equinox Aspects at the evening reception Tuesday night. The talk on Spring-DM will introduce the possibilities of using the Spring framework and Spring-DM within the OSGi world using some examples and live code. For the evening demo of Equinox Aspects I will do my very best to show the current state of Equinox Aspects together with some cool new features things like dynamics (aspects coming and going) with Equinox Aspects and (maybe) even load-time aspect weaving for Spring and Spring-DM within OSGi using Equinox Aspects. So please keep your fingers crossed for my live demos. :-)

Saturday, May 10, 2008

Finally aspects become dynamic

I recently committed some changes to the Equinox Aspects project which allows the Equinox Aspects runtime to handle dynamically uninstalled aspects correctly with regards to the woven bundles in the system. Having this it was only a small step to also deal with dynamic updates to aspect bundles as well as woven bundles at runtime. And now, finally, we are there: real dynamics for aspects. You can install, update and uninstall aspects at runtime as you like and the Equinox Aspects runtime takes care that everything will be woven and re-woven correctly. This is really really cool and a huge step towards real OSGi-enabled AOP, I think.

But what happens if aspect bundles are installed, updated or uninstalled at runtime? All other bundles that need to be woven, that need to be re-woven or that need to be un-woven from the aspect are updated automatically by the aspect runtime using the OSGi mechanisms. This means also that your system should be able to deal with OSGi dynamics and bundles coming and going (which is not a trivial thing to do). So be a good citizen of the OSGi world and your bundles will behave well when aspects are coming and going at runtime... :-)

Thursday, May 01, 2008

Aspect Weaving for OSGi at Java Forum Stuttgart

This years Java-Forum-Stuttgart 2008 is on the 3rd of July and takes place again at the Kultur- & Kongresszentrum Liederhalle (KKL) in Stuttgart, Germany. I attended this nice conference over the past years talking about various topics and listened to interesting talks there. Its well organized and its a pleasure to be there.
This year I will talk about one of my favorite topics: Aspect Weaving in OSGi. I will tell people what they need if they are going to adopt OSGi and AOP for the same system and how it is possible to modularize aspects into OSGi bundles. The talk will contain some live demos showing load-time aspect weaving for OSGi using the Equinox Aspects open-source project. It will be way cool, don't miss it! :-)

Saturday, April 26, 2008

When all is said and done I become a Guru ;-)

While reading the OSGi book from my colleagues I stopped by the dedication section on the first pages and found that Matthias dedicated the book not only to his wife and his daughter but also say thanks to me in this section, calling me his "personal Equinox Guru". Wow, I finally become a Guru... ;-)

Aside from not feeling like a guru at all and aside from the fact that there are hundreds or even thousands of developers on the planet knowing more about Equinox than I do - I feel somewhat proud to be mentioned in this book in such a nice way. :-)

Thank you, Matthias!

German OSGi Book

Colleagues and friends of mine have published a great introductory book on OSGi. Its called "Die OSGi Service Platform -Eine Einführung mit Eclipse Equinox". Its completely written in German (but don't be afraid, they told me an English version is somewhere in the pipe) and the first book on OSGi on the planet. Wow. Make sure you get a copy and learn about OSGi. I can just highly recommend to read this great book!