Entries are used to pass additional information about services that clients can use to decide if a particular service is what it wants.
When a service registers itself, it does so with a set of attributes.
Each set is given by an instance of a type or
class. For example, an editor may have an
attribute type of 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 array of attribute sets, meaning that it
can satisfy all of them using an array of 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 the 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 greater than some value. It cannot ask for a printer without a capability, such as anything except a color printer. An attribute must either match exactly or be ignored. The relational operators such as `<' and `!=' are not supported.
Entries are shipped around using RMI. Exported service objects are serialized, moved around by RMI and reconstituted as objects at some remote client. 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.
The class AbstractEntry
is a subclass of Entry
,
and is designed as a convenience class. It implements methods such
as equals()
and toString()
.
Hoever, it doesn't really seem to add much that would justify using
it, in my opinion.
In addtion, Sun's implementation of Jini contains a further set of
convenience classes, all subclassed out of AbstractEntry
.
They are
Address
- the address of the physical component of a service.
Comment
- a free-form comment about a service.
Location
- the location of the physical component of a service.
This is distinct from the Address
class in that it can be used alone in a small, local
organization.
Name
- the name of a service as used by users.
A service may have multiple names.
ServiceInfo
- generic information about a service.
This includes the name of the manufacturer, the product, and the vendor.
ServiceType
- human-oriented information about the "type" of a service.
This is not related to its data or class types, and is more oriented towards allowing
someone to determine what a service (for example, a printer) does and that
it is similar to another, without needing to know anything about data or
class types for the Java platform.
Status
- the base class from which other status-related entry
classes may be derived.
For example, the Address
class contains
String country;
String locality; // City or locality name.
String organization; // Name of the company or organization that provides this service.
String organizationalUnit; // The unit within the organization that provides this service.
String postalCode; // Postal code.
String stateOrProvince; // Full name or standard postal abbreviation of a state or province.
String street; //Street address.
You may find these classes useful; on the other hand, what services would like to
advertise, and what clients would like to match on is pretty much unknown as yet.
These classes are not part of the formal Jini specification.
This file is Copyright ©Jan Newmarch
(http://jan.newmarch.name)
jan@newmarch.name