Presentation is loading. Please wait.

Presentation is loading. Please wait.

Session #, Session Title1 Print APIs for Jini Connection Technology Robert Herriot Xerox Alan Kaminsky Xerox.

Similar presentations


Presentation on theme: "Session #, Session Title1 Print APIs for Jini Connection Technology Robert Herriot Xerox Alan Kaminsky Xerox."— Presentation transcript:

1 Session #, Session Title1 Print APIs for Jini Connection Technology Robert Herriot Xerox Alan Kaminsky Xerox

2 Session #, Session Title2 Goals of Print API Allow client software to –find Printers with particular features –submit Print Jobs to a Printer –make use of a Printers features, e.g. copies (multiple copies of a document) sides (one-sided or two-sided printing) finishing (stapling, binding, drilling, folding) –query Printer and Job characteristics –cancel a Print Job

3 Session #, Session Title3 Source of Print Model for Print APIs Print APIs for Jini technology (Jini Print APIs) are based on IPP –a.k.a. Internet Printing Protocol IPP is an industry standard –IETF RFC 2565: encoding and transport –IETF RFC 2566: print model Many IPP implementations –more than 25 printer and system vendors

4 Session #, Session Title4 IPP Model output device or proxy Printerclient IPP over network

5 Session #, Session Title5 IPP model in the context of Jini technology output device or proxy Printer client IPP or other protocol Print Service Jini look up service Print Service Find Print Service

6 Session #, Session Title6 IPP Concepts: Operations IPP Operations perform the basic tasks –Examples Create-Job Send-Document Send-URI –printer fetches print data from a URI Cancel-Job Get-Job-Attributes Get-Printer-Attributes Get-Jobs (not in current API)

7 Session #, Session Title7 IPP Concepts: Objects Three object classes –Printer the software that provides the Print Service –Job what the Create-Job operation creates –Subscription for notification not yet an RFC

8 Session #, Session Title8 IPP Concepts: Attributes IPP Attributes –act as parameters to operations, e.g. copies=4, sides=two-sided-long-edge –indicate capabilities of a Printer sides-supported= {one-sided, two-sided-long-edge} –describe Printer printer-state=idle –describe Job job-state=completed

9 Session #, Session Title9 IPP Encoding & Transport RFC 2565 specifies –a binary encoding MIME media type is application/ipp –a transport HTTP using the POST method Model allows for other encodings and transports, e.g. –XML –RMI

10 Session #, Session Title10 Print Services based on Java Technology In packages under javax.print –talk earlier today at JavaOne Common infrastructure for printing in –net.jini.print –java.awt.print Classes or concepts borrowed from Jini Print API work

11 Session #, Session Title11 Use of Color in this Talk Color is used: –specification of an API: DocAttributeSet getAttributes() –code fragment: new AttributeEntry(Sides) { Copies(4), Sides.ONE_SIDED } –for a class name: PrintService

12 Session #, Session Title12 Jini Print API Overview of Topics Infrastructure –Attributes, AttributeSets and DocFlavors –Print Data with Docs and MultiDocs Printer Look-up –PrintService Job Submission –PrintRequest –PrintJob Exceptions and Events

13 Session #, Session Title13 ServiceRegistrar JLUS = // Obtain a Jini Lookup // Service (JLUS) proxy Class[] cl = {PrintService.class}; ServiceTemplate tm = new ServiceTemplate(null,cl,null); PrintService svc =(PrintService) JLUS.lookup (tm); if (svc != null){ DocPrintRequest req = svc.createDocPrintRequest(); Doc doc = new StringDoc ("Hello, world!", null); req.setDoc(doc); HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet(new Copies(10)); as.add(Sides.TWO_SIDED_LONG_EDGE); req.setAttributes(as); req.print(); } Sample Code for a Client to Print

14 Session #, Session Title14 Infrastructure: Attributes Same concept as IPP Attributes –Examples IPP copies is Java programming language Class (Java Class) Copies IPP sides is Java Class Sides IPP printer-state is Java Class PrinterState –Exception IPP document-format is Class DocFlavor –DocFlavor is not an Attribute

15 Session #, Session Title15 javax.print.attribute.standard Class Copies (hierarchy) Class Copies Class IntegerSyntax Interface PrintJobAttribute Interface PrintRequestAttribute Interface Attribute Class Object Interface Serializable Interface Cloneable data type attribute name can be member of PrintRequest can be member of PrintJob is an attribute

