Pages

Friday, July 25, 2008

GSOC2008: The Pluggable Editors for Guvnor

One of the goals in this year's GSoC project for me is to enable plugging of content editors as jars. Today I've completed the automation for this aim.

I've integrated the rolodex widget for using image data in Guvnor. Next, the aim was to isolate the code into a separate place, so that it doesn't affect the base source code, and using some code generation routines integrate the new widget to Guvnor.


Here's the summary:

  • The pluggable code is moved into modules/ directory under drools-guvnor

  • build.xml was extended to generate some code pieces to integrate the pluggable editors. Some classes in Guvnor required a minor refactoring in order to support code generation.


It is not as smooth as it could be in GuvnorNG, but the goal is achieved to some extent, I think :)

Friday, July 18, 2008

GSOC2008: Rolodex Panel Assembly for Guvnor

In my previous post about integrating rolodex into Guvnor I tried to create the example just with a set of pre-compiled images which are then assembled into drools-guvnor.war. But the real goal is actually to display the pictures stored in Jackrabbit repository for Guvnor.
Now, after some experiments with rolodex and Guvnor, I have a widget where one may upload a picture and display it.


Currently it can accept only one picture per RuleAsset class instance. Therefore the content handler for this asset should be extended to support multiple images per RuleAsset.

RolodexCardBundle images = getImagesFromAsset();
RolodexCard[] rolodexCards = images.getRolodexCards();
if (rolodexCards.length > 0) {
final RolodexPanel rolodex =
new RolodexPanel(images, 3, rolodexCards[0], true);
layout.addRow(rolodex);
}

