com.jniwrapper.win32.automation
Class OleMessageLoop

java.lang.Object
  extended bycom.jniwrapper.win32.MessageLoopThread
      extended bycom.jniwrapper.win32.automation.OleMessageLoop

public class OleMessageLoop
extends MessageLoopThread

This class provides the dedicated message queue thread for OLE/COM.


Field Summary
 
Fields inherited from class com.jniwrapper.win32.MessageLoopThread
_log
 
Constructor Summary
OleMessageLoop()
          Creates message loop instance.
OleMessageLoop(boolean daemon)
          Creates a message loop instance.
OleMessageLoop(java.lang.String name)
          Creates message loop instance.
 
Method Summary
static void addAction(java.lang.Runnable action)
          Adds a runnable action that will be executed in the message thread.
static void addAction(java.lang.Runnable action, boolean postWorkerAvailableMessage)
          Adds the runnable action to be executed within the message thread.
static void addMessageListener(MessageLoopListener listener)
          Adds the new process messages listener to receive events from the message loop.
 IUnknown bindObject(IUnknown unknown)
          Binds the specified object to the thread.
static OleMessageLoop get(java.lang.Thread thread)
           
static OleMessageLoop getInstance()
          Returns main application message loop.
static void invokeAndWait(java.lang.Runnable action)
          Invokes the specified action in the message loop thread and waits for its termination
static void invokeLater(java.lang.Runnable action)
          Adds a runnable action that will be executed in the message thread.
static java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName)
          Invokes a method of calling an object in the message thread.
static java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] parameters)
          Invokes a method of calling object in message thread.
protected  void onStart()
           
protected  void onStop()
           
static void postThreadMessage(int message)
          Posts the message to the message queue of the message loop thread.
static void postThreadMessage(int message, int wParam, int lParam)
          Deprecated. This method is incompatible with 64-bit architectures. Use postThreadMessage(int message, long wParam, long lParam) instead.
static void postThreadMessage(int message, long wParam, long lParam)
          Posts the specified message to the message queue of the message loop thread.
static void removeMessageListener(MessageLoopListener listener)
          Removes the specified process message listener.
static void start()
          Starts the message loop thread.
static void stop()
          Terminates the message thread.
 
Methods inherited from class com.jniwrapper.win32.MessageLoopThread
doAddMessageListener, doInvokeAndWait, doInvokeLater, doInvokeMethod, doInvokeMethod, doRemoveMessageListener, doStart, doStop, getMessageLoops, getName, isDispatchThread, isStarted, pingMessageLoopThread, postSyncThreadMessage, postSyncThreadMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OleMessageLoop

public OleMessageLoop()
Creates message loop instance.


OleMessageLoop

public OleMessageLoop(java.lang.String name)
Creates message loop instance.


OleMessageLoop

public OleMessageLoop(boolean daemon)
Creates a message loop instance.

Parameters:
daemon - determines if the message loop thread is a daemon thread or not.
Method Detail

get

public static OleMessageLoop get(java.lang.Thread thread)

getInstance

public static OleMessageLoop getInstance()
Returns main application message loop. There is one main message loop for application.

Returns:
ole message loop instance

addMessageListener

public static void addMessageListener(MessageLoopListener listener)
Adds the new process messages listener to receive events from the message loop.

Parameters:
listener - the process message listener.

removeMessageListener

public static void removeMessageListener(MessageLoopListener listener)
Removes the specified process message listener.

Parameters:
listener - the process message listener.

start

public static void start()
Starts the message loop thread.


postThreadMessage

public static void postThreadMessage(int message)
Posts the message to the message queue of the message loop thread.

Parameters:
message - the type of message to be posted.

postThreadMessage

public static void postThreadMessage(int message,
                                     int wParam,
                                     int lParam)
Deprecated. This method is incompatible with 64-bit architectures. Use postThreadMessage(int message, long wParam, long lParam) instead.

Posts the specified message to the message queue of the message loop thread.

Parameters:
message - the type of message to be posted.
wParam - additional message-specific information.
lParam - additional message-specific information.

postThreadMessage

public static void postThreadMessage(int message,
                                     long wParam,
                                     long lParam)
Posts the specified message to the message queue of the message loop thread.

Parameters:
message - the type of message to be posted.
wParam - additional message-specific information.
lParam - additional message-specific information.

addAction

public static void addAction(java.lang.Runnable action,
                             boolean postWorkerAvailableMessage)
Adds the runnable action to be executed within the message thread.

Parameters:
action - the action to run within message loop.
postWorkerAvailableMessage - if true - posts the Msg.WM_USER message to avake the thread.

addAction

public static void addAction(java.lang.Runnable action)
Adds a runnable action that will be executed in the message thread.

Parameters:
action - is an action to be executed within the thread.

invokeLater

public static void invokeLater(java.lang.Runnable action)
Adds a runnable action that will be executed in the message thread.

Parameters:
action - is an action to be executed within the thread.

invokeAndWait

public static void invokeAndWait(java.lang.Runnable action)
                          throws java.lang.InterruptedException,
                                 java.lang.reflect.InvocationTargetException
Invokes the specified action in the message loop thread and waits for its termination

Parameters:
action - action to execute.
Throws:
java.lang.InterruptedException
java.lang.reflect.InvocationTargetException

invokeMethod

public static java.lang.Object invokeMethod(java.lang.Object object,
                                            java.lang.String methodName)
                                     throws java.lang.InterruptedException,
                                            java.lang.reflect.InvocationTargetException
Invokes a method of calling an object in the message thread.

Parameters:
object - is a caller whose method is to be executed.
methodName - is a method name to execute.
Returns:
execution result.
Throws:
java.lang.InterruptedException
java.lang.reflect.InvocationTargetException

invokeMethod

public static java.lang.Object invokeMethod(java.lang.Object object,
                                            java.lang.String methodName,
                                            java.lang.Object[] parameters)
                                     throws java.lang.InterruptedException,
                                            java.lang.reflect.InvocationTargetException
Invokes a method of calling object in message thread.

Parameters:
object - is a caller whose method is to be executed.
methodName - is a method name to execute.
parameters - are method parameters; can be null if there are no parameters.
Returns:
execution result.
Throws:
java.lang.InterruptedException
java.lang.reflect.InvocationTargetException

stop

public static void stop()
Terminates the message thread.


onStart

protected void onStart()

onStop

protected void onStop()

bindObject

public IUnknown bindObject(IUnknown unknown)
Binds the specified object to the thread.

Parameters:
unknown -
Returns:
binded IUnknown object