LS.4. Generic Attribute Classes

We will now describe some attribute classes that are generic to many or all services and the JavaBeans components that are associated with each. Unless otherwise stated, all classes defined here live in the net.jini.lookup.entry package. The definitions assume the following classes to have been imported:

java.io.Serializable 
net.jini.entry.AbstractEntry 

LS.4.1. Indicating User Modifiability

To indicate that certain entry classes should only be modified by the service that registered itself with instances of these entry classes, we annotate them with the ServiceControlled interface.

public interface ServiceControlled {
} 

Authors of administrative tools that modify fields of attribute objects at the lookup service should not permit users to either modify any fields or add any new instances of objects that implement this interface.

LS.4.2. Basic Service Information

The ServiceInfo attribute class provides some basic information about a service.

public class ServiceInfo extends AbstractEntry 
    implements ServiceControlled 
{
    public ServiceInfo() {...} 
    public ServiceInfo(String name, String manufacturer, 
                       String vendor, String version, 
                       String model, String serialNumber) {...} 
    public String name; 
    public String manufacturer; 
    public String vendor; 
    public String version; 
    public String model; 
    public String serialNumber; 
} 

public class ServiceInfoBean 
    implements EntryBean, Serializable 
{
    public String getName() {...} 
    public void setName(String s) {...} 
    public String getManufacturer() {...} 
    public void setManufacturer(String s) {...} 
    public String getVendor() {...} 
    public void setVendor(String s) {...} 
    public String getVersion() {...} 
    public void setVersion(String s) {...} 
    public String getModel() {...} 
    public void setModel(String s) {...} 
    public String getSerialNumber() {...} 
    public void setSerialNumber(String s) {...} 
} 

Each service should register itself with only one instance of this class. The fields of the ServiceInfo class have the following meanings:

  • The name field contains a specific product name, such as "Ultra 30" (for a particular workstation) or "JavaSafe" (for a specific configuration management service). This string should not include the name of the manufacturer or vendor.

  • The manufacturer field provides the name of the company that “built” this service. This might be a hardware manufacturer or a software authoring company.

  • The vendor field contains the name of the company that sells the software or hardware that provides this service. This may be the same name as is in the manufacturer field, or it could be the name of a reseller. This field exists so that in cases in which resellers relabel products built by other companies, users will be able to search based on either name.

  • The version field provides information about the version of this service. It is a free-form field, though we expect that service implementors will follow normal version-naming conventions in using it.

  • The model field contains the specific model name or number of the product, if any.

  • The serialNumber field provides the serial number of this instance of the service, if any.

LS.4.3. More Specific Information

The ServiceType class allows an author of a service to deliver information that is specific to a particular instance of a service, rather than to services in general.

public class ServiceType extends AbstractEntry 
        implements ServiceControlled 
{
    public ServiceType() {...} 
    public java.awt.Image getIcon(int iconKind) {...} 
    public String getDisplayName() {...} 
    public String getShortDescription() {...} 
} 

Each service may register itself with multiple instances of this class, usually with one instance for each type of service interface it implements.

This class has no public fields and, as a result, has no associated JavaBeans component.

The getIcon method returns an icon of the appropriate kind for the service; it works in the same way as the getIcon method in the java.beans.BeanInfo interface, with the value of iconKind being taken from the possibilities defined in that interface. The getDisplayName and getShortDescription methods return a localized human-readable name and description for the service, in the same manner as their counterparts in the java.beans.FeatureDescriptor class. Each of these methods returns null if no information of the appropriate kind is defined.

In case the distinction between the information this class provides and that provided by a JavaBeans component’s meta-information is unclear, the class ServiceType is meant to be used in the lookup service as one of the entry classes with which a service registers itself, and so it can be customized on a per-service basis. By contrast, the FeatureDescriptor and BeanInfo objects for all EntryBean classes provide only generic information about those classes and none about specific instances of those classes.

LS.4.4. Naming a Service

People like to associate names with particular services and may do so using the Name class.

public class Name extends AbstractEntry {
    public Name() {...} 
    public Name(String name) {...} 

    public String name; 
} 

public class NameBean implements EntryBean, Serializable {
    public String getName() {...} 
    public void setName(String s) {...} 
} 

Services may register themselves with multiple instances of this class, and either services or administrators may add, modify, or remove instances of this class from the attribute set under which a service is registered.

