VelociPeek

Eric’s weblog on tech

Tuesday, February 19th, 2008

JMagick OS X Leopard Port

Song of The Day: Give Me One Good Reason - Artist: Blink-182



Just a quick note to let folks know that I have an initial i368 port of JMagick, the JNI-based interface into the popular C/C++ ImageMagick API, to OS X Leopard.

For now the binaries and sources are hosted here. It’s based upon ImageMagick version 6.3.6-9_0 (libMagick.10.0.9.dylib).

I’m on the JMagick listserv to see if the development team wants to incorporate any of the changes, etc.

Here’s a quick list of what changed in the code:

  • New configure script option: –with-shared-lib-ext [defaults to .so]. This helped with allowing the extension to be changed during the make process (i.e., looked to be hardcoded to .so in spots or not always appended correctly).

    The build process, for OS X at the moment, creates a dynamic library that can be loaded with dlopen (MH_DYLIB), etc. Although it appears to work, it is just a quick workaround. In the future I imagine it would be better to have the configure script handle dynamic libs and bundles with an option and the extensions then added seamlessly.

  • The binary distribution comes with prebuilt MacPorts dependencies: ibexpat.1.dylib, libtiff.3.dylib, libMagick.10.dylib, libfontconfig.1.dylib, libz.1.dylib, libWand.10.dylib, libfreetype.6.dylib, libbz2.1.dylib, libjpeg.62.dylib.

  • The build process builds the binaries and jar files with a version number (noted below).

Note: The build process attaches the version as a part of the filename. For example the lib name looks something like libJMagick-6.2.6.dylib with a symlink to libJMagick.dylib.

The symlink ensures that Java-based calls to load the shared object work (e.g., make test):

static {
     System.loadLibrary("JMagick");
}

Tags: ,

Thursday, December 13th, 2007

Hibernate with MySQL Stored Procedures, Spring Framework integration - Java Source Code

Song Of The Day: Breathe - Artist: The Prodigy

Update (2/19/2008): The source code is now available here.

Thank you for your patience!
Eric

This week I thought I’d post a few things about Hibernate 3.x, stored procedures, and even the Spring Framework. BTW consider this Part 2 to this previous post on the Spring Framework and MVC.

More after the jump…

Read the rest of this entry »

Thursday, November 29th, 2007

The Spring Framework: MVC At Its Best - Part 1

Song of The Day: Spring 2001 - Artist: Lila



Recently, I rewrote a significant part of a Tomcat/JSP/JDBC application using the Spring Framework 2.x and Hibernate 3.x. Although Hibernate has its niceties and nuances, the Spring Framework integration alone reduced the code complexity, made the code more readable and maintainable, and reinforced good coding practices.

Those in the Java space likely already know the advantages of an MVC framework, possibly having used Struts or Spring previously, but today I thought I’d write a few thoughts about it.

So What is Spring

Spring is a component framework introduced by Rod Johnson back in 2002. The latest version has a plethora of features, but probably one of the best known, and best publicized for some time now, is the IOC (inversion of control) implementation, which may be more correctly be termed with certain concepts as dependency injection (DI). Another facet, considered positive by most I think, is that Spring emphasizes POJO-based development, which may keep architectures simpler compared to EJB-based frameworks. Moreover, the brief example below takes advantage of Spring’s Web MVC Framework as well, which can dramatically reduce effort on forms.

Read the rest of this entry »

Wednesday, November 28th, 2007

AOLserver/Joggame on iPod Touch

Song Of The Day: Clown Artist: Korn

Just a short note to let folks know that the distribution WILL work on the iPod Touch without a recompile. I released the source and package a while back, but thought people may find the iPod Touch capability nice as well.

I’ve been pretty busy with stuff lately, but do plan a broader update on overall progress in the future.

As always, you can check for updates on this blog or on the Joggame webpage for Joggame Server.



compliments of snap

BTW thanks to Erica for the snap utility at her site.

Of course, you will have to jailbreak your iPod Touch first, which may have various unknown side-effects, so proceed cautiously.

Tags: ,

Monday, November 12th, 2007

OS X Leopard Startup Script for MySQL

Song of The Day: Secret Crowds - Artist: AVA

Okay, so today I decided to fix the fact that my MySQL server doesn’t auto-load upon boot on OS X Leopard.

To be honest I’ve been doing the whole “mysqld_safe &”-thing for a while (i.e., pre-Leopard) and grew tired of that. So there is a simple way to do this right? Well, of course there is, but it’s surprising to find myriad articles on the Net explaining how to accomplish this in slightly different ways! You gotta love the Internet for access but not always for its uniformity :).

