FreeHEP API
Version current

hep.aida.ref.remote
Class RemoteClient

java.lang.Object
  extended byhep.aida.ref.remote.RemoteClient
All Implemented Interfaces:
AidaTreeClient, Runnable
Direct Known Subclasses:
RmiRemoteClient

public abstract class RemoteClient
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:
RemoteClient.java

Field Summary
protected  boolean blocking
           
protected  String clientID
           
protected  boolean duplex
           
protected  boolean isConnected
           
protected  boolean keepUpdating
           
protected  RemoteUpdatableQueue queue
           
protected  Logger remoteLogger
           
protected  AidaTreeServant servant
           
protected  AidaTreeServer server
           
protected  IDevMutableStore store
           
protected  long updateInterval
           
 
Constructor Summary
RemoteClient(IDevMutableStore store)
          Creates a new instance of RemoteClient.
RemoteClient(IDevMutableStore store, boolean duplex)
           
 
Method Summary
 boolean connect()
           
protected  void connectDuplex()
          Retrieves Duplex AidaTreeServant from the AidaTreeServer.
protected  void connectNonDuplex()
          Retrieves non-Duplex AidaTreeServant from the AidaTreeServer.
 boolean disconnect()
           
 Object find(String path)
           
protected abstract  AidaTreeServer getServer()
          Retrieves reference to the AidaTreeServer.
protected  void init()
           
 boolean isBlocking()
           
 boolean isConnected()
           
 String[] listObjectNames(String path, boolean recursive)
           
 String[] listObjectTypes(String path, boolean recursive)
           
static void main(String[] args)
           
 void run()
           
 void setBlocking(boolean b)
           
 void setDuplex(boolean duplex)
          Set duplex mode.
 void setUpdateTime(long updateInterval)
          Set time interval (in milliseconds) for AidaTreeClient to check for updates.
 void stateChanged(AidaUpdateEvent[] 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 RemoteUpdatableQueue queue

duplex

protected boolean duplex

blocking

protected boolean blocking

isConnected

protected boolean isConnected

updateInterval

protected long updateInterval

keepUpdating

protected boolean keepUpdating

clientID

protected String clientID

remoteLogger

protected Logger remoteLogger
Constructor Detail

RemoteClient

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


RemoteClient

public RemoteClient(IDevMutableStore store,
                    boolean duplex)
Method Detail

init

protected void init()

setBlocking

public void setBlocking(boolean b)

isBlocking

public boolean isBlocking()

getServer

protected abstract AidaTreeServer getServer()
Retrieves reference to the AidaTreeServer. Must 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 RemoteConnectionException
Retrieves Duplex AidaTreeServant from the AidaTreeServer.

Throws:
RemoteConnectionException

connectNonDuplex

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

Throws:
RemoteConnectionException

listObjectNames

public String[] listObjectNames(String path,
                                boolean recursive)
                         throws IllegalArgumentException
Throws:
IllegalArgumentException

listObjectTypes

public String[] listObjectTypes(String path,
                                boolean recursive)
                         throws IllegalArgumentException
Throws:
IllegalArgumentException

find

public Object find(String path)
            throws IllegalArgumentException
Throws:
IllegalArgumentException

stateChanged

public void stateChanged(AidaUpdateEvent[] 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()

connect

public boolean connect()
                throws RemoteConnectionException
Throws:
RemoteConnectionException

disconnect

public boolean disconnect()

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.