Java Application for Creating a Shared Object Cache
I. Mejuev
I. AbeHigh Energy Accelerator Research Organization (KEK)
1-1 OHO, Tsukuba, Ibaraki 305, JapanAbstract
The Java language is used to create thin GUI clientsconnected to a server implemented as a Java application.
The server contains an object cache, which is updated bycalls to an underlying system layer. Using objectconnection technology, we establish connections between
objects from the server cache and GUI clients’ objects. The
states of the connected objects are synchronized so that allchanges in the objects’ state are transferred from client tothe server, and vise versa. Since only changes aretransferred, the control network traffic is reduced and theperformance increased. Software development is also
simplified, since both the client and server don’t have totake care of the objects’ states synchronization. The sockets
or distributed Java object systems, such as RMI or HORB,
can be used to transfer the states. Since the system isimplemented completely on Java, it can be made amultiplatform, and control clients can run on any Javaenabled browsers with minimum system requirements.

libraries. This application is used as a distributor of data
coming from devices to clients’ applets, and also forproviding the possibility of bi-directional data exchange.
The development of Java class libraries and applications isin line with our efforts to apply a variety of Internet andIntranet technologies for accelerator control [1], [2].
2 Data channel classes
A data channel class library provides basic functions,which are used by the other Java classes and applications
described in this paper. The main idea of using channels isrepresented in the Figure 1. A Java application called a“channel server” is run on HOST 2, so that applets orapplications running on other computers can create, delete,subscribe, unsubscribe and update channels on HOST 1.
HOST 1Java Application
or Applet

1 Introduction
The main advantages of applying Java for accelerator
control are the use of a Java distributed software model andconnectivity provided by this language. The benefits ofusing browsers as client software are also well known.
Besides, currently, the majority of software support Java,and today we have an excellent choice of authoring andpublishing software.
However, severe timing limitations and the nature ofcontrol programs pose additional requirements on thesoftware and class libraries used for development. In
control software it is often necessary to deal with a data
stream, rather than with a simple request-reply
communication model. The performance of applications
based on device polling is often not sufficient if the numberof devices is growing. This is especially true for Java
applets, which are supposed to run on browsers withminimum system requirements. The solution to thisproblem is to use notification or “push” technology, whereclients are informed by the server about any changes ofrelevant data.
In this paper we describe Java class libraries developed toprovide notifications for clients’ applets with extended
capabilities, such as the creation of named data channels aswell as subscription and synchronization of objects’ statesacross a network.Further, we describe the design of a
“Shared Object Cache” application based on those classdevicemanagerserverclientHOST 2Java Application

HOST 3
Java Applet

clientHOST 4Java Applet

Figure 1
If the application or applet from HOST 1 updates achannel owned by HOST 2 and, that channel has been
subscribed by HOST 3 and HOST 4, the applets running on
those hosts receive a notification. A channel update means
the submission of a primitive data type to a channel,
followed by a value name, represented by an instance of theString class in Java.
The ChannelManager class provides the functionality
described above; it uses an interface named
ChannelUpdateListener to notify the user about channels’
updates and other events. To indicate errors, aChannelException instance is thrown.
2.1 ChannelManager classChannelManager class has two constructors. One createsa channel server with the possibility to own channels aswell as to send requests to other hosts. Another constructor
creates only a client, which can use channels served byanother host. Since Java applets loaded from a remote hostcannot listen for TCP connections, they can use only thesecond type of constructor. Below we describe the public
methods of ChannelManager class in more detail. A
destination (where) is represented in the form of a string,which contains the TCP port and host name.
• addListener(ChannelUpdateListener listener)
Registers an object which has implemented theChannelUpdateListener interface; through the methodsof this interface the user receives notifications about the
updates of channels' and other events.
• pingHost(String where)
Verifies that there is a ChannelManager running at a
specified location, and that it can accept connections.
• createChannel(String channel, String where)
Creates a channel at a specified location.
• closeChannel(String channel, String where)
Closes a channel at a specified location; if the channel
doesn't exist, a ChannelException is thrown.
• subscribe(String channel, String where)
Subscribes a channel at a specified location; if thechannel doesn't exist, a ChannelException is thrown.
• unsubscribe(String channel, String where)
Unsubscribes a channel at a specified location; if thechannel doesn’t exist, or it hasn’t been subscribed,nothing happens.
•updateChannel(String channel, String where, StringvalueID, Object value)
Updates a channel at a specified location. The stringvalueID is used as a value name. If the channel exists, all
subscribers receive a channelUpdated message.
The value can be an instance of the following Java classes:
String, Integer, Long, Float, Double, Boolean or a Vector,
comprising these types. It is possible to mix different types
in a Vector. An attempt to pass an illegal data type to thisfunction generates a ChannelException.
2.2 Channel update listener interface
An applet or application using ChannelManager implements functions of this interface to receive the updates ofchannels and other kinds of notifications. Throwing anexception in these interface methods generates an error
reply; it can be used to create some kind of security.
Abstract methods of the Channel Update Listener interface
are described below.
•channelUpdated(String channel, String where, StringvalueID, Object value, String byWhom)
Called by ChannelManager when a remote or local
channel is updated, and if that channel has beenpreviously subscribed. It is possible to prevent updatingof a local channel by throwing an exception.