Most of the reason for the lack of uniformity on the subject concerns older versions of OS X and older versions of MySQL on OS X. However, as I learned all too well from my iPhone third-party application experience, the new–well somewhat new–direction for loading items during startup is with OS X’s system wide and per-user daemon and agent manager: launchd and launchctl. That service, launchd, replaces init.d and “rc” scripts of which most Unix-based users are familiar. Why? Well, you can read more about that here. The nutshell synopsis is that Apple merged the launch capabilities of init, inetd, and cron into “a single, standardized, interface to any and all programs started automatically by the system.”

As such, launchd is the preferred way for loading daemons from OS X Tiger (10.4) and beyond. There is a small learning curve, but not too bad after the first experience.

There are numerous articles that reference the older, but still widely used, mechanism of using OS X and MySQL /Library/StartupItems, good for pre-Tiger versions of OS X and for daemons not designed to run with launchd, but this entry focuses upon the newer launchd mechanism. Here’s another StartupItems how-to referenced from an older Apple document.

So here it is:

  • Check out “man launchd,” “man launchd.plist,” and “man launchctl.” Reading about its history isn’t bad either.
  • Add the following plist contents to a file, with your specific directories and option values, called org.mysql.launchd.mysql.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>org.mysql.launchd.mysql</string>
    <key>ProgramArguments</key>
    <array>
    <string>/usr/local/mysql-max-5.0.24-osx10.4-i686/bin/mysqld_safe</string>
    </array>
    <key>KeepAlive</key>
    <true/>
    <key>SuccessfulExit</key>
    <true/>
    <key>RunAtLoad</key>
    <true/>
    <UserName>
    <string>_mysql</string>
    <GroupName>
    <string>_mysql</string>
    </dict>
    </plist>

  • Issue the following in launchctl or reboot:

    sudo launchctl
    launchd% load /System/Library/LaunchDaemons/org.mysql.launchd.mysql.plist
    launchd% exit

Interestingly, after writing a quick solution based upon my Joggame Server plist for the iPhone, I found this older blog entry on the net. It still appears mostly valid, but the author doesn’t mention the OnDemand key as a part of the service. The OnDemand option, deprecated by the KeepAlive option in Leopard, allows one to either allow a daemon to keep running continuously or to allow the launchd service to launch the daemon once needed.

Read the rest of this entry »

Tuesday, October 30th, 2007

OS X Leopard Test Drive - Part 2 - 64-bit

Song of The Day: What’d I Say - Artist: Ray Charles



Over the weekend I started a post about OS X Leopard. Thought I’d post a follow-up or two about the features. Most have probably read or heard about the Dock and Finder improvements, which include reflections, Cover Flow and Stacks.

Those alone could be enough for one to justify a purchase, but I thought I’d write a few thoughts about one of the less emphasized features (i.e., at least lately) of OS X Leopard: full 64-bit support in the OS and Xcode 3.0. BTW Xcode 3.0 is offered as an optional install from the OS X Leopard installation disc. From the Apple website Xcode 3.0, Cocoa, and 64-bit blow the ceiling off of memory and data restrictions:

  • 64-bit addressing of up to 16 exabytes of virtual memory and 4 terabytes of physical memory
  • Full 64-bit arithmetic
  • 64-bit development tools
  • 64-bit performance monitoring tools
  • Seamless deployment
  • LP64 data model
  • Common source base support

Granted, most probably won’t see much need for it immediately, but its introduction paves a great evolutionary step forward. For example, Leopard applications running on Intel-based Core 2 Duo processors may take advantage of the x86-64 instruction set. One area where this may make a difference is in software rendering for games, etc.

There was an announcement by Apple a while back regarding the use of LLVM with OpenGL for software rendering. When particular hardware features are unavailable LLVM helps fill the gap. Using the 64-bit version could improvement performance substantially.

Furthermore, as mentioned, if an app or OS needs over 4GB of memory, then 64-bit removes that boundary, allowing up to 16 exabytes of VM or 4 TB of physical! Don’t see many reasons a typical consumer laptop or desktop would need such capability; however, intense graphics and video applications (i.e., data intensive in general) could substantially benefit from increased memory and larger file pointer sizes.

As a little test drive for Cocoa and 64-bit, I recompiled my simple Cocoa-based dentp program (i.e., a pinger). It was pretty easy, but I ran into a few initial gotchas due to the way I loaded my Xcode 2.x project with Xcode 3.0.



Initially, I just adjusted the Project Settings within Xcode 3.0 to use Architectures 64-bit and changed the Base SDK Path to point to “/Developer/SDKs/MacOSX10.5.sdk” because it was pointing to the “MacOSX10.4u.sdk” from my previous installation. It built and ran, but after using the file command on the dentp binary, I noticed that it still read:

