I run a Mac Mini as my home server, currently with OS X 10.4. Tonight I dug around and got GlassFish up and running using OS X's answer to SMF on Solaris, launchd. I am by no means an expert on launchd but I will happily document what worked for me. First off I installed GlassFish v2 to "/usr/local/glassfish" as per the documented instructions.
Once I verified that it all worked, I sought out how to integrate it into launchd. I certainly don't want it running as root, so I took a look at the available users and groups using the NetInfo Manager application. I found an "appserver" user and associated "appserverusr" group. Seemed a good place to start. I changed the ownership recursively for my install directory to this user and group combination. Once done, I created my launchd plist file and saved it to "/Library/LaunchDaemons/glassfish.plist".
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.sun.glassfish</string>
<key>Disabled</key>
<false/>
<key>UserName</key>
<string>appserver</string>
<key>GroupName</key>
<string>appserverusr</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/glassfish/bin/asadmin</string>
<string>start-domain</string>
<string>domain1</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Similar to SMF you have to load/import the service description. On OS X you use "launchctl load ./glassfish.plist" for this purpose. If all goes well you will have a running instance of GlassFish. If not, you will see rather vague error messaging in the system.log file.
Some drawbacks. It seems that launchd relies on sending a SIGTERM to the process when you attempt to stop it using "launchctl stop com.sun.glassfish". This doesn't work for GlassFish. I prefer the ability of SMF to define a appropriate shutdown command. Not a huge deal as I can easily stop GlassFish using asadmin or the admin console when needed. Once the process is stopped you can use "launchctl start com.sun.glassfish" to bring it back up. There is no notion of a restarter if the process dies. I think there is a new KeepAlive element in OS X 10.5 but I haven't be able to experiment with that version yet. Sounds promising though.
All in all this works pretty well. GlassFish will launch on boot using the recommended subsystem. If anyone has any tips on achieving a tighter integration with launchd let me know.