When a service registers itself, it does so with a set of attributes.
Each set is given by an instance of a FileType
:
public Class FileType implements Entry {
public String type; // this is a MIME type
public FileType(String type) {
this.type = type;
}
}
For a text editor, the attribute set would be FileType("plain/text")
.
For a RTF editor, the attribute set would be FileType("application/rtf")
.
(Of course, there may be more than one field in the class!)
Some services may be able to handle more than one set of attributes. For example,
most word-processors can handle many document types. In this case, a service is
able to register an Entry
's:
Entry[] entries = new Entry[] {new FileType("plain/text"),
new FileType("application/rtf")
};
On the other side, a client wishes to find services that can handle the attributes
that it requires. The client uses same Entry
class for this.
For any particular Entry
, the client specifies
null
value)
This is pretty crude. A printer typically has the capacity to print a
certain number of pages per minute. If it specifies this, then it actually
makes it rather hard to find! A client can request a printer service
in which it does not care about speed, or for a particular speed. It
cannot ask for printers with a speed without
a
capability, say, anything
Entries are shipped around using RMI. Exported service objects are serialized, moved around by RMI and reconstituted as objects at some remote. Entries are similarly serialized and moved around by RMI, but are not reconstituted. So when it comes to comparing an entry from a service and an entry from a client request, it is the serialized forms that are compared.
An entry cannot have as field one of the primitive types such as
int
or char
. If one of these fields is
required, then it must be wrapped up in a class such as
Integer
or Character
.
The only fields of interest are public, non-static, non-transient and non-final.
This file is Copyright ©Jan Newmarch (http://jan.newmarch.name) jan@newmarch.name