I have set the hight of the panel manually as the picture was cropped otherwise in the widget. (Don't know the reason yet). getImagesFromAsset() is used for converting the asset's content to the RolodexCard:

public RolodexCardBundle getImagesFromAsset() {
return new RolodexCardBundle() {
public int getMaxHeight() {
return 200;
}

ClippedImagePrototype clip = new ClippedImagePrototype(
GWT.getModuleBaseURL() +
"asset?" + HTMLFileManagerFields.FORM_FIELD_UUID +
"=" + asset.uuid
,
0, 0, 300, 200 );

RolodexCard card =
new RolodexCard(clip, clip, clip, 300, 100, 10);

public RolodexCard[] getRolodexCards() {
return new RolodexCard[]{card};
}
};
}

I've cheated with the code that composes the RolodexCard, as ClippedImagePrototype's javadoc says:
This class is used internally by the image bundle generator and is not intended for general use. It is subject to change without warning.
But the implementation of ClippedImagePrototype is actually what I need. Probably, if it is really the subject to change at any time, I would rather cope'n'paste this class into Guvnor code base.

TODO:
A heavy part of the work will have to be carried out by the content handler. The content handler will have to support the multiple images per asset and also perform some graphics routines in order to replace the pre-compilation phase implemented in rolodex to adjust images.

Tuesday, July 15, 2008

The time applet in Ubuntu

Recently I discovered that there's one cool feature in the GNOME's time applet: the Locations tab. There I can specify my location and customize the applet look. One interesting feature attracted me the most - the "weather" label. I can see that the weather is if I take a look out of the window. But I think I couldn't say exactly how cold/warm is it - and the applet can show me this information. Small but neat feature I have to say! :)

GSOC2008: Integrating Rolodex to Guvnor

In Guvnor, there are many different widgets that are used to display or edit different assets. One interesting widget is about to be added - a widget that could accept images and display them. For this purpose, rolodex, a widget that can display a stack of images, can be used. Rolodex uses deferred binding for the image generation and animation. Let's see how can we quickly add a new widget displaying some predefined images.

First, create a class, implementing RolodexCardBundle interface (from the rolodex library) and declare a few methods that will return the images (just like ImageBundle described in the book):


public abstract class Images implements RolodexCardBundle {

/**
* @gwt.resource img_3861.jpg
*/
public abstract RolodexCard imgA();

/**
* @gwt.resource img_3863.jpg
*/
public abstract RolodexCard imgB();

/**
* @gwt.resource img_3865.jpg
*/
public abstract RolodexCard imgC();

...

private final RolodexCard[] cards = new RolodexCard[]{
imgA(), imgB(), imgC()
};

public RolodexCard[] getRolodexCards() {
return cards;
}


Next, to display those images, create ImageSetWidget (or you-name-it) class extending DirtyableComposite:

public class ImageSetEditor extends DirtyableComposite {
// asset and viewer are not used now...
public ImageSetEditor(RuleAsset asset, RuleViewer viewer) {
final Images images = (Images) GWT.create(Images.class);
final RolodexPanel rolodex
= new RolodexPanel(images, 3, images.imgA(), true);
initWidget(rolodex);
}
}


For Guvnor to be able to launch the editor, we have to modify EditorLauncher class:

...
else if (asset.metaData.format.equals(AssetFormats.IMAGE_SET)) {
return new ImageSetEditor(asset, viewer);
...

AssetFormats should be supplied with the new constant for this new type, of course.

To allow user to create such widgets in UI, a new menu item needs to be added.


This means, ExplorerLayoutManger#rulesNewMenu() should be modified:

m.addItem(new Item("New ImageSet",
new BaseItemListenerAdapter() {
public void onClick(BaseItem item, EventObject e) {
launchWizard(AssetFormats.IMAGE_SET, "New ImageSet", true);
}
}, "images/rule_asset.gif"));

And last, but not least we need to include the following line in Guvnor.gwt.xml:
<inherits name='com.yesmail.gwt.rolodex.Rolodex'/>


Now, after the project has been rebuilt and redeployed we get the following widget on the screen:


Currenly, the widget is displaying a predefined set of images and animates them as we roll the mouse over. So we have now a rolodex-powered widget inside Guvnor. Sounds cool! :)

Now, there are a lot of TODOs to make use of this new cool widget.

  • Menus should be pluggable. So far I knew that the only class that we should generate in order to support adding new rule editor widgets. Without doubt, a user needs a button to create the widget in his workspace, and therefor we should inject the new menu item. I suppose we can generate this part also. Therefore we need to extract the ExplorerLayoutManger#rulesNewMenu() method into a separate class.
    Currently I have an ant task ready to generate a new EditorLauncher class source to plug a new asset type editor. But perhaps, if we have more of these classes to be generated, I'd better add a new ruby script to do this job.

  • Upload of new images. There's no use of this widget if it can redisplay only the predefined set of images.



  • RuleAsset support for images.The images should be supplied via the RuleAsset, i.e. the content should be a class that could represent a set of images.


  • A content handler is required as well.

Friday, July 11, 2008

Google OSS Jam: Zurich Meetup for GSoC'08

I've spent 3 days in Zürich, again! I really like this city :)


Thanks to Maximilian Albert I'm now aware of Inkscape, an Open Source vector graphics editor, and lib2geom. Thanks to Peter Arrenbrecht a mentor for Mercurial GSoC project, I'm now totally convinced that the DVCS is what I really need, either Git or Mercurial :) And thanks to Stefano Tortarolo, a student from Mercurial, the next programming language in my arsenal should definitely be Python!

Some more interesting OSS projects that were presented at the OSS Jam:

Friday, June 27, 2008

JAZOON 2008, Post Mortem

I think that JAZOON'08 was a real success and this conference has a lot of potential in the future! We have to give a credit to Jürg Eberhard, Christian Frei and the rest for the outstanding organization!
What I really liked about the conference is that many presenters talked about the real projects and proposed solutions, instead of just talking about the standards, methodologies, frameworks, etc.
I would suggest this conference to my colleagues. Furthermore, the location is just right - Zürich - one of the nicest cities I have visited so far!

Long live JAZOON!

JAZOON 2008, Day 3

The keynote was given by Joshua Bloch, Principal Engineer at Google. In Effective Java Reloaded he presented some chapters from the 2nd edition of his book Effective Java. Joshua talked about generics, enums and concurrency.
After the talk he was signing the book, Effective Java - 2nd Edition, which was exclusively available at Jazoon'08. So now I have a pleasure happy to own the book signed by Joshua Bloch! :)


After I've got my book signed I went to listen about the new features in Eclipse 3.4. After the release of Ganymede, there are some very cool features which I probably would like to see in IntelliJIDEA too! :)

Next, Dan Allen was continuing with Seam Framework related talk It's evolution, baby! Bijection deplaces dependency injection. It is a very promising concept on bi-directional dependency management which is widely used in even the simplest Seam web applications.

Later, Heinz Kabutz has shocked crowd with his blizzard talk about threading in Java - The Secrets of Concurrency. No one couldn't even ask a question! :)
Here's one useful idiom that I managed to put down:
while(!Thread.currentThread().isInterrupted){
try {
Thread.sleep(100);
} catch(InterruptedException e){
Thread.currentThread().interrupt();
break;
}
}
It is funny that "idiom" and "idiot" are quite close - Heinz said :)
The last session I attended The Closures Controversy by Joshua Bloch. To be honest, I like closures ... outside Java! Really, if one is really eager to use these fancy syntactical constructs - there's JRuby, Groovy or Scala available - use them!
Here's just some of the facts I picked up from the presentation. Closures are/have:

  • hard to read

  • produce cryptic error messages

  • don't interact well with autocompletion

  • have two kinds of returns, whereas the real meaning of the return keyword has changed

  • unclear semantics

  • not thread safe