> file dentp
dentp: Mach-O executable i386

Once I switched my “Cross-Develop Using Target SDK” under the General tab under Project Settings to use Mac OS 10.5 (or Current Mac OS) and the Active Target to x86_64, I eventually saw the desired file type:

> file dentp
dentp: Mach-O 64-bit executable x86_64



However, I still wasn’t able to compile for multiple architectures together (i.e., i386 and x86_64) as I wanted. For example, if you do the following on the Xcode binary it will display four architectures:


[newton]:/Developer/Applications/Xcode.app/Contents/MacOS]
> file Xcode
Xcode: Mach-O universal binary with 4 architectures
Xcode (for architecture ppc7400): Mach-O executable ppc
Xcode (for architecture ppc64): Mach-O 64-bit executable ppc64
Xcode (for architecture i386): Mach-O executable i386
Xcode (for architecture x86_64): Mach-O 64-bit executable x86_64

To build a universal binary for all four I had to Edit active target “dentp.” I added the the additional 64-bit targets to the default i386 and ppc target Architectures and I was golden:


[newton]:~/code/dentp2/build/Release/dentp.app/Contents/MacOS]
> file dentp
dentp: Mach-O universal binary with 4 architectures
dentp (for architecture i386): Mach-O executable i386
dentp (for architecture ppc7400): Mach-O executable ppc
dentp (for architecture ppc64): Mach-O 64-bit executable ppc64
dentp (for architecture x86_64): Mach-O 64-bit executable x86_64

Overall, it didn’t make my program any noticeably faster or better; however, it was, now, an official 64-bit binary running on OS X Leopard, which is pretty cool. Also, no additional CD requests needed to get 64-bit support with Leopard (umm…like with Vista? :) and no reason to release multiple binaries on the Mac platform! That’s the beauty of universal.

And to think that I would have needed a super computer a few years back!

Perhaps, a few notes on other features in the next few posts…

Tags: , ,

Friday, September 21st, 2007

Joggame Server

Song Of The Day: Beautiful Day Artist: U2

Today, I am pleased to announce a spin-off of the open source AOLserver project for devices: Joggame Server (pronounced jog-gu-mE).

The technology, acquired by AOL in 1995 from NaviSoft, has a long history of technical achievement and innovation. It was one of the first to offer multi-threaded support. It was one of the first to embed an interpreter versus using the slower, and less efficient, CGI. For the iPhone it is one of the first web application development environments. Its ease-of-use, and long history of reliability, security, and cross-platform support, make it the perfect choice for the iPhone and other web-enabled devices.

With this new vision my hope is that the Joggame Server project will continue to carry the legacy forward.


SourceForge Main
SVN Repository

Tags: , ,

Wednesday, September 19th, 2007

iPhone AOLserver and Tcl Ports - part 2

Song Of The Day: Clown Artist: Korn

The AOLserver, binary port is here (i.e., with the launchctl directive plist), likely to be available on AppTapp soon.

If you download the AOLserver distribution you do not need the Tcl package if you don’t want. Within the AOLserver distribution the tcl distribution resides under the installation directory.

Sources (Tcl and nsd) are currently here.

This should go without saying :), but these packages are VERY experimental and you will be installing and using at your own risk.

Tags: , ,

Monday, September 17th, 2007

iPhone AOLserver and Tcl Ports - part 1

Song Of The Day: Blind Artist: Korn

So what have I been up to the last few days…?

I ported Tcl 8.4.x and AOLserver 4.x to the iPhone. Tcl is already available via AppTapp and AOLserver will follow soon, hopefully.

Tags: , ,

Sunday, June 10th, 2007

WWDC 2007 - Registration Day

Song of The Day: Coming Up - Artist: Paul McCartney

It’s been a while since I blogged, but today seems like a fitting day to check in. I’m in San Francisco this week for the WWDC 2007. There are various thoughts about what will be announced, but it would be nice to hear an official announcement involving the iPhone and 3rd party integration. How nice would that be?

Steve Jobs alluded to this already at D5, but it would be great to hear some more news. Regardless, it will be a fun and rewarding week.

One thing I never tire of, unashamedly, is the conference loot. :) This year’s black t-shirt has “WWDC07″ on the front and the quote “Power to the programmers” on the back. Attendees also get a carrying bag, a badge, and conference maps upon registration.

The conference registrars tell attendees that all sessions are confidential except the keynote, so I’ll be sure to publish a few thoughts and notes about the keynote afterwards. As usual, all the major news outlets will cover things, but I’ll provide a personal account for any interested.




For now, 600) )4j.

Tags: , ,