4th International Conference on Principles and Practices ... - MADOC
4th International Conference on Principles and Practices ... - MADOC
4th International Conference on Principles and Practices ... - MADOC
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
associati<strong>on</strong>s, which may result in references c<strong>on</strong>taining a null<br />
value, <strong>and</strong> the fact that not all informati<strong>on</strong> is aggregated <strong>and</strong><br />
organized in a way suitable for the generati<strong>on</strong> process.<br />
After the initial processing of the models has been performed,<br />
domain-specific transformati<strong>on</strong>s of the static <strong>and</strong> dynamic models<br />
are carried out, leading to a modified generator model M’. In the<br />
case of the static models this means that additi<strong>on</strong>al domainspecific<br />
attributes are woven into the model. The transformati<strong>on</strong> is<br />
c<strong>on</strong>trolled via an XML definiti<strong>on</strong> of the attributes that are<br />
supposed to be added to classes of a particular metaclass. For<br />
example, all classes of type Article receive a new attribute called<br />
Approved, which is used for the review process.<br />
Additi<strong>on</strong>ally, in this processing step patterns are resolved, i.e., the<br />
state-substate pattern in the dynamic model (see secti<strong>on</strong> 3.3). The<br />
transformati<strong>on</strong>s required for this step are also defined in XML,<br />
<strong>and</strong> offer opti<strong>on</strong>s such as the introducti<strong>on</strong> of new states to a<br />
dynamic model <strong>and</strong> the rerouting of transiti<strong>on</strong>s to incorporate<br />
these new states.<br />
The final step in the generati<strong>on</strong> process is the actual model-tocode<br />
transformati<strong>on</strong> performed by the Velocity template engine<br />
(represented by the last arrow in Figure 3). For each node in the<br />
static models a set of templates is invoked according to an XML<br />
mapping associating metaclass names with output templates. A<br />
reference to this node is then passed to each of the invoked<br />
templates, which query the node object for its relevant properties<br />
such as name, attributes <strong>and</strong> associati<strong>on</strong>s with other nodes. For<br />
example, informati<strong>on</strong> about attributes provides the basis for<br />
attributes <strong>and</strong>/or getter <strong>and</strong> setter methods in a Java source file.<br />
It is important to note that each input node from M’ can result in<br />
any number of output resources, e.g., a node with the metaclass<br />
DataSet can be transformed into an EJB bean class <strong>and</strong> the<br />
various interfaces required. C<strong>on</strong>versely, a single output resource<br />
can also be generated from the extent of all classes instantiating<br />
the same metaclass, i.e., the XML deployment descriptor in an<br />
EJB envir<strong>on</strong>ment.<br />
Static nodes that are associated with dynamic models are subject<br />
to further processing. The generator applies the state pattern (cf.<br />
[14], [15]) to create the implementati<strong>on</strong> of a state machine for<br />
every dynamic model.<br />
All these artifacts are written to a prepared skelet<strong>on</strong> eclipse<br />
project that c<strong>on</strong>tains required libraries <strong>and</strong> a build script that<br />
creates a deployable, ready-to-run binary file of the modeled<br />
system.<br />
While the process described above uses established code<br />
generati<strong>on</strong> techniques, it allows for accessing the metainformati<strong>on</strong><br />
provided by the hierarchy. For example, domain-specific<br />
attributes <strong>and</strong> methods can be woven into classes based <strong>on</strong> their<br />
metaclasses. The separati<strong>on</strong> of templates for the different layers<br />
(i.e., technical <strong>and</strong> business) has been implemented using basic<br />
model-to-model transformati<strong>on</strong>s <strong>and</strong> facilitates the rapid creati<strong>on</strong><br />
of additi<strong>on</strong>al business domain templates.<br />
6. JAVA-SPECIFIC CODE GENERATION<br />
PROBLEMS<br />
In the previous secti<strong>on</strong> we have provided an overview of the code<br />
generati<strong>on</strong> process. In this secti<strong>on</strong> we will discuss some selected<br />
issues we have experienced during the implementati<strong>on</strong> <strong>and</strong><br />
evaluati<strong>on</strong> of the code generati<strong>on</strong> plugin.<br />
For the purpose of evaluati<strong>on</strong> we have created several examples<br />
targeted at J2EE/EJB2.x compliant applicati<strong>on</strong> servers. This<br />
choice was made due to the multitude of services provided by a<br />
J2EE envir<strong>on</strong>ment, such as persistence, transacti<strong>on</strong> management,<br />
declarative, role-based security, etc. that were needed for the<br />
realizati<strong>on</strong> of the examples.<br />
J2EE as a target platform has generally proven beneficial;<br />
however, some inherent characteristics of the platform<br />
complicated the development of the source code templates. The<br />
amount of classes <strong>and</strong> interfaces required to implement an EJB<br />
entity bean for example has been somewhat hindering during the<br />
initial creati<strong>on</strong> of the source code templates, due to the fact that<br />
even simple changes required adapting various templates. We<br />
expect this situati<strong>on</strong> to improve by adopting the Java Persistence<br />
API that simplifies the development of persistence-capable,<br />
transacti<strong>on</strong>-safe classes.<br />
Initial proof-of-c<strong>on</strong>cept implementati<strong>on</strong>s of our examples were<br />
closely tied to the EJB technology, because they were focused <strong>on</strong><br />
dem<strong>on</strong>strating the applicability of our own Web framework<br />
COBANA rather than <strong>on</strong> efficient implementati<strong>on</strong>. The basis for<br />
using alternative technologies, such as Hibernate, was created by<br />
refactoring our reference implementati<strong>on</strong>, separating EJB-specific<br />
from other system aspects by introducing patterns such as<br />
Business Delegate or Data Transfer Object (cf. [16]).<br />
In secti<strong>on</strong> 3.3 the noti<strong>on</strong> of the explicit metastate was introduced<br />
as a state c<strong>on</strong>taining entry code supplied by the modeler for<br />
situati<strong>on</strong>s where n<strong>on</strong>e of the implicit metastates c<strong>on</strong>tained in the<br />
hierarchy is applicable. As the modeler is relatively free as to what<br />
kind of code to insert, the problem of gracefully h<strong>and</strong>ling<br />
potential excepti<strong>on</strong>s arises. Due to the lack of a Java metamodel in<br />
the Velocity template engine, it is not possible to wrap critical<br />
parts of the code with the required specific excepti<strong>on</strong> h<strong>and</strong>ling<br />
code. The <strong>on</strong>ly way to ensure the correctness of the generated<br />
code is to wrap all modeler-defined entry code passages with<br />
generic excepti<strong>on</strong> h<strong>and</strong>ling. This situati<strong>on</strong> was improved by the<br />
definiti<strong>on</strong> of technology-independent but meaningful excepti<strong>on</strong><br />
types, i.e. for excepti<strong>on</strong>s occurring during data access.<br />
For the access c<strong>on</strong>trol example described in secti<strong>on</strong> 4.3 the use of<br />
declarative servlet security mechanisms was planned. In order to<br />
be able to specify access restricti<strong>on</strong>s for URL patterns, the passing<br />
of View names (cf. secti<strong>on</strong> 4.1) via query strings was replaced by<br />
a mechanism based <strong>on</strong> URL rewriting, a mechanism that enables a<br />
Web server to programmatically manipulate the URLs of<br />
incoming requests. In our case it allows for the representati<strong>on</strong> of<br />
query strings in an URL-like fashi<strong>on</strong>, e.g.,<br />
http://localhost/C<strong>on</strong>trollerView=Library can be expressed as<br />
http://localhost/C<strong>on</strong>troller/Library. As URL patterns in the<br />
servlet specificati<strong>on</strong> are not supposed to be specified via regular<br />
expressi<strong>on</strong>s, all possible combinati<strong>on</strong>s of Views <strong>and</strong> ChildViews<br />
have to be declared in the security c<strong>on</strong>figurati<strong>on</strong>.<br />
On a more general level, the lack of an equivalent for UML-style<br />
bidirecti<strong>on</strong>al associati<strong>on</strong>s in the Java programming language<br />
requires representati<strong>on</strong> as two unidirecti<strong>on</strong>al references causing<br />
some overhead <strong>and</strong> loss of semantics.<br />
222