ADK Example Code
|
The following examples are included with the ADK to illustrate the basic
structure of SIF Agents developed with the class framework. If you're
familiar with Java and SIF concepts, you should be able to easily walk
through the source code. Each sample is a fully-functional SIF Agent that
supports all of the capabilities of SIF 1.0r1 and SIF 1.0r2 specifications.
Many runtime settings, such as whether to use Push or Pull mode to
communication with the ZIS, are specified on the command-line.
| | |
To compile and run these examples, you'll need to download the
ADK 30-Day Evaluation. Once installed, use the
batch files in the examples directory to compile and run
each sample.
| | |
Common File
|
The following file is used by all ADK Example agents to parse the
command-line and to read a list of zones from a text file on disk. It's
provided here for completeness.
| | |
LibraryProvider
|
The LibraryProvider agent is a Swing-based application with a graphical
user interface. It demonstrates how to:
| | |
- Request StudentPersonal and StaffPersonal objects
- Subscribe to SIF_Events for StudentPersonal and StaffPersonal
- Invoke Selective Message Blocking to query for an object while processing a SIF Event
- Provide LibraryPatronStatus objects
-
Respond to SIF Requests for LibraryPatronStatus objects for all
patrons, for students only, for staff only, or for a specific student
or teacher by RefId
| | |
|
Like all ADK Example agents this one supports multiple zones and generates
the appropriate LibraryPatronStatus object for SIF 1.0r1 and SIF 1.0r2. Use
the /ver option on the command line to specify the version of SIF the agent
should use when generating messages (it will respond to requests in any
version).
| | |
GetSchoolInfo
The GetSchoolInfo agent demonstrates how to subscribe to SIF Events and
execute SIF Requests with the ADK. It supports multiple zones by reading a
list of zone names and URLs from a configuration file on disk. It then
establishes a Topic class for "SchoolInfo" objects and "joins" each zone
to that topic. To handle incoming SIF Messages, the sample implements the
Subscriber and QueryResults message handler
interfaces, called by the ADK whenever a SIF_Event and SIF_Response message
is received from a zone. These message handlers are registered with the
Topic instance so that they will be called for all SchoolInfo-related
messages regardless of which zone it was received from. To request
SchoolInfo objects, the agent simply calls the Topic.query()
method to query all zones.
| | |
GetSchoolInfoSync
|
The GetSchoolInfoSync agent demonstrates how to execute synchronous
SIF Requests with the ADK. The TrackQueryResults class is used to issue a
SIF Request for SchoolInfo objects. The request will timeout if no results
are received in 30 seconds.
| | |
SchoolInfoProvider
|
The SchoolInfoProvider agent demonstrates how to build a simple Provider of
SchoolInfo objects without using the SIF Data Object (SDO) classes.
When responding to SIF_Request queries, the agent reads a <SchoolInfo>
object from a file on disk. The agent also reports SIF Events whenever that
file is changed. You can use a text editor to edit the file while the agent
is running as a means of easily generating SIF Events for the GetSchoolInfo
agent to respond to.
| | |
GetZoneStatus
The GetZoneStatus agent queries a ZIS for its SIF_ZoneStatus object, then
prints it to the console. This example illustrates the use of the Zone.getZoneStatus
method, which simplifies querying zones for SIF_ZoneStatus by eliminating
the need to create a QueryResults message handler. It works
synchronously by blocking the calling thread until a response is received
or a timeout occurs.
| | |
QueryZoneStatus
The QueryZoneStatus agent queries one or more zones for its SIF_ZoneStatus
object, then prints the contents of the object to the console. Unlike the
GetZoneStatus example, this agent does not use the Zone.getZoneStatus
convenience method. Instead, it demonstrates how to query for SIF_ZoneStatus
asynchronously using Topics and a QueryResults message handler
in the same way other kinds of objects are requested with the ADK. One
benefit to not using the getZoneStatus method is that with a Query object
you can specify conditions on the query, illustrated here by specifically
requesting only a subset of fields (use the /full option to request
SIF_ZoneStatus objects with all elements and attributes.)
| | |
|
| | |
|