The CDE generated Java code provides a specific implementation of the general contracts micro-architecture. This document discusses some implementation issues as well as some assumptions or points to have in mind regarding the generated Java code. However, details of implementation are not discussed, mainly for two reasons: Firstly, the focus of CDE users should be on the methodological aspects of contracts and not on the specific implementation. Secondly, knowing implementation details is often tempting for performing code modifications that may result in behaviour that does not comply with the contracts semantics. Any specific questions, however, are welcomed for those wishing to obtain a more clear understanding of the generated Java code. In this context, the implementation points we wish to present are the following:
In the general micro-architecture Subject and SubjectToProxyAdapter appear as two different classes. However, for reasons explained in the micro-architecture document, the previous two classes are merged in one class, Subject.
In the general micro-architecture class ISubjectProxy is supposed to implement SubjectInterface and also Subject and ISubjectPartner are subclasses of (implement) ISubjectProxy. However, in the CDE generated code instead of ISubjectProxy, a general, not specific to the Subject, class CrdIProxy is used. Each Subject either has CrdIProxy or inherits it from its parent class. The presence or no presence of contracts is determined by controlling CrdIProxy _proxy. If _proxy==null there are no contracts involved, otherwise contracts exists and calls to Subject are delegated to contracts.
The chain of responsibility management operations are provided by a framework class CrdContractPartner from which ISubjectPartner inherits. For each call on a participant that is forwarded to the chain, all active partners are determined, the first one takes responsibility and executes its actions, then it forwards to the next one and so on until no active partners are left. The current implementation does not allow the setting of priorities between contracts in the chain. Therefore, priorities of contracts is currently a matter of configuration i.e the order contracts are established between participants is also the execution order in the chain of responsibility. In the future versions of CDE, however, the ability to set the contracts priorities in the chain management will be provided.
Contract's state conditions rules are evaluated whenever a call to an operation that changes the state of a participant occurs. This is accomplished by invoking an operation named stateChange() that is defined on each contract.
©
Copyright 2001 ATX Software SA. All rights reserved.