com.moesol.bindings.platform_sdk.component_services
Class OleThread

java.lang.Object
  extended by com.moesol.bindings.platform_sdk.component_services.OleThread
All Implemented Interfaces:
Runnable

public class OleThread
extends Object
implements Runnable

Creates a COM/OLE Apartment Thread. In the COM/OLE architecture Aparment threads must pump windows messages. OleThread satisfies this requirement. Typical usage is to create a subclass that is a singleton.

 public class MyOleThread extends OleThread {
     private MyOleThread() {
         super("MyOleThread");
     }
     public static synchronized MyOleThread instance() {
         if (s_instance == null) {
             s_instance = new MyOleThread();
             s_instance.startAndInit();
         }
         return s_instance;
     }

     private static MyOleThread s_instance = null;
 }
 
You can use invokeLater and invokeAndWait in a similar manner as the EventQueue.
 MyOleThread.instance().invokeLater(new Runnable() {
     public void run() {
         // code that runs on MyOleThread and in the
         // MyOleThread apartment.
     }
 });
 


Constructor Summary
OleThread(String name)
           
 
Method Summary
 void attachCurrent()
           
 void finalize()
           
static OleThread getCurrentOleThread()
           
 Thread getJavaThread()
           
 void invokeAndWait(Runnable runable)
           
 void invokeAndWaitOrRuntimeException(Runnable runnable)
          Call invokeAndWait and wrap exceptions in a RuntimeException.
 void invokeLater(Runnable runable)
           
static void oleInitialize()
           
static void oleUninitialize()
           
 void run()
           
 void safeInvokeAndWait(Runnable runnable)
          Call simpleInvokeAndWait, but wrap any Error thrown in a RuntimeException so that the error will propagate back to the caller.
 void simpleInvokeAndWait(Runnable runnable)
          Deprecated. Use safeInvokeAndWait instead.
 void startAndInit()
           
 void stopAndDeinit()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OleThread

public OleThread(String name)
Method Detail

finalize

public void finalize()
Overrides:
finalize in class Object

getJavaThread

public Thread getJavaThread()

getCurrentOleThread

public static OleThread getCurrentOleThread()

oleInitialize

public static void oleInitialize()

oleUninitialize

public static void oleUninitialize()

startAndInit

public void startAndInit()

attachCurrent

public void attachCurrent()

stopAndDeinit

public void stopAndDeinit()

run

public void run()
Specified by:
run in interface Runnable

invokeLater

public void invokeLater(Runnable runable)

invokeAndWait

public void invokeAndWait(Runnable runable)
                   throws InterruptedException,
                          InvocationTargetException
Throws:
InterruptedException
InvocationTargetException

invokeAndWaitOrRuntimeException

public void invokeAndWaitOrRuntimeException(Runnable runnable)
Call invokeAndWait and wrap exceptions in a RuntimeException. This method makes calling invokeAndWait easy by mapping checked expections to runtime exceptions.

Parameters:
runnable -

simpleInvokeAndWait

public void simpleInvokeAndWait(Runnable runnable)
Deprecated. Use safeInvokeAndWait instead.

Call invokeAndWaitOrRuntimeException unless we are already running on the thread associated with this OleThread.

Parameters:
runnable -

safeInvokeAndWait

public void safeInvokeAndWait(Runnable runnable)
Call simpleInvokeAndWait, but wrap any Error thrown in a RuntimeException so that the error will propagate back to the caller.



Copyright © 2004 Moebius Solutions, Inc. All Rights Reserved.