Archive for the ‘java’ Category

New Year, new start

Sunday, January 13th, 2008

In the true tradition of ringing out the changes with the new year, I’ve decide on a few changes myself. I’m separating the blogging stuff I do for myself (because my memory is sooo bad!) from the work that interest me.

So from today, I’ve launched a new site MinimalSoftware. Check out the blog
too.

The rest of my bizarre ramblings will stay here!

Using the Swing Application Framework

Tuesday, July 10th, 2007

I wrote a while ago about JSR-296. Well, John O’Connor has put up a new article on using it Using the Swing App Framework and provides a real example showing the lifecycle, session management, resource bundles and how a project gets organised. There’s even a demo app to keep you going…

Swing Application Framework and Beans Binding – Joshua Marinacci

Friday, May 25th, 2007

An excellent session on the following JSRs:-
JSR-296 Swing Application Framework
JSR 295 Beans Binding

Put together, these address some of the issues in quickly building Swing applications. In reality, the desktop api is very big and what was given to developers was a whole bunch of components, without structure, lifecycle or wiring. What needed to follow was tool support and a framework – both of these have been patchy at best.

Anyway the goal was to create a framework as small as possible that could be explained in 1 hour, and would work well for small to medium sized apps, and provide the following key services:

Lifecycle
Actions
Resources
Tasks
Session state

Getting started is straight forward, you subclass Application, create and show the UI in the startup method i.e. @override protected void startup(), then use the Application Context to manage the services.

From the GUI builder, there is a nice encapsulation of behaviour, a default GUI, and the ability to recall or set enabled or selected states of components.

Managing actions for Swing has always been difficult, now you use the @Action annotation for your method, then to use an action, it’s something like
Action myAction = getAction(”sayHello”) which gets the registered action from the context.

One other thing you’ve always needed to do (though we’ve all done it wrong sometimes!), is use a background thread for event dispatching. The framework includes SwingWorker, which allows you to monitor progress, handle messages, and do start/stop. This has been extended with Task which gives additional support.

To create from the GUI, there’s a simple task editor, with a select box to enable as a background task. You can even allow them to block too if you like, so you can do things like freeze the UI until your search results come back.

Then very cool, right-click the app and select enable webstart. That’s it nothing else.

JSR- 295 really is about keeping two sets of objects in sync.From source through a converter to the target, then back through a converter and validator to the source (a property on a bean).

The editor allows you to specify a source using simple EL e.g. ${customer.salary}, or a whole object e.g. customer. The beauty here, is that it doesn’t need any special object types to do this, it uses a standard property change listener, and it deals with collections too, by using observable variants of Map and List. There is also support for various update strategies: read once, only from source and keep in sync. Finally, you can validation and transformation to convert a String to a Color.

To manage all the bindings, you use a binding context.

The binding stuff is still work in progress, but in good shape already. You can get more at
beans binding and on Shannon’s blog at Shannon’s blog

Then a very cool demo showing creating a flickr photo search app, built from scratch in about 4 mins.

Wait, more demos! A mashup – Maps and a database.
When you create a new Swing Application Framework project, you have the option of the basic one with built-in menus and progress bar, or creating a Database app, which connects to your database, and uses JPA, to build a form for you. Then they showed changing the cell renderer for the part that had a URI in from string, so it would go and show a picture of a real estate property, then they added the JXMapkit to display on a map the location.

Very nice. A lot of hard work has gone into this, check it out, I know I’ll be downloading it for a play.

JRuby, Understanding the fuss…

Friday, May 25th, 2007

JRuby – Understanding the fuss

Some background, Ruby is a dynamically typed, pure OO language. It’s open source, pretty easy to write and fairly powerful. A couple of deficiencies being addressed in the current 2.0 effort include green threads and unicode support.

Everything in Ruby is an object, dynamically typed, though strongly typed. However, type is less important than behaviour:

