Nuxeo Enterprise Platform 5.3

com.anwrt.ooserver.daemon
Class OfficeProcess

java.lang.Object
  extended by java.lang.Thread
      extended by com.anwrt.ooserver.daemon.OfficeProcess
All Implemented Interfaces:
Runnable

public class OfficeProcess
extends Thread

All the informations and management of an open office server instance

Author:
Jounayd Id Salah

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
OfficeProcess(Daemon daemon, String userId, Integer index)
           
 
Method Summary
 void endUsage()
          Informs the OfficeProcess that the client has finished using the server instance.
 com.sun.star.bridge.XBridge getBridge()
           
 String getConnectString()
          Builds a connection string that is used by oo servers.
 com.sun.star.uno.XComponentContext getContext()
           
 Integer getIndex()
           
 Long getTimestamp()
          The time saved when the usage of the process started
 Integer getUsage()
          Number of clients that used the process.
 long getUsageDuration()
          Gets the duration since the client started to use the server instance
 String getUserId()
           
 boolean isResponsive()
          Creates a new thread that will test if the process is responsive.
 boolean restartWhenNecessary()
          Tests if it's necessary to restart an OpenOffice instance (not responsive or maxUsageCount reached).
 void start()
          Starts a new openOffice server instance represented by a java 'process'
 void startUsage()
          Informs that a client has started to use the server instance.
 void terminate()
          Closes the current server instance (killed if not responding)
 boolean terminateAndRestart()
          Closes the server instance and tries to restart it
 String toString()
          small string
 String toStringDetailed()
          large information string
 boolean tryConnect()
          Try to connect to one instance of open office using the current index of the OfficeProcess object
 boolean waitTillReady(Integer timeout)
          Requests connection with server instance until it gets it or the timeout is reached
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OfficeProcess

public OfficeProcess(Daemon daemon,
                     String userId,
                     Integer index)
Method Detail

getTimestamp

public Long getTimestamp()
The time saved when the usage of the process started

Returns:
date in milliseconds

getUsage

public Integer getUsage()
Number of clients that used the process.

Returns:
-

getUserId

public String getUserId()

getIndex

public Integer getIndex()

getContext

public com.sun.star.uno.XComponentContext getContext()

getBridge

public com.sun.star.bridge.XBridge getBridge()

start

public void start()
Starts a new openOffice server instance represented by a java 'process'

Overrides:
start in class Thread

terminate

public void terminate()
Closes the current server instance (killed if not responding)


terminateAndRestart

public boolean terminateAndRestart()
Closes the server instance and tries to restart it

Returns:
true if restarted and connected successfully

tryConnect

public boolean tryConnect()
Try to connect to one instance of open office using the current index of the OfficeProcess object

Returns:
true if connected

waitTillReady

public boolean waitTillReady(Integer timeout)
Requests connection with server instance until it gets it or the timeout is reached

Parameters:
timeout - try to connect in the given timeout, the method returns if the timeout is reached
Returns:
true if connected successfully

startUsage

public void startUsage()
Informs that a client has started to use the server instance.


getUsageDuration

public long getUsageDuration()
Gets the duration since the client started to use the server instance

Returns:
the duration

endUsage

public void endUsage()
Informs the OfficeProcess that the client has finished using the server instance.


isResponsive

public boolean isResponsive()
Creates a new thread that will test if the process is responsive.

Returns:
true if the process responds correctly

restartWhenNecessary

public boolean restartWhenNecessary()
Tests if it's necessary to restart an OpenOffice instance (not responsive or maxUsageCount reached). If it is, it will try to restart it.

Returns:
true if the process is restarted and connected

getConnectString

public String getConnectString()
Builds a connection string that is used by oo servers. Pipe is used by default : daemon should resides on the same machine than open office server user installations

Returns:
connection string

toString

public String toString()
small string

Overrides:
toString in class Thread
Returns:
small string
See Also:
Thread.toString()

toStringDetailed

public String toStringDetailed()
large information string

Returns:
large information string

Nuxeo Enterprise Platform 5.3

Copyright © 2010 Nuxeo SAS. All Rights Reserved.