1 / 56

Print APIs for Jini™ Connection Technology

Print APIs for Jini™ Connection Technology. Robert Herriot Xerox. Alan Kaminsky Xerox. Goals of Print API. Allow client software to find Printers with particular features submit Print Jobs to a Printer make use of a Printer’s features, e.g. copies (multiple copies of a document)

maryscott
Download Presentation

Print APIs for Jini™ Connection Technology

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Print APIs for Jini™ Connection Technology Robert Herriot Xerox Alan Kaminsky Xerox Session #, Session Title

  2. Goals of Print API • Allow client software to • find Printers with particular features • submit Print Jobs to a Printer • make use of a Printer’s 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 Session #, Session Title

  3. Source of Print Modelfor 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 Session #, Session Title

  4. IPP Model outputdevice or proxy client Printer IPP over network Session #, Session Title

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

  6. 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) Session #, Session Title

  7. 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 Session #, Session Title

  8. 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 Session #, Session Title

  9. 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 Session #, Session Title

  10. 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 Session #, Session Title

  11. 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 Session #, Session Title

  12. Jini Print APIOverview of Topics • Infrastructure • Attributes, AttributeSets and DocFlavors • Print Data with Docs and MultiDocs • Printer Look-up • PrintService • Job Submission • PrintRequest • PrintJob • Exceptions and Events Session #, Session Title

  13. Sample Code for aClient to Print 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(); } Session #, Session Title

  14. 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 Session #, Session Title

  15. javax.print.attribute.standardClass Copies (hierarchy) ClassCopies attribute name ClassObject ClassIntegerSyntax InterfaceSerializable data type InterfaceCloneable InterfacePrintRequestAttribute InterfaceAttribute can be member of PrintRequest is an attribute InterfacePrintJobAttribute InterfaceAttribute can be member of PrintJob Session #, Session Title

  16. javax.print.attributeInterface PrintJobAttribute • Tags the attribute • attribute can be a member of a PrintJob • provides type safety for setting values • Other similar classes • Naming pattern: ClassNameAttribute • DocAttribute • PrintRequestAttribute • PrintServiceAttribute Session #, Session Title

  17. javax.print.attributeClass 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() Session #, Session Title

  18. javax.print.attribute.standardClass 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" Session #, Session Title

  19. javax.print.attribute.standardClass PrinterState (hierarchy) ClassPrinterState attribute name ClassObject ClassEnumSyntax InterfaceSerializable data type InterfaceCloneable InterfacePrintServiceAttribute InterfaceAttribute can be member of PrintService is an attribute Session #, Session Title

  20. javax.print.attribute.standardClass 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.PROCESSINGX Session #, Session Title

  21. javax.print.attributeInterface 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: ClassNameAttributeSet • DocAttributeSet • PrintJobAttributeSet • PrintRequestAttributeSet • PrintServiceAttributeSet Session #, Session Title

  22. javax.print.attributeInterface 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)isequivalent toSides s = Sides.ONE_SIDED; put(s.getCategory(),s);Note: s.getCategory() == Sides.class Session #, Session Title

  23. javax.print.attributeClass HashAttributeSet • Extends Class java.util.HashMap • Implements Interface AttributeSet • Has subclasses • Naming pattern: HashClassNameAttributeSet • HashDocAttributeSet • HashPrintJobAttributeSet • HashPrintRequestAttributeSet • HashPrintServiceAttributeSet Session #, Session Title

  24. javax.print.dataClass 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 Session #, Session Title

  25. 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 Session #, Session Title

  26. net.jini.print.dataInterface 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 Session #, Session Title

  27. net.jini.print.dataInterface 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.InputStreamobject • Reader or InputStream for Print Data • Reader getReaderForText() • InputStream getStreamForBytes() Session #, Session Title

  28. net.jini.print.dataInterface 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() Session #, Session Title

  29. 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 Session #, Session Title

  30. net.jini.print.lookupClass 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) Session #, Session Title

  31. net.jini.print.lookupClass 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) Session #, Session Title

  32. net.jini.print.serviceInterface 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 Session #, Session Title

  33. net.jini.print.serviceInterface 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),… } Session #, Session Title

  34. net.jini.print.serviceInterface 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() Session #, Session Title

  35. net.jini.print.serviceInterface 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 Session #, Session Title

  36. net.jini.print.serviceInterface PrintService (services) • Provides services • adds an event listener • for changes in PrintService attribute values • creates a PrintRequest • DocPrintRequest CreateDocPrintRequest() Session #, Session Title

  37. net.jini.print.serviceInterface 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) Session #, Session Title

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

  39. Steps in Job Submission (1) • With PrintService • Client creates PrintRequest • e.g.DocPrintRequest req = svc.createDocPrintRequest(); • Printer doesn’t remember PrintRequests Session #, Session Title

  40. Steps in Job Submission (2) • With a PrintRequest, a client • Adds Attributes and Doc’s (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 Session #, Session Title

  41. net.jini.print.jobInterface PrintRequest • Acts as a container for • Attributes • Doc’s (i.e. Print Data) • Has two subinterfaces for setting Doc’s • DocPrintRequest: • void SetDoc(Doc) • MultiDocPrintRequest: • void SetMultiDoc(MultiDoc) Session #, Session Title

  42. net.jini.print.jobInterface 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) Session #, Session Title

  43. net.jini.print.jobClass PrintJobAndLease • Extends Object • Contains two objects • net.jini.core.lease.Lease • client must hold a lease on the PrintJob • PrintJob Session #, Session Title

  44. 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 Session #, Session Title

  45. 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() Session #, Session Title

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

  47. 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() Session #, Session Title

  48. 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() Session #, Session Title

  49. 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() Session #, Session Title

  50. 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 Session #, Session Title

More Related