Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
dec1dfd1
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
dec1dfd1
编写于
1月 20, 2014
作者:
S
simonis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8031134: PPC64: implement printing on AIX
Reviewed-by: prr
上级
27eaa89b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
158 addition
and
1 deletion
+158
-1
src/solaris/classes/sun/print/UnixPrintService.java
src/solaris/classes/sun/print/UnixPrintService.java
+78
-0
src/solaris/classes/sun/print/UnixPrintServiceLookup.java
src/solaris/classes/sun/print/UnixPrintServiceLookup.java
+80
-1
未找到文件。
src/solaris/classes/sun/print/UnixPrintService.java
浏览文件 @
dec1dfd1
...
@@ -28,6 +28,7 @@ package sun.print;
...
@@ -28,6 +28,7 @@ package sun.print;
import
java.io.File
;
import
java.io.File
;
import
java.net.URI
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
import
java.util.ArrayList
;
import
java.util.Locale
;
import
java.util.Locale
;
import
javax.print.DocFlavor
;
import
javax.print.DocFlavor
;
...
@@ -273,11 +274,58 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
...
@@ -273,11 +274,58 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
return
PrinterIsAcceptingJobs
.
NOT_ACCEPTING_JOBS
;
return
PrinterIsAcceptingJobs
.
NOT_ACCEPTING_JOBS
;
}
}
// Filter the list of possible AIX Printers and remove header lines
// and extra lines which have been added for remote printers.
// 'protected' because this method is also used from UnixPrintServiceLookup.
protected
static
String
[]
filterPrinterNamesAIX
(
String
[]
posPrinters
)
{
ArrayList
printers
=
new
ArrayList
();
String
[]
splitPart
;
for
(
int
i
=
0
;
i
<
posPrinters
.
length
;
i
++)
{
// Remove the header lines
if
(
posPrinters
[
i
].
startsWith
(
"---"
)
||
posPrinters
[
i
].
startsWith
(
"Queue"
)
||
posPrinters
[
i
].
equals
(
""
))
continue
;
// Check if there is a ":" in the end of the first colomn.
// This means that it is not a valid printer definition.
splitPart
=
posPrinters
[
i
].
split
(
" "
);
if
(
splitPart
.
length
>=
1
&&
!
splitPart
[
0
].
trim
().
endsWith
(
":"
))
{
printers
.
add
(
posPrinters
[
i
]);
}
}
return
(
String
[])
printers
.
toArray
(
new
String
[
printers
.
size
()]);
}
private
PrinterIsAcceptingJobs
getPrinterIsAcceptingJobsAIX
()
{
// On AIX there should not be a blank after '-a'.
String
command
=
"/usr/bin/lpstat -a"
+
printer
;
String
results
[]=
UnixPrintServiceLookup
.
execCmd
(
command
);
// Remove headers and bogus entries added by remote printers.
results
=
filterPrinterNamesAIX
(
results
);
if
(
results
!=
null
&&
results
.
length
>
0
)
{
for
(
int
i
=
0
;
i
<
results
.
length
;
i
++)
{
if
(
results
[
i
].
contains
(
"READY"
)
||
results
[
i
].
contains
(
"RUNNING"
))
{
return
PrinterIsAcceptingJobs
.
ACCEPTING_JOBS
;
}
}
}
return
PrinterIsAcceptingJobs
.
NOT_ACCEPTING_JOBS
;
}
private
PrinterIsAcceptingJobs
getPrinterIsAcceptingJobs
()
{
private
PrinterIsAcceptingJobs
getPrinterIsAcceptingJobs
()
{
if
(
UnixPrintServiceLookup
.
isSysV
())
{
if
(
UnixPrintServiceLookup
.
isSysV
())
{
return
getPrinterIsAcceptingJobsSysV
();
return
getPrinterIsAcceptingJobsSysV
();
}
else
if
(
UnixPrintServiceLookup
.
isBSD
())
{
}
else
if
(
UnixPrintServiceLookup
.
isBSD
())
{
return
getPrinterIsAcceptingJobsBSD
();
return
getPrinterIsAcceptingJobsBSD
();
}
else
if
(
UnixPrintServiceLookup
.
isAIX
())
{
return
getPrinterIsAcceptingJobsAIX
();
}
else
{
}
else
{
return
PrinterIsAcceptingJobs
.
ACCEPTING_JOBS
;
return
PrinterIsAcceptingJobs
.
ACCEPTING_JOBS
;
}
}
...
@@ -345,11 +393,32 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
...
@@ -345,11 +393,32 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
return
new
QueuedJobCount
(
qlen
);
return
new
QueuedJobCount
(
qlen
);
}
}
private
QueuedJobCount
getQueuedJobCountAIX
()
{
// On AIX there should not be a blank after '-a'.
String
command
=
"/usr/bin/lpstat -a"
+
printer
;
String
results
[]=
UnixPrintServiceLookup
.
execCmd
(
command
);
// Remove headers and bogus entries added by remote printers.
results
=
filterPrinterNamesAIX
(
results
);
int
qlen
=
0
;
if
(
results
!=
null
&&
results
.
length
>
0
){
for
(
int
i
=
0
;
i
<
results
.
length
;
i
++)
{
if
(
results
[
i
].
contains
(
"QUEUED"
)){
qlen
++;
}
}
}
return
new
QueuedJobCount
(
qlen
);
}
private
QueuedJobCount
getQueuedJobCount
()
{
private
QueuedJobCount
getQueuedJobCount
()
{
if
(
UnixPrintServiceLookup
.
isSysV
())
{
if
(
UnixPrintServiceLookup
.
isSysV
())
{
return
getQueuedJobCountSysV
();
return
getQueuedJobCountSysV
();
}
else
if
(
UnixPrintServiceLookup
.
isBSD
())
{
}
else
if
(
UnixPrintServiceLookup
.
isBSD
())
{
return
getQueuedJobCountBSD
();
return
getQueuedJobCountBSD
();
}
else
if
(
UnixPrintServiceLookup
.
isAIX
())
{
return
getQueuedJobCountAIX
();
}
else
{
}
else
{
return
new
QueuedJobCount
(
0
);
return
new
QueuedJobCount
(
0
);
}
}
...
@@ -369,6 +438,13 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
...
@@ -369,6 +438,13 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
return
attrs
;
return
attrs
;
}
}
private
PrintServiceAttributeSet
getAIXServiceAttributes
()
{
PrintServiceAttributeSet
attrs
=
new
HashPrintServiceAttributeSet
();
attrs
.
add
(
getQueuedJobCountAIX
());
attrs
.
add
(
getPrinterIsAcceptingJobsAIX
());
return
attrs
;
}
private
boolean
isSupportedCopies
(
Copies
copies
)
{
private
boolean
isSupportedCopies
(
Copies
copies
)
{
int
numCopies
=
copies
.
getValue
();
int
numCopies
=
copies
.
getValue
();
return
(
numCopies
>
0
&&
numCopies
<
MAXCOPIES
);
return
(
numCopies
>
0
&&
numCopies
<
MAXCOPIES
);
...
@@ -394,6 +470,8 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
...
@@ -394,6 +470,8 @@ public class UnixPrintService implements PrintService, AttributeUpdater,
private
PrintServiceAttributeSet
getDynamicAttributes
()
{
private
PrintServiceAttributeSet
getDynamicAttributes
()
{
if
(
UnixPrintServiceLookup
.
isSysV
())
{
if
(
UnixPrintServiceLookup
.
isSysV
())
{
return
getSysVServiceAttributes
();
return
getSysVServiceAttributes
();
}
else
if
(
UnixPrintServiceLookup
.
isAIX
())
{
return
getAIXServiceAttributes
();
}
else
{
}
else
{
return
getBSDServiceAttributes
();
return
getBSDServiceAttributes
();
}
}
...
...
src/solaris/classes/sun/print/UnixPrintServiceLookup.java
浏览文件 @
dec1dfd1
...
@@ -78,6 +78,19 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
...
@@ -78,6 +78,19 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
static
String
osname
;
static
String
osname
;
// List of commands used to deal with the printer queues on AIX
String
[]
lpNameComAix
=
{
"/usr/bin/lsallq"
,
"/usr/bin/lpstat -W -p|/usr/bin/expand|/usr/bin/cut -f1 -d' '"
,
"/usr/bin/lpstat -W -d|/usr/bin/expand|/usr/bin/cut -f1 -d' '"
,
"/usr/bin/lpstat -W -v"
};
private
static
final
int
aix_lsallq
=
0
;
private
static
final
int
aix_lpstat_p
=
1
;
private
static
final
int
aix_lpstat_d
=
2
;
private
static
final
int
aix_lpstat_v
=
3
;
private
static
int
aix_defaultPrinterEnumeration
=
aix_lsallq
;
static
{
static
{
/* The system property "sun.java2d.print.polling"
/* The system property "sun.java2d.print.polling"
* can be used to force the printing code to poll or not poll
* can be used to force the printing code to poll or not poll
...
@@ -114,6 +127,24 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
...
@@ -114,6 +127,24 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
osname
=
java
.
security
.
AccessController
.
doPrivileged
(
osname
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"os.name"
));
new
sun
.
security
.
action
.
GetPropertyAction
(
"os.name"
));
/* The system property "sun.java2d.print.aix.lpstat"
* can be used to force the usage of 'lpstat -p' to enumerate all
* printer queues. By default we use 'lsallq', because 'lpstat -p' can
* take lots of time if thousands of printers are attached to a server.
*/
if
(
isAIX
())
{
String
aixPrinterEnumerator
=
java
.
security
.
AccessController
.
doPrivileged
(
new
sun
.
security
.
action
.
GetPropertyAction
(
"sun.java2d.print.aix.lpstat"
));
if
(
aixPrinterEnumerator
!=
null
)
{
if
(
aixPrinterEnumerator
.
equalsIgnoreCase
(
"lpstat"
))
{
aix_defaultPrinterEnumeration
=
aix_lpstat_p
;
}
else
if
(
aixPrinterEnumerator
.
equalsIgnoreCase
(
"lsallq"
))
{
aix_defaultPrinterEnumeration
=
aix_lsallq
;
}
}
}
}
}
static
boolean
isMac
()
{
static
boolean
isMac
()
{
...
@@ -133,6 +164,10 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
...
@@ -133,6 +164,10 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
osname
.
contains
(
"OS X"
));
osname
.
contains
(
"OS X"
));
}
}
static
boolean
isAIX
()
{
return
osname
.
equals
(
"AIX"
);
}
static
final
int
UNINITIALIZED
=
-
1
;
static
final
int
UNINITIALIZED
=
-
1
;
static
final
int
BSD_LPD
=
0
;
static
final
int
BSD_LPD
=
0
;
static
final
int
BSD_LPD_NG
=
1
;
static
final
int
BSD_LPD_NG
=
1
;
...
@@ -251,6 +286,8 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
...
@@ -251,6 +286,8 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
}
else
{
}
else
{
if
(
isMac
()
||
isSysV
())
{
if
(
isMac
()
||
isSysV
())
{
printers
=
getAllPrinterNamesSysV
();
printers
=
getAllPrinterNamesSysV
();
}
else
if
(
isAIX
())
{
printers
=
getAllPrinterNamesAIX
();
}
else
{
//BSD
}
else
{
//BSD
printers
=
getAllPrinterNamesBSD
();
printers
=
getAllPrinterNamesBSD
();
}
}
...
@@ -435,6 +472,8 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
...
@@ -435,6 +472,8 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
PrintService
printer
=
null
;
PrintService
printer
=
null
;
if
(
isMac
()
||
isSysV
())
{
if
(
isMac
()
||
isSysV
())
{
printer
=
getNamedPrinterNameSysV
(
name
);
printer
=
getNamedPrinterNameSysV
(
name
);
}
else
if
(
isAIX
())
{
printer
=
getNamedPrinterNameAIX
(
name
);
}
else
{
}
else
{
printer
=
getNamedPrinterNameBSD
(
name
);
printer
=
getNamedPrinterNameBSD
(
name
);
}
}
...
@@ -600,6 +639,8 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
...
@@ -600,6 +639,8 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
}
else
{
}
else
{
if
(
isMac
()
||
isSysV
())
{
if
(
isMac
()
||
isSysV
())
{
defaultPrinter
=
getDefaultPrinterNameSysV
();
defaultPrinter
=
getDefaultPrinterNameSysV
();
}
else
if
(
isAIX
())
{
defaultPrinter
=
getDefaultPrinterNameAIX
();
}
else
{
}
else
{
defaultPrinter
=
getDefaultPrinterNameBSD
();
defaultPrinter
=
getDefaultPrinterNameBSD
();
}
}
...
@@ -774,11 +815,49 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
...
@@ -774,11 +815,49 @@ public class UnixPrintServiceLookup extends PrintServiceLookup
return
(
String
[])
printerNames
.
toArray
(
new
String
[
printerNames
.
size
()]);
return
(
String
[])
printerNames
.
toArray
(
new
String
[
printerNames
.
size
()]);
}
}
private
String
getDefaultPrinterNameAIX
()
{
String
[]
names
=
execCmd
(
lpNameComAix
[
aix_lpstat_d
]);
// Remove headers and bogus entries added by remote printers.
names
=
UnixPrintService
.
filterPrinterNamesAIX
(
names
);
if
(
names
==
null
||
names
.
length
!=
1
)
{
// No default printer found
return
null
;
}
else
{
return
names
[
0
];
}
}
private
PrintService
getNamedPrinterNameAIX
(
String
name
)
{
// On AIX there should be no blank after '-v'.
String
[]
result
=
execCmd
(
lpNameComAix
[
aix_lpstat_v
]
+
name
);
// Remove headers and bogus entries added by remote printers.
result
=
UnixPrintService
.
filterPrinterNamesAIX
(
result
);
if
(
result
==
null
||
result
.
length
!=
1
)
{
return
null
;
}
else
{
return
new
UnixPrintService
(
name
);
}
}
private
String
[]
getAllPrinterNamesAIX
()
{
// Determine all printers of the system.
String
[]
names
=
execCmd
(
lpNameComAix
[
aix_defaultPrinterEnumeration
]);
// Remove headers and bogus entries added by remote printers.
names
=
UnixPrintService
.
filterPrinterNamesAIX
(
names
);
ArrayList
<
String
>
printerNames
=
new
ArrayList
<
String
>();
for
(
int
i
=
0
;
i
<
names
.
length
;
i
++)
{
printerNames
.
add
(
names
[
i
]);
}
return
(
String
[])
printerNames
.
toArray
(
new
String
[
printerNames
.
size
()]);
}
static
String
[]
execCmd
(
final
String
command
)
{
static
String
[]
execCmd
(
final
String
command
)
{
ArrayList
results
=
null
;
ArrayList
results
=
null
;
try
{
try
{
final
String
[]
cmd
=
new
String
[
3
];
final
String
[]
cmd
=
new
String
[
3
];
if
(
isSysV
())
{
if
(
isSysV
()
||
isAIX
()
)
{
cmd
[
0
]
=
"/usr/bin/sh"
;
cmd
[
0
]
=
"/usr/bin/sh"
;
cmd
[
1
]
=
"-c"
;
cmd
[
1
]
=
"-c"
;
cmd
[
2
]
=
"env LC_ALL=C "
+
command
;
cmd
[
2
]
=
"env LC_ALL=C "
+
command
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录