16 Session #, Session Title16 javax.print.attribute Interface PrintJobAttribute Tags the attribute –attribute can be a member of a PrintJob provides type safety for setting values Other similar classes –Naming pattern: ClassName Attribute DocAttribute PrintRequestAttribute PrintServiceAttribute

17 Session #, Session Title17 javax.print.attribute Class IntegerSyntax For an Attribute with an integer value Provides access to –integer value int getValue() String toString() Provides service –equals boolean equals(Object) –hash code int hashcode()

18 Session #, Session Title18 javax.print.attribute.standard Class Copies Provides access to –attribute name Class getCategory() –i.e. Copies.class String getName() –i.e. "Copies" –integer value (inherited from IntegerSyntax) int getValue() –e.g. 10 String toString() –e.g. "10"

19 Session #, Session Title19 javax.print.attribute.standard Class PrinterState (hierarchy) Class PrinterState Class EnumSyntax Interface PrintServiceAttribute Interface Attribute Class Object Interface Serializable Interface Cloneable data type attribute name can be member of PrintService is an attribute

20 Session #, Session Title20 javax.print.attribute.standard Class PrinterState Provides access to –attribute name Class getCategory() –i.e. PrinterState.class String getName() –i.e. "PrinterState" –value (inherited from EnumSyntax) String toString() –e.g. "idle", "stopped or "processing" predefined constants –e.g. PrinterState.IDLE, PrinterState.STOPPED or PrinterState.PROCESSING X

21 Session #, Session Title21 javax.print.attribute Interface AttributeSet Extends Interface java.util.Map Is a set of attributes with distinct names –e.g. { Copies(4), Sides.ONE_SIDED } NOT {Sides.ONE_SIDED,Sides.TWO_SIDED_LONG_EDGE} Has subinterfaces –Naming pattern: ClassName AttributeSet DocAttributeSet PrintJobAttributeSet PrintRequestAttributeSet PrintServiceAttributeSet

22 Session #, Session Title22 javax.print.attribute Interface AttributeSet (services) Provides services –methods of java.util.Map –special get method Attribute get(Class); –e.g. get(Sides) -> Sides.ONE_SIDED –special variant of put method boolean add(Attribute); –e.g. add(Sides.ONE_SIDED) is equivalent to Sides s = Sides.ONE_SIDED; put(s.getCategory(),s); Note: s.getCategory() == Sides.class

23 Session #, Session Title23 javax.print.attribute Class HashAttributeSet Extends Class java.util.HashMap Implements Interface AttributeSet Has subclasses –Naming pattern: Hash ClassName AttributeSet HashDocAttributeSet HashPrintJobAttributeSet HashPrintRequestAttributeSet HashPrintServiceAttributeSet

24 Session #, Session Title24 javax.print.data Class DocFlavor Specifies –the MIME media type of a Document, e.g. "text/plain" "application/PostScript" "image/jpeg" –the class of Print Data object, e.g. char[] byte[] java.lang.String java.io.InputStream java.awt.print.Printable

25 Session #, Session Title25 Infrastructure: Print Data E.g., if the Print Data is a PostScript File –Class DocFlavor specifies application/PostScript (as MIME media type) java.io. InputStream ( as Print Data class) Two Interfaces for Print Data –Doc wraps the Print Data implemented by a client application –MultiDoc contains multiple Docs implemented by a client application

26 Session #, Session Title26 net.jini.print.data Interface Doc Extends Interface javax.print.data.Doc –methods throw RemoteException methods in javax.print.data throw IOException Provides access to –Associated attributes DocAttributeSet getAttributes() –Continued on next slide

27 Session #, Session Title27 net.jini.print.data Interface Doc (more access) Provides access to –Its DocFlavor, DocFlavor getFlavor() returns e.g. DocFlavor.INPUT_STREAM.POSTSCRIPT –Object containing Print Data Object getPrintData() returns e.g. java.io.InputStream object –Reader or InputStream for Print Data Reader getReaderForText() InputStream getStreamForBytes()

28 Session #, Session Title28 net.jini.print.data Interface MultiDoc Extends Interface javax.print.data.MultiDoc –methods throw RemoteException methods in javax.print.data throw IOException Contains data of multiple documents –Acts like a linked list of Doc elements Provides access to –Doc of list element: it is accessible with Doc getDoc() –Remaining MultiDoc: it is accessible with MultiDoc next()

