The SPADE Directory Facilitator (DF)

SPADE's DF serves as yellow pages index where the services offered by the agents are published for others to find. The way of publishing services is by uploading to the DF agent a set of service descriptions that contain information about services and how to access them. Each agent can publish its own set of service descriptions.

The interface for an agent to publish its own services is a bit unconventional and stilted in order to comply with the FIPA specification. First, the agent has to describe its services by using the spade.DF.ServiceDescription class. The objects of this class store the information of a particular service: its name, type, the protocols it requires, the ontologies associated with the service, the content languages that are used, its ownership and some additional properties it may have. This information can be set up using the dedicated methods of these objects.

Next, the agent has to instantiate a spade.DF.DfAgentDescription object (which is quite similar to a spade.AMS.AmsAgentDescription object) which will host the collection of spade.DF.ServiceDescription objects. This is the object that will be passed to the registerService method of the agent in order to register all the services. Each agent can upload only one set of services at a time. In order to remove a service, an agent would use the registerService method with a spade.DF.DfAgentDescription containing the active services minus the one that is to be removed (that is why we encourage agent developers to keep a local copy of a spade.DF.DfAgentDescription object with a set of the active services). Again, this interface is not straightforward but FIPA-compliant, and so an example is helpful:

		sd = spade.DF.ServiceDescription()
		sd.setName("test")
		sd.setType("testservice")
		dad = spade.DF.DfAgentDescription()
		dad.addService(sd)
		sd = spade.DF.ServiceDescription()
		sd.setName("MYSERVICE")
		sd.setType("MYTYPE")
		dad.addService(sd)
		dad.setAID(self.myAgent.getAID())
		res = self.myAgent.registerService(dad)
		print "Service Registered:",str(res)