Duck typing, runtime exceptions (sounds scary, but rarely happen – I’m waiting to be convinced!).
Mixin modules allow you to include additional behaviour e.g. class Circle include ShapeStuff.

Blocks are nameless functions you can pass and invoke to remove repetitive code.

Well, that’s my version of Ruby in a very small nutshell, now onto JRuby – a Java implementation oof Ruby.

JRuby, gives you easy integration with Java libraries, and you can call to Ruby from Java via JSR-223, and use Java classes from Ruby.

include Java
import javax.swing.JFrame

Now you can script Java.

JRuby offers a rapid MVC framework, and prefers convention over configuration.

So why do Java users want it?

- easy to learn
- less code
- features missing from Java (closures, open classes, literals for Arrays and duck typing)

It’s a better language for tying libraries together, and you can easily create domain specific languages (DSLs)to wrap libraries.

There’s also JRuby on Rails for Java developers, much less rails code than Java application config, and simple CRUD apps in minutes.

Am I sold? Not yet…then again I am biased. There’s more on DSL’s latter this week.

James Gosling, the Semantic Web, and a dog feeder.

Friday, May 25th, 2007

No T-shirt hurling machines this year, which is a shame.

Three main themes as teasers, Netbeans, Semantic Web and SPOT.

Firstly, from the community itself, there’s now a PDF Netbeans magazine on the community website, looks good, useful articles, and the right price :-)

Then we had Henry Story and Tim Boudreau, on making the semantic web dog simple (there’s a dog theme here, we’ll get to it soon).

Quick Recap:
URI – Identifies a resource e.g. documents, people,concepts

REST – REpresentational State Transfer. Things to remember, a resource can return any number of representations, representation can be cached on the Internet, and REST describes the architectural style of the web.

Consider a database table, at the intersection of a row and column, there is a value with a name. In this instance the relationship is local not universal, therefore we need to turn all these relations into URI’s like relation, subject, object (aka triples).

One of the added benefits here is that because we use URI’s, we can click on them to follow the object, and what that is giving us is self describing metadata about objects.

With it so far? Well, that’s the basics, and coincidently these, subject, relation/property, objects are how RDF, the Resource Description Framework classifies things.

And these are at the heart of the Semantic Web. The semantic web, requires structured data, and people don’t like creating structure, but many of the tools we already use create structures

- blog engines like MovableType
- Social networking sites (FOAF)
- Open Source project sites

At the heart of it, is a simple scheme, based on URIs, delivered on a scalable simple mechanism (REST), using RDF which can’t have any less than a subject-relation-object, and it’s clickable.

They gave an example of a scheme for describing projects (project, homepage, license etc.) DOAP (description of a project).

Finally, Bob Beasly showing off a rich client app he’d built, and he’s a non-techie, using the visual web pack. Well, I thought I’d seen it all….No, he’s built a webapp he can use to remotely control a PC that he uses to train his dog. He clicks buttons to re-play WAV files to command the dog to sit etc. then click another button to reward the dog ‘Sadie’.All watched via webcam. Well the reward mechanism uses a SunSpot device (see http://www.sunspotworld.com), to activate a chute that delivers a doggie treat.

Good to see the most expensive dog feeder on the planet.

JavaOne luminaries – Tim Bray and Tim O’reilly in conversation on web 2.0

Friday, May 25th, 2007

The opening general session was a meeting of luminaries for an on-stage chat and (semi-)heated debate – Tim O’reilly, Rich Green, Tim Bray and Ian Murdoch.

Firstly, Open Source:
Tim O’Reilly stated by highlighting how we could learn from the evolution of the IBM PC. As it turns out, the Internet is the platform; built on Open Source, though the services provided on it are not necessarily being Open Source, it’s really many things:

- Services not packaged apps
- Data Aggregators, not just software

And the key to it all, are the network effects from user collaborations, which lead to market dominance.

Web 2.0
It seems the focus on licensing of technology was a red herring, what mattered more are:
- Modular architectures that allow programs to collaborate
- Internet as the enabler for collaborative development
- Users as co-contributors. Personally, I believe this one stems back to the days when the Internet was created when it’s use was seen as one where everyone was a peer and the thought was as both publisher and consumer in near equal quantities. As things evolved, there were few publishers, and many consumers. Now comes the user contributed revolution…

He went on to illustrate with a piece about the Law of Conservation of Attractive profits, a temporal stage of potential for exploitation, where prospective profits emerge adjacent to innovations, and the commodity concepts are software, and proprietary software is a service.

This leads to systems that harness network effects of key contributors e.g. Craigslist, and hence Web 2.0. So the most powerful sites on the web build or harness network effects through an architecture of participation.

- Data is the next ‘Intel Inside’. On data, they quoted Norwich Union in the UK, who are offering a new ‘pay as you drive’ insurance, the cost of which is based on how far you drive through data captured in the vehicle, and potentially the way you drive in the future e.g. speed.

- the rise of the perpetual beta aka ‘Live’ software. He quoted Mark Lucovsky (Google, ex. Microsoft), who said ‘how cool is that – I can finish this project tonight and push it live tomorrow’. This is vs. the upto 3 years cycle he had to wait at Microsoft.

The teams that seem to work best are small ‘two pizza’ teams like those at Amazon, building small pieces of software loosely joined.

It all starts to sound plausible, how events panned out. I like Tim’s standard question he applies to everything – ‘What would Google do, if Google provided X?’

For example, if they were your phone company, wouldn’t they automatically build your address book for you from calls made and received, and allow you to call anyone of them just like that? Not just the last 5 calls you received, like you get on your phone.

To push further forward development of software has to be more accessible to normal users, and that’s what is starting to happen now.

Tim’s vision for Web 3.0, is one where apps are driven by what we do, rather than how we interact with them; one where we stop typing, start gesturing, and cell phones collect GPS data and have inertia sensors. Only then will we see something really surprising.

More and more there will be more contention for the users first few clicks, and delivery of in-line content.

Not a bad first session.

What did feature highly during the session was the Rich Green ‘Wired/Tired’ hot list :-

  • Gestalt,
  • Deep DNA Concept,
  • the Swiss mode of providing software,
  • Virtual Space,
  • Aura.

I think I need a tag cloud…and a coffee.

JavaOne San Francisco – Day 0

Monday, May 7th, 2007

Well, I made it to San Francisco, late and with zero notice but made it. If you’ve never been, JavaOne is well worth the trip, and San Francsico more so. It’s already made me realise part of me misses it, it’s just one of those cities that grows on you (I lived there for 5 years during the boom and bubble burst).

Anyway, great view of a SF tradition from my hotel…. The Tonga lounge under the Fairmont..
tonga
I kid you not, Polynesian lounge, complete with a floating stage, cover band, and indoor thunderstorms – a 4 beer experience. tonga
Seen Tiki Bar TV?
Tikibar

Publishing via ROME

Wednesday, April 11th, 2007

I just found a potentially useful API for Andrew’s RSS Goodness Publishing Project Acta Diurana

Propono libraries for web publishing via the IETF Atom Publishing Protocol (APP) and the XML-RPC based MetaWeblog API.

Sounds interesting – from the overview:

  • Atom Publishing Protocol (APP) client library, which makes it easy for your Java client and server applications to interact with APP services.
  • Atom Publishing Protocol server framework, which makes it possible for you to add APP server capabilties to your Java web applications.
  • Atom Publishing Protocol file-server sample: a simple file-based APP implementation that stores Atom entries and associated media files in a directory strcuture within your webapp’s context directory.
  • Blog Client library, which makes it easy for your Java client and server applications interact with blog servers that support either MetaWeblog API or APP.

Can’t wait to find an excuse to try it myself. It’s even given me ideas for some new project – think Growl ;-)