29 Session #, Session Title29 Jini Technology Look-up Service (review) Client specifies any of –java.lang.Class[ ], e.g. (Class[]){ PrintService } –net.jini.core.entry.Entry[ ], e.g. (Entry[]){ net.jini.lookup.entry.Location (floor 2,room 12, bldg 23) } Look-up Service returns a matching service Object, e.g. PrintService MultiDocPrintService

30 Session #, Session Title30 net.jini.print.lookup Class AttributeEntry Extends net.jini.entry.AbstractEntry –which implements Entry Matches Entry in Look-up service –any Attribute new AttributeEntry() –any Attribute of a specified class, e.g. new AttributeEntry(Sides) –any Attribute with specified value (& class), e.g. new AttributeEntry(Sides.ONE_SIDED)

31 Session #, Session Title31 net.jini.print.lookup Class FlavorEntry Extends net.jini.entry.AbstractEntry –which implements Entry Matches Entry in Look-up service –any DocFlavor new FlavorEntry() –any DocFlavor with specified value, e.g. new FlavorEntry(DocFlavor.BYTE_ARRAY.JPEG)

32 Session #, Session Title32 net.jini.print.service Interface PrintService Gives access to the Printer –Provides access to attributes that relate to Printer information Printer capabilities for Job Creation –Provides services of Events Job Creation

33 Session #, Session Title33 net.jini.print.service Interface PrintService (info) Provides access to Printer Information –attribute values of all Printer attributes PrintServiceAttributeSet getAttributes() returns e.g. { PrinterState.PROCESSING, new PrinterName("speedy",locale), new QueuedJobCount(8),… }

34 Session #, Session Title34 net.jini.print.service Interface PrintService (Job Creation) Provides access to Job Creation info –attribute names supported, Class[] getSupportedAttributeCategories(… ) returns e.g. (Class[]){ Sides, Copies, … } –attribute values supported Object getSupportedAttributeValues(Class,…) returns e.g. (with parameters (Sides, … ) ) (Sides[]) {Sides.ONE_SIDED,Sides.TWO_SIDED_LONG_EDGE} DocFlavors[] getSupportedDocFlavors()

35 Session #, Session Title35 net.jini.print.service Interface PrintService (Job Creation) Provides access to Job Creation info –default attribute values Object getDefaultAttributeValue(Class) returns e.g. (with parameter (Sides) ) Sides.TWO_SIDED_LONG_EDGE

36 Session #, Session Title36 net.jini.print.service Interface PrintService (services) Provides services –adds an event listener for changes in PrintService attribute values –creates a PrintRequest DocPrintRequest CreateDocPrintRequest()

37 Session #, Session Title37 net.jini.print.service Interface LocalizedPrintService Extends PrintService –Exists if a PrintService provides localized strings Provides access to –supported locales Locale[] getSupportedLocales() Provides services –localizes attribute names String localize(Class,Locale) –localizes attribute and DocFlavor values String localize(Attribute,Locale) String localize(DocFlavor,Locale)

38 Session #, Session Title38 net.jini.print.service Interface MultiDocPrintService Extends PrintService –Exists if a PrintService allows jobs to contain more than one Document Provides services –creates a PrintRequest MultiDocPrintRequest CreateMultiDocPrintRequest()

39 Session #, Session Title39 Steps in Job Submission (1) With PrintService –Client creates PrintRequest e.g. DocPrintRequest req = svc.createDocPrintRequest(); –Printer doesnt remember PrintRequests

40 Session #, Session Title40 Steps in Job Submission (2) With a PrintRequest, a client –Adds Attributes and Docs (i.e. Print Data) e.g. req.setDoc(doc); HashPrintRequestAttributeSet as = new HashPrintRequestAttributeSet(new Copies(10)); as.add(Sides.TWO_SIDED_LONG_EDGE); req.setAttributes(as); –Then creates a PrintJob with the print method e.g. req.print(); –Can track progress of a PrintJob

41 Session #, Session Title41 net.jini.print.job Interface PrintRequest Acts as a container for –Attributes –Docs (i.e. Print Data) Has two subinterfaces for setting Docs –DocPrintRequest: void SetDoc(Doc) –MultiDocPrintRequest: void SetMultiDoc(MultiDoc)

42 Session #, Session Title42 net.jini.print.job Interface PrintRequest (services) Provides Services –Sets Attributes requested for the Job void SetAttributes(PrintRequestAttributeSet) –Adds event listeners for changes in PrintJob attribute values –Submits PrintRequest to Printer void Print() PrintJobAndLease Print(long leaseDuration)

