View Javadoc

1   /*
2    * Copyright (c) 2005, The K-Wf Grid Consortium
3    * Fraunhofer Institute for Computer Architecture and Software Technology
4    * See http://www.kwfgrid.eu and http://www.first.fraunhofer.de for more details.
5    */
6   package net.kwfgrid.gworkflowdl.protocol;
7   
8   import net.kwfgrid.gworkflowdl.protocol.calls.IMethodCall;
9   import net.kwfgrid.gworkflowdl.protocol.calls.MethodCallException;
10  import net.kwfgrid.gworkflowdl.protocol.structure.IStructureListenerExt;
11  import net.kwfgrid.gworkflowdl.protocol.structure.IStructureListener;
12  import net.kwfgrid.gworkflowdl.protocol.structure.IRootObject;
13  
14  import org.apache.log4j.Logger;
15  
16  /***
17     Abstract class that provides protected methods to fire events to instances of <code>IStructureListenerExt</code>.
18   */
19  public abstract class AbstractMethodCallStrategyExt implements IMethodCallStrategy {
20      private static final Logger logger = Logger.getLogger(AbstractMethodCallStrategyExt.class);
21  
22      protected void fireBeginModifications(IRootObject structure) {
23  	IStructureListener[] ll = structure.getStructureListeners();
24  	for (int i=0; i<ll.length; i++) {
25  
26  //	    logger.debug("Firing beginModifications() to "+ll[i]);
27  
28  	    if (ll[i] instanceof IStructureListenerExt)
29  		((IStructureListenerExt)ll[i]).beginModifications(structure);
30  	}
31      }
32  
33      protected void fireEndModifications(IRootObject structure) {
34  	IStructureListener[] ll = structure.getStructureListeners();
35  	for (int i=0; i<ll.length; i++) {
36  
37  //	    logger.debug("Firing endModifications() to "+ll[i]);
38  
39  	    if (ll[i] instanceof IStructureListenerExt)
40  		((IStructureListenerExt)ll[i]).endModifications(structure);
41  	}
42      }
43  
44      protected void fireException(IRootObject structure, Throwable x) {
45  	IStructureListener[] ll = structure.getStructureListeners();
46  	for (int i=0; i<ll.length; i++) {
47  
48  //	    logger.debug("Firing exception() to "+ll[i]);
49  
50  	    if (ll[i] instanceof IStructureListenerExt)
51  		((IStructureListenerExt)ll[i]).exception(structure, x);
52  	}
53      }
54  }