Download fulltext - DiVA Portal
Transcript
6 2.2 JADE Event System 2.2 JADE Event System 9o The purpose of the GuiEvent class is to pass messages to and from GuiAgents. It has two mandatory attributes, the source of the event (Object), and the type of the event (int). In addition, it has methods for adding a variable number of parameters to the event. These parameters must be Objects, so primitives should be wrapped in appropriate Objects. The challenge with the GuiEvents is that they are passed in an asynchronous manner (when a request is sent, the application is not blocked waiting for an answer and the user can continue to perform other tasks while the message remains unanswered). Although handy in network programming, asynchronous communication when directly linked to GUIs quickly becomes a burden. This is especially so when you have no concrete information about the receiving end of your messages. Will your messages be answered within a given timeframe? Will they be answered at all? Will they reach their target correctly? The best we can do is guess at these questions, introduce certain design rules, and make assumptions. We can also make an eort to handle all incoming requests or answers (independent of the time they arrive, or in which order), so that the user does not experience any "glitches" or button-clicks that appear as if they do nothing. 2.3 Using JADE In Your Application JADE comes with its own API which is in most areas well documented, however JADE has one apparent problem that the API (as it was when we started coding) did not cover. It seems that the developers intended JADE to work as the the backbone system when used. JADE wants to be launched directly from a command prompt so that JADE controls the underlying main thread, which naturally is very restrictive. We appreciate the idea that JADE allows us to use GuiAgents to spawn our GUI, but in a system like ours we would like to separate the GUI from JADE whenever and wherever we can. We do not want to have to rely on agents and the JADE framework to start our GUI components. There are several reasons for this, the foremost being that our application extends beyond the scope of JADE. Not all of its parts utilizes JADE functionality, and thus should not be dependant of it. Secondly, we would like the possibility to start, stop, and modify the JADE platform during application runtime without closing our application altogether. It should be said that with the current release of JADE, new classes and methods have been introduced to deal with this matter, making it trivial. 2.4 JADE Prole and Agent Containers JADE environments are called agent containers. Typically, in a multi-agent application, there will be several containers (with agents) running on dierent machines. The rst container started must be a main container which maintains a central registry of all the others so that agents can discover and interact with each other. Each subsequent container started after the rst one must be non-main containers, else a IllegalStateException will be thrown, and they must also be told where to nd (host and port) the main container. It is possible for non-main containers to use a remote main container.