Class CocoaJavaBridge
- java.lang.Object
-
- com.biglybt.platform.macosx.NativeInvocationBridge
-
- com.biglybt.platform.macosx.access.cocoa.CocoaJavaBridge
-
public final class CocoaJavaBridge extends NativeInvocationBridge
NOTE: This is only used for OSX 10.4 and non-up-to-date 10.5,10.6. OSX 10.5 Update 6 and OSX 10.6 Update 1 provides revealInFinder and moveToTrash functionality.Performs PlatformManager tasks using Cocoa-Java (FoundationKit only)
For now, operations are performed using NSAppleScript, rather than using NSWorkspace. This is still significantly faster than calling the cmd-line osascript.
- Version:
- 2.1 Apr 2, 2005
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CocoaJavaBridge.RunnableDispatcher
A dispatch object to help facilitate asychronous script execution (from the main thread) in a more predictable fashion.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Class
claNSAppleEventDescriptor
private java.lang.Class<?>
claNSAppleScript
private java.lang.Class<?>
claNSAutoreleasePool
private java.lang.Class<?>
claNSMutableDictionary
protected static java.lang.String
CLASS_PATH
The path the Cocoa-Java class files are located atprotected AEMonitor
classMon
private static java.lang.String
DEL_SCRIPT_FORMAT
protected boolean
isDisposed
private int
mainPool
Main NSAutoreleasePoolprivate java.lang.reflect.Method
methNSAppleEventDescriptor_descriptorWithBoolean
private java.lang.reflect.Method
methNSAppleScript_execute
private java.lang.reflect.Method
methNSMutableDictionary_objectForKey
private java.lang.reflect.Method
methPop
private java.lang.reflect.Method
methPush
private java.lang.String
NSAppleScript_AppleScriptErrorMessage
private static java.lang.String
REVEAL_SCRIPT_FORMAT
protected CocoaJavaBridge.RunnableDispatcher
scriptDispatcher
private AEMonitor
scriptMon
-
Constructor Summary
Constructors Constructor Description CocoaJavaBridge()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
dispose()
Disposes system resourcesprotected java.lang.Object
executeScript(java.lang.String scriptFormat, java.lang.Object[] params)
Executes a new instance of NSAppleScriptprotected java.lang.Object
executeScriptWithAsync(java.lang.String scriptFormat, java.lang.Object[] params)
Asynchronously executes a new instance of NSAppleScriptprotected java.lang.Object
executeScriptWithNewThread(java.lang.String scriptFormat, java.lang.Object[] params)
Executes a new instance of NSAppleScript in a forked AEThreadprotected void
finalize()
protected boolean
isEnabled()
Gets whether the invocation bridge is available for useprivate void
logWarning(java.lang.String message)
Logs a warning message to Logger.private java.lang.Object
new_NSAppleScript(java.lang.String s)
private java.lang.Object
new_NSMutableDictionary()
private java.lang.Object
NSAppleScript_execute(java.lang.Object NSAppleScript, java.lang.Object NSMutableDictionary)
private void
NSAutoreleasePool_pop(int i)
private int
NSAutoreleasePool_push()
private java.lang.Object
NSMutableDictionary_objectForKey(java.lang.Object NSMutableDictionary, java.lang.String s)
protected boolean
performRecoverableFileDelete(java.io.File path)
protected boolean
showInFinder(java.io.File path, java.lang.String fileBrowserApp)
-
Methods inherited from class com.biglybt.platform.macosx.NativeInvocationBridge
hasSharedInstance, sharedInstance
-
-
-
-
Field Detail
-
CLASS_PATH
protected static final java.lang.String CLASS_PATH
The path the Cocoa-Java class files are located at- See Also:
- Constant Field Values
-
REVEAL_SCRIPT_FORMAT
private static final java.lang.String REVEAL_SCRIPT_FORMAT
- See Also:
- Constant Field Values
-
DEL_SCRIPT_FORMAT
private static final java.lang.String DEL_SCRIPT_FORMAT
- See Also:
- Constant Field Values
-
mainPool
private int mainPool
Main NSAutoreleasePool
-
classMon
protected AEMonitor classMon
-
scriptMon
private AEMonitor scriptMon
-
isDisposed
protected boolean isDisposed
-
scriptDispatcher
protected CocoaJavaBridge.RunnableDispatcher scriptDispatcher
-
claNSAppleEventDescriptor
private java.lang.Class claNSAppleEventDescriptor
-
claNSAutoreleasePool
private java.lang.Class<?> claNSAutoreleasePool
-
methPush
private java.lang.reflect.Method methPush
-
methPop
private java.lang.reflect.Method methPop
-
methNSAppleEventDescriptor_descriptorWithBoolean
private java.lang.reflect.Method methNSAppleEventDescriptor_descriptorWithBoolean
-
claNSAppleScript
private java.lang.Class<?> claNSAppleScript
-
claNSMutableDictionary
private java.lang.Class<?> claNSMutableDictionary
-
methNSAppleScript_execute
private java.lang.reflect.Method methNSAppleScript_execute
-
NSAppleScript_AppleScriptErrorMessage
private java.lang.String NSAppleScript_AppleScriptErrorMessage
-
methNSMutableDictionary_objectForKey
private java.lang.reflect.Method methNSMutableDictionary_objectForKey
-
-
Method Detail
-
NSAutoreleasePool_push
private int NSAutoreleasePool_push() throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
NSAutoreleasePool_pop
private void NSAutoreleasePool_pop(int i) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
new_NSAppleScript
private java.lang.Object new_NSAppleScript(java.lang.String s) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
NSAppleScript_execute
private java.lang.Object NSAppleScript_execute(java.lang.Object NSAppleScript, java.lang.Object NSMutableDictionary) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
new_NSMutableDictionary
private java.lang.Object new_NSMutableDictionary() throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
NSMutableDictionary_objectForKey
private java.lang.Object NSMutableDictionary_objectForKey(java.lang.Object NSMutableDictionary, java.lang.String s) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
performRecoverableFileDelete
protected boolean performRecoverableFileDelete(java.io.File path)
- Overrides:
performRecoverableFileDelete
in classNativeInvocationBridge
- See Also:
PlatformManager#performRecoverableFileDelete(java.io.File)
-
showInFinder
protected boolean showInFinder(java.io.File path, java.lang.String fileBrowserApp)
- Overrides:
showInFinder
in classNativeInvocationBridge
- See Also:
PlatformManagerImpl.showInFinder(java.io.File)
-
isEnabled
protected boolean isEnabled()
Gets whether the invocation bridge is available for use
This method is used to anticipate scenarios such as where the bridge will fail due to missing classpaths
- Specified by:
isEnabled
in classNativeInvocationBridge
-
executeScript
protected final java.lang.Object executeScript(java.lang.String scriptFormat, java.lang.Object[] params) throws java.lang.Throwable
Executes a new instance of NSAppleScript
The method is wrapped in an autorelease pool and an AEMonitor. If there are no format parameters, MessageFormat is not used to parse the format string, and the format string will be treated as the source itself.
- Throws:
java.lang.Throwable
- See Also:
MessageFormat.format(String, Object...)
,NSAppleScript#execute(com.apple.cocoa.foundation.NSMutableDictionary)
-
executeScriptWithNewThread
protected final java.lang.Object executeScriptWithNewThread(java.lang.String scriptFormat, java.lang.Object[] params) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Executes a new instance of NSAppleScript in a forked AEThread
This method always returns a "true" event descriptor. Callbacks are currently unsupported , so in the event of an error, the logger is autuomatically notified.
The thread's runSupport method is wrapped in an autorelease pool. If there are no format parameters, MessageFormat is not used to parse the format string, and the format string will be treated as the source itself.
- Returns:
- NSAppleEventDescriptor.descriptorWithBoolean(true)
- Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
- See Also:
AEThread.runSupport()
,MessageFormat.format(String, Object...)
,NSAppleScript#execute(com.apple.cocoa.foundation.NSMutableDictionary)
-
executeScriptWithAsync
protected final java.lang.Object executeScriptWithAsync(java.lang.String scriptFormat, java.lang.Object[] params) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Asynchronously executes a new instance of NSAppleScript
This method always returns a "true" event descriptor. Callbacks are currently unsupported , so in the event of an error, the logger is autuomatically notified.
The thread's runSupport method is wrapped in an autorelease pool. If there are no format parameters, MessageFormat is not used to parse the format string, and the format string will be treated as the source itself.
- Returns:
- NSAppleEventDescriptor.descriptorWithBoolean(true)
- Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
- See Also:
AEThread.runSupport()
,MessageFormat.format(String, Object...)
,NSAppleScript#execute(com.apple.cocoa.foundation.NSMutableDictionary)
-
logWarning
private void logWarning(java.lang.String message)
Logs a warning message to Logger. The class monitor is used.- Parameters:
message
- A warning message
-
dispose
protected void dispose()
Disposes system resources- Overrides:
dispose
in classNativeInvocationBridge
-
finalize
protected void finalize() throws java.lang.Throwable
- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
-