on June 26, 2004 at 3:06 PM PDT
The dataloader api is ambiguous in the loadMetaData method about what an
implementation should do if no metadata is available until the entire stream
has been read.
The startLoading method may benefit from having a thread pool to work with.
For an application that is sending data back and forth constantly, it might
be nicer to have a thread pool than to spin up 10 threads every time a new
window is opened. This can be achieved either by providing an abstract
method in the startLoading class called 'getWorkerThread' or something and
let extending classes decide what to do about it. Or, perhaps, a method
called 'runWorker(Runnabled run)' that would allow the concrete
implementation do what it will with the runnable (such as passing it off to
The dataLoader is not flexible enough in its loadMetaData(Object model,
InputStream is), startLoading(final Object model, final InputStream is), and
possibly readData(InputStream is) methods.
Consider the following situation: The data you need to load is located on
some remote server. The
DataLoader only deals with inputstreams, so you must create a URL for the
remote site and call
openConnection(). At this point you already have 200+ms of delay in the
responsiveness of your
application because the URL opened a socket connection to the remote host on
the event dispatch
thread! Furthermore, in Java 1.5 if you specifiy a host name like
"192.168.1.9" in the Socket
constructor, the code tries to do a reverse host name lookup before opening
the connection (to revent spoofing, I suppose). In an environment where the
name does not resolve because there is no authoritative DNS server, the 'new
Socket(host, port)' call hangs for about a second and a half. And according
to DataLoader, this must be done *before* the data loading thread is called.
Solution: Either craft an interface representing an input stream that hasn't
been opened yet, or allow 'Object source' to be the parameter passed to the
methods. Let the concrete implementations handle the details. The interface
approach is most likely the wisest choice.
PS> Of course, I am working on implementations of these ideas to see how
well they work. I'll let you know.
MSN Toolbar provides one-click access to Hotmail from any Web page ? FREE
To unsubscribe, e-mail: email@example.com
For additional commands, e-mail: firstname.lastname@example.org