summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpshi2011-10-26 03:04:10 (EDT)
committer mwu2011-10-26 03:04:10 (EDT)
commitd23e8c6f1b61eefbfe2b276a154db9c4072e4405 (patch)
tree71b7300a6054b159257fd04fd91f1cf6377783d3
parentf1c9726f672f008649bdfca1f5d7b9183fe32c6c (diff)
downloadorg.eclipse.birt-d23e8c6f1b61eefbfe2b276a154db9c4072e4405.zip
org.eclipse.birt-d23e8c6f1b61eefbfe2b276a154db9c4072e4405.tar.gz
org.eclipse.birt-d23e8c6f1b61eefbfe2b276a154db9c4072e4405.tar.bz2
fixed ted 43578, fixed, initialize the event handler
-rw-r--r--engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSetScriptExecutor.java28
-rw-r--r--engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSourceScriptExecutor.java30
-rw-r--r--engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSetScriptExecutor.java8
-rw-r--r--engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSourceScriptExecutor.java15
4 files changed, 55 insertions, 26 deletions
diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSetScriptExecutor.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSetScriptExecutor.java
index 748fa7f..b91a961 100644
--- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSetScriptExecutor.java
+++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSetScriptExecutor.java
@@ -45,8 +45,9 @@ public class DataSetScriptExecutor extends DtEScriptExecutor implements
private boolean useBeforeOpenEventHandler = false;
private boolean useBeforeCloseEventHandler = false;
+ private boolean flag = false;
private final String beforeOpenMethodID, beforeCloseMethodID,
- afterOpenMethodID, afterCloseMethodID, onFetchMethodID;
+ afterOpenMethodID, afterCloseMethodID, onFetchMethodID, className;
private Map<IDataSetInstanceHandle, Scriptable> scopeCache = new HashMap<IDataSetInstanceHandle, Scriptable>( );
@@ -55,8 +56,7 @@ public class DataSetScriptExecutor extends DtEScriptExecutor implements
{
super( context );
this.dataSetHandle = dataSetHandle;
- String className = dataSetHandle.getEventHandlerClass( );
- initEventHandler( className );
+ className = dataSetHandle.getEventHandlerClass( );
useOnFetchEventHandler = ScriptTextUtil.isNullOrComments( dataSetHandle.getOnFetch( ) );
useAfterCloseEventHandler = ScriptTextUtil.isNullOrComments( dataSetHandle.getAfterClose( ) );
useAfterOpenEventHandler = ScriptTextUtil.isNullOrComments( dataSetHandle.getAfterOpen( ) );
@@ -70,19 +70,24 @@ public class DataSetScriptExecutor extends DtEScriptExecutor implements
onFetchMethodID = ModuleUtil.getScriptUID( dataSetHandle.getPropertyHandle( ISimpleDataSetModel.ON_FETCH_METHOD ) );
}
- protected void initEventHandler( String className )
+ protected void initEventHandler( )
{
- if ( className != null )
+ if ( className != null && !flag )
{
try
{
- eventHandler = ( IDataSetEventHandler ) getInstance( className,
+ eventHandler = (IDataSetEventHandler) getInstance( className,
context );
- } catch ( ClassCastException e )
+ flag = true;
+ }
+ catch ( ClassCastException e )
{
- addClassCastException( context, e, dataSetHandle,
+ addClassCastException( context,
+ e,
+ dataSetHandle,
IScriptedDataSetEventHandler.class );
- } catch ( EngineException e )
+ }
+ catch ( EngineException e )
{
addException( context, e, dataSetHandle );
}
@@ -91,6 +96,7 @@ public class DataSetScriptExecutor extends DtEScriptExecutor implements
public void handleBeforeOpen( IDataSetInstanceHandle dataSet )
{
+ initEventHandler( );
if ( reportContext == null )
return;
try
@@ -117,6 +123,7 @@ public class DataSetScriptExecutor extends DtEScriptExecutor implements
public void handleBeforeClose( IDataSetInstanceHandle dataSet )
{
+ initEventHandler( );
if ( reportContext == null )
return;
try
@@ -142,6 +149,7 @@ public class DataSetScriptExecutor extends DtEScriptExecutor implements
public void handleAfterOpen( IDataSetInstanceHandle dataSet )
{
+ initEventHandler( );
if ( reportContext == null )
return;
try
@@ -192,6 +200,7 @@ public class DataSetScriptExecutor extends DtEScriptExecutor implements
public void handleAfterClose( IDataSetInstanceHandle dataSet )
{
+ initEventHandler( );
if ( reportContext == null )
return;
try
@@ -217,6 +226,7 @@ public class DataSetScriptExecutor extends DtEScriptExecutor implements
public void handleOnFetch( IDataSetInstanceHandle dataSet, IDataRow row )
{
+ initEventHandler( );
if ( reportContext == null )
return;
try
diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSourceScriptExecutor.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSourceScriptExecutor.java
index e3ab537..5696121 100644
--- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSourceScriptExecutor.java
+++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/DataSourceScriptExecutor.java
@@ -36,15 +36,16 @@ public class DataSourceScriptExecutor extends DtEScriptExecutor implements
private boolean useAfterOpenEventHandler = false;
private boolean useAfterCloseEventHandler = false;
- private final String beforeOpenMethodID, beforeCloseMethodID, afterOpenMethodID, afterCloseMethodID;
+ private final String beforeOpenMethodID, beforeCloseMethodID,
+ afterOpenMethodID, afterCloseMethodID, className;
+ private boolean flag = false;
public DataSourceScriptExecutor( DataSourceHandle dataSourceHandle,
ExecutionContext context ) throws BirtException
{
super( context );
this.dataSourceHandle = dataSourceHandle;
- String className = dataSourceHandle.getEventHandlerClass( );
- initEventHandler( className );
+ className = dataSourceHandle.getEventHandlerClass( );
this.useBeforeOpenEventHandler = ScriptTextUtil.isNullOrComments( dataSourceHandle.getBeforeOpen( ) );
this.useBeforeCloseEventHandler = ScriptTextUtil.isNullOrComments( dataSourceHandle.getBeforeClose( ) );
this.useAfterOpenEventHandler = ScriptTextUtil.isNullOrComments( dataSourceHandle.getAfterOpen( ) );
@@ -56,19 +57,24 @@ public class DataSourceScriptExecutor extends DtEScriptExecutor implements
afterCloseMethodID = ModuleUtil.getScriptUID( dataSourceHandle.getPropertyHandle( IDataSourceModel.AFTER_CLOSE_METHOD ) );
}
- protected void initEventHandler( String className )
+ protected void initEventHandler( )
{
- if ( className != null )
+ if ( className != null && !flag )
{
try
{
- eventHandler = ( IDataSourceEventHandler ) getInstance(
- className, context );
- } catch ( ClassCastException e )
+ eventHandler = (IDataSourceEventHandler) getInstance( className,
+ context );
+ flag = true;
+ }
+ catch ( ClassCastException e )
{
- addClassCastException( context, e, dataSourceHandle,
+ addClassCastException( context,
+ e,
+ dataSourceHandle,
IScriptedDataSetEventHandler.class );
- } catch ( EngineException e )
+ }
+ catch ( EngineException e )
{
addException( context, e, dataSourceHandle );
}
@@ -77,6 +83,7 @@ public class DataSourceScriptExecutor extends DtEScriptExecutor implements
public void handleBeforeOpen( IDataSourceInstanceHandle dataSource )
{
+ initEventHandler( );
if ( reportContext == null )
return;
try
@@ -102,6 +109,7 @@ public class DataSourceScriptExecutor extends DtEScriptExecutor implements
public void handleBeforeClose( IDataSourceInstanceHandle dataSource )
{
+ initEventHandler( );
if ( reportContext == null )
return;
try
@@ -126,6 +134,7 @@ public class DataSourceScriptExecutor extends DtEScriptExecutor implements
public void handleAfterOpen( IDataSourceInstanceHandle dataSource )
{
+ initEventHandler( );
if ( reportContext == null )
return;
try
@@ -150,6 +159,7 @@ public class DataSourceScriptExecutor extends DtEScriptExecutor implements
public void handleAfterClose( IDataSourceInstanceHandle dataSource )
{
+ initEventHandler( );
if ( reportContext == null )
return;
try
diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSetScriptExecutor.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSetScriptExecutor.java
index 0ec49e3..13d6947 100644
--- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSetScriptExecutor.java
+++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSetScriptExecutor.java
@@ -71,9 +71,9 @@ public class ScriptDataSetScriptExecutor extends DataSetScriptExecutor
}
- protected void initEventHandler( String className )
+ protected void initEventHandler( )
{
- super.initEventHandler( className );
+ super.initEventHandler( );
if ( eventHandler != null )
{
try
@@ -90,6 +90,7 @@ public class ScriptDataSetScriptExecutor extends DataSetScriptExecutor
public void handleOpen( IDataSetInstanceHandle dataSet )
throws BirtException
{
+ initEventHandler( );
try
{
if ( !this.useOpenEventHandler )
@@ -111,6 +112,7 @@ public class ScriptDataSetScriptExecutor extends DataSetScriptExecutor
public void handleClose( IDataSetInstanceHandle dataSet )
{
+ initEventHandler( );
try
{
if ( !this.useCloseEventHandler )
@@ -133,6 +135,7 @@ public class ScriptDataSetScriptExecutor extends DataSetScriptExecutor
public boolean handleFetch( IDataSetInstanceHandle dataSet, IDataRow row )
{
+ initEventHandler( );
try
{
if ( !useFetchEventHandler )
@@ -167,6 +170,7 @@ public class ScriptDataSetScriptExecutor extends DataSetScriptExecutor
public boolean handleDescribe( IDataSetInstanceHandle dataSet,
IScriptDataSetMetaDataDefinition metaData ) throws BirtException
{
+ initEventHandler( );
try
{
if ( !this.useDescribeEventHandler )
diff --git a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSourceScriptExecutor.java b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSourceScriptExecutor.java
index 923e7d9..8ad8396 100644
--- a/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSourceScriptExecutor.java
+++ b/engine/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/script/internal/ScriptDataSourceScriptExecutor.java
@@ -37,17 +37,20 @@ public class ScriptDataSourceScriptExecutor extends DataSourceScriptExecutor
super( dataSourceHandle, context );
}
- protected void initEventHandler( String className )
+ protected void initEventHandler( )
{
- super.initEventHandler( className );
+ super.initEventHandler( );
if ( eventHandler != null )
{
try
{
- scriptedEventHandler = ( IScriptedDataSourceEventHandler ) eventHandler;
- } catch ( ClassCastException e )
+ scriptedEventHandler = (IScriptedDataSourceEventHandler) eventHandler;
+ }
+ catch ( ClassCastException e )
{
- addClassCastException( context, e, dataSourceHandle,
+ addClassCastException( context,
+ e,
+ dataSourceHandle,
IScriptedDataSetEventHandler.class );
}
}
@@ -55,6 +58,7 @@ public class ScriptDataSourceScriptExecutor extends DataSourceScriptExecutor
public void handleOpen( IDataSourceInstanceHandle dataSource )
{
+ initEventHandler( );
try
{
String id = ModuleUtil.getScriptUID( dataSourceHandle.getPropertyHandle( IScriptDataSourceModel.OPEN_METHOD ) );
@@ -74,6 +78,7 @@ public class ScriptDataSourceScriptExecutor extends DataSourceScriptExecutor
public void handleClose( IDataSourceInstanceHandle dataSource )
{
+ initEventHandler( );
try
{
String id = ModuleUtil.getScriptUID( dataSourceHandle.getPropertyHandle( IScriptDataSourceModel.CLOSE_METHOD ) );