net.sf.jasperreports.engine.fill
Class AsynchronousFillHandle

java.lang.Object
  extended by net.sf.jasperreports.engine.fill.AsynchronousFillHandle

public class AsynchronousFillHandle
extends java.lang.Object

Class used to perform report filling asychronously.

An instance of this type can be used as a handle to an asychronous fill process. The main benefit of this method is that the filling process can be cancelled.

Version:
$Id: AsynchronousFillHandle.java 3659 2010-03-31 10:20:49Z shertage $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)

Nested Class Summary
protected  class AsynchronousFillHandle.ReportFiller
           
 
Field Summary
protected  boolean cancelled
           
protected  java.sql.Connection conn
           
protected  JRDataSource dataSource
           
protected  JRBaseFiller filler
           
protected  java.lang.Thread fillThread
           
protected  JasperReport jasperReport
           
protected  java.util.List listeners
           
protected  java.lang.Object lock
           
protected  java.util.Map parameters
           
protected  java.lang.Integer priority
           
protected  boolean running
           
protected  boolean started
           
protected  java.lang.String threadName
           
 
Constructor Summary
protected AsynchronousFillHandle(JasperReport jasperReport, java.util.Map parameters)
           
protected AsynchronousFillHandle(JasperReport jasperReport, java.util.Map parameters, java.sql.Connection conn)
           
protected AsynchronousFillHandle(JasperReport jasperReport, java.util.Map parameters, JRDataSource dataSource)
           
protected AsynchronousFillHandle(JasperReport jasperReport, java.util.Map parameters, JRDataSource dataSource, java.sql.Connection conn)
           
 
Method Summary
 void addListener(AsynchronousFilllListener listener)
          Adds a listener to the filling process.
 void cancellFill()
          Cancels the fill started by the handle.
static AsynchronousFillHandle createHandle(JasperReport jasperReport, java.util.Map parameters)
          Creates an asychronous filling handle.
static AsynchronousFillHandle createHandle(JasperReport jasperReport, java.util.Map parameters, java.sql.Connection conn)
          Creates an asychronous filling handle.
static AsynchronousFillHandle createHandle(JasperReport jasperReport, java.util.Map parameters, JRDataSource dataSource)
          Creates an asychronous filling handle.
protected  void notifyCancel()
           
protected  void notifyError(java.lang.Throwable e)
           
protected  void notifyFinish(JasperPrint print)
           
 boolean removeListener(AsynchronousFilllListener listener)
          Removes a listener from the filling process.
 void setPriority(int priority)
          Sets the priority of the filler thread.
 void setThreadName(java.lang.String name)
          Sets the name of the filler thread.
 void startFill()
          Starts the filling process asychronously.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jasperReport

protected final JasperReport jasperReport

parameters

protected final java.util.Map parameters

dataSource

protected final JRDataSource dataSource

conn

protected final java.sql.Connection conn

filler

protected final JRBaseFiller filler

listeners

protected final java.util.List listeners

fillThread

protected java.lang.Thread fillThread

started

protected boolean started

running

protected boolean running

cancelled

protected boolean cancelled

lock

protected final java.lang.Object lock

priority

protected java.lang.Integer priority

threadName

protected java.lang.String threadName
Constructor Detail

AsynchronousFillHandle

protected AsynchronousFillHandle(JasperReport jasperReport,
                                 java.util.Map parameters,
                                 JRDataSource dataSource)
                          throws JRException
Throws:
JRException

AsynchronousFillHandle

protected AsynchronousFillHandle(JasperReport jasperReport,
                                 java.util.Map parameters,
                                 java.sql.Connection conn)
                          throws JRException
Throws:
JRException

AsynchronousFillHandle

protected AsynchronousFillHandle(JasperReport jasperReport,
                                 java.util.Map parameters)
                          throws JRException
Throws:
JRException

AsynchronousFillHandle

protected AsynchronousFillHandle(JasperReport jasperReport,
                                 java.util.Map parameters,
                                 JRDataSource dataSource,
                                 java.sql.Connection conn)
                          throws JRException
Throws:
JRException
Method Detail

addListener

public void addListener(AsynchronousFilllListener listener)
Adds a listener to the filling process.

Parameters:
listener - the listener to be added

removeListener

public boolean removeListener(AsynchronousFilllListener listener)
Removes a listener from the filling process.

Parameters:
listener - the listener to be removed
Returns:
true if the listener was found and removed

startFill

public void startFill()
Starts the filling process asychronously.

The filling is launched on a new thread and the method exits after the thread is started.

When the filling finishes either in success or failure, the listeners are notified.


cancellFill

public void cancellFill()
                 throws JRException
Cancels the fill started by the handle.

The method sends a cancel signal to the filling process. When the filling process will end, the listeners will be notified that the filling has been cancelled.

Throws:
JRException

notifyFinish

protected void notifyFinish(JasperPrint print)

notifyCancel

protected void notifyCancel()

notifyError

protected void notifyError(java.lang.Throwable e)

createHandle

public static AsynchronousFillHandle createHandle(JasperReport jasperReport,
                                                  java.util.Map parameters,
                                                  JRDataSource dataSource)
                                           throws JRException
Creates an asychronous filling handle.

Parameters:
jasperReport - the report
parameters - the parameter map
dataSource - the data source
Returns:
the handle
Throws:
JRException

createHandle

public static AsynchronousFillHandle createHandle(JasperReport jasperReport,
                                                  java.util.Map parameters,
                                                  java.sql.Connection conn)
                                           throws JRException
Creates an asychronous filling handle.

Parameters:
jasperReport - the report
parameters - the parameter map
conn - the connection
Returns:
the handle
Throws:
JRException

createHandle

public static AsynchronousFillHandle createHandle(JasperReport jasperReport,
                                                  java.util.Map parameters)
                                           throws JRException
Creates an asychronous filling handle.

Parameters:
jasperReport - the report
parameters - the parameter map
Returns:
the handle
Throws:
JRException

setPriority

public void setPriority(int priority)
Sets the priority of the filler thread.

Parameters:
priority - the filler thread priority.
See Also:
Thread.setPriority(int)

setThreadName

public void setThreadName(java.lang.String name)
Sets the name of the filler thread.

Parameters:
name - the filler thread name.
See Also:
Thread.setName(java.lang.String)


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com