2 * Copyright (C) 2003 <a href="http://www.lohndirekt.de/">lohndirekt.de</a>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 package de
.lohndirekt
.print
;
21 import java
.lang
.reflect
.Constructor
;
24 import javax
.print
.attribute
.AttributeSet
;
25 import javax
.print
.attribute
.HashAttributeSet
;
26 import javax
.print
.attribute
.standard
.RequestingUserName
;
28 import de
.lohndirekt
.print
.attribute
.auth
.RequestingUserPassword
;
29 import de
.lohndirekt
.print
.attribute
.ipp
.printerdesc
.supported
.OperationsSupported
;
35 public final class IppRequestFactory
{
37 final static String IPP_REQUEST_IMPL_KEY
= "de.lohndirekt.print.IppRequest.Impl";
39 final static IppRequest
createIppRequest(URI uri
,
40 OperationsSupported operation
, RequestingUserName user
,
41 RequestingUserPassword passwd
) {
42 String requestClassName
= System
.getProperty(IPP_REQUEST_IMPL_KEY
);
43 IppRequest request
= null;
44 if (requestClassName
== null) {
45 request
= new IppRequestCupsImpl(uri
, operation
);
49 clazz
= Class
.forName(requestClassName
);
50 } catch (ClassNotFoundException e
) {
51 throw new IllegalArgumentException("Class " + requestClassName
52 + " does not exist.");
56 Constructor constructor
= clazz
57 .getDeclaredConstructor(new Class
[] { URI
.class,
58 OperationsSupported
.class });
59 request
= (IppRequest
) constructor
.newInstance(new Object
[] {
61 } catch (Exception e
) {
62 throw new RuntimeException(e
);
65 if (user
!= null && passwd
!= null) {
66 AttributeSet set
= new HashAttributeSet();
69 request
.addOperationAttributes(set
);