org.gudy.azureus2.platform.macosx.access.cocoa
Class CocoaJavaBridge

java.lang.Object
  extended by org.gudy.azureus2.platform.macosx.NativeInvocationBridge
      extended by org.gudy.azureus2.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

Field Summary
protected static java.lang.String CLASS_PATH
          The path the Cocoa-Java class files are located at
protected  AEMonitor classMon
           
protected  boolean isDisposed
           
protected  org.gudy.azureus2.platform.macosx.access.cocoa.CocoaJavaBridge.RunnableDispatcher scriptDispatcher
           
 
Constructor Summary
CocoaJavaBridge()
           
 
Method Summary
protected  void dispose()
          Disposes system resources
protected  java.lang.Object executeScript(java.lang.String scriptFormat, java.lang.Object[] params)
          Executes a new instance of NSAppleScript
protected  java.lang.Object executeScriptWithAsync(java.lang.String scriptFormat, java.lang.Object[] params)
          Asynchronously executes a new instance of NSAppleScript
protected  java.lang.Object executeScriptWithNewThread(java.lang.String scriptFormat, java.lang.Object[] params)
          Executes a new instance of NSAppleScript in a forked AEThread
protected  void finalize()
          
protected  boolean isEnabled()
          Gets whether the invocation bridge is available for use
protected  boolean performRecoverableFileDelete(java.io.File path)
          
protected  boolean showInFinder(java.io.File path, java.lang.String fileBrowserApp)
          
 
Methods inherited from class org.gudy.azureus2.platform.macosx.NativeInvocationBridge
hasSharedInstance, sharedInstance
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

classMon

protected AEMonitor classMon

isDisposed

protected boolean isDisposed

scriptDispatcher

protected org.gudy.azureus2.platform.macosx.access.cocoa.CocoaJavaBridge.RunnableDispatcher scriptDispatcher
Constructor Detail

CocoaJavaBridge

public CocoaJavaBridge()
                throws java.lang.Throwable
Throws:
java.lang.Throwable
Method Detail

performRecoverableFileDelete

protected boolean performRecoverableFileDelete(java.io.File path)

Overrides:
performRecoverableFileDelete in class NativeInvocationBridge
See Also:
PlatformManager#performRecoverableFileDelete(java.io.File)

showInFinder

protected boolean showInFinder(java.io.File path,
                               java.lang.String fileBrowserApp)

Overrides:
showInFinder in class NativeInvocationBridge
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 class NativeInvocationBridge

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)

dispose

protected void dispose()
Disposes system resources

Overrides:
dispose in class NativeInvocationBridge

finalize

protected void finalize()
                 throws java.lang.Throwable

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable