Saturday, September 27, 2008

As a Java developer I'm sometimes bitten by a bug when runtime loads a wrong class form a wrong library. Often times I'd loose a lot of time tracing the problem to multiple versions of the same library loaded. This quite often happens when you use Maven. For instance, if you put a dependency on two different libraries, and one of them pulls down one version of Log4J, while another loads a different version of it, you are going to end up with two versions of the same. Chances are that they not compatible with one another.

After stumbling into this situation a few times, I decided to write a simple Swing based app for tracing down all the jars in a specific directory. Thus, the JarExplorer was born.

JarExplorer is a simple tool which can be used to inspect large jar repositories. It will allow to locate classes, property files, images, and all other resources inside those libs.

It works very well for me, and I hope someone else will also find it useful.

It can be downloaded from the following location: http://code.google.com/p/jar-explorer/


Besides ability to open images, text and HTML, it also alloes to peek inside classes. It will show inheritance, all methods (even private) as well as all member variables. This is accomplished via use of a library called javad: http://www.bearcave.com/software/java/javad/index.html by Ian Kaplan.
Java reflection was too limiting for the purpose, but Ian's library worked quite well.

The JarExplorer is fully self-sufficient, and does not require anything else (besides Java :)).
When it starts up, point it to a directory with jar files and wait a bit until it indexes every jar in it (recursively of course). After that you can do very fast searches using this tool.


Good luck
igor

Monday, February 18, 2008

Exadel Flamingo Released

Although this blog is a bit late on the news, nonetheless, we finally released Exadel Flamingo 1.6. This is a bog milestone for the project.
For those who does not know what Flamingo is, can refer to the following articles: Integrating Flex with Seam and Flamingo.
Even though this article describes integration with JBoss Seam, Flamingo supports combination of Spring/Hibernate pretty much the same.

The new release, besides the previous features, contains vast improvements. It moved made a few steps in the direction to become an agile development framework for Flex on Java. The features of interest are:
  • Code generation greatly improved with generation of ActionScript files from Java, added ability to create CRUD screens for entities with relations (e.g. one-to-many)
  • 'CallSet' and 'Binding' Flex components added for Spring
  • Added "search by relationship" and sorting for dynamic methods
  • Spring Security integration added

The nice thing about Flamingo is now, you can develop applications on Flex blazingly fast. There is a wealth of simple scripts to generate most artifacts in the project, including a fully working scaffolding for entities - completely wired up. This is a great way to prototype a relationship model.

Another advanced feature is Dynamic Persistent Methods. This allows Flex developers to simply call methods on the remote object even though these methods are not declared anywhere!
Here is an example:
Let's say you have a Hibernate entity class declared like this:

@Entity
public class Person implements Serializable {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}


On the client side, you can just execute this:

<mx:RemoteObject id="person" destination="Person" result="resultHandler(event)"/>
...
private function resultHandler(event:ResultEvent):void
{
entities = event.result as ArrayCollection;
}
...
person.findAll();
person.findByNameLike("John%");
person.findByNameNotEqual("John Smith");



The simplicity and power are apparent. No need for extra configuration, no need to think about mapping of web services, the call just executes and returns what is expected.

Dynamic Persistent Methods also support relationships. If you have two entities in a relationship:


@Entity
public class Author implements Serializable {

private Set books;
@OneToMany(mappedBy = "author", fetch = FetchType.EAGER)
public Set getBooks() {
return books;
}
}
@Entity
public class Book implements Serializable {
private Author author;

@ManyToOne(fetch = FetchType.EAGER)
public Person getAuthor() {
return person;
}
}


On the Flex side, you can call dynamic methods on relationships like this:


<mx:RemoteObject id="book" destination="Book"/>
...
book.findByPerson(currentPerson)


How was this accomplished, since these methods were not declared on the class "Person" in Java? There is not magic here, just some clever programming. Flamingo on the server side parses the request from the call, and recognizes that a method is dynamic. Then, based on the syntax rules for method names, it generates a dynamic Hibernate SQL query, executes it and returns results back to the caller (on the client side!).

As you can see, this is some powerful stuff. Of course, Flamingo is not for everyone. If you develop business database driven applications, Flamingo is a perfect candidate for consideration, if you already have an application based on Seam or Spring/Hibernate and you want you make it mode dynamic, Flamingo will suit well.

Exadel Flamingo lives here: http://www.exadel.com/web/portal/flamingo

Good luck