charly.server
Class ChServerImpl

java.lang.Object
  extended byjava.rmi.server.RemoteObject
      extended byjava.rmi.server.RemoteServer
          extended byjava.rmi.server.UnicastRemoteObject
              extended bycharly.server.ChServerImpl
All Implemented Interfaces:
ChServer, java.rmi.Remote, java.io.Serializable

public class ChServerImpl
extends java.rmi.server.UnicastRemoteObject
implements java.rmi.Remote, ChServer

Implementation of the server interface. This is the central class of the server-side part of Charly. It adds devices (such as ChGpibDevice) and the client starts the communication to the server always via an object of this class. See main(String []) for calling details.

See Also:
Serialized Form

Field Summary
(package private)  java.util.Hashtable Devices
          Keys sind vom Typ String und enthalten den Namen des Devices in Großbuchstaben, Value-Elemente sind vom Typ ChDevice
(package private)  ChRsrcManager rsrcMgr
           
static java.lang.String title
           
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
 
Fields inherited from class java.rmi.server.RemoteServer
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
(package private) ChServerImpl()
           
 
Method Summary
 void addDevice(ChDevice newDvc)
           
static void error(java.lang.String msg)
          wird aufgerufen, wenn ein schwerer noch nicht behandelter Fehler im Programm auftritt
 ChDevice getDevice(java.lang.String dvcName)
          returns the device by its name.
 ChRsrcManager getRsrcMgr()
          initializes the internal ChRsrcManager, if not already done.
 void log(java.lang.Object src, java.lang.String msg)
          just a simple logging function which prints the msg to System.out.
static void main(java.lang.String[] args)
          Calling ChServerImpl is quite complex because of the use of RMI.
static void printLocalAddress()
           
static void problem(java.lang.String msg)
          wird aufgerufen, wenn ein Problem auftritt, durch das die Stabilität des Servers aber nicht beeinträchtigt wird
(package private)  void registryBind()
          binds this to the local host - registry with the name "CharlyServer"
 void setRsrcMgr(ChRsrcManager rsrcMgr)
           
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

title

public static final java.lang.String title
See Also:
Constant Field Values

rsrcMgr

ChRsrcManager rsrcMgr

Devices

java.util.Hashtable Devices
Keys sind vom Typ String und enthalten den Namen des Devices in Großbuchstaben, Value-Elemente sind vom Typ ChDevice

See Also:
ChDevice
Constructor Detail

ChServerImpl

ChServerImpl()
       throws java.rmi.RemoteException
Method Detail

getRsrcMgr

public ChRsrcManager getRsrcMgr()
                         throws java.rmi.RemoteException
initializes the internal ChRsrcManager, if not already done.

Specified by:
getRsrcMgr in interface ChServer
Throws:
java.rmi.RemoteException

setRsrcMgr

public void setRsrcMgr(ChRsrcManager rsrcMgr)

main

public static void main(java.lang.String[] args)
                 throws java.lang.IllegalArgumentException,
                        java.net.MalformedURLException,
                        java.rmi.RemoteException

Calling ChServerImpl is quite complex because of the use of RMI. Before calling ChServerImpl the RMI-registry has to be started (in Windows: rmiregistry.exe).

A policy file is needed. A very simple policy file (ChPolicy) is joint with this distribution. It is not safe to use this file, because it grants all permissions. On starting, the property java.security.policy must be set to the name of the property file.

Charly has to be able to load some classes code to the RMI. That is why a codebase has to be given. The property java.rmi.server.codebase has to be set to the codebase (the directory or the JAR-file, but only one).

Device drivers are arguments for main. Device drivers have to implement ChDevice.


Beispiel:
java -Djava.rmi.server.codebase=file:///H:/Java/classes/ -Djava.security.policy=H:\java\charly\ChPolicy charly.server.ChServerImpl charly.server.ChGpibDevice

Throws:
java.lang.IllegalArgumentException - Diese Ausnahme dürfte nicht auftreten: Tödlicher Fehler
java.net.MalformedURLException
java.rmi.RemoteException
See Also:
ChGpibDevice, ChRobDevice

log

public void log(java.lang.Object src,
                java.lang.String msg)
just a simple logging function which prints the msg to System.out.


registryBind

void registryBind()
            throws java.net.MalformedURLException,
                   java.rmi.RemoteException,
                   java.rmi.AccessException
binds this to the local host - registry with the name "CharlyServer"

Throws:
java.net.MalformedURLException
java.rmi.RemoteException
java.rmi.AccessException

printLocalAddress

public static void printLocalAddress()

addDevice

public void addDevice(ChDevice newDvc)

getDevice

public ChDevice getDevice(java.lang.String dvcName)
                   throws java.rmi.RemoteException
Description copied from interface: ChServer
returns the device by its name.

Specified by:
getDevice in interface ChServer
Throws:
java.rmi.RemoteException

error

public static void error(java.lang.String msg)
wird aufgerufen, wenn ein schwerer noch nicht behandelter Fehler im Programm auftritt


problem

public static void problem(java.lang.String msg)
wird aufgerufen, wenn ein Problem auftritt, durch das die Stabilität des Servers aber nicht beeinträchtigt wird