What is really wrong with the inner classes compared to closures? Only that you do not have to make a new class and don't have to create it with the new keyword? I think that inner classes are still better from what we could see with Java closures. Closures are for dynamic languages which can be used in conjunction with Java! So I'm strongly opposed to the idea of including this feature into Java language. Java has to stay clean! Unfortunately it has already been rubbished with the spoiled implementation of generic types :(

Wednesday, June 25, 2008

JAZOON 2008, Day 2

On the second day of JAZOON ...

The opening session

Rethinking Enterprise by Ted Neward (Neward & Associates) was a great introduction to the day! He pointed out the things that I'm talking about to all my relatives and friends - the education system sucks! The problem is that almost everything that we learn in school we forget. And this is just because of the system - we are presented with some theory and then we are tested on that theory using some problem statement, and after that - nobody cares.
One great statement I put down - "The problem and its solution are never apart". And this statement actually describes the problem above - at schools we are never forced to think beyond the theory which we just learned.
This was also a funny talk with some jokes about the "long-haired guy". This is a good one - Ted said (jokingly of course):
I know how to make copy-paste in PowerPoint, because I am an architect!
.


Open Architecture by Roy T. Fielding (Day Software). This was a little boring talk, but to say the least it was truly right talk. I mean all the things that Roy was talking about are valid I think - of how the open architecture matters for open source software, how the ecosystems work, etc.
Now I know what the Conway's Law is.
Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.

And also after Roy's talk I would like to try what can Apache Sling do.

Spring Framework 2.5 - Selected New Features, Juergen Hoeller (SpringSource). This was a neat overview of Spring's AOP and the new features that can be implemented with Java annotations. Basically I could read everything he talked about in the web, but it is quite nice to get it to know from "the source".

Then I attended the session called Stacking the deck by integrating Spring beans and Seam components by Dan Allen (TetraTech, Inc.). The point was that we can use Spring in co-operation with Seam in order to wire up JSF pages to the underlying beans, and this avoid using the expression language (EL). The talk was quite interesting and very technical too. It seems to me that the sessions that are somehow related to JBoss are the most interesting ones @ JAZOON.

JSR-303: From a world of Constraints to Constrain the world by Emmanuel Bernard (JBoss). Again, the JBoss related topic was just the right session to choose. Emmanuel was talking about the beans validation (JSR-303) which can be implemented using Java annotations. He also pointed out that there should be a clear separation between bean validation and conversion (and I do agree on that).

I noticed that theres a huge trend for most of the topics - the Java annotations. Almost in every presentations the authors wanted to implement things using annotation-based configuration. Perhaps, this is the real hype of meta-programming in Java community.

An interesting type of presentations is the one where the author is presenting a deployed solution and talking about the problems he faced while implementing the system. At the talk called Distributed client/server Java Persistence by Alexander Snaps (Axen/Alten Group) the author was presenting his solution for offline clients with centralized database. He also mentioned a new framework he implemented for this purpose - Hölchoko (need to have a look on it).

And the last session I attended was Cluster your POJOs with PojoCache by Bela Ban (JBoss). This was just perfect as always :).

