Agent Smith: graduated
Monday, March 26th, 2007A quick one: AgentSmith has graduated from the javatools incubator and is now part of the javatools project.
Current release (0.8) will become 1.0 during the following weeks.
A quick one: AgentSmith has graduated from the javatools incubator and is now part of the javatools project.
Current release (0.8) will become 1.0 during the following weeks.
Eclipse will finally store user installed plugins into user’s $HOME folder IF the folder into which Eclipse is installed is not writable.
This problem affected every Linux distribution and, thanks to the guys from the Fedora project (Ben Konrath in particular), a patch was provided since Eclipse 3.1.
The bug was filed on April, 2005 (!!!). Hopefully linux-distro project will take care of such problems in the future.
[ More details ]
Ok, I must admit it, I can’t hide: I was wrong. I’ve just discovered that Agent Smith features are already available. To everyone.
A brief explanation.
I’m an Eclipse user. I have been (silly) used in reloading my webapp every time I changed a Struts action or a piece of an Echo2 application.
I wanted to find a way to avoid reloading my webapp.
I saw Groovy. But it didn’t work with Echo2, because of the API.
I saw the Instrumentation interface and I thought: “Hey I will do that: Grovvy won’t be necessary”.
So Agent Smith saw the light. And it was just reaching version 1.0 when I was told that, actually, Eclipse has already a feature like Smith. And it’s really simple to activate it.
So, Smith is dead. Long live to Smith. Thanks to Adrians at the Echo2 forums for finally pointing that out.
I’m very sad, you know. I’ve wasted some days. The most disappointing aspect is that it took two weeks of marketing for someone to come out and say “Hey, you are wrong”.
But!
I know I’m not the only one with this lack of knowledge, so let me flip the bad news in a good news and let me explain how to avoid reloading apps with Eclipse.
Right click on your, say, web project and “Debug as”, “Debug on Server”. Now code.
I can hear you: “Whaaaaaatt? THAT simple!?!?“.
Yes, that simple.
Agent Smith has just been approved by the java-tools community at java.net. It’s currently in the “incubator” but I’m sure it will graduate soon.
Following my previous post, in the agent smith post series.
Smith comes in two versions: one is java5 only, the other is java6+, meaning you must have at least java 6 (or mustang) to run it.
The two versions differ in one feature only: the ability to load the agent after the jvm start up, instead of the usual way that’s by specifying it with a command line parameter. Anyway, such feature is experimental (even if I use it daily).
Let’s see what to do to begin using Smith.
ant dist
javac Main.java
java -javaagent:<PATH_TO_SMITH_JAR>=<PATH_TO_CURRENT_FOLDER> Main
Every path must be absolute.
You should see two messages repeating every one second
Bar: I’m doing something
Bar$Foo: What else???
Easier done than said :)
Next time we’ll set up Tomcat to use Smith into a webapp.
This is the first of a series of articles about Agent Smith. I will begin with an introduction, followed by a “try it, test it how-to”, ending with some examples together with Echo2, Struts and Spring.
As you may know, I am a bit involved with Echo2. Really, I’m a fan of it, I love the way I create ajax UIs coding the swing way. And forgetting the page thing.
But Echo2 has two problems: it consumes a bit of memory (but I don’t really care, since my apps are not intended to be delivered to the world “wild” web) and, if you don’t use EchoStudio, it needs you to reload the webapp to check even small UI changes (obliging you to a constant code-restart-code).
Well, the second problem has been solved. Its solution is called Agent Smith.
Why “agent” ? In java, there are many meanings of the word “agent”. One meaning is a class that has access to the Instrumentation interface, introduced since java 5. With Instrumentation you can call a wonderful method:
With such method you can change the definition of an entire class, while your program is running. If you have ever played with ClassLoader (creating your own implementations) you know what the method “defineClass” does and you know it is final.
Instrumentation can be used as a workaround to the problem of class redefinition, meaning you can actually use java as a scripting language.
So why not just use Groovy or some other scripting language ?
Because Groovy is slow. Because scripting languages are usually slow. Test Groovy. I found it 18 to 20 times slower that “native” java code.
Java has been criticized by every Microsoft developer for being slow. And they were right. Were. They are no more. Why the heck should I use Groovy to code? Would you shoot at your feet?
But don’t take my humble opinion as a “scripting languages are the wrong way” opinion. Groovy in particular has a lot of nice features (especially the syntax) but, since I’ve read articles about using groovy to speed up Struts actions building, you may find an agent a smarter and cleaner solution.
I think there are times when we really need to avoid app server restart. Think about your JEE application running into JBoss, about your JSF backing bean…
Scripting languages allow us to avoid server (or app) restart, but they also add weight to your code, making it slower.
An agent is a bit hard to set up and so it may not be a good solution. But if you are planning to work on the same project for the following two weeks, then it is.
In the next article I will explain how to compile and set up Smith.
See you soon.
Today was my last day in Concept. After 1 year and a half, my very first java experience, I’ve stopped being part of the staff.
I hope I’ve done well, but I’m quite sure I’ve chosen the right way. Not really because I’ve brought (learned and taught) Echo2.
Because I’ve had the opportunity to learn and share a lot of things, things that made the company switch to AJAX and TDD.
After almost 6 years spent in Milan, tomorrow I’ll go back home, Turin, where I have a couple of things to do.
First, a flat. I’ll sleep in my parents’ house for some weeks but I need to get a flat.
Second, a new job. Something that could allow me to start being a one-man-company. I want to keep on working together with Concept, I want to closely follow some open source projects I’m interested in and I need a job for a living. Want, want, need. Uhmm… :/
Third, helping my friends switch to GNU/Linux.
Fourth, getting a life. It’s been quite hard since today. Things have to change.
Wish me luck, something new is going to start here.
As I’ve promised, here is the translation of my interview by JavaJournal, the italian java magazine.
Hope you’ll enjoy it.
A server-side solution obliges you to keep an eye open on memory consumption but it also gives you a security layer for free, due to the session. Echo2 adds to that a synchronization mechanism that, given a valid session, does not allow you to “press a button” currently invisible to that user. With client-side solutions you need to code such checks manually.
Finally, Echo2 implements a Swing-like API that can flat down the learning curve.
As far as I’ve seen till now, an average complex application takes about 30 Kb for each user.
Together with the quality of the final result, Echo2 is a tasty solution, surely worth an evaluation.
I’ve been interviewed about Echo2 by Michele Sciabarrà from JavaJournal.
If you understand italian, you can read it here; otherwise, please wait until tomorrow, when I will post the translation on my blog.
Quite excited, I must admit; even a bit embarrassed ;)
Some users from the Echo2 community forums have been complaining about the lack of presence from Tod Liebeck, developer and maintainer of Echo.
As I’ve supposed, Tod have been completely caught by his company projects.
Now Tod has posted a status update about Echo 2.1 (the RC is coming! at last) and 2.2, that promises to be faster than the current 2.1.
We are all looking forward to them, Tod! Welcome back!!