43 Session #, Session Title43 net.jini.print.job Class PrintJobAndLease Extends Object Contains two objects –net.jini.core.lease.Lease client must hold a lease on the PrintJob –PrintJob

44 Session #, Session Title44 net.jini.print.job Interface PrintJob Represents a Job on the Printer –i.e. the Printer has knowledge of it. Provides access to –Attributes in the PrintJob PrintJobAttributeSet getAttributes() Provides services –Adds event listener for changes in PrintJob attribute values same method and effect as for PrintRequest

45 Session #, Session Title45 net.jini.print.job Interface CancelablePrintJob Extends PrintJob –Exists if a PrintService allows a client to cancel a PrintJob Allows client to cancel a PrintJob void cancel()

46 Session #, Session Title46 javax.print.exception Class PrintException Extends java.lang.Exception 3 subclasses className Exception net.jini.print.service.PrintServiceException net.jini.print.job.PrintRequestException net.jini.print.job.PrintJobException Interfaces for additional information AttributeException DocFlavorException NestedException

47 Session #, Session Title47 net.jini.print.service Class PrintServiceException Is thrown during PrintRequest creation by –Interface PrintService for DocPrintRequest CreateDocPrintRequest() –Interface MultiDocPrintService for MultiDocPrintRequest CreateMultiDocPrintRequest() Provides access to –PrintService object causing exception PrintService getPrintService()

48 Session #, Session Title48 net.jini.print.job Class PrintRequestException Is thrown during PrintJob creation by –Interface PrintRequest void Print() PrintJobAndLease Print(long leaseDuration) Provides access to –PrintRequest object causing exception PrintRequest getPrintRequest() –Unsupported attributes or values (optional) via javax.print.exception.AttributeException –Class[] getUnsupportdAttributes() –Attribute[] getUnsupportdValues()

49 Session #, Session Title49 net.jini.print.job Class PrintJobException Is thrown by –Interface CancelablePrintJob void cancel() Provides access to –PrintJob object causing exception PrintJob getPrintJob() –NestedException (optional) via javax.print.exception.NestedException –Throwable getNestedException()

50 Session #, Session Title50 Events can add event listeners to: –PrintService –PrintRequest –PrintJob can listen for change of –any attribute –any specified attribute –any attribute achieving a specified value

51 Session #, Session Title51 net.jini.print.event Class PrintEvent Extends Jini technology RemoteEvent –net.jini.core.remote.RemoteEvent Provides access to events PrintService PrintService getPrintService() Has subclasses: –PrintServiceEvent –PrintJobEvent –PrintDataEvent –PrintJobFinishedEvent

52 Session #, Session Title52 net.jini.print.service Class PrintServiceEvent Sent when attribute value changes in –PrintService Provides access to –Attributes that changed PrintServiceAttributeSet getAttributes() –Events PrintService in superclass PrintEvent (just discussed) PrintService getPrintService()

53 Session #, Session Title53 net.jini.print.job Class PrintJobEvent Sent when attribute value changes in –PrintJob Provides access to –Attributes that changed in PrintJob PrintJobAttributeSet getAttributes() –PrintJob in which attributes changed PrintJob getPrintJob()

54 Session #, Session Title54 net.jini.print.job Class PrintDataEvent Sent when Printer has finished obtaining a unit (Doc) of Print Data Provides access to –Whether the Printer was successful boolean succeeded() –Exception if the Printer failed Throwable getException() –PrintJob intended to receive the print data PrintJob getPrintJob()

55 Session #, Session Title55 net.jini.print.job Class PrintJobFinishedEvent Sent when Printer has finished printing a PrintJob Provides access to –JobState of the PrintJob when it finished JobState getFinalState() returns e.g. JobState.COMPLETED, or JobState.CANCELED, or JobState.ABORTED –PrintJob that finished PrintJob getPrintJob()

56 Session #, Session Title56 Documentation for Jini Print API Web page for Jini Printing Working Group –http://developer.jini.org/exchange/users/jpgwg Latest document is (with above prefix) : –JiniPrintService/standards/ JiniPrintServiceApi20000523.zip


Download ppt "Session #, Session Title1 Print APIs for Jini Connection Technology Robert Herriot Xerox Alan Kaminsky Xerox."

Similar presentations


Ads by Google