muffin stuff (webstart cookies)

Webstart demonstration:
http://kaioa.com/src/tools/MuffinStreamTest.jnlp

You’ll see a JFrame with a JTextArea and nothing else. Write something… close it and start it again. The text should be there again (loaded from a muffin).

The source:
http://kaioa.com/src/tools/MuffinStreamTest.java
http://kaioa.com/src/tools/MuffinOutputStream.java
http://kaioa.com/src/tools/MuffinInputStreamGetter.java

Showsrc-ified:
http://showsrc.com/$http://kaioa.com/src/tools/MuffinStreamTest.java
http://showsrc.com/$http://kaioa.com/src/tools/MuffinOutputStream.java
http://showsrc.com/$http://kaioa.com/src/tools/MuffinInputStreamGetter.java

On the first run the load method in MuffinStreamTest will end up in the catch block, because there isn’t a muffin.

Muffins should be nicer to handle with these two classes. It should be good enough for most of the webstart apps. It’s written somewhat simple minded, but why not?

Design-wise it’s asymetric - I’m very sorry :stuck_out_tongue: (it just made more sense to handle it this way). One thing worth noting… the muffin itself is actually written in the close() method, because you need to know the maximum size of muffin before writing.

You’ll need either the webstart devkit (I used the jnlp.jar from “javaws-1_2-dev.zip”) or javaws.jar (from your javaws directory) in your classpath for compilation.

Condition of use/license:
a) don’t sue me
b) use it like you want to
c) change it like you want to
d) if you find bugs or ways to improve it, let me (us) know :slight_smile:

There is one issue with the demo…

-start
-write
-close
-start
-text is there… don’t move the cursor
-close
-start
and the text is gone. That doen’s happen if you move the cursor at least once. So it has something to do with that getText() thingy of JTextArea (JTextComponent actually).

Hmm. :-/

Guess cheap “” init plus append(thatText) hackery would help :stuck_out_tongue:

edit:

No, I was wrong… it’s something different, which I hadn’t fully tracked down. After it was saved two times it won’t get deleted (why?) and thus creation fails (insert failed in cache: target already exixts) and I forget to check if webstart actually granted us that much space…

uh uh… gonna post again if I got around fixing it.

Sorry :stuck_out_tongue:

/me pukes

Haha. Very funny. >:(

Dunno what’s wrong… it works nicely (=always) if I run it from my lan server ???

And that other thing works always? I’m really somewhat puzzled right now :-/

ps.setTag(muffinURL,PersistenceService.CACHED);

That did the trick.

[quote]The individual entries can be tagged as either cached, meaning the server has an up-to-date copy, dirty, meaning the server does not have an up-to-date copy, or temporary, meaning that the file can always be recreated.
[/quote]
Well, I had to guess here ::slight_smile:

But it makes some sense… some (the server doesn’t have any copy at all, therefore it’s as good as if it would be actually cached :P).

I tried mimicing your MuffinStreamTest.jnlp for my own jnlp file, and so I changed the variables to fit my stuff, and opened it, and got this error:

This XML file does not appear to have any style information associated with it. The document tree is shown below

Can someone clarify what I might have done wrong?

The jnlp (your’s) is most likely perfectly fine.

However, the server doesn’t know the mime type of jnlp files. If it’s free webspace… well bad luck.

If you’ve paid for it you’ll usually have several options… some of em are outlined here:
http://grexengine.com/sections/externalgames/articles/Kevin%20Glass-A%20Walkthrough%20with%20WebStart-JNLP-1.html

If you can use “.htaccess” you just need to add a file with that name in the root directory (or if it already exists just append the folowing line):
AddType application/x-java-jnlp-file .jnlp