org.allcolor.yahp.cl.converter.oo
Class COOoConnection

java.lang.Object
  extended by org.allcolor.yahp.cl.converter.oo.COOoConnection
All Implemented Interfaces:
com.sun.star.lang.XEventListener, com.sun.star.uno.XInterface

public class COOoConnection
extends java.lang.Object
implements com.sun.star.lang.XEventListener

Represent an UNO connection to OpenOffice.org

Version:
v0.94
Author:
Quentin Anciaux

Field Summary
private  boolean autoReconnecting
          if true reconnect automatically if the connection is closed
private  com.sun.star.bridge.XBridge bridge
          OOo internal Api object
private  boolean closingExpected
          if true, the closing of the connection is expected to come
private  com.sun.star.uno.XComponentContext context
          OOo internal Api object
private  java.lang.String hostName
          hostname where OOo is running on
private static org.apache.log4j.Logger log
          use for logging
private  int port
          port on which OOo is running on
private  com.sun.star.lang.XMultiComponentFactory serviceManager
          OOo internal Api object
 
Fields inherited from interface com.sun.star.lang.XEventListener
UNOTYPEINFO
 
Constructor Summary
COOoConnection()
          Creates a new COOoConnection object.
COOoConnection(int port)
          Creates a new COOoConnection object.
COOoConnection(int port, java.lang.String hostName)
          Creates a new COOoConnection object.
 
Method Summary
 void close()
          Close the connection
 void connect()
          Connect to OOo
 void disposing(com.sun.star.lang.EventObject event)
          sent by OOO when closing.
 boolean getAutoReconnecting()
          return the status of the auto reconnect flag
 com.sun.star.frame.XComponentLoader getDesktop()
          Obtains the com.sun.star.frame.Desktop service.
 java.lang.String getHostName()
           
 int getPort()
           
protected  java.lang.Object getService(java.lang.String service)
          Obtains a UNO service.
 void setAutoReconnecting(boolean autoReconnecting)
          Should we try to reestablish the connection if it goes down?
 void setHostName(java.lang.String hostName)
          set hostname where OOo is running on
 void setPort(int port)
          set port on which OOo is running on
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Logger log
use for logging


hostName

private java.lang.String hostName
hostname where OOo is running on


bridge

private com.sun.star.bridge.XBridge bridge
OOo internal Api object


context

private com.sun.star.uno.XComponentContext context
OOo internal Api object


serviceManager

private com.sun.star.lang.XMultiComponentFactory serviceManager
OOo internal Api object


autoReconnecting

private boolean autoReconnecting
if true reconnect automatically if the connection is closed


closingExpected

private boolean closingExpected
if true, the closing of the connection is expected to come


port

private int port
port on which OOo is running on

Constructor Detail

COOoConnection

public COOoConnection()
Creates a new COOoConnection object.


COOoConnection

public COOoConnection(int port)
Creates a new COOoConnection object.

Parameters:
port - port on which OOo is running on

COOoConnection

public COOoConnection(int port,
                      java.lang.String hostName)
Creates a new COOoConnection object.

Parameters:
port - port on which OOo is running on
hostName - hostname where OOo is running on
Method Detail

setHostName

public final void setHostName(java.lang.String hostName)
set hostname where OOo is running on

Parameters:
hostName - The hostName to set.

getHostName

public final java.lang.String getHostName()
Returns:
Returns the hostName.

setPort

public void setPort(int port)
set port on which OOo is running on

Parameters:
port - port on which OOo is running on

getPort

public final int getPort()
Returns:
Returns the port.

setAutoReconnecting

public void setAutoReconnecting(boolean autoReconnecting)
Should we try to reestablish the connection if it goes down?

Parameters:
autoReconnecting -

getAutoReconnecting

public boolean getAutoReconnecting()
return the status of the auto reconnect flag

Returns:
the status of the auto reconnect flag

getDesktop

public com.sun.star.frame.XComponentLoader getDesktop()
                                               throws java.net.ConnectException
Obtains the com.sun.star.frame.Desktop service.

Returns:
com.sun.star.frame.Desktop service
Throws:
java.net.ConnectException - if an excetpion occurs

close

public void close()
Close the connection


connect

public void connect()
             throws java.net.ConnectException
Connect to OOo

Throws:
java.net.ConnectException - if an error occurs
java.lang.RuntimeException - if an error occurs

disposing

public void disposing(com.sun.star.lang.EventObject event)
sent by OOO when closing.

Specified by:
disposing in interface com.sun.star.lang.XEventListener
Parameters:
event - OOo event

getService

protected java.lang.Object getService(java.lang.String service)
                               throws java.net.ConnectException
Obtains a UNO service.

Parameters:
service - the UNO service name (e.g. "com.sun.star.frame.Desktop")
Returns:
the service
Throws:
java.net.ConnectException - if the underlying connection went down
java.lang.IllegalStateException - if an error occurs
java.lang.RuntimeException - if an error occurs