1 /*
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
34 import javax.print.attribute.PrintRequestAttributeSet;
35
36 import sun.awt.AppContext;
37
38 /**
39 * A {@code StreamPrintServiceFactory} is the factory for
40 * {@link StreamPrintService} instances, which can print to an output stream in
41 * a particular document format described as a mime type. A typical output
42 * document format may be Postscript(TM).
43 * <p>
44 * This class is implemented by a service and located by the implementation
45 * using the {@link ServiceLoader} facility.
46 * <p>
47 * Applications locate instances of this class by calling the
48 * {@link #lookupStreamPrintServiceFactories(DocFlavor, String)} method.
49 * <p>
50 * Applications can use a {@code StreamPrintService} obtained from a factory in
51 * place of a {@code PrintService} which represents a physical printer device.
52 */
53 public abstract class StreamPrintServiceFactory {
54
55 /**
56 * Contains a list of factories.
57 */
58 static class Services {
59
60 /**
61 * The list of factories which will be stored per appcontext.
62 */
63 private ArrayList<StreamPrintServiceFactory> listOfFactories = null;
64 }
65
66 /**
67 * Returns the services from the current appcontext.
68 *
69 * @return the services
70 */
71 private static Services getServices() {
72 Services services =
73 (Services)AppContext.getAppContext().get(Services.class);
|
1 /*
2 * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
34 import javax.print.attribute.PrintRequestAttributeSet;
35
36 import sun.awt.AppContext;
37
38 /**
39 * A {@code StreamPrintServiceFactory} is the factory for
40 * {@link StreamPrintService} instances, which can print to an output stream in
41 * a particular document format described as a mime type. A typical output
42 * document format may be Postscript(TM).
43 * <p>
44 * This class is implemented by a service and located by the implementation
45 * using the {@link ServiceLoader} facility.
46 * <p>
47 * Applications locate instances of this class by calling the
48 * {@link #lookupStreamPrintServiceFactories(DocFlavor, String)} method.
49 * <p>
50 * Applications can use a {@code StreamPrintService} obtained from a factory in
51 * place of a {@code PrintService} which represents a physical printer device.
52 */
53 public abstract class StreamPrintServiceFactory {
54
55 /**
56 * Constructor for subclasses to call.
57 */
58 public StreamPrintServiceFactory() {}
59
60 /**
61 * Contains a list of factories.
62 */
63 static class Services {
64
65 /**
66 * The list of factories which will be stored per appcontext.
67 */
68 private ArrayList<StreamPrintServiceFactory> listOfFactories = null;
69 }
70
71 /**
72 * Returns the services from the current appcontext.
73 *
74 * @return the services
75 */
76 private static Services getServices() {
77 Services services =
78 (Services)AppContext.getAppContext().get(Services.class);
|