Servlet
FsmServlet
This
class is the point of contact between the applet and the server's business logic. It receives and sends on each demand of the applet a Communication-object. There a several types of demands: a logon-, graph-, refresparameters- and present-demand. Each type of demand is delegated to a separate method of the FsmManager class.public
void doPost(HttpServletRequest request, HttpServletResponse response)This
method overrides the doPost method of the HttpServlet. It provides the communication between te applet and the serverpublic
void destroy()This
method overrides the destroy-method of the HttpServlet and isexecuted
when the servlet is unloaded. It stops the Graph-cachingof
the mangager.Utils
Sizeof
Provides
a helper method for determining the serialized size of an object.Calculates
the serialized size of an object by writing it into a byte array and the returning the array size.Stopwatch
Gewone stopwatch functie
public
synchronized long getElapsedTime()public
synchronized void reset()public
synchronized void start()public
synchronized void stop()Manager
FsmManager
This
class manages all actions to be taken on the server. It can also start and stop the automatic graph caching thread.his
constructor starts the AutoGraphCaching-thread.public
Communication logon(SessionBean session)This
method logs on a user using a SessionBean. It will set the graph- and preference attribute of the SessionBean, and redirect it to the ClientState. If the graph is customized, it will not cache the sessionbean.public
Communication refresh(SessionBean session)This
method treats a refresh-demand for the applet. It will set only the Graph attribute of the SessionBean, it will take this value out of the ClientState except for a customized graph, there it will regenerate the Graph value.public
Communication refreshParameters(SessionBean session)This
method reloads the preferences in the ClientState for that session. This is usefull because the automatic graph caching gets it preferences out of the ClientState.public
Communication detail(SessionBean session, String comm_desc)Not
yet implementedpublic
Communication activateSession(SessionBean session)Activates
or reactivates a session.public
Graph generateGraph(SessionBean session)Based
on the groupname and graphnr, this method will give the FsmReader the command to generate a graphpublic
void stopManager()This
method stops the AutoGraphCaching-thread and the ClientMaintenance-thread. It deletes all instances of the ClientState, AutoGraphCaching and ReaderAutoGraphCaching
AutoGraphCaching
regenerates for every session that is present in the cachevector of the ClientState, a graph. This Graph-object will be put in a SessionBean and will be afterwards saved in the cachevector. This is done every 5 minutes.The
constructor makes a link with the Manager (FsmManager), ClientState (FsmClientState) and the Reader (FsmReader)public
void run()Starts
the AutoGraphCaching-threadprivate
void pause(int sec)Clientstate
FsmClientState
The
ClientState (FsmClientState) is responsible for the caching of actively logged-on users. This cache is a vector of SessionBeans. A SessionBean is a self-written class that contains userinfo, Preferences and a Graph. The ClientState has several methods to retrieve, modify, add or delete information from its cachepublic
FsmClientState()The
contructor creates a new cache-vector for storing SessionBeans and it creates and starts an instance of the ClientStateMaintenance-class.public
void stopMaintenance()Used
to stop the instance of the ClientStateMaintenance-class that was started in the constructor of FsmClientState. The sessionvector, used for caching SessionBeans, will be emptied.public
synchronized Object executeOperation(int operation, SessionBean b)Main
-method to perform synchronized operations on the sessionvector. Use a semaphore to accomplish an operation.private
int indexOf(SessionBean b)private
void activateBean(SessionBean b)private
void deactivateBean(SessionBean b)ClientStateMaintenance
The
ClientStateMaintance, that is a Thread, has the duty to maintain the cachevector of the ClientState. This maintenance consists out of finding and deleting users that currently are not logged on. It uses this principle: Every minute the applet sends a command to the server that indicated the applet/user is logged-on. Every 2 minutes the ClientStateMaintance considers all sessions in-active. When an applet/user resends it "i'm present"-command, ClientStateMaintance considers it active. The next time the pause of 2 minutes has elapsed, ClientStateMaintance tracks the sessions that were not back set to active. Those sessionbeans will then be unregistered.public
void run()Start
the ClientStateMaintance-thread.private
void pause(int sec)Backend
FsmAutorisationReader
The
AuthorisationReader is responsible to return data that ensures the security-policy of the GEM (A-130) and FSM (A-140).public
ArrayList getGraph_nrs(String group)Ensures
FSM's security-policypublic
ArrayList getAutorisedCzs(String user)Ensures
GEM's security-policyprivate
ArrayList getAllCzs()FsmConstants
This
class houses a large number of constants, used in the base classes for generating graphs: GraphComposer and VectorTool. The motherVector is vector of Strings. These Strings have a common structure. The constants of this class defines that structure. It defines the start (_S) and end position (_E)of every field in a String of the motherVector.FsmGraphComposer
The
GraphComposer has several methods that are used in the Reader to generate a Graph-object. It's a low-level component that contains most of the business-logic for designing a Graph-object. The data for this class is supplied by the VectorTool in the shape of a motherVector. Different than the Vectortool, the GraphComposer performs it's operations solely with Java-objects and doesn't has to read from the mainframe. That's why, once a motherVector is built, a Graph-object can be so quickly generated.constructor,
creates a new instance of the Constants-classpublic
Vector addTrainInfo(Vector XmotherVector, Vector beanVector, Vector infrastructure, Preferences p, Date startDate)This
method adds TrainMovements to the infrastructurepublic
Vector addOperationInfo(Vector XmotherVector, Vector beanVector, Vector infrastructure, Preferences p, Date startDate)This
method adds TrackOperations to the infrastructurepublic
Vector addWagonQuantityInfo(Vector XmotherVector, Vector beanVector, Vector infrastructure, Preferences p, Date startDate)This
method adds WagonQuantities to the infrastructure
FsmInfrastructureBuilder
The
InfrastructureBuilder is specialised in infrastructure building and consultationspublic
Vector buildInfrastructure(Vector cl)This
method determines the infrastructure (tracks and hill) for one or more requested communicationzones.public
boolean displayTrack(Vector cz_list, String track, String cz)This
method checks if a specified track in a specified cz is present in the list of displayed tracks in the current Preferencespublic
boolean displayHill(Vector cz_list, String hill, String czThis
method checks if a specified hill in a specified cz is present in the list of displayed hills in the current PreferencesFsmNetComposer
public
ArrayList getZoneComposition(String cz)public
void generateNetwork()public
void generateZone(String cz)FsmPreferenceReader
The
PreferenceReader combines reading mainframetables Grafiek_Weergave and Grafiek_Opbouw so that it becomes the only class that can read the preferences stored on the mainframepublic
Preferences getPreferences(SessionBean session)This
method is used when the Preferences for a group + graphnr is neededpublic
Vector buildCz_list(String key)Used
for retrieving the list of displayed tracks and hills for a communicationzoneFsmReader
The
Reader is a low-level delegating class that gives instructions to the VectorTool, InfrastructureBuilder, GraphComposer for ultimately returning a Graph-object. Therefore it becomes the point-of contact of other management-classes such as ClientState and ManagerThe
constructor establishes a link to the ClientState, creates instances of the InfrastructureBuilder, VectorTool and GraphComposer.public
Graph generateGraph(SessionBean session)This
method will give instructions to the other low-level components (InfrastructureBuilder, VectorTool and GraphComposer)in order to become a Graph-object as return valueFsmVectorTool
This
is the low-level class to build the motherVector. It uses ergonomic methods to unburden the mainframe. It reads the mainframetables Operatie, Op_Loc and Trein_Op_Loc. The mothervector is in fact a "de-normalised" table of the three earlier named mainframetables. This table is a Vector with String-objects as a record. The structure of a record is defined in FsmConstants. A field can be retrieved by the method substring(). Because of the lack of a language such as SQL, I have written several methods where you can give a single condition to select records such as get(), search(), exclude(), include() etc...Constructor
establishes a link between the VectorTool and the InfraStructurebuilder It creates also an instance of FsmConstants.public
Vector buildMotherVector(Vector clv, Date start, int duration)Builds
the mothervectorpublic
Vector convertMotherVector(Vector result)This
method converts a flat String-table into a Object-Oriented Table. In fact the Strings are converted to a SuperBean. Every field will be stocked into a attribute of that SuperBean. It's easier to access an attribute than retrieving the fields content using the substring()-method.public
Vector returnSortedMotherVector(Vector bvx)This
method sorts the beanVector using the fields 'begindatum' + 'einddatum'.RailNetwork
public
void setZoneComposition(String cz, ArrayList composition)public
ArrayList getZoneComposition(String cz)SessionBean
A
Sessionbean contains all necessary information about a session of a user/group. It stores info like username, groupname, graph_nr, Preferences, Graph and an indication if the session is still active. Note that if there are more than 1 user from a same group only 1 sessionbean for that group will be stored in the cachevector from the ClientState.public
boolean equals(SessionBean sb)Compare
current sessionbean with a specified sessionbean. If both groupname and graph_nr are the same. Both sessionbeans are consired as equal and a true-value is returned.SuperBean
A
SuperBean is the OO-version of a flat String-record from the motherVector. Sometimes it's easier to work with attributes of an object instead of using substring() methods.public
int compareTo(Object bx)Method
to sort SuperBeans in a BeanVector. It is sorted by begindatum then by einddatumSerialobjects
Communication
Class
for the communication between the servlet and the applet.Date
Class
using the gregorian calendar to reimplements the deprecated methods of java-util-Date.CzList
Class
to store the communication zones.Klassen voor het bewaren van de trackinfo, voorkeuren van de gebruiker , operaties op een spoor …