com.jniwrapper.win32.ie
Class IsolatedBrowserGroup

java.lang.Object
  extended by com.jniwrapper.win32.ie.IsolatedBrowserGroup

public class IsolatedBrowserGroup
extends java.lang.Object

This implementation represents a group of WebBrowser Controls that are running in separate native process. During construction a new instance of this class the new native process will be launched as run32dll.exe process.

Disposing the instance of this class shutdown already launched run32dll.exe process. If java process in which the instance of this class is running will shutdown, then a native run32dll.exe process will detect this action and destroy itself.


Constructor Summary
IsolatedBrowserGroup()
          Creates a new instance of IsolatedBrowserGroup class and starts a new native run32dll.exe process.
 
Method Summary
 com.jniwrapper.win32.com.IUnknown createComObject()
          Creates a new instance of IWebBrowser2 COM interface which is run in separate native process.
 void dispose()
          Disposes current group and shutdown native process if it still available and running.
 void getAndDispatchNextMessage()
           
protected  com.jniwrapper.win32.com.types.CLSID getCLSID()
          Returns a CLSID value of IWebBrowser2 COM interface.
 java.util.Set<Cookie> getCookies(java.net.URL url)
           
 long getCurrentThreadId()
           
 com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
          Returns the OleMessageLoop thread in which all registered WebBrowserSupport instances in this group are working.
 ProxyConfiguration getProxy()
          Returns the proxy settings for the current Browser group that is running in separate native process.
protected  java.util.Set<T> getRegisteredBrowsers()
          Returns a set of all registered WebBrowser instances.
 void installMessageFilter(boolean install)
           
 boolean isNativeProcessAlive()
           
 boolean isRegistered(T b)
          Returns true if this group contains the specified WebBrowserSupport instance.
 int[] oleDraw(com.jniwrapper.win32.com.impl.IUnknownImpl unknown, com.jniwrapper.Int32 wnd, com.jniwrapper.win32.Rect rect, com.jniwrapper.win32.Size size)
          Returns an array of pixels that represents an image of the specified HTML Document that loaded in WebBrowser component.
 void registerBrowser(com.jniwrapper.win32.ie.WebBrowserSupport b)
          Registers the specified WebBrowserSupport instance to this group if it is not already present.
 long registerTranslateAcceleratorCallback(com.jniwrapper.win32.ole.IOleInPlaceActiveObject activeObject)
           
 void revokeTranslateAcceleratorCallback(long callbackCookie)
           
 void setCookies(java.net.URL url, java.util.Set<Cookie> cookies)
           
 void setProxy(ProxyConfiguration conf)
          Sets the specified proxy settings for the current Browser group that is running in separate native process.
 void unregisterBrowser(com.jniwrapper.win32.ie.WebBrowserSupport b)
          Removes the specified WebBrowser instance from this group if it is present.
 void updateBounds(com.jniwrapper.win32.ui.Wnd wnd, java.awt.Rectangle rectangle, boolean asynch)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IsolatedBrowserGroup

public IsolatedBrowserGroup()
                     throws java.lang.reflect.InvocationTargetException,
                            java.lang.InterruptedException
Creates a new instance of IsolatedBrowserGroup class and starts a new native run32dll.exe process.

Throws:
java.lang.InterruptedException - if another thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
java.lang.reflect.InvocationTargetException - when error during initialization of this instance is occurs.
Method Detail

registerBrowser

public void registerBrowser(com.jniwrapper.win32.ie.WebBrowserSupport b)
Registers the specified WebBrowserSupport instance to this group if it is not already present. If this group already contains the specified WebBrowserSupport instance, the call leaves this group unchanged.

Parameters:
b - instance to be added to this group.

unregisterBrowser

public void unregisterBrowser(com.jniwrapper.win32.ie.WebBrowserSupport b)
Removes the specified WebBrowser instance from this group if it is present. If b it is the latest instance in this groupt, then the group will be disposed.

Parameters:
b - instance to be removed from this group, if present.

createComObject

public com.jniwrapper.win32.com.IUnknown createComObject()
Creates a new instance of IWebBrowser2 COM interface which is run in separate native process. The returned value can be casted to IWebBrowser2 interface.

Returns:
a new instance of IWebBrowser2 COM interface.

registerTranslateAcceleratorCallback

public long registerTranslateAcceleratorCallback(com.jniwrapper.win32.ole.IOleInPlaceActiveObject activeObject)

revokeTranslateAcceleratorCallback

public void revokeTranslateAcceleratorCallback(long callbackCookie)

getCookies

public java.util.Set<Cookie> getCookies(java.net.URL url)

setCookies

public void setCookies(java.net.URL url,
                       java.util.Set<Cookie> cookies)

getProxy

public ProxyConfiguration getProxy()
Returns the proxy settings for the current Browser group that is running in separate native process.

Returns:
the proxy settings for the current Browser group.

setProxy

public void setProxy(ProxyConfiguration conf)
Sets the specified proxy settings for the current Browser group that is running in separate native process.

These settings will be applied only for the current process and they will not affect on the system local area network (LAN) proxy settings.

Parameters:
conf - the proxy settings. This parameter cannot be null.

oleDraw

public int[] oleDraw(com.jniwrapper.win32.com.impl.IUnknownImpl unknown,
                     com.jniwrapper.Int32 wnd,
                     com.jniwrapper.win32.Rect rect,
                     com.jniwrapper.win32.Size size)
Returns an array of pixels that represents an image of the specified HTML Document that loaded in WebBrowser component.

This method must be invoked in OleMessageLoop thread.

Parameters:
unknown - the HTML document that is currently loaded.
wnd - the WebBrowser control window
rect - the region to be captured
size - the result image size
Returns:
an array of pixels that represents an image.
Throws:
java.lang.IllegalStateException - when this method isn't invoked in OleMessageLoop thread.

dispose

public void dispose()
Disposes current group and shutdown native process if it still available and running. This method also clears all resources that were allocated by this group instance.


isNativeProcessAlive

public boolean isNativeProcessAlive()

installMessageFilter

public void installMessageFilter(boolean install)

getAndDispatchNextMessage

public void getAndDispatchNextMessage()

getCurrentThreadId

public long getCurrentThreadId()

updateBounds

public void updateBounds(com.jniwrapper.win32.ui.Wnd wnd,
                         java.awt.Rectangle rectangle,
                         boolean asynch)

getCLSID

protected com.jniwrapper.win32.com.types.CLSID getCLSID()
Returns a CLSID value of IWebBrowser2 COM interface. This method is used for internal stuff relative to creating IWebBrowser2 instances.

Returns:
a CLSID value of IWebBrowser2 COM interface.

getRegisteredBrowsers

protected java.util.Set<T> getRegisteredBrowsers()
Returns a set of all registered WebBrowser instances.

Returns:
a set of all registered WebBrowser instances.

isRegistered

public boolean isRegistered(T b)
Returns true if this group contains the specified WebBrowserSupport instance.

Parameters:
b - instance whose presence in this group is to be tested.
Returns:
true if this group contains the specified instance.

getOleMessageLoop

public com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
Returns the OleMessageLoop thread in which all registered WebBrowserSupport instances in this group are working.

Returns:
this group OleMessageLoop thread instance.