Class 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 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
      • isDisposed

        protected boolean isDisposed
      • 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
    • Constructor Detail

      • CocoaJavaBridge

        public CocoaJavaBridge()
                        throws java.lang.Throwable
        Throws:
        java.lang.Throwable
    • 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
      • 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)
      • logWarning

        private void logWarning​(java.lang.String message)
        Logs a warning message to Logger. The class monitor is used.
        Parameters:
        message - A warning message
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable