有没有办法限制 JasperReport 的大小?我们刚刚查看了一个 WebSphere 6.1 Heapdump,有人试图创建一个报告,堆中有 1.5GB 的内存。它使我们的 Websphere 服务器瘫痪。谢谢,
Tom
问问题
8121 次
3 回答
2
我不熟悉 JasperReports,但您可以包装您的 I/O 流以确保读取/写入的数据量不超过定义的限制。
输出流示例:
public class LimitedSizeOutputStream extends OutputStream {
private final OutputStream delegate;
private final long limit;
private long written = 0L;
/**
* Creates a stream wrapper that will throw an IOException if the write
* limit is exceeded.
*
* @param delegate
* the underlying stream
* @param limit
* the maximum number of bytes this stream will accept
*/
public LimitedSizeOutputStream(OutputStream delegate, long limit) {
this.delegate = delegate;
this.limit = limit;
}
private void checkLimit(long byteCount) throws IOException {
if (byteCount + written > limit) {
throw new IOException("Exceeded stream size limit");
}
written += byteCount;
}
@Override
public void write(int b) throws IOException {
checkLimit(1);
delegate.write(b);
}
@Override
public void write(byte[] b) throws IOException {
checkLimit(b.length);
delegate.write(b);
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
checkLimit(len);
delegate.write(b, off, len);
}
@Override
public void close() throws IOException {
delegate.close();
}
}
包装InputStream也很容易。
于 2009-02-13T11:45:30.833 回答
1
JasperReports 现在具有限制报告输出大小的“报告管理器”。例如,您可以设置这些配置参数:
net.sf.jasperreports.governor.max.pages.enabled=[true|false]
net.sf.jasperreports.governor.max.pages=[integer]
有关更多信息,请参阅JasperReports 论坛上的此帖子。
于 2010-02-19T21:14:42.427 回答
0
您是否尝试过限制从数据库返回的记录集中的行?
于 2009-06-02T11:57:47.843 回答