••

•

•

channelClosed(String channel, String where, StringbyWhom)
Called when a previously subscribed channel is about
to be closed. It is possible to prevent the closing of a
local channel by throwing an exception.
channelSubscribed(String channel, String byWhom)
Called when a remote host or a local listener subscribes
a local channel. Throwing an exception can prevent asubscription.
channelCreated(String channel, String byWhom)
Called then a local channel is created by a remote hostor a local listener. Can be prevented by throwing anexception.
channelUnsubscribed(String channel, String byWhom)
Called when a local channel is unsubscribed by aremote host or a local listener.

2.3 Channel server application
Clients’ applets use connections to the Channel Server
application in order to transfer commands and to exchange
data. Additional functionality, which is provided by thisapplication, includes a graphical user interface, logging,and the possibility to inform applets about what channels
are currently available on a server.

Figure 2
2.4 Channel client applet
To simplify the diagnostics and testing of software wealso developed a Channel Client Applet, which provides
the possibility to manually execute channel commands
using a convenient graphical interface.
3 Object connection classes
Data channels can be used for a wide range of control
and other applications; however it is often necessary tosynchronize the states of objects distributed across anetwork. For these purpose we developed classes
implementing such synchronization. These classes use achannel library for data transfer. The following publicclasses have been developed: ObjectConnectionManager
and CMObject.
The source code for a client using an object connection isvery simple:maintenance cost.
Data providers, such as various device managers, while
communicating with a server use a data channel interface,which is more suitable for handling data streams. Data
coming from the devices are cached in the server memory,thus significantly increasing the clients’ applets performance.
The design layout of the Object Cache application is represented in Figure 4.

Data Provider

Data Provider

Data Channels
Figure 3
manager = new ObjectConnectionManager();
object = new CMObject(“name”, manager);
object.connect(“port@host”);
This code creates a connection between local object andserver object on “host”.
If either server or client modifies the local object executing
for instance:
object.update(new Float(1.1));
the change in object’s state is transferred across networkand method updated() is called for a remote object.
4Object Cash
Application
Object Connections

Java AppletObject cache application design

Object Cache Application belongs to a middle layer ofthe control software. It provides device managers andconsole
or remote clients with the possibility to share a common
object database. Since sockets (TCP) are used for datatransfer, the application performance is better if comparedwith SQL databases or distributed object systems.
Applets or applications, providing a graphical interface
for the users, communicate to a shared object cache using
Object Connection classes, which are described above. It
Significantly simplifies the development of graphicalInterface software, and also reduces the upgrade andJava Applet
Figure 4References[1] The Use of Virtual Reality For a Multimedia
Informational System Development; Igor Mejuev andIsamu Abe; International Workshop on Controls for
Small- and Medium-Scale Accelerators, 1996, KEK,Tsukuba, Japan.
[2]Applications of Internet and Intranet Technologies
for Distributed Control; I. Mejuev, I. Abe;
Proceedings of the 22nd Linear Accelerator Meetingin Japan; September 9-11, 1997, Sendai, Japan.