November 2005 Archives

Robert Cooper

AddThis Social Bookmark Button

After monkeying around with some DIY Ajax stuff, I started looking at some of the emerging tools out there. Please forgive me if I don’t mention [insert project name here]. Honestly, I have played with a number of them. No, I haven’t put all of them completely through the motions. However, there are a few that I think are pretty great.

Target Audience: Pretty typical Struts developer looking to enhance functionality without radically redefining the way she builds software.

Ascendancy: Order of invasiveness to your app.

AJAXTags

AJAXTags is a simple JSP taglib that offers some nice functionality. It is not a framework. It is not a methodology. It is, simply, a handful of app-friendly tricks that you can stick into your application. They have a nice demo page demonstrating each of the tags. There is a nice “sliding doors” CSS tabset, an autocomplete widget and a bean-bound table (imagine that :P). If you are like me, a lot of this is stuff that you have built by hand already, but having some standard tags for it is handy.

Taconite

Taconite uses the word “framework”, but I wouldn’t go that far. The short version is it is a tool that simplifies (a) making your XmlHttpRequest call and (b) gives you server-side markup that controls basic insert parameters.

For instance: If you want a button to append something to the bottom of a content area:

<script><!--
function foo(url){
   var ajaxRequest = new AjaxRequest(url);
   ajaxRequest.sendRequest();
}
//--></script>
<button onclick="foo('runButton.action?id=bar');">

Then your JSP for runButton would have:

<taconite-root xml:space="preserve">
  <taconite-append-as-children
    contextNodeID="idOfNodeToAppendTo"
    parseInBrowser="true">
        <div style="font-weight:bold;color:orange;">
           Taconite says: Hello World!!!
       </div>
   </taconite-append-as-children>
</taconite-root>

Of course, with some clever breaking up of JSPs, it is not hard to use the same content set for an AJAX and Non-AJAX version of your app.

Direct Web Remoting

The Zipperheads have a nice intro to this. This is the most invasive of anything here. This is basically an easy way to expose a service bean to a web client through JavaScript directly. If you are like me, and tend to build your business services with Axis SOAP in mind, you will find it nearly brain-free to re-expose them as a DWR “JavaScript Service”.

Moo.fx

This is just some chrome for your app, but its not bad and is a small and noninvasive way to give your app some polish. It is a set of nicely animated transitions and visibility controls. They have some fancy demos, but if you look at the test page you can see all the individual functions laid out pretty well.

Paul Browne

AddThis Social Bookmark Button

Related link: http://searchopensource.techtarget.com/originalContent/0,289142,sid39_gci1144375…

It’s probably too simple for you (after all, you’re reading an O’Reilly Technical blog!), but it could be good if you have to explain Ajax to your Boss (and yes, I’m pandering to the stereotype that the person you work for doesn’t know as much about technology as you do).

On the plus side, the article explains Ajax in nice simple terms. If you’re using it to explain why you project should use Ajax techniques, you boss will be happy to see big names like Microsoft and Google already doing it.

On the downside, the article glosses over what Ajax really means for Microsoft - by enabling rich applications to be delivered via a Web browser, it undermines the powerbase that control over the desktop has given them. Ironic for a technology first introduced and exploited by Microsoft themselves.

What do you think - How are you going to convince your boss to use Ajax?

Robert Cooper

AddThis Social Bookmark Button

Related link: http://www.bytonic.de/html/benchmarks.html

Jake2, a Java port of Quake2 is pretty cool. More than anything, however, it provides this interesting table:









































System


Original
C Code



Jake2-0.9.1
JRE1.5
jogl


Jake2-0.9.2
JRE1.5
fastjogl



Jake2-0.9.3
JRE1.5
fastjogl


Jake2-0.9.4
JRE1.5
fastjogl/lwjgl



AMD Athlon XP 2400
Geforce4 MX
Windows 2000
800×600 window


245 fps



172 fps


213 fps



241 fps



260/250 fps


AMD Athlon XP 2400
Geforce4 MX
Windows 2000
800×600 fullscreen


