| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
|
I did something similar to this by writing my MenuExtra in Cocoa and then having it communicate with my Java code using XMLRPC. On the Cocoa side, I sent out the XMLRPC commands using the following: - (OSStatus)sendMessage:(NSString *)message withParamString:(NSString *)param result:(NSDictionary **)result { NSString *command = [self commandForMessage:message withParamString:param]; NSAppleScript *script = [[[NSAppleScript alloc] initWithSource:source] autorelease]; NSAppleEventDescriptor *descriptor = [script executeAndReturnError:result]; ... error checking goes here ... } - (NSString *)commandForMessage:(NSString *)message withParamString:(NSString *)params { return [NSString stringWithFormat:@"\ tell application \"http://localhost:%d\" \n\ with timeout of 15 seconds \n\ return call xmlrpc {method name:\"%@\", parameters:{%@}} \n\ end timeout \n\ end tell", [self port], message, params]; } And on the Java side I used the Apache XMLRPC code to handle the incoming messages. An example of calling a method named "echo" would look something like: Cocoa: messager = ... init messager object, passing in correct port ... [messager sendMessage:@"echo" withParamString:@"\"some text\"" result:&result]; Java: public String echo(String input) { System.out.println(input); return input; } To enable my menu extra, I used MenuExtraEnabler by unsanity.com. There is a lot of info out there on writing menu extras, so even if you're not familiar with Cocoa you should be able to get something up and running and then do most of your work in Java. I hope this helps! John using unsanity.com's MenuExtraEnabler to make it accessible in the menubar) On Jan 28, 2008, at 6:31 PM, gonzalo gon wrote:
|
_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.