O'Reilly logo

Java RMI by William Grosso

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Value Objects

There are three value objects: AttributeSet, Path, and ContextList. As I mentioned earlier, one of the reasons for implementing our own container objects is to preserve flexibility. However, these objects—especially AttributeSet—also have other functionalities.

AttributeSet

An instance of AttributeSet represents a set of name-value pairs which can be queried. That is, when a client calls:

public Remote[] list(Path path, String name, AttributeSet attributes) throws
    RemoteException, NamingException;

the server is supposed to do the following:

  • Find the context associated with path.

  • Find all the objects that were bound into the path context as servers (not as contexts) using name. There can be more than one, as long as the attributes are different.

  • From those objects, pull out the ones that match attributes. By “match,” I mean, “It has the same values for all individual name-value pairs set in attributes. But the match may have additional name-value pairs that are not defined in attributes.”

In order to do this, we’ve made AttributeSet into a fairly sophisticated object with four main features:

  • An instance of AttributeSet stores name-value pairs.

  • AttributeSet implements Serializable.

  • AttributeSets are comparable and can be sorted.

  • An instance of AttributeSet can tell whether it is a superset of another instance of AttributeSet in a reasonably efficient way.

The first two features are easy to implement. The last two are more difficult, and the implementation is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required