charly.server.resources
Class ChRsrcManagerImpl

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

public class ChRsrcManagerImpl
extends java.rmi.server.UnicastRemoteObject
implements java.rmi.Remote, java.io.Serializable, ChRsrcManager

Objects of this class manage the ressources available on a server. The devices call assertAccess(String,String). This manager does not check whether the resources are really available! It only checks whether they are reserved for other tasks or not.

See Also:
Serialized Form

Nested Class Summary
(package private) static class ChRsrcManagerImpl.ChClientTaskInfo
           
 
Field Summary
(package private)  ChServerImpl server
           
(package private)  int taskCounter
           
(package private)  java.util.HashMap tasks
          maps elems of type String (taskID) to elems of type ChClientTaskInfo
(package private)  java.util.HashMap tasksBook
          maps elems of type ChClientTask to elems of type String (taskID)
 
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
 
Fields inherited from interface charly.server.resources.ChRsrcManager
DELIMITERCHAR
 
Constructor Summary
ChRsrcManagerImpl(ChServerImpl server)
           
 
Method Summary
 void abortTask(java.lang.String taskID)
          abnormal abort of a running task. this method is usually called by ChMonitor.abortTask(String).
 void assertAccess(java.lang.String taskID, java.lang.String rsrcName)
          tests if task with taskID has access to ressource called rsrcName.
protected  void checkNextTaskAcceptance()
          checks if one or more tasks can be accepted and accepts them.
protected  boolean checkTaskAcceptance(java.lang.String taskID)
          checks if taskID can be accepted and accepts in case of success.
protected  java.lang.String createTaskID(java.lang.String taskName)
          produces a String based on taskName and a counter.
 java.util.Set getTasks()
          returns all known tasks.
 boolean isTaskStarted(java.lang.String taskID)
          returns true if the given task has been started and not yet stopped or aborted.
 java.lang.String startTask(ChClientTask task, java.lang.String taskName, java.util.Set rsrcs)
          sets task in state starting or if possible starts it already.
 void stopTask(ChClientTask task)
          normal finish of a task.
 void stopTask(java.lang.String taskID)
          normal finish of a task.
 
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

tasks

java.util.HashMap tasks
maps elems of type String (taskID) to elems of type ChClientTaskInfo

See Also:
ChRsrcManagerImpl.ChClientTaskInfo

tasksBook

java.util.HashMap tasksBook
maps elems of type ChClientTask to elems of type String (taskID)


taskCounter

int taskCounter
See Also:
createTaskID(String)

server

ChServerImpl server
Constructor Detail

ChRsrcManagerImpl

public ChRsrcManagerImpl(ChServerImpl server)
                  throws java.rmi.RemoteException
Method Detail

createTaskID

protected java.lang.String createTaskID(java.lang.String taskName)
produces a String based on taskName and a counter.

See Also:
taskCounter

startTask

public java.lang.String startTask(ChClientTask task,
                                  java.lang.String taskName,
                                  java.util.Set rsrcs)
                           throws ChAlreadyStartingException,
                                  ChAlreadyStartedException
sets task in state starting or if possible starts it already.

Specified by:
startTask in interface ChRsrcManager
Parameters:
task - the client-side task. Its taskStarted()-method is called.
taskName - the name of the task. The taskID is created on the base of this name.
rsrcs - this is a Set of String describing each a resource on the server, e.g. "GPIB/7".
Returns:
taskID this taskID describes the clientTask
Throws:
ChAlreadyStartingException
ChAlreadyStartedException

stopTask

public void stopTask(ChClientTask task)
              throws ChTaskNotRunningException,
                     java.rmi.RemoteException
normal finish of a task. This method is called by ChTask.stop()

Specified by:
stopTask in interface ChRsrcManager
Throws:
ChTaskNotRunningException
java.rmi.RemoteException
See Also:
stopTask(String)

stopTask

public void stopTask(java.lang.String taskID)
              throws ChTaskNotRunningException,
                     java.rmi.RemoteException
normal finish of a task. This method is called by ChTask.stop()

Specified by:
stopTask in interface ChRsrcManager
Throws:
ChTaskNotRunningException
java.rmi.RemoteException
See Also:
stopTask(ChClientTask), abortTask(String taskID)

abortTask

public void abortTask(java.lang.String taskID)
abnormal abort of a running task. this method is usually called by ChMonitor.abortTask(String).

Specified by:
abortTask in interface ChRsrcManager

getTasks

public java.util.Set getTasks()
returns all known tasks.

Specified by:
getTasks in interface ChRsrcManager
Returns:
Set of ChTaskInfo

checkTaskAcceptance

protected boolean checkTaskAcceptance(java.lang.String taskID)
checks if taskID can be accepted and accepts in case of success.

Returns:
true only if specified task was accepted. It is false if the task was already accepted.
See Also:
checkNextTaskAcceptance()

checkNextTaskAcceptance

protected void checkNextTaskAcceptance()
checks if one or more tasks can be accepted and accepts them. An order of acceptance is not yet implemented!!!

See Also:
checkTaskAcceptance(String)

assertAccess

public void assertAccess(java.lang.String taskID,
                         java.lang.String rsrcName)
                  throws ChTaskNotStartedException,
                         ChAccessDeniedException
tests if task with taskID has access to ressource called rsrcName.

Throws:
ChTaskNotStartedException
ChAccessDeniedException

isTaskStarted

public boolean isTaskStarted(java.lang.String taskID)
returns true if the given task has been started and not yet stopped or aborted.