Tuesday, June 24, 2008

JAZOON 2008, Day 1

The first day @ JAZOON is complete!

The opening session.

  • At the talk called The Challenge of Scalable Languages, Martin Odersky (the creator of Scala) was talking mainly about Scala language and how does it relates to Java. Explaining some of the design decisions for Scala (at last, I've got the answer for the silly declaration construct in Scala, i.e. var x: Int). There are many nice features in Scala I think. But I do not really understand why the operator overloading is brought in again?! Operator overloading was the feature that Java designers wanted to get rid of after C++, because when you read the A+B you cannot be sure weather the operands are really numbers.


  • Simon Phipps was talking about The Adoption-Led Market. He started with Sun's relation to open-source, continuing with open-source history and licensing. This was a good talk with a lot of funny stuff in it. The only question to Sun is that if Sun is so opened to open-source software, why did to closed the source of MySQL engine??


  • Next, Rod Johnson expressed a lot of criticism in respect to J2EE, JCP, etc in his talk Where will Tomorrow's Innovation Come From in Enterprise Java. For sure, he didn't forget to mention the Spring Application Platform :)


Next, Dmitri Buzdin was talking about his experiences with GWT adoption. I piked up that there are some difficulties with GWT, specially for developers who have less experience.

Against all odds - efficient Rich GUI development in Java. This was a talk about the rich UI development for a company called APG that is dealing with billboarding. The current solution was implementing Oracle Forms technology and as Forms is being deprecated, they decided to implement the rich client in Java with Swing.
So basically they were talking about the rewrite of UI without touching the back-end. As the result there's the direct connection from client to the database. I'm not sure how scalable new solution is, but the technology used for implementation is what amazed me the most. The UI is being generated based on meta-data described with some DSL. The framework used for this is the openArchitectureWare. The guys were claiming that this way they increased the development speed compared to the Oracle Forms. I think that the complete solution is a real crap. I can tell why. First, while the demo failed, they showed us the code - it was half-german, half-english code there, i.e. some methods were named in German which I think is a rally bad practice. Secondly, the technology stack which lead from the specification to the implementation is very unclear: if there will be an error, the application developer will be seeking for the problem all the day long instead of writing the real code. And last but not least, they did not finalize the project yet, so it was a little bit too early to talk about its success. I think even if the project gets finalized, if future the cost of maintaining this piece of software will be inadequate.
Perhaps I'm too rude in expressing my opinion to the solution some people may think is really good. May be it is just that I do not understand the MDA really well. So probably I'll take a look at it if it happens that I have nothing else to do :)

AJAX Push for Revolutionary Enterprise Applications presented by Micha Kiener (mimacom ag) and Ted Goddard (ICEsoft Technologies Inc.) was a nice presentation I enjoyed. The technology presented is quite innovative and it looks like pushing a new wave in the area of Web 2.0 application development. The keywords: Ajax Push, Comet, "Reverse Ajax", ICEFaces, Edoras, Servlet 3.0.

Disqus for Code Impossible