Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preference shortcut for 10.2 and 10.3



email@hidden wrote:

>The application targets the K-12 market, and must continue to run under not
>only OS/X 10.2, but even Mac Classic. While I can--and do--take advantage of
>newer features, I cannot simply stop supporting the 10.2 clients, so I do need
>a way to get the application to work. Unlike Apple, I can't leave any
>student--or computer--behind with this application. :)
>
>I was trying to do that with calls that would work under all of the Mac OS/X
>systems. Is there a way to do so?

There is probably not one way that will work everywhere. It looks like
you'll have to use conditional code and multiple implementations.

Loading a specific implementation by name is pretty easy: Class.forName().
Having it implement a predefined interface, or subclass a predefined
subclass, of your design is also pretty easy.

Compiling all the various implementations on a single host platform is
kinda painful, but you can copy classes out of the various Java
installations you're targeting, put them in a jar, and compile against
them. That works pretty well. I did that with some classes I needed for
my MacBinary Toolkit imps, which I put into "MBXCarbonCore.jar" and
compiled against:
<http://www.amug.org/~glguerin/sw/macbinary/rebuilding.html#macos>


Lately, the approach I take in deciding which implementation to load is a
Chain of Irresponsibility pattern. This is a series of independent
try/catch constructs where I attempt to load and return one imp, catch and
ignore all Throwables (that's the "irresponsible" part), and then work my
way back through the known imps. If none work, then I instantiate a
do-nothing stub imp and return that. The code fragment looks something
like:
try
{ return ( instantiate( "glguerin.blah.ThingFor142" ) ); }
catch ( Throwable ignored )
{ ; }

try
{ return ( instantiate( "glguerin.blah.ThingFor141" ) ); }
catch ( Throwable ignored )
{ ; }

try
{ return ( instantiate( "glguerin.blah.ThingFor13X" ) ); }
catch ( Throwable ignored )
{ ; }

return ( new ThingStub() );

and instantiate() looks something like:
private Thing
instantiate( String className )
throws Throwable
{
return ( (Thing) Class.forName( className ).newInstance() );
}

There are many other ways to work through a series of possible
implementations. This is just a fairly simple and straightforward one.
Using a series of numbered properties is more flexible, and can be tweaked
in the field more easily. Defining properties with a name comprised partly
of the Java or OS version is another approach, and can more easily pin a
specific Thing implementation to a specifically identified Java and/or OS
version.


BTW, I've noticed in some version of 1.4.1 that the cmd-comma shortcut is
automatically placed on the Preferences menu-item. I definitely see it on
1.4.1_01-69, and it may also have been on 1.4.2, but I've forgotten the
details when I tested on someone else's 10.3 box. In those cases, I don't
think you have to do anything at all, so a StubThing implementation would
be entirely appropriate.

-- GG
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.