The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
[Originally posted by nishi4]

Hi Shigeoka,
Let me thank you at the outset for a wonderful book on IM in Java. It
helped me build a IM system. But, I ran into a couple of issues.
a) Since you used LinkedList as a Collection... The previous versions of
browsers which use 1.1.x of java don't support. To fix this I added java.util
classes in my client applet jar. ( Initially size of jar was 48kb, after I
added java.util classes it became 400kb ). Alternatively I can write my own
Collection class implementing FIFO. If you think of an better solution, please
let me know.
b) Same with xerces.jar... I had to add all the sax parsing related xerces
classes to my client applet jar to make it even worse ( The size now is a
little over 1MB). Is wring my own parser ineveitable too. I would be appauled
if I have to do so. Sometimes I think I am totally wrong in implementing my
client 'coz its forcing me to put all sax parser related xerces in my client.
I don't know...

Ian.. I would really appreciate it if you can come up with better solutions
for these two problems and help make my client applet smaller.

Thanks

Note: I can't ask my users to have java plug-in.
import-bot (20211) [Avatar] Offline
#2
Re: Help to reduce size of client applet
[Originally posted by iainshigeoka]

> Hi Shigeoka,
> Let me thank you at the outset for a wonderful book on IM in Java. It
> helped me build a IM system. But, I ran into a couple of issues.

I'm glad you found it useful. I'd really appreciate it if you could leave a
review on amazon.com. Believe it or not publishers take those reviews
seriously.

> a) Since you used LinkedList as a Collection... The previous versions of
> browsers which use 1.1.x of java don't support. To fix this I added java.util
> classes in my client applet jar. ( Initially size of jar was 48kb, after I
> added java.util classes it became 400kb ). Alternatively I can write my own
> Collection class implementing FIFO. If you think of an better solution, please
> let me know.

Agreed. I wasn't thinking about applets when creating the client library. The
client library was created for testing the server so is pretty sad for doing
applet work. I think removing java.util requirements would be essential. A
very simple linked list implementation is probably the easiest work around if
you want to continue using the book code.

> b) Same with xerces.jar... I had to add all the sax parsing related xerces
> classes to my client applet jar to make it even worse ( The size now is a
> little over 1MB). Is wring my own parser ineveitable too. I would be appauled
> if I have to do so. Sometimes I think I am totally wrong in implementing my
> client 'coz its forcing me to put all sax parser related xerces in my client.
> I don't know...

For applets, I would highly suggest using an xml pull parser. There are two
free ones currently available. You can learn more about pull parsers at
www.xmlpull.org. The kbxml parser is very small and quite suitable for use on
j2me devices (and hence very good for applets). The XPP parser is extremely
fast, and not too big (a stripped version is about 20kb, the full version is
45kb). Basically, the difference in the client code is, rather than write an
listener and having the parser push events to it, you write a handler that
pulls XML data from the parser in code that looks a bit like using an
Iterator. It shouldn't take longer than an hour or so to make the switch from
SAX to xmlpull.

As a bonus XPP handles streaming XML well, so you can eliminate the Xerces
char reader hack and it works more reliably.

> Ian.. I would really appreciate it if you can come up with better solutions
> for these two problems and help make my client applet smaller.

I'm working on a new client library that should take care of all these issues
(it aims to be small, extremely easy to work with, and well suited to applet
work). The work is being done under contract for a company. They're deciding
right now whether to open source it, make it available for free (and have
developers pay to access the souce code if they need to), or make it a
commercial product.

If you want to influence the decision making, send me an email stating your
case (iain.shigeoka at messaginglogic.com) and I can forward it to them. I'm
pretty sure we'll go open source with it but your input could help tip the
scales.

-iain