315 fps



not supported



225 fps


235 fps



250/282 fps



AMD Athlon XP 2400
Geforce4 MX
Linux
800×600 window



262 fps


141 fps



212 fps


215 fps



228/240 fps


AMD K6-2 350
Geforce2 MX
Windows 2000
800×600 window



56 fps


21 fps



31 fps



 



 


This is a great show of 3D prowess. Things like this, as well as the Narya 2D open source engine from ThreeRings really are starting to at least show Java can serve as a first-class gaming platform. More than that, just having seen all the… *cough* horrible code in games before, having things like Java’s threading model, network and database support might really make it a BETTER platform for a lot of forthcoming games than C.

The other thing I find interesting, as an aside, in the games industry is the divergence of “Graphics” and “Non-graphics”. WoW is a really great game, for example, that in terms of the industry has almost primitive graphics. However, stylization and “art” factors in to make the downright 1996 polycount look absolutely great, even on older computers. It could simply be that somewhere in the neighborhood of Q2’s polycount is all a lot of games really need. Of course, adding all the great new card features — bumpmapping, lighting, etc — really drive up the visual satisfaction you get out of those lower counts. More importantly, it keeps the generation of art assets in the range that (a) the open source project can put out something that looks nice and (b) the smaller game shop doesn’t need a team of thousands doing modelling.

Robert Cooper

AddThis Social Bookmark Button

Related link: http://www.theserverside.com/news/thread.tss?thread_id=37794

TSS is noting that WebWork and Struts are merging.

Ted goes on to lay out a longer term ideal of coalescence:

PROPOSAL: Bring WebWork into Struts through Struts Ti

We would to amend the Struts Ti sandbox proposal to provide for
merging WebWork 2.2 into our codebase. The WebWork merger would be Ti
phase 1. Much of the work now proposed for Ti would become phase 2.

* Ti phase 1 = WebWork 2.2 + Struts 1.x compatibility library and
migration tools
* Ti phase 2 = phase 1 + Commons Chain integration + Beehive’s Page
Flow + simplified annotations + quick development mode

When the Ti phase 1 has coalesced and is providing a high degree of
Struts 1.x compatibility, our intention would be to propose Ti as a
Struts Action Framework 2.x candidate. Until that time, we would
continue to consider Ti a “next generation” proposal and, pending a
decison by the PMC, avoid attaching the 2.x label to Ti.

When BeeHive Page Flow matures, it may be proposed to be merged with
Struts Ti as phase 2. That work could also be positioned as a new
subproject depending on where the PMC feels it would be better suited.
As we work on Struts Ti, we would also expect that work would continue
on Struts Action 1.x, perhaps including feature changes that would
bring the codebases even closer together.

TSS goes on, in their ever so cheezy “Conversation Starter” to ask:

Is there a push for a “single web framework” in Java? The JCP has produced a specification, JavaServer Faces, for web frameworks, which clearly doesn’t address all use cases (i.e., WebWork is an extension of XWork, an action framework, with web functionality, and JSF doesn’t address the AJAX pattern of having all user flow downloaded as required.) Some have said that it would be an advantage for Java to have a single framework, as Microsoft does, to reduce conflict and code invested merely to fulfill feature comparisons. Is that what you think? Is the merger of frameworks a good thing for web developers?

Now in this space, I have made no secret of my disdain for ‘framework’ and ‘tool’ proliferation in the Java space. So in response to TSS’ first question HELL YES. Frankly, we have WAY WAY too many projects that are, to use Ted’s language, “Conceptually… very similar,” out there. I will also make no secret about the fact that I think JSF is a bit silly over all, I am curious what the overarching plan is between “Struts Ti” and “Struts Shale”. In truth, Shale seems like more what JSF should have been from the get-go.

Either way, it really seems like we are starting to get somewhere in terms of unification. Now the question for the Java community seems to be, will Java keep pace. Shale and Ti are big steps. the W3C’s Web API and Web Application Formats look to be promising. My question is, (a) will we get to a point where Shale remoting supports the Web API and (b) the JRE/Plug in supports the Web App Formats in a reasonable time-frame.

