Jini Print Service Tutorial -- Lesson 8. Service Registration

## Jini Print Service Tutorial

Introduction Lesson 1. The Very Basics Lesson 2. Print Data Attributes Lesson 3. Lookup Lesson 4. Print Job Status | Lesson 5. Print Job Events Lesson 6. File Print Jobs Lesson 7. URL Print Jobs Lesson 8. Service Registration

## Lesson 8. Service Registration

Turning from the print client's point of view to the print service provider's point of view, below is an example code fragment showing how a Jini Print Service instance might set up its service registration (class net.jini.core.lookup.ServiceItem) to go into the Jini Lookup Service (JLUS). The general scheme is described in package net.jini.print.lookup. This code shows how to realize the lookup scheme for a particular printer, the one (hypothetically) located in U.S. President Bill Clinton's office, which happens to be a (fictitious) PaperEater 440 printer made by the (imaginary) Papyrophagus Corporation.

The service registration comprises three things: the service ID, the service proxy object, and the service attributes. Line 47 obtains a reference to the Jini Print Service instance's service ID. According to the rules of good Jini citizenship, the print service got the service ID from some JLUS the first time the print service ever registered, and the print service saved its assigned service ID in persistent storage for use in all subsequent registrations. (The details are not shown here.)

Line 48 obtains a reference to the Jini Print Service instance's service proxy object. (Again, the details are not shown here.) The service proxy object mandatorily implements interface PrintService. The service proxy object may also implement other PrintService subinterfaces if the printer supports the corresponding capabilities. For this example, the optional capabilities are not supported.

Line 49 creates an array of service attributes (which are subclasses of class net.jini.core.entry.Entry) following the requirements in package net.jini.print.lookup. There are three categories of service attributes: general attributes, supported doc flavors, and supported printing attributes.

Lines 51-92 set up the general attributes. These include a mandatory PrinterDescriptionEntry with the following characteristics:

- The printer's name is the Presidential Printer.
- The printer's location is the Oval Office.
- The printer's information says not to use this printer unless you're Bill Clinton.
- The URL from which to obtain more information about this particular printer is `http://billsprinter`.
- The printer make and model is Papyrophagus PaperEater 440.
- The URL from which to obtain more information about this kind of printer is `http://www.papyrophagus.com/support/papereater440/`.
- This printer supports color.
- This printer will attempt to override job instructions in the print data with the printing attribute settings in the Print Request.
- This printer does 8 pages per minute black and white.
- This printer does 4 pages per minute color.

The general attributes also include the print service's address, location, name, service info, and comment stored in the appropriate standard Jini Entry classes from package net.jini.lookup.entry; these service attributes are optional.

Lines 94-109 set up the supported doc flavors. This Jini Print Service instance happens to support plain text, HTML, and PostScript documents. It can obtain them from an input stream and from a URL. It supports plain text and HTML encoded in the default, US-ASCII, and UTF-8 character sets. This Jini Print Service instance also supports printing plain text Unicode strings and renderable images. Support for plain text from an input stream and for renderable images is mandatory; this printer additionally supports the HTML and PostScript MIME types and the String and URL print data representation classes. For each supported doc flavor, one instance of class FlavorEntry wrapping the doc flavor goes into the service registration.

Lines 111-135 set up the supported printing attributes, each wrapped in an AttributeEntry (or a MediaEntry for a supported Media attribute). This Jini Print Service instance happens to support the following printing attributes:

- Printing documents in monochrome or color (lines 111-112).
- Uncompressed print data (line 113).
- Any number of copies of a job (line 114).
- Only one kind of media: 8.5 x 11 inch white opaque 24-pound (90 g/m2) nonrecycled bond sheets with no holes, preprinting, tabs, back coating, or front coating (lines 115-131).
- Portrait or landscape orientation (lines 132-133).
- Printing at 600 x 600 dots per inch (lines 134-135).

Finally, lines 136-137 bundle the previously set up service ID, service proxy object, and service attributes into a service item (class net.jini.core.lookup.ServiceItem) that can be passed to a JLUS's `register()` method.

DRAFT STANDARD VERSION 1.0 (23-MAY-2000)