Factory (JNA API)
Description: declaration: package: com.sun.jna.platform.win32.COM.util, class: Factory

Package com.sun.jna.platform.win32.COM.util

# Class Factory

java.lang.Object
com.sun.jna.platform.win32.COM.util.ObjectFactory
com.sun.jna.platform.win32.COM.util.Factory

public class Factory extends ObjectFactory
Factory is intended as a simpler to use version of ObjectFactory.

The Factory abstracts the necessity to handle COM threading by introducing a dispatching thread, that is correctly COM initialized and is used to handle all outgoing calls.

NOTE: Remember to call factory.getComThread().terminate() at some appropriate point, when the factory is not used anymore

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Factory()`
  `Factory(ComThread comThread)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `(package private) IDispatchCallback`
  `createDispatchCallback(Class<?> comEventCallbackInterface, IComEventCallbackListener comEventCallbackListener)`
  `<T> T`
  `createObject(Class<T> comInterface)`
  Creates a new COM object (CoCreateInstance) for the given progId and returns a ProxyObject for the given interface.
  `<T> T`
  `createProxy(Class<T> comInterface, IDispatch dispatch)`
  Creates a ProxyObject for the given interface and IDispatch pointer.
  `(package private) Guid.GUID`
  `discoverClsId(ComObject annotation)`
  `<T> T`
  `fetchObject(Class<T> comInterface)`
  Gets and existing COM object (GetActiveObject) for the given progId and returns a ProxyObject for the given interface.
  `ComThread`
  `getComThread()`
  `IRunningObjectTable`
  `getRunningObjectTable()`
  CoInitialize must be called be fore this method.

  ### Methods inherited from class com.sun.jna.platform.win32.COM.util.ObjectFactory

  `disposeAll, finalize, getLCID, register, setLCID, unregister`

  ### Methods inherited from class java.lang.Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Factory

    public Factory()

  - ### Factory

    public Factory(ComThread comThread)

- ## Method Details

  - ### createProxy

    public <T> T createProxy(Class<T> comInterface, IDispatch dispatch)
    Description copied from class: `ObjectFactory`
    Creates a ProxyObject for the given interface and IDispatch pointer.

    Overrides:
      `createProxy` in class `ObjectFactory`

  - ### discoverClsId

    Guid.GUID discoverClsId(ComObject annotation)
    Overrides:
      `discoverClsId` in class `ObjectFactory`

  - ### fetchObject

    public <T> T fetchObject(Class<T> comInterface) throws COMException
    Description copied from class: `ObjectFactory`
    Gets and existing COM object (GetActiveObject) for the given progId and returns a ProxyObject for the given interface.
    Overrides:
      `fetchObject` in class `ObjectFactory`
    Throws:
      `COMException`

  - ### createObject

    public <T> T createObject(Class<T> comInterface)
    Description copied from class: `ObjectFactory`
    Creates a new COM object (CoCreateInstance) for the given progId and returns a ProxyObject for the given interface.
    Overrides:
      `createObject` in class `ObjectFactory`

  - ### createDispatchCallback

    IDispatchCallback createDispatchCallback(Class<?> comEventCallbackInterface, IComEventCallbackListener comEventCallbackListener)
    Overrides:
      `createDispatchCallback` in class `ObjectFactory`

  - ### getRunningObjectTable

    public IRunningObjectTable getRunningObjectTable()
    Description copied from class: `ObjectFactory`
    CoInitialize must be called be fore this method. Either explicitly or implicitly via other methods.
    Overrides:
      `getRunningObjectTable` in class `ObjectFactory`
    Returns:
      running object table

  - ### getComThread

    public ComThread getComThread()