Next: Generating The Faults
Up: Input Translator
Previous: Generating The Program State
Generating The Fault-Intolerant Program
We describe the automatic generation of the ProgramImplementation class. This class models the abstract structure of the fault-intolerant program. Accompanied with the generation of this class, we generate Java classes corresponding to each process of the fault-intolerant program. In this subsection, we first describe the structure of the ProgramImplementation class, and then we describe the structure of the Java files that are created for each process.
[commandchars=\\\{\},
numbers=left,numbersep=3pt, fontsize=\footnotesize,
xleftmargin=10mm,xrightmargin=10mm]
public class ProgramImplementation implements Program_Implementor \{
Component cmpts[];
int no_components;
public ProgramImplementation()\{
no_components = ProblemSpecific.NO_COMPONENTS;
cmpts = new Component[no_components];
// Create the internal representation of the first process
try \{
\}
catch(Exception e) \{
System.out.println(" Exception in constructing Process i " + e); \}
// Create the internal representation of the second process
try \{
\}
catch(Exception e) \{
System.out.println(" Exception in constructing Process i " + e); \}
. . .
. . .
\}
public Stack exploreImp( State s, Hashtable states) \{
Stack ns = new Stack();
for(int i = 0; i < no_components; i++) \{
cmpts[i].explore(ns,s,states); \}
return ns;
\}
public boolean solveDeadlockImp( State s, Invariant inv, Hashtable states,
SafetySpecification spec, Program fitp ) \{
for(int i = 0; i < no_components; i++) \{
if( cmpts[i].solveDeadlock( s, inv, states, spec, fitp ) )
return true; \}
return false; \}
public boolean solveDeadlockMoreImp( State s, Invariant inv, Hashtable states,
SafetySpecification spec, Program fitp, Hashtable recStates ) \{
for(int i = 0; i < no_components; i++) \{
if( cmpts[i].solveDeadlockMore( s, inv, states, spec, fitp, recStates ) )
return true; \}
return false; \}
public boolean producesTransitionImp(Transition t) \{
for(int i = 0; i < no_components; i++) \{
if( cmpts[i].producesTransition(t) ) return true; \}
return false; \}
public boolean isDeadlockedImp(State s) \{
for(int i = 0; i < no_components; i++) \{
if( !cmpts[i].isDeadlocked(s) ) return false; \}
return true; \}
public void printImp() \{
System.out.println("Printing Program.....");
System.out.println();
for(int i = 0; i < no_components; i++) \{
System.out.println("Printing component" + i);
cmpts[i].print(); \}
\}
\}
The ProgramImplementation class implements the interface defined by the Bridge design pattern applied on the abstract class Program. This way, the implementation of the program structure remains independent of the abstract design of the framework. The ProgramImplementation class has three sections. In this first section, we declare the state variables of the class. In the second section, we create a try block corresponding to each process of the fault-intolerant program (cf. the documentation of the code for the details of this section.). In the third section, we have a set of methods that we use for the generation of the reachability graph and resolution of the deadlock states.
Next: Generating The Faults
Up: Input Translator
Previous: Generating The Program State
Ali Ebnenasir
2003-10-26