FreeHEP API
Version current

hep.aida.ref.remote.basic
Class BasicTreeClient

java.lang.Object
  extended byhep.aida.ref.remote.basic.BasicTreeClient
All Implemented Interfaces:
AidaTreeClient, Runnable

public class BasicTreeClient
extends Object
implements AidaTreeClient, Runnable

This is Basic implementation of AidaTreeClient that support both "Duplex" and "non-Duplex" modes of communication with the AIDA Tree server. In "Duplex" mode AidaTreeServant call stateChanged() method to notify BasicTreeClient about updates/changes in the server-side AIDA tree. In "non-Duplex" mode BasicTreeClient runs as a separate thread and periodically calls updates() method of AidaTreeServant to get information about updates/changes in the server-side AIDA tree. BasicTreeClient also implements IMutableStore, so it can be used as a Store for any IDevTree.

Author:
serbo
Source Code:
BasicTreeClient.java

Field Summary
protected  String clientID
           
protected  boolean duplex
           
protected  boolean isConnected
           
protected  boolean keepUpdating
           
protected  UpdatableQueue queue
           
protected  AidaTreeServant servant
           
protected  AidaTreeServer server
           
protected  IDevMutableStore store
           
protected  long updateInterval
           
 
Constructor Summary
BasicTreeClient()
          Creates a new instance of BasicTreeClient.
BasicTreeClient(IDevMutableStore store)
           
BasicTreeClient(IDevMutableStore store, boolean duplex)
           
 
Method Summary
 boolean connect()
          Make initial connection to the AidaTreeServer.
protected  void connectDuplex()
          Retrieves Duplex AidaTreeServant from the AidaTreeServer.
protected  void connectNonDuplex()
          Retrieves non-Duplex AidaTreeServant from the AidaTreeServer.
 boolean disconnect()
          Disconnect from the AidaTreeServer and free all resources associated with it.
 Object find(String path)
          Get the data for IManagedObject, at a given path in the ITree.
protected  AidaTreeServer getServer()
          Retrieves reference to the AidaTreeServer.
protected  void init()
           
 boolean isConnected()
          Return true if AidaTreeClient is already connected to the AidaTreeServer
 String[] listObjectNames(String path)
          Get the list of names of the IManagedObjects under a given path, including directories (but not "." and "..").
 String[] listObjectTypes(String path)
          Get the list of types of the IManagedObjects under a given path.
static void main(String[] args)
           
 void run()
           
 void setDuplex(boolean duplex)
          Set duplex mode.
 void setUpdateTime(long updateInterval)
          Set time interval (in milliseconds) for AidaTreeClient to check for updates.
 void stateChanged(UpdateEvent[] events)
          In this implementation stateChanged(UpdateEvent[] events) method simply schedules updates in the UpdatableQueue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server

protected AidaTreeServer server

servant

protected AidaTreeServant servant

store

protected IDevMutableStore store

queue

protected UpdatableQueue queue

duplex

protected boolean duplex

isConnected

protected boolean isConnected

updateInterval

protected long updateInterval

keepUpdating

protected boolean keepUpdating

clientID

protected String clientID
Constructor Detail

BasicTreeClient

public BasicTreeClient()
Creates a new instance of BasicTreeClient. Duplex is default to "true". If AidaTreeServer does not support Duplex mode, try to connect in non-Duplex.


BasicTreeClient

public BasicTreeClient(IDevMutableStore store)

BasicTreeClient

public BasicTreeClient(IDevMutableStore store,
                       boolean duplex)
Method Detail

init

protected void init()

getServer

protected AidaTreeServer getServer()
Retrieves reference to the AidaTreeServer. Should be overwritten by subclasses.


setUpdateTime

public void setUpdateTime(long updateInterval)
Set time interval (in milliseconds) for AidaTreeClient to check for updates. Relevant only for non-Duplex Mode, as in Duplex Mode updates are "pushed" into AidaTreeClient by AidaTreeServer calling "stateChanged()" method. Default value: updateInterval=2000 milliseconds.


setDuplex

public void setDuplex(boolean duplex)
Set duplex mode. Default is "true".


connectDuplex

protected void connectDuplex()
                      throws AidaConnectionException
Retrieves Duplex AidaTreeServant from the AidaTreeServer.

Throws:
AidaConnectionException

connectNonDuplex

protected void connectNonDuplex()
                         throws AidaConnectionException
Retrieves non-Duplex AidaTreeServant from the AidaTreeServer.

Throws:
AidaConnectionException

listObjectNames

public String[] listObjectNames(String path)
                         throws IllegalArgumentException
Description copied from interface: AidaTreeClient
Get the list of names of the IManagedObjects under a given path, including directories (but not "." and ".."). Directories end with "/". The returned names are appended to the given path unless the latter is "." The path is an absolute path from the ITree root.

Specified by:
listObjectNames in interface AidaTreeClient
Throws:
IllegalArgumentException - if path does not exist.

listObjectTypes

public String[] listObjectTypes(String path)
                         throws IllegalArgumentException
Description copied from interface: AidaTreeClient
Get the list of types of the IManagedObjects under a given path. The types are the leaf class of the Interface, e.g. "IHistogram1D", "ITuple", etc. Directories are marked with "dir". The order of the types is the same as the order for the listObjectNames() method to achieve a one-to-one correspondance between object names and types. The path is an absolute path from the ITree root.

Specified by:
listObjectTypes in interface AidaTreeClient
Throws:
IllegalArgumentException - if path does not exist.

find

public Object find(String path)
            throws IllegalArgumentException
Description copied from interface: AidaTreeClient
Get the data for IManagedObject, at a given path in the ITree. The path is an absolute path from the ITree root.

Specified by:
find in interface AidaTreeClient
Throws:
IllegalArgumentException - if path does not exist, or path does not point to a directory.

stateChanged

public void stateChanged(UpdateEvent[] events)
In this implementation stateChanged(UpdateEvent[] events) method simply schedules updates in the UpdatableQueue. Later queue invokes stateChanged(UpdateEvent event) method on a separate thread to process updates.

Specified by:
stateChanged in interface AidaTreeClient

isConnected

public boolean isConnected()
Description copied from interface: AidaTreeClient
Return true if AidaTreeClient is already connected to the AidaTreeServer

Specified by:
isConnected in interface AidaTreeClient

connect

public boolean connect()
                throws AidaConnectionException
Description copied from interface: AidaTreeClient
Make initial connection to the AidaTreeServer. If BasicTreeClient is already connected, throws AidaConnectionException.

Specified by:
connect in interface AidaTreeClient
Throws:
AidaConnectionException

disconnect

public boolean disconnect()
Description copied from interface: AidaTreeClient
Disconnect from the AidaTreeServer and free all resources associated with it.

Specified by:
disconnect in interface AidaTreeClient

run

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

main

public static void main(String[] args)

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.