The name field provides a short name for a particular instance of a service (for example, “Bob's toaster”).

LS.4.5. Adding a Comment to a Service

In cases in which some kind of comment is appropriate for a service (for example, “this toaster tends to burn bagels”), the Comment class provides an appropriate facility.

public class Comment extends AbstractEntry {
    public Comment() {...} 
    public Comment(String comment) {...} 

    public String comment; 
} 

public class CommentBean implements EntryBean, Serializable {
    public String getComment() {...} 
    public void setComment(String s) {...} 
} 

A service may have more than one comment associated with it, and comments may be added, removed, or edited by either a service itself, administrators, or users.

LS.4.6. Physical Location

The Location and Address classes provide information about the physical location of a particular service.

Since many services have no physical location, some have one, and a few may have more than one, it might make sense for a service to register itself with zero or more instances of either of these classes, depending on its nature.

The Location class is intended to provide information about the physical location of a service in a single building or on a small, unified campus. The Address class provides more information and may be appropriate for use with the Location class in a larger, more geographically distributed organization.

public class Location extends AbstractEntry {
    public Location() {...} 
    public Location(String floor, String room, 
                    String building) {...} 

    public String floor; 
    public String room; 
    public String building; 
} 

public class LocationBean implements EntryBean, Serializable {
    public String getFloor() {...} 
    public void setFloor(String s) {...} 
    public String getRoom() {...} 
    public void setRoom(String s) {...} 
    public String getBuilding() {...} 
    public void setBuilding(String s) {...} 
} 

public class Address extends AbstractEntry {
    public Address() {...} 
    public Address(String street, String organization, 
                   String organizationalUnit, String locality, 
                   String stateOrProvince, String postalCode, 
                   String country) {...} 

    public String street; 
    public String organization; 
    public String organizationalUnit; 
    public String locality; 
    public String stateOrProvince; 
    public String postalCode; 
    public String country; 
} 

public class AddressBean implements EntryBean, Serializable {
    public String getStreet() {...} 
    public void setStreet(String s) {...} 
    public String getOrganization() {...} 
    public void setOrganization(String s) {...} 
    public String getOrganizationalUnit() {...} 
    public void setOrganizationalUnit(String s) {...} 
    public String getLocality() {...} 
    public void setLocality(String s) {...} 
    public String getStateOrProvince() {...} 
    public void setStateOrProvince(String s) {...} 
    public String getPostalCode() {...} 
    public void setPostalCode(String s) {...} 
    public String getCountry() {...} 
    public void setCountry(String s) {...} 
} 

We believe the fields of these classes to be self-explanatory, with the possible exception of the locality field of the Address class, which would typically hold the name of a city.

LS.4.7. Status Information

Some attributes of a service may constitute long-lived status, such as an indication that a printer is out of paper. We provide a class, Status, that implementors can use as a base for providing status-related entry classes.

public abstract class Status extends AbstractEntry {
    protected Status() {...} 
    protected Status(StatusType severity) {...} 
    public StatusType severity; 
} 

public class StatusType implements Serializable {
    private final int type; 
    private StatusType(int t) { type = t; } 
    public static final StatusType ERROR =  new StatusType(1); 
    public static final StatusType WARNING = 
                                            new StatusType(2); 
    public static final StatusType NOTICE = new StatusType(3); 
    public static final StatusType NORMAL = new StatusType(4); 
} 

public abstract class StatusBean 
    implements EntryBean, Serializable 
{
    public StatusType getSeverity() {...} 
    public void setSeverity(StatusType i) {...} 
} 

We define a separate StatusType class to make it possible to write a property editor that will work with the StatusBean class (we do not currently provide a property editor implementation).

LS.4.8. Serialized Forms

Class serialVersionUID Serialized Fields
Address 2896136903322046578L all public fields
AddressBean 4491500432084550577L Address asoc
Comment 7138608904371928208L all public fields
CommentBean 5272583409036504625L Comment asoc
Location –3275276677967431315L all public fields
LocationBean –4182591284470292829L Location asoc
Name 2743215148071307201L all public fields
NameBean –6026791845102735793L Name asoc

Class serialVersionUID Serialized Fields
ServiceInfo –1116664185758541509L all public fields
ServiceInfoBean 8352546663361067804L ServiceInfo asoc
ServiceType –6443809721367395836L all public fields
Status –5193075846115040838L all public fields
StatusBean –1975539395914887503L Status asoc
StatusType –8268735508512712203L int type

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.35.122