Wednesday Jan 16, 2008

Is Javascript the C of the Web

Last night, while the wheelers and dealers of MySQL, Sun, Oracle and BEA were signing on dotted lines the tech crowd was at Google's building 43 for the Silicon Valley Web and Java Users group meeting to hear a presentation about GWT.

Bob Vawter's presentation was excellent. He covered the basics quickly and took questions. His presentation provided answer to some of the things that make folks go, "Hmmm", when they look at the output of the GWT compiler.... Like, "What are all those obtuse numerically named files all about?"
Short answer (heavily paraphrased): They are the Javascript of the UI that you created in GWT, pretailored for each of the four major browsers out there today. The names are created from a hash of their content and are safe and easy to cache. When you change the UI, the name of the files will change, so folks don't keep seeing an old UI and have your server side processing freak out because of missing data.

There was a raffle for a number of books. I won a book.

Why does this entry have its title?

While Bob was talking about GWT, it reminded me of working at Interactive Software Engineering, now known as Eiffel Software. The Eiffel compiler used a similar "trick" of transforming a strongly typed language (Eiffel) into a weakly typed language (C). From the outside, it looks like GWT is doing something similar with Javascript playing the part of C.

Another parallel between GWT and the Eiffel compiler was the amount of optimization it could do. After expressing his sample in a rich language, Java, the compiler optimized almost ALL that richness out of the resulting Javascript code... making it much leaner.

Friday Jul 27, 2007

Java API design antipattern and tip

The Antipattern: Don't Create an Event Object for Your Listener Interface's Methods

I discovered this while trying to implement against a Listener interface that just sent in the "interesting" parts of the event... A String or two.

I needed to find out the source of the event (which is a pretty standard member of an Event interface), so that I could react to the event. This is easy to resolve by creating the listener with an additional member for the "expected" source. Or it is easy to resolve until you try to garbage collect these listeners that know their source...

An Event/Listener pair helps your API mature gracefully. Additional members/accessors can get added to the Event side of the interface without requiring changes in code that implements the Listener, unless the listener wants to USE that new member/accessor.

In the interest of transparency and honesty; I have to admit that I helped review and approve the Listener interface that lead to this entry. It just goes to show the value of having to write REAL code against an interface before you say, "Oh. That looks fine."

Friday Jan 27, 2006

Equinox Hibernate Spring GlassFish

Jerome has an interesting entry about using Spring and Hibernate on GlassFish.

I looked at the entry that Matt Raible posted, and decided to see if I could help him....

I assume that Matt was trying to get Equinox to run on GlassFish. So, I tried to deploy and run it, myself.

Well, I can see why Matt had so much trouble. The installation instructions were very sketchy, but I was able to get things to work. Here is what I did:

  1. Get PostgreSQL installed and configured on my Mac... [That was a whole 'nother story].
  2. Downloaded Equinox
  3. Extracted it into /Volumes/300gb/equinox.
  4. Edited build.properties, to add the following
      server.home=/Volumes/300gb/glassfish
      
  5. Ran 'ant new -Dapp.name=test3'.
    This created a directory /Volumes/300gb/test3
  6. `cd /Volumes/300gb/test3`
  7. Ran 'ant test-all'
    The tomcat tests failed, but I pressed onward...
  8. Ran 'ant deploy'
    This created an new directory and content under /Volumes/300gb/glassfish/webapps/test3. I check it out and it looked like a web-app, so it was all good.
  9. I started up GlassFish.
  10. I ran 'asadmin deploydir /Volumes/300gb/glassfish/webapps/test3'.
    At this point, I saw exceptions just like Matt's. I took a deep breath and said to myself, "Don't panic, you can beat this. It is just a web-app!"
  11. I added the following lines to the server.policy file for the domain.
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/hibernate-3.1.jar" {
              permission java.util.PropertyPermission "\*", "read,write";
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/spring-1.2.6.jar" {
              permission java.util.PropertyPermission "\*", "read,write";
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/cglib-2.1_3.jar" {
              permission java.security.AllPermission;
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/commons-validator-1.1.3.jar" {
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/springmodules-validator-0.1.jar" {
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
    Note: I did have to iterate (start the server, read the log, stop the server, change the server.policy file) a couple times to come up with this list.
  12. Once the server started up "clean", I went to "http://localhost:8080/test3" and things looked good.

    Until I pressed the "View Demonstration" button. That is when I got the error discussed in this thread.
  13. I used the Admin Console to change the server's classpath a bit...
  14. At this point, I was able to go through the demo without any problems (AFAICT).
One thing to remember, THIS IS ALL A HACK... I don't recommend that you change your server.policy file without good reason. If running Equinox is a "good reason", then I hope this entry helps you.

I would have used NetBeans 5.0 RC2 to do this, if I had needed to actually look at real code.

Monday Jan 23, 2006

Custom Certificate Dialogs for JWS App Clients

Java Web Start is an awesome technology... but like all awesome technologies, it can have a darkside. I went to a site yesterday that had a JWS enabled demo that had a self-signed certificate. When JWS asked me to trust the site, I had to say 'No'.

That reminded me that I had to do something similar for the application client that I created in one of my earlier entries. So I started to ask folks about how to get a real certificate associated with my clients.

To implement 'Webstartability' (Note to the AP, don't ask Steven Colbert or Michael Adams to define this soon to be 'Word of 2006'. You'll need to ask Tim Quinn) the GlassFish Project's implementation uses a generic client that is reused by all user implemented clients.

The shared, generic client is in the lib directory of the GlassFish installation. It is called 'appserv-jwsacc-signed.jar'. It is the file that triggers the security certificate dialog that appears when you start an webstartable app client. [For an example, see this entry If you take a second look in the lib directory, you will also see the file 'appserv-jwsacc.jar'. This is the unsigned version of the generic client.

Why is this file there? This file is there, so that you can sign it with YOUR own certificate. By replacing the 'appserv-jwsacc-signed.jar' with a copy of the appserv-jwsacc.jar file that is signed with your certificate and NAMED 'appserv-jwsacc-signed.jar', your users will see a new dialog, when they are asked to trust the certificate... One with your organization's name in it!

Friday Jan 13, 2006

Sun Java System Application Server... Not, Just for NetBeans any more!!!

I love to troll... I mean read... the threads on the eclipse zone. This one caught my eye, though.

A hidden feature in the GlassFish plugin for Eclipse is the ability to register instances of Sun Java System Application Server 8.x (where x == 1 or 2). And hey, if you want SJSAS 8.2, you can get it from here (Windows), here (Linux)... and more.

NetBeans users are still ahead of the pack!

This is hard to believe...

http://java.sun.com/j2ee/1.4/download.html

still hasn't been updated with Sun Java System Application Server 8.2, yet..

If you want the Latest and Greatest App Server from Sun

You gotta get it...HERE

Thursday Jan 12, 2006

NetBeans gives you the hottest J2EE bits first!

That is right kids...

I took these screen shots at Jan 12, 2005 at 7:10 pm PST...

http://java.sun.com/j2ee/1.4/download.html has

http://www.netbeans.info/downloads/download.php has

That's right. NetBeans users are the very first in the world to get Sun Java System Application Server 8.2 bits.

Who loves you....

About


Vince Kraemer writes the entries in this blog.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News
Blogroll

No bookmarks in folder

automarks