I smell a revolution out there. The question is, will Java be storming the barricades or first against the wall.

Dejan Bosanac

AddThis Social Bookmark Button

Related link: http://www.jacuba.com

Today, the majority of web content is being generated directly through web pages, using TEXTAREA boxes. And with all this new AJAX movement I think that more and more people will replace their editors and word processors with some kind of on-line solutions for the most of their daily tasks.
So what we really need are services that will ease this on-line text editing. One of the most often requirements for web applications is to enable some kind of spell checking. Just a few years ago this was not a trivial task, but as AJAX became popular many solutions emerged.
The project that I especially like is Jacuba. It brings you an instant spell checking functionality for your web sites and browsers. I love simple things and could it be simpler than to add two lines in your header file and to enable spell checking for all TEXTAREA fields in your application? No download and installation, just two lines in your HTML.
Even if you are not a web developer, you can benefit from this service. You can easily add support for spell checking in your web browser (Firefox, IE and Mozilla) and use it on sites that don’t have it. This blog entry is written in TEXTAREA box and checked with Jacuba :)
Downsides? Well, a web page will be somewhat slower, of course. The more TEXTAREAs the slower the page, but it is not that bad especially if most of your users have a solid Internet connection.
Another issue is whether Jacuba component design will fit in your site design? The component style is very design neutral so in most cases it will not be a problem. Also, their project manager told me that they are thinking of providing a mechanism for easy component styling, so I hope that it will be addressed soon
Of course, you can find other projects that enables you to implement some kind of AJAX-based spell checking services, but the simplicity of Jacuba hooked me. Try it, you’ll like it.


Robert Cooper

AddThis Social Bookmark Button

After jumping through some hoops with my neighbor on a “How do I make Maven do this issue”, I believe we have officially found a better way to package in-VM unit tests and remote unit/integrations tests into a single Maven project. The trick is one property on the test plug in and one property that isn’t even documented on the properties page! Sometimes actually looking at the jelly file pans out.

The trick is:

/src/java
/src/test <-junit tests
/src/remote-test <- SOAP/JWebUnit/HTTPUnit etc.

Set: <unitTestSourceDirectory>src/test</unitTestSourceDirectory> and <includes><include>**/*Test.java</include></includes> or your preferred pattern.

Next, add maven.test.compile.src.set=src/test/remote-test to the project.properties.

Finally, you can define a goal, or set as a post-goal to tomcat:deploy, for example, in your maven.xml file:
<goal name=”remote-test”>
<ant:property name=”maven.test.search.classdir” value=”true” /><attainGoal name=”test:test” /></goal>
or run maven from the command line as
maven -Dmaven.test.search.classdir=true test:test
to pick up the remote tests.

Paul Browne

AddThis Social Bookmark Button

Related link: http://www.firstpartners.net/blog/technology/2005/11/18/your-applications-unsafe…

In the 60’s, the Auto industry used to say ‘Safety doesn’t sell’ - the thinking was that buyers were more interested in new features like whitewall tyres or the latest radio. That begun to change with Ralph Naders Unsafe at any speed and manufacturers became liable for their safety defects. Now any car that doesn’t do well in the Safety rankings will not do well in the salesroom.

When it comes to Security, is your application still stuck in the 60’s? Until recently it was thought that ‘Security doesn’t sell’. That has begun to change as buyers become aware of the possible threats that are out there. One such initive aimed at end users is Make it Secure (it’s run by the Irish Government, so excuse the photo’s). Once users are aware of the risks they are going to demand that we , as manufacturers of software, do much much better.

What do you think? - Are your applications unsecure at any speed?

Dejan Bosanac

AddThis Social Bookmark Button

Recently as a part of the larger Java project, I had to write the code that will convert IP address into the appropriate host name.
The first obvious solution was to use java.net.InetAddress object and its getHostByName() method. For example:

InetAddress addr = InetAddress.getByName("208.201.239.36");
System.out.println(addr.getHostName());

should print

www.oreillynet.com

which is all fine.
The problem starts when you encounter an IP address for which there is no host name that could be found.
To demonstrate this, we will rewrite the previous example in the following manner

long before = System.currentTimeMillis();
InetAddress addr = InetAddress.getByName("192.168.4.1");
System.out.println(addr.getHostName());
long after = System.currentTimeMillis();
System.out.println((after - before) + " ms");

Now, let’s suppose that there is no such address defined in your local network and that there is no reverse DNS properly set. The code snippet from above will print something like this

192.168.4.1
4737 ms

What is important here is that it took nearly 5 seconds to resolve this address, which is practically unacceptable for most of the applications. This behaviour could be easily encountered if you are using the Windows platform.
There are various sources on the Internet that suggests that this problem could be solved by adding a reverse DNS entry for the specified host.
For example, the following line

192.168.4.1	192.168.4.1

in the

%WINDIR%System32Driversetc

on the WinXp host will make the previous code to execute in 90 ms insted of 5 seconds.
But in my case, I need to deal with any IP address and program needs to work fast enough on any machine. So I looked up for the library that could help me.
dnsjava project is much more than I needed, it’s an implementation of DNS in Java, but it solved my problem.
Since I didn’t find any example of how to issue reverse DNS queries with dnsjava, I’ll post it here. The point is to create the replacement for the getHostName() method.

import org.xbill.DNS.*;
import java.io.IOException;

    public class ReverseDnsTest {
       public static String reverseDns(String hostIp) throws IOException {
             Record opt = null;
             Resolver res = new ExtendedResolver();

             Name name = ReverseMap.fromAddress(hostIp);
             int type = Type.PTR;
             int dclass = DClass.IN;
             Record rec = Record.newRecord(name, type, dclass);
             Message query = Message.newQuery(rec);
             Message response = res.send(query);

             Record[] answers = response.getSectionArray(Section.ANSWER);
             if (answers.length == 0)
                return hostIp;
             else
                return answers[0].rdataToString();
       }
       public static void main(String args[]) throws IOException {
             long now = System.currentTimeMillis();
             System.out.println(reverseDns("192.222.1.13"));
             System.out.println(reverseDns("208.201.239.36"));
             long after = System.currentTimeMillis();
             System.out.println((after - now) + " ms");
       }
    }

This program will print

192.168.4.1
www.oreillynet.com.
781 ms

As you can see, in this way we have both positive and negative query executed in less than one second. This is of course the result on the WinXP machine where the standard getHostName() method does the same job in 5 seconds.
Hopefully, the bug related to the java.net.InetAddress will be fixed in the Mustang release (6.0).


Paul Browne

AddThis Social Bookmark Button

Related link: http://www.firstpartners.net/blog

We’re currently doing some Oracle work as part of a Java development project and have come across a problem that must have been solved before.

We need to synchronise Oracle Databases, both over time (get DB to the state it was at a particular time) and locations (We have developers working on multiple sites with the only thing in common being CVS).We need a script rather than binary solution (so standard Oracle replication is out).

Our current solution involves custom Ant tasks and scripting the changes to the database (both static data and database object changes) in an incremental manner. The Database and CVS will be synchronised when a ‘CVS commit’ is carried out, with the usual CVS mantra of the 2nd developer to commit being responsible for sorting out any conflicts.

While this solution works well, I can’t help but think there must be a better, more standard way …

What do readers think? Are there any products/ solutions that you would recommend for this problem?

Tim O

AddThis Social Bookmark Button

Related link: http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO2&Sect2=HITOFF&p=1&u=/netahtm…

It looks like ETrade has been assigned a patent based on some component caching architecture it built using an application server in 98 or 99. Patent #6,964,052 is entitled “Caching output from an object in an application server environment”. Read on for more detail…

How about you? You going to stop caching objects?

Paul Browne

AddThis Social Bookmark Button

Related link: http://java.meetup.com/15/

Us folks in Dublin, Ireland sometimes get jealous of the amount of get-togethers that are available to you guys in the states.

OK, it’s less than 300 Dollars and 5 hours to get to New York for us, but while that’s ok for popping over for some of the bigger/more interesting conferences, it’s not really an option for the more informal get togethers to put faces to the names of people we see online.

Luckily, we now have the Dublin Java Meetup, an event where we meet up, talk Java , and basically find out some good ideas of what other people are up to.

In the spirit of Irish hospitality, all O’Reilly Weblog readers are invited along if they’re in the neighbourhood. You’ll need to be quick - the next meeting is on Tuesday 15th November. Luckily, there will be follow ups the 1st Tuesday of every month, so feel free to drop in then.

With the original Guinness Brewery just down the road, we can guarantee that this event has the best pint of any techie gathering!

What do you think? Are you booking your plane tickets now?

Tim O

AddThis Social Bookmark Button

A few years ago, I tried the Emacs keyboard mappings for Eclipse. I wasn’t impressed, I think there were a few missing features, etc. But, I’ve been screwing up ever since. I constantly switch between Emacs and Eclipse. I use Emacs for everyday text editing, and I use Eclipse for some programming. I do prefer Emacs for most tasks, but, with some of today’s programming languages, not using a tool like Eclipse with autocomplete and refactoring is a tedious exercise. Now with that being said, I do find myself programming Ruby in Emacs, maybe that say more about efficient language design than anything else.

I turned on the Emacs mappings for Eclipse today and was happily surprised. Suddenly the world made more sense. Instead of having to filter all of my instinctual keystrokes, I could search forward with CTRL-S and I didn’t have to interact with some “search dialog”. I could switch between buffers with CTRL-X, CTRL-B. Now, sure, I can’t hit META-X and type in “5×5″ or “zippy”, but I’ll take what I can get.

It’s funny though….I didn’t see the option to use VI key bindings in Emacs. Maybe the Eclipse Foundation realizes that vi is just wrong. :-) (I had to.)

On another note, doesn’t it feel strange to read “a few years ago” and “Eclipse” in the same sentence?

Did I just write this blog entry so he could write “vi is just wrong”? I think I did.

Paul Browne

AddThis Social Bookmark Button

Related link: http://www.firstpartners.net/blog

  • Java for allowing me to pay the rent.
  • VOIP for making sure that distance doesn’t matter (important when you’re on an island like Ireland).
  • Eclipse for being such a good development environment
  • MySql for making Oracle come out with a free edition.
  • JBoss for just working
  • PHP being soo easy-peasy to use

What are you favourite (tech) things?

Robert Cooper

AddThis Social Bookmark Button

Related link: http://javaposse.com/index.php?post_id=32346

The JavaPosse podcast has a good interview with Cedric Beust (one of my favorite Java pundits) up. He talks about TestNG, C# 3.0, Mono, Ruby and more. While he is much less of a bomb thrower than I am, but he joins the cry for a more agressive stance on updating the Java language.

Robert Cooper

AddThis Social Bookmark Button

So, it is easy these days to find people predicting the death of Java, or discussing the continuing utility of a framework and in the very next breath pontificating about the demise of the same. It is also imposible to miss the deification of the next great thing among the technorati.

I admit, recently I find myself more and more disillusioned with Java. And whether it its my own gripes about constant framework proliferation and NIH syndrome among the people who disclaim it at every turn, the Java world is getting seriously muddled.

At the server level, it is obvious that some things are more than a little over hyped and introduce complexity that shouldn’t be there, but the stanards people have just dropped the ball on driving us forward to a future with levels of complexity from the basic to the “I need everything.” The sad truth that “Enterprise” Java has missed for so long, is that even in the “Enterprise” only 1 in 500 applications need “Enterprise” functionality. While there are finally steps in the right direction, most of the world is still way more complicated than it needs to be.

On the desktop, you end up with mutliple solutions to identical problems that really should be getting driven at the JRE level. Not to mention several advancements in what we should be expecting from our environment that Java’s competition has gone to school on over the last few years. Sure there are partial great solutions to some of these problems, but none of them offer what you really want, and they are certainly not something you can expect the world to standardize on when they aren’t coming from the “standards” bodies.

No, Java is not dead. At worst, Java will be around for years in the same way ANSI-C has. There is just too much out there to walk away. However, Java seems to have become an also ran in every possible category. It is not “the language of the Web”, nor is it a “first class citizen” in the desktop. Even in the world of “AJAX” and “RIA” which Java foretold, it has lost the lead in technology and is negligible in mindshare. Java, however, needs some new life. It needs to reinvent the “Applet” into something cool and powerfully cool. It needs to absorb the things almost everyone needs in every app into not just a spec, but into the core runtime. I noted today that a lot of the very fair criticism of Linux could be applied 100% to Java with a simple search and replace. But most of all, what Java needs — for the first time I can think of — is not just someone who can design software or APIs well, it needs “the vision thing”.

Amir Shevat

AddThis Social Bookmark Button

Lately we have been getting feedback from users of our open source product, MantaRay, saying that our open-source license is not very business friendly. Our product is a serverless messaging middleware, in other words MantaRay is a JMS provider. Applications import our manta.jar and work with it as if they had a messaging server (broker) while actually they are working purely peer-2-peer. All the logic that was in the server is distributed and embedded in the edge applications.

MantaRay is released under the General Public License (GPL). GPL is contagious, meaning that if you embed a GPL library in your code you must release your own code under the GPL license as well. The situation is different when your code is decoupled from the GPL code; if your application is decoupled from the GPL code then you do not have this constraint. Take sugarCRM for example, it utilizes a GPL Database called MySQL but is released under the Mozilla Public License. It is up to the user that uses sugarCRM to install and configure the MySQL DB.

Some of our users are saying that GPL libraries are not really useable because of this viral nature of GPL, they suggest that we release MantaRay under the LGPL license which is a more business friendly license for Java libraries. On the other hand GPL is by far the most popular open-source license. Moreover, an interesting article by one of the people in the Free Software Foundation suggests that “Proprietary software developers have the advantage of money; free software developers need to make advantages for each other. Using the ordinary GPL for a library gives free software developers an advantage over proprietary developers: a library that they can use, while proprietary developers cannot use it.”, I guess this is not a clear-cut decision.

Should Open source Java libraries be released under the GPL license?

Tom Marrs

AddThis Social Bookmark Button

It took us a year and a half, but we finally finished JBoss At Work: A Practical Guide.

We wrote the book because we felt that there was a huge need in the JBoss community for a book that was aimed at developers who wanted to use JBoss. We found all kinds of good reference books that showed JBoss internals, but there was nothing that showed real working examples on how to deploy all of the core J2EE technologies (plus Hibernate) for a typical application on JBoss. We found a lot of good articles and tutorials on the web that showed how to do each individual technology, but there was no
single place to go.

So, our goal was to start with a simple
example that did nothing (it only had static HTML pages) and then iteratively add in the rest of the technology stack: JSPs, Servlets, database access (JDBC and Hibernate), EJBs, JMS, security, Web Services, and logging. Instead of bombarding people with everything at once, we felt that people could learn how to use JBoss faster by adding one technology at a time.

We feel that our book is important right now because:

  • JBoss has the greatest market share among leading J2EE
    application servers.
  • JBoss is gaining tremendous mind share in the Open Source Java/J2EE community.
  • There isn’t a lot of end user-oriented JBoss documentation.
  • JBoss 4.x is JBoss’ flagship release that complies with J2EE 1.4 (the Web Services release).
  • JBoss 4.x uses Hibernate 3.x, the latest production release of Hibernate.

The most important thing for our readers is that they will be able to take our code and start deploying it immediately - right out of the box. They can use the example application as a template for their own work and quickly get jumpstart their own projects with a working application.

Even if you don’t know back-end technologies such as EJBs, you would still be able to use this book if you’ve done a bit of web development. Even those developers experienced with all facets of JBoss/J2EE technologies will find the book useful because it shows how to use the latest & greatest J2EE 1.4 technologies on JBoss 4.x.