2

JasperReport のサイズに制限を設定する方法はありますか? WebSphere 6.1 の Heapdump を調べたところ、誰かがレポートを作成しようとしたところ、ヒープに 1.5GB のメモリがありました。そして、それは私たちの Websphere サーバーを屈服させました。ありがとう、T

4

3 に答える 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 に答える