|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Zone
A Zone is a logical grouping of applications that exchange data through the Schools Interoperability Framework. Each zone is managed by a Zone Integration Server (ZIS). Refer to the SIF Specifications for a more detailed definition. Agents developed with the ADK may connect to multiple zones concurrently.
Zones have the following characteristics:
Zone.getProperties method
to obtain the zone's AgentProperties object, then call its accessor
methods. Properties must be set prior to calling connect.
connect
method, the agent may also send SIF registration messages to establish
similar resources on the server.
An agent obtains a Zone instance by calling Agent.getZoneFactory.
When finished interacting with a zone, call the disconnect
method to release local resources held by the ADK as well as to optionally
send a SIF_Unregister message to the server. Disconnecting all zones to
which an agent is connected is easily done by calling the Agent.shutdown
method when the agent exits.
Agents typically use Topic objects to aggregate publish, subscribe, and query activity across multiple zones. Refer to the Topic interface for details.
| Method Summary | |
|---|---|
void |
addMessagingListener(MessagingListener listener)
Register a MessagingListener to listen to messages received by the message handlers of this class. |
void |
connect(int flags)
Connects the agent with this zone. |
void |
disconnect(int flags)
Disconnects the agent from this zone. |
Agent |
getAgent()
Gets the Agent object |
java.util.List<SIFException> |
getConnectWarnings()
Gets a read-only list of any SIF Errors that resulted from the sending of provisioning messages to the zone. |
UndeliverableMessageHandler |
getErrorHandler()
Gets the UndeliverableMessageHandler for this zone. |
org.apache.log4j.Logger |
getLog()
Gets the Log4j Logger for this zone. |
AgentProperties |
getProperties()
Gets the properties for this zone. |
ServerLog |
getServerLog()
Gets the ServerLog for this zone. |
java.lang.Object |
getUserData()
Gets the application-supplied object for this Zone |
java.lang.String |
getZoneId()
Gets the zone identifier |
SIF_ZoneStatus |
getZoneStatus()
Gets the SIF_ZoneStatus object from the ZIS managing this zone. |
SIF_ZoneStatus |
getZoneStatus(int timeout)
Gets the SIF_ZoneStatus object from the ZIS managing this zone. |
java.net.URL |
getZoneUrl()
Gets the URL of the Zone Integration Server that manages this zone |
boolean |
isConnected()
Gets the connection state of this zone |
boolean |
isSleeping(int flags)
Determines if the agent's queue for this zone is in sleep mode. |
void |
purgeQueue(boolean incoming,
boolean outgoing)
Purge all pending incoming and/or outgoing messages from this agent's queue. |
java.lang.String |
query(Query query)
Query the zone. |
java.lang.String |
query(Query query,
int queryOptions)
Query the zone with options. |
java.lang.String |
query(Query query,
MessagingListener listener)
Query the zone and notify a MessagingListener |
java.lang.String |
query(Query query,
MessagingListener listener,
int queryOptions)
Query the zone with options and notify a MessagingListener |
java.lang.String |
query(Query query,
MessagingListener listener,
java.lang.String destinationId,
int queryOptions)
Query a specific agent registered with this zone (a directed query) and notify a MessagingListener. |
java.lang.String |
query(Query query,
java.lang.String destinationId,
int queryOptions)
Query a specific agent registered with this zone (a directed query). |
void |
removeMessagingListener(MessagingListener listener)
Remove a MessagingListener previously registered with the addMessagingListener method. |
void |
reportEvent(Event event)
Report a SIF Event to the zone |
void |
reportEvent(SIFDataObject obj,
EventAction actionCode)
Report a SIF Event to the zone |
void |
reportEvent(SIFDataObject obj,
EventAction actionCode,
SIFContext... contexts)
Report a SIF Event to the zone in one or more specific SIF Contexts |
void |
reportEvent(SIFDataObject obj,
EventAction action,
java.lang.String destinationId)
Report a directed SIF Event to the agent in the zone identified by destinationId. |
void |
setErrorHandler(UndeliverableMessageHandler handler)
Sets the UndeliverableMessageHandler to be called when a dispatching error occurs on this zone. |
void |
setProperties(AgentProperties props)
Assigns a new properties object to this zone. |
void |
setUserData(java.lang.Object data)
Assigns an application-supplied object to this Zone |
SIF_Ack |
sifPing()
Sends a SIF_Ping message to the ZIS that manages this zone. |
SIF_Ack |
sifProvide(java.lang.String[] objectType)
Sends a SIF_Provide message to the ZIS. |
SIF_Ack |
sifRegister()
Sends a SIF_Register message to the ZIS. |
SIF_Ack |
sifSend(java.lang.String xml)
Sends arbitrary SIF_Message content to the zone. |
SIF_Ack |
sifSubscribe(java.lang.String[] objectType)
Sends a SIF_Subscribe message to the ZIS. |
SIF_Ack |
sifUnprovide(java.lang.String[] objectType)
Sends a SIF_Unprovide message to the ZIS. |
SIF_Ack |
sifUnregister()
Sends a SIF_Unregister message to the ZIS. |
SIF_Ack |
sifUnsubscribe(java.lang.String[] objectType)
Sends a SIF_Unsubscribe message to the ZIS. |
void |
sleep()
Puts this zone into sleep mode. |
java.lang.String |
toString()
Returns the string representation of this zone as "zoneId@zoneUrl" |
void |
wakeup()
Wakes up this zone if currently in sleep mode. |
| Methods inherited from interface com.edustructures.sifworks.Provisioner |
|---|
setPublisher, setPublisher, setQueryResults, setQueryResults, setReportPublisher, setSubscriber |
| Method Detail |
|---|
AgentProperties getProperties()
By default, a zone inherits the default agent properties.
void setProperties(AgentProperties props)
By default, a zone inherits the default agent properties. To change a property, first call the getProperties method to obtain the zone's properties object, then call any of the accessor methods available on that object. Because zones are constructed with a default AgentProperties object, it is typically not necessary to call this method.
props - A new properties object to replace the existing objectAgent getAgent()
java.lang.String getZoneId()
java.net.URL getZoneUrl()
void connect(int flags)
throws ADKException
An agent must connect to a zone in order to perform messaging within the context of the ADK Class Framework. A typical agent calls this method at startup for each zone it will connect to, then optionally joins the Zone with one or more Topics.
The ADK's Provisioning Mode affects the messages sent by this method. Refer to the AgentProperties class for more information.
The ADK will send <SIF_Subscribe> and <SIF_Provide>
messages to the zone to provision the SIF Data Objects for which the agent has registered a
Subscriber and Publisher message handlers, respectively.
The adk.provisioning.batch agent property (refer to the
AgentProperties class) determines whether the ADK sends a single message
or individual messages for each SIF Data Object. When individual messages
are sent (the default), Category 4 Access Control errors are treated as
warnings. Connect warnings can be retrieved by calling the
getConnectWarnings method. When a single message is sent,
any SIF Error will result in the raising of a SIFException.
Note the SIF_Wakeup and SIF_Ping system control messages are sent to the server upon successful connection.
flags - One or more of the following flags:
| Flag | Description |
ADKFlags.REGISTER |
Sends a SIF_Register message to the ZIS and wakes up the agent queue on the server if previously in sleep mode. |
java.lang.IllegalStateException - is thrown if this zone is already in
the connected state (i.e. connect has already been called
without a corresponding call to disconnect)
ADKException - is thrown if there is a SIF Error acknowledgement
to a <SIF_Register>, <SIF_Subscribe>,
or <SIF_Provide> message as described abovedisconnect(int)
void disconnect(int flags)
throws ADKException
Resources held by the Class Framework, including the Agent Local Queue,
are closed. To ensure these resources are properly closed, agents should
disconnect from zones even when not planning on sending a <
SIF_Unregister> provisioning message.
Provisioning messages are sent as follows:
<
SIF_Unregister> message is sent to the ZIS when the
ADKFlags.PROV_UNREGISTER flag is specified. When
ADK-managed provisioning is disabled, no messages are sent to
the zone.
Note that SIF Agent sessions are long-lived and therefore an agent may remain registered with a ZIS even when it is "disconnected" from the perspective of the ADK Class Framework.
Disconnecting a zone also places the agent's server queue in sleep mode. This functionality can be disabled via the zone properties.
flags - One or more flags as described above
java.lang.IllegalStateException - is thrown if this zone is not in the
connected state (i.e. connect has not been called, or disconnect has
already been called)
ADKException - is thrown if there is an error sending a
<SIF_Unregister> messageconnect(int)java.util.List<SIFException> getConnectWarnings()
connect method
boolean isConnected()
void reportEvent(Event event)
throws ADKException
event - An Event object describing the SIF Data Object that has
changed and how it has changed (added, updated, or removed)
ADKException
void reportEvent(SIFDataObject obj,
EventAction actionCode)
throws ADKException
obj - The object that was added, changed, or deletedactionCode - The action being taken on the object
( ADD, CHANGE, or DELETE )
ADKException
void reportEvent(SIFDataObject obj,
EventAction actionCode,
SIFContext... contexts)
throws ADKException
obj - the object that was added, changed, or deletedactionCode - The action being taken on the objectcontexts - An array or sequence (varargs) of specific SIF Contexts to
report this event in.
ADKException
void reportEvent(SIFDataObject obj,
EventAction action,
java.lang.String destinationId)
throws ADKException
destinationId. Note: Directed SIF Events may not be supported
by all zone integration servers.
obj - The object that was added, changed, or deletedaction - The action being taken on the objectdestinationId - The SourceId of the agent to which the SIF Event
will be routed by the zone integration server
ADKException - If an error occurs while reporting the event
java.lang.String query(Query query)
throws ADKException
query - A Query object describing the parameters of the query,
including optional conditions and field restrictions
ADKException - If an error occurs while sending the Query to the zone
java.lang.String query(Query query,
MessagingListener listener)
throws ADKException
query - A Query object describing the parameters of the query,
including optional conditions and field restrictionslistener - A MessagingListener that will be notified when the
SIF_Request message is sent to the zone. Any other MessagingListeners
registered with the zone will also be called.
ADKException - If an error occurs while sending the query to the zone
java.lang.String query(Query query,
int queryOptions)
throws ADKException
query - A Query object describing the parameters of the query,
including optional conditions and field restrictions.queryOptions - Reserved for future use.
ADKException - If an error occurs while sending the query to the zone
java.lang.String query(Query query,
MessagingListener listener,
int queryOptions)
throws ADKException
query - A Query object describing the parameters of the query,
including optional conditions and field restrictions.listener - A MessagingListener that will be notified when the
SIF_Request message is sent to the zone. Any other MessagingListeners
registered with the zone will also be called.queryOptions - Reserved for future use.
ADKException
java.lang.String query(Query query,
java.lang.String destinationId,
int queryOptions)
throws ADKException
Directed queries are used primarily when the source of data is known because of a message previously received from that agent. For example, if your agent receives a SIF_Event and you wish to query the author of that event for additional data, a directed query is appropriate.
In addition, some kinds of SIF Data Objects in SIF 1.5 and later may be designed to require agents to send directed queries if more than one agent in a zone typically offers support for the object. This is necessary because only one agent can be the authoritative provider of a given object type in each zone.
query - A Query object describing the parameters of the query,
including optional conditions and field restrictionsdestinationId - The SourceId of the agent to which the SIF Request
will be routed by the zone integration serverqueryOptions - Reserved for future use
ADKException
java.lang.String query(Query query,
MessagingListener listener,
java.lang.String destinationId,
int queryOptions)
throws ADKException
Directed queries are used primarily when the source of data is known because of a message previously received from that agent. For example, if your agent receives a SIF_Event and you wish to query the author of that event for additional data, a directed query is appropriate.
In addition, some kinds of SIF Data Objects in SIF 1.5 and later may be designed to require agents to send directed queries if more than one agent in a zone typically offers support for the object. This is necessary because only one agent can be the authoritative provider of a given object type in each zone.
query - A Query object describing the parameters of the query,
including optional conditions and field restrictionslistener - A MessagingListener that will be notified when the
SIF_Request message is sent to the zone. Any other MessagingListeners
registered with the zone will also be called.destinationId - The SourceId of the agent to which the SIF Request
will be routed by the zone integration serverqueryOptions - Reserved for future use
ADKException - Thrown if an error occurs while sending the query to the zone
SIF_ZoneStatus getZoneStatus()
throws ADKException
ADKException - If the ADK cannot connect to the zone to request
the SIF_ZoneStatus object
SIF_ZoneStatus getZoneStatus(int timeout)
throws ADKException
timeout - The amount of time to wait for a SIF_ZoneStatus object to
be received by the agent (or -1 to wait infinitely)
ADKException - If the ADK cannot connect to the zone to request
the SIF_ZoneStatus objectvoid addMessagingListener(MessagingListener listener)
NOTE: Agents may register a MessagingListener with the Agent or Zone classes. When a listener is registered with both classes, it will be called twice. Consequently, it is recommended that most implementations choose to register MessagingListeners with only one of these classes depending on whether the agent is interested in receiving global notifications or notifications on only a subset of zones.
listener - a MessagingListener implementationvoid removeMessagingListener(MessagingListener listener)
addMessagingListener method.
listener - a MessagingListener implementation
void purgeQueue(boolean incoming,
boolean outgoing)
throws ADKException
incoming - true to purge incoming messagesoutgoing - true to purge outgoing messages (e.g. pending SIF_Events)
when the Agent Local Queue is enabled
ADKException - Thrown if an error occurs while purging the queue
void sleep()
throws ADKException
A SIF_Sleep message is sent to the Zone Integration Server to request
that this agent's queue be put into sleep mode. If successful, the ZIS
should not deliver further messages to this agent until it is receives
a SIF_Register or SIF_Wakeup message from the agent. Note the ADK keeps
an internal sleep flag for each zone, which is initialized when the
connect method is called by sending a SIF_Ping to the ZIS.
This flag is set so that the ADK will return a Status Code 8 ("Receiver
is sleeping") in response to any message received by the ZIS for the
duration of the session.
If the SIF_Sleep message is not successful, an exception is thrown and the ADK's internal sleep flag for this zone is not changed.
ADKException - thrown if the SIF_Sleep message is unsuccessful
void wakeup()
throws ADKException
A SIF_Wakeup message is sent to the Zone Integration Server to request
that sleep mode be removed from this agent's queue. Note the ADK keeps
an internal sleep flag for each zone, which is initialized when the
connect method is called by sending a SIF_Ping to the ZIS.
This flag is cleared so that the ADK will no longer return a Status Code
8 ("Receiver is sleeping") in response to messages received by the ZIS.
If the SIF_Sleep message is not successful, an exception is thrown and the ADK's internal sleep flag for this zone is not changed.
ADKException - thrown if the SIF_Wakeup message is unsuccessfulvoid setErrorHandler(UndeliverableMessageHandler handler)
handler - The handler to call when the ADK cannot dispatch an
inbound messageUndeliverableMessageHandler getErrorHandler()
UndeliverableMessageHandler
for this zonesetErrorHandler(com.edustructures.sifworks.UndeliverableMessageHandler)
boolean isSleeping(int flags)
throws ADKException
flags - When ADKFlags.LOCAL_QUEUE is specified, returns true if the
Agent Local Queue is currently in sleep mode. False is returned if
the Agent Local Queue is disabled. When ADKFlags.SERVER_QUEUE is
specified, queries the sleep mode of the Zone Integration Server
by sending a SIF_Ping message.
ADKException - Thrown if an error occurs while checking the zone's
sleep status
SIF_Ack sifRegister()
throws ADKException
ADKException - Thrown if an error occurs while sending the sif
SIF_Ack sifUnregister()
throws ADKException
ADKException
SIF_Ack sifSubscribe(java.lang.String[] objectType)
throws ADKException
ADKException
SIF_Ack sifUnsubscribe(java.lang.String[] objectType)
throws ADKException
ADKException
SIF_Ack sifProvide(java.lang.String[] objectType)
throws ADKException
ADKException
SIF_Ack sifUnprovide(java.lang.String[] objectType)
throws ADKException
ADKException
SIF_Ack sifPing()
throws ADKException
ADKException
SIF_Ack sifSend(java.lang.String xml)
throws ADKException
xml - A valid SIF_Message complete with a SIF_Header header and a
payload such as SIF_Register, SIF_Request, SIF_Event, etc.
ADKExceptionvoid setUserData(java.lang.Object data)
data - Any object the application wishes to attach to this Zone instancejava.lang.Object getUserData()
setUserData methodorg.apache.log4j.Logger getLog()
ServerLog getServerLog()
java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||