Figura 2.5: A C2 architecture composed by a client component and a server iC2C.
6. ClientComponentreceives the exception and routes it to ClientAbnormalActivity;
7. ClientAbnormalActivity handles the exception and sends a return to normal request to ClientNormalActivity, indicating that processing should be resumed;
8. ClientNormalActivity resumes processing.
2.5
Exception Handling System in the Framework
FaTC2
In this section, we describe FaTC2, an object-oriented framework which implements our architectural-level exception handling approach. FaTC2 is an extension of the Java [82] version of the C2.FW framework. The original C2.FW framework does not provide ade- quate support for the construction of fault-tolerant systems. FaTC2 extends C2.FW with the concept of iC2C, in order to provide the support for forward error recovery, by means of the EHS described in Section 2.4.
Figure 2.7 presents a partial class hierarchy for FaTC2, and its intersection with C2.FW. In the following sections, we describe the framework FaTC2, based on the notions described in Figure 2.2.
2.5. Exception Handling System in the Framework FaTC2 35
Figura 2.6: A scenario illustrating the termination model adopted by ALEx.
2.5.1
IC2C
The iC2C is the basic unit provided by FaTC2 for attaching handlers to components or configurations. The creation of an iC2C is encapsulated by the IC2C class. In order to create an instance of IC2C, objects representing the NormalActivity and AbnormalActivity components (Figure 2.2) must be supplied. Optionally, the developer may chose to also supply objects representing the iC2C top and iC2C bottom connectors, in case filtering or domain-translation are required. Otherwise, default implementations are employed.
Although the IC2C class may be used directly in an application, it is recommended that developers create subclasses of it, specifying the NormalActivity and AbnormalActivity components, and iC2C top and iC2C bottom connectors which are to be used.
An analogous structuring may be used for representing fault-tolerant connectors, as long as the semantic differences between components and connectors are taken into ac- count.
2.5.2
NormalActivity Component
The NormalActivity component encapsulates the functionality (normal activity) of an iC2C. It may represent both a single component and a configuration. In this work, we will only address the case where an iC2C represents a single component.
In order to define a NormalActivity component, a developer must provide a class that implements the INormalActivity interface. This interface declares three operations which define the application-dependent behavior of the component: handleRequest(), returnToNormal(), and reset().
2.5. Exception Handling System in the Framework FaTC2 36
Figura 2.7: A partial class hierarchy for C2.FW and FaTC2.
The handleRequest() method is responsible for (i) processing service requests and (ii) detecting errors. It takes as argument the request message to be processed, and returns a response notification to be delivered to the client component. If an error is detected during the processing of a service request, this method signals an exception, which may be a FailureArchitecturalException or an InterfaceArchitecturalException. Exceptions are caught by the framework and packaged as exception notifications, which are sent to the AbnormalActivity component.
The returnToNormal() and reset() methods are related to the abnormal activity of the iC2C. The former is called when the iC2C has successfully handled an exception, and should resume processing. The latter is called when the iC2C is unable to handle an exception, and should perform some cleanup actions before handling new requests.
FaTC2 provides developers with an abstract class which implements the application- independent behavior of the NormalActivity component, as defined by ALEx (Section 2.4). This class is called AbstractNormalActivityComponent, and should be extended by the class which implements the NormalActivity component for a given iC2C. In the situ- ations described above, the tasks of delivering requests to the handleRequest() method, sending response notifications to client components, and packaging and sending exception notifications to the AbnormalActivity component are performed by AbstractNormalActi- vityComponent.
2.5. Exception Handling System in the Framework FaTC2 37
In case the handling of a request demands the NormalActivity component to request services from components located in upper layers of the architecture, the AbstractNor- malActivityComponent class provides a utility method, requestService(), which may be used to send synchronous (request/response) requests transparently, upwards the archi- tecture.
2.5.3
AbnormalActivity Component
The AbnormalActivity component encapsulates the exception handlers of an iC2C. In order to implement it, a developer must provide a class that implements the IAbnormalAc- tivityComponent interface. This interface declares a single method, handleException(), which defines the default exception handler of the component. This scheme enforces the policy defined by ALEx, that at least the default exception handler must be implemented by every AbnormalActivity component.
Additional handlers are defined by handler methods that are declared in the same class which implements the IAbnormalActivityComponent interface. The order in which they are declared is not important. Handler methods present the following structure:
public Message handleException(<exception> e, Request m) raises Exception {
// Body of a handler for <exception>. }
In the code snippet above, <exception> stands for the exception type (a Java class) which the handler is capable of handling. The Request r parameter refers to the request which was being processed when the exception was signaled. If an exception is success- fully handled, the handler method returns an object of type Message. This represents a C2 message which is delivered to the NormalActivity component in order for processing to be resumed. If an exception can not be handled, the handler method should resignal it or raise another exception. Either way, the exception is propagated to the enclosing exception handling context (Section 2.4.3).
FaTC2 provides developers with an abstract class which implements the application- independent behavior of the AbnormalActivity component, as defined by ALEx (Section 2.4). This class is called AbstractAbnormalActivityComponent, and should be extended by the class which implements the AbnormalActivity component for a given iC2C.
In case the handling of an exception requires the AbnormalActivityComponent to request services from other components, or from the NormalActivityComponent in the same iC2C, class AbstractAbnormalActivityComponent provides methods which allow syn- chronous requests to be carried transparently, similarly to the AbstractNormalActivityCom- ponent class.