executionContext ); layoutEngine.setPageHandler( handle );
executionContext ); layoutPageHandler.addPageHandler( handle ); layoutPageHandler.addPageHandler( new ContextPageBreakHandler( executionContext ) );  layoutEngine.setPageHandler( layoutPageHandler );
	public void run( ) throws EngineException	{		setRunningFlag( true );		// register default parameters and validate		if ( !validateParameters( ) )		{			setRunningFlag( false );			throw new EngineException(					MessageConstants.INVALID_PARAMETER_EXCEPTION ); //$NON-NLS-1$		}		loadDesign( );		prepareDesign( );		startFactory( );		startRender( );		try		{			IContentEmitter emitter = createContentEmitter( );			Report reportDesign = executionContext.getReport( );			ReportExecutor executor = new ReportExecutor( executionContext,					reportDesign, null );			IReportExecutor lExecutor = new LocalizedReportExecutor(					executionContext, executor );			executionContext.setExecutor( executor );			initializeContentEmitter( emitter, executor );			// if we need do the paginate, do the paginate.			if ( ExtensionManager.NO_PAGINATION.equals( pagination ))			{				HTMLTableLayoutNestEmitter tableLayoutEmitter = new HTMLTableLayoutNestEmitter(						emitter );				lExecutor.execute( reportDesign.getReportDesign( ),						tableLayoutEmitter );			}			else			{				String format = executionContext.getOutputFormat( );				boolean paginate = true;				if ( FORMAT_HTML.equalsIgnoreCase( format ) ) //$NON-NLS-1$				{					if ( renderOptions instanceof HTMLRenderOption )					{						HTMLRenderOption htmlOption = (HTMLRenderOption) renderOptions;						paginate = htmlOption.getHtmlPagination( );					}				}				synchronized ( this )				{					if ( !executionContext.isCanceled( ) )					{						layoutEngine = LayoutEngineFactory								.createLayoutEngine( pagination );					}				}				if ( layoutEngine != null )				{					OnPageBreakLayoutPageHandle handle = new OnPageBreakLayoutPageHandle(							executionContext );					layoutEngine.setPageHandler( handle );					CompositeContentEmitter outputEmitters = new CompositeContentEmitter(							format );					outputEmitters.addEmitter( emitter );					outputEmitters.addEmitter( handle.getEmitter( ) );					layoutEngine.layout( lExecutor, outputEmitters, paginate );				}			}			closeRender( );			closeFactory( );		}		catch ( EngineException e )		{			throw e;		}		catch ( Exception ex )		{			ex.printStackTrace( );			log.log( Level.SEVERE,					"An error happened while running the report. Cause:", ex ); //$NON-NLS-1$			throw new EngineException(					"Error happened while running the report", ex ); //$NON-NLS-1$		}		catch ( OutOfMemoryError err )		{			err.printStackTrace( );			log.log( Level.SEVERE,					"An OutOfMemory error happened while running the report." ); //$NON-NLS-1$			throw err;		}		catch ( Throwable t )		{			log.log( Level.SEVERE,					"Error happened while running the report.", t ); //$NON-NLS-1$			throw new EngineException( "Error happened while running the report", t ); //$NON-NLS-1$		}		finally		{			setRunningFlag( false );		}	}