Kennissessie Services op 24 oktober: de videos
Geplaatst door Richard van der Laan in Celix, OSGi, Uncategorized op 16 november 2011
Op 24 oktober 2011 vond een kennissessie plaats over services in gedistribueerde en/of embedded omgevingen. Deze sessie was georganiseerd door Luminis in samenwerking met Thales en leden van de Apache community, en ging in op de vraag hoe het toepassen van services kan helpen bij het verbeteren van de flexibiliteit van bestaande systemen.
De video presentaties van deze sessie zijn nu beschikbaar.
Innovatie, Services en Open Source
Rene van Hees, Technical Authority Software bij Thales
OSGi en Dynamische Services
Marcel Offermans, lid van de Apache Software Foundation
Apache Celix en Apache Foundation
Alexander Broekhuis, Software Engineer Luminis, committer Apache Celix
CHARTER Surveillance Use Case – Industrial Evaluation
Geplaatst door Andriy Levytskyy in MDD, Uncategorized, java op 10 oktober 2011
This month, Luminis has started development of a surveillance use case. The purpose of the case is industrial assessment and validation of tools and technologies developed in the “Critical and High Assurance Requirements Transformed through Engineering Rigor” project (CHARTER). The ultimate goal of CHARTER is to ease, accelerate, and cost-reduce the certification of embedded systems. The CHARTER tool-suite employs real-time Java, Model Driven Development (MDD), rule-based compilation and formal verification. The coming series of articles will describe evaluation experiences in the surveillance use case.
The CHARTER project includes user partners from four key industries: aerospace, automotive, surveillance and medical, each of which develops embedded systems that require high assurance or formal certification in order to meet business or governmental requirements. The four user partners will each validate the CHARTER tools and methodology using industrial applications and actual development scenarios, which will provide feedback for the project and ensure the tools and technologies perform as expected, and deliver the expected improvements in embedded systems development. As part of the evaluation process, metrics will be used to quantify industrial experiences in terms of development effort, cost savings, verification time, etc., to document for others the benefits achieved.
The CHARTER project was established to improve the software development process for developing critical embedded systems. Critical embedded software systems assist, accelerate, and control various aspects of society and are common in cars, aircraft, medical instruments and major industrial and utility plants. These systems are critical to human life and need to be held to the highest standards of performance through formal certification procedures. Improving the quality and robustness of these systems is paramount to their widespread adoption.
Domain Specific Languages in Groovy
Domain Specific Languages in Groovy demonstrates how Groovy shines when it comes to domain specific languages.
About Domain Specific Languages
A Domain Specific Languages[1] (DSL) is a language tailored to describe a part of a specific domain. An example of a DSL are regular expressions[2]. Regular expressions provide a language that allow a user to specify which strings are accepted. Formally the domain for regular expression are finite-state machines[3] that accept strings. A regular expression describes a finite-state machine.
A DSL can enhance productivity enormously. By providing an abstraction over a specific domain, DSL’s allow a user to be more expressive. This expressiveness can cut the development time. A DSL also bridges the communication gap between a developer and a domain expert. The book Domain-specific Languages[4] by Martin Fowler and Rebecca Parsons is a great exposition about the subject.
About Groovy
Groovy[5] is a dynamic language running on the Java Virtual Machine (JVM). It takes the power of the JVM and provides a modern programming language for it. Groovy is inspired by successful languages like Python and Ruby. It rids most of the tedious boilerplate from Java code, replacing it with powerful primitives. You can try Groovy in your browser at http://groovyconsole.appspot.com/.
DSL’s in Groovy
Groovy uses a lot of domain specific languages. A notable example is the MarkupBuilder[6]. This class provides a DSL for the creation of xml. For example, the following code
new MarkupBuilder().root {
a( a1:'one' ) {
b { mkp.yield( '3 < 5' ) }
c( a2:'two', 'blah' )
}
}
will produce
<root>
<a a1='one'>
<b>3 < 5</b>
<c a2='two'>blah</c>
</a>
</root>
Custom DSL
Groovy allows the introduction of custom DSLs. Groovy provides a BuilderSupport[7] class. By extending this class a DSL like the MarkupBuilder can be created. We will demonstrate the use of BuilderSupport with the following example.
Let’s assume that we have a Robot. The robot is controlled via the executeCommand method. The executeCommand method accepts command codes. There are three of them 0x37, 0x51 and 0x88 with the following interpretation.
| Code | Command |
| 0×37 | Move Forward |
| 0×51 | Turn Left |
| 0×88 | Turn Right |
It would be tedious to perform complex movements with this robot. Multiple calls to the executeCommand method, all strung together, are necessary to do something trivial as navigate around a room. Instead, one would rather say something like.
do(4) {
forward()
left()
}
We can start bridging the syntactic gap by introducing a few auxiliary classes. The following class diagram shows the participants. It combines the composite[8] pattern with the visitor[9] pattern.
The contract of the Program interface is to execute itself with a provided visiting Robot. There are two concrete programs types. There are BasicPrograms, one for each command, i.e. ForwardProgram, LeftProgram and RightProgram. These Programs execute the corresponding command on the provided Robot. The other concrete Program is the DoProgram. The DoProgram is composed of other Programs. When a DoProgram is asked to execute with a Robot, it asks it’s component Programs in turn to execute with the Robot.
The Program interface and its implementations help to express the intention of a user of the Robot. But this convenience comes at a price. There is a lot of boilerplate code necessary to express a program to navigate the robot around a room.
DoProgram program = new DoProgram(4) program.add(new ForwardProgram()) program.add(new LeftProgram())
This is where DSL’s step in.
ProgramBuilder
We will now use the power of BuilderSupport[7] to go the extra mile and close the syntactic gap. We will use BuilderSupport to create a ProgramBuilder class.
The BuilderSupport class has five abstract methods. These methods are subdivided in two categories. On the one hand there are various createNode methods. On the other hand is the setParent method.
The createNode methods only vary in their signature. The all have a name parameter in common. The createNode methods can also sport an value parameter, an attributes parameter, both parameters or no extra parameter. We chained the various methods to a single method, so we will focus on the createNode(String name) method.
The various createNode methods are called when a method is executed which is not defined. The name parameter is set to the missing method name. For example, in the following code
new ProgramBuilder().forward()
the createNode method is called with the name parameter set to "forward". A createNode method should return an object. In this case it would return a ForwardProgram.
The setParent(Object parent, Object child) method is called when a missing method is called with a closure[10]. First the createNode method should return an object. This object will act as parent parameter for the subsequent calls to createNode from the closure. I.e. every time a createNode method is called, the returned object is the child parameter in a call to setParent.
A code example should clear things up. The call sequence of the following code is determined.
ProgramBuilder b = new ProgramBuilder()
b.do() {
b.forward()
}
The call sequence will be: createNode("do"), createNode("forward") followed by a call to setParent(parent,child) where parent is the return value of the first call to createNode and child is the return value of the second call to createNode. In this example createNode("do") would return a DoProgram, createNode("forward") would return a ForwardProgram and setParent(parent,child) would call parent.add(child).
By using the various createNode method on can imagine that the following code can be used to navigate a Robot around a room. If you would like to look into the specifics the code can be found at GitHub.
ProgramBuilder b = new ProgramBuilder()
Program program = b.do(4) {
b.forward()
b.left()
}
Robot robot = new Robot()
program.executeWith(robot)
Conclusion
Groovy offers ample opportunities to introduce domain specific languages in a project. The BuilderSupport class is a great tool to create domain specific languages with. Domain specific languages can bridge the communication gap between a domain expert and a developer.
References
- http://en.wikipedia.org/wiki/Domain-specific_language
- http://en.wikipedia.org/wiki/Regular_expression
- http://en.wikipedia.org/wiki/Finite-state_machine
- http://martinfowler.com/books.html
- http://groovy.codehaus.org/
- http://groovy.codehaus.org/api/groovy/xml/MarkupBuilder.html
- http://groovy.codehaus.org/api/groovy/util/BuilderSupport.html
- http://en.wikipedia.org/wiki/Composite_pattern
- http://en.wikipedia.org/wiki/Visitor_pattern
- http://en.wikipedia.org/wiki/Closure_(computer_science)
GraniteDS and AIR for mobile
Geplaatst door Walter Treur in Flex / AIR, iPhone/ iPad, java, mobility, technical op 5 september 2011
In this article I will briefly show how to resolve some obstacles I came across when I developed my first application with AIR for mobile and GraniteDS. The most noteworthy reason of using AIR to create mobile applications is of course the multi-platform deployment using a single codebase. Furthermore, with Granite you are able to disclose the services of an existing Java backend to a mobile platform without significant changes to the backend. This offers great potential for enterprises who are struggling with the fragmented mobile market and don’t want to completely rewrite their existing Java backend.
I will assume you have some familiarity with AIR for mobile and Granite. It’s mostly the same as for Flex but there are some things you have to take into account.
1. Get the right version of Granite
The latest version of Granite is 2.2.1 GA. However, in the most recent version of AIR and Flex Adobe made some changes in the API which breaks backwards compatibility for some features of Granite. Therefore this release of Granite won’t work using the newest SDK. Refer to this post on the Granite form for more info on how to make these changes yourself. If you don’t want be bothered with building Granite yourself just download this version of GraniteDS to get started immediately.
2. Connecting to the right server
A problem for AIR applications in general (both desktop and mobile) is setting the right server settings. It is quite simple when running within the browser: The server address is changed with a single reconfiguration of the swf-file and all clients are using the new address on a browser refresh. With AIR it is a bit different and you’re not always at liberty to ‘hardcode’ the service settings in the AIR distribution package.
Granite offers a method for dynamic server configuration using the server initializer component:
Tide.getInstance().addComponentWithFactory( "serviceInitializer", DefaultServiceInitializer, { contextRoot: '/my-app', serverName: “10.0.0.1”, serverPort: “8080” });
Note that once a connection is made, it is not possible to reconnect with another configuration, because the service initializer is only used once. You have to restart the application to enable the new connection settings or reset Tide’s RemoteObject. Unfortunately Tide’s API doesn’t support this reset. I came up with a small workaround which requires you to extend the EJB class with an extra reset method with the following body:
public class Ejb extends org.granite.tide.ejb.Ejb { /** * Reset the Tide Connection to allow new server settings */ public function resetConnection():void { if (_ro) { _ro.disconnect(); } _ro = null; } }
This method resets Tide’s RemoteObject so the next remote call will force a reinitialization using the current settings of serviceInitializer. Refer to Granite’s issue tracker or forum thread for more details.
3. Automatic logout
Applications running on mobile platforms are always susceptible to unpredictable interruptions. For example when a phone call or text is received. Mobile AIR applications provide a deactivate event which is dispatched when the application is halted somehow. The application I wrote was using Tide’s Identity class for user login. Therefore I added an event handler to automatically logout the user and push the LoginView on top of the navigator stack:
private function deactivateHandler(event:Event):void { if (identity.loggedIn) { identity.logout(); } navigator.popAll(); // Purge the navigator history to disable back button usage navigator.pushView(LoginView); }
4. Build, build, build!
This isn’t directly related to Granite or AIR for mobile. But since they can both be used for enterprise scale applications I thought I’d mention it shortly: Make sure you have a proper build script. Now, I’ve got an example from Chris Black which provides a good starting point. I’ve only added the metadata compiler options required for Tide and of course a reference to the Granite libraries and generated Actionscript classes.
<mxmlc ... > <!-- .... --> <!-- location of generated as classes with gas3 --> <source-path path-element="${gen.src.dir}" /> <compiler.library-path dir="${basedir}/libs" append="true"> <include name="granite-essentials.swc" /> <include name="granite.swc" /> </compiler.library-path> <keep-as3-metadata name="Bindable" /> <keep-as3-metadata name="ChangeEvent" /> <keep-as3-metadata name="Destroy" /> <keep-as3-metadata name="Id" /> <keep-as3-metadata name="In" /> <keep-as3-metadata name="Inject" /> <keep-as3-metadata name="Managed" /> <keep-as3-metadata name="ManagedEvent" /> <keep-as3-metadata name="Name" /> <keep-as3-metadata name="NonCommittingChangeEvent" /> <keep-as3-metadata name="Observer" /> <keep-as3-metadata name="Out" /> <keep-as3-metadata name="PostConstruct" /> <keep-as3-metadata name="Transient" /> <keep-as3-metadata name="Version" /> </mxmlc>
One plus one
I can imagine one must be thinking: ‘Everyone could have figured that out!’ And I totally agree, because that’s exactly what this article is about. With some experience with Flex, a developer can write a mobile application on top of a Java EE backend. It doesn’t take much to utilize an existing backend from a mobile platform. Since the latest release of AIR the performance for iOS and Android is pretty good and together with the Granite Enterprise Platform the barrier to emerge an enterprise application to a mobile platform has become much lower.
When MDE does not reduce effort
Geplaatst door Andriy Levytskyy in MDD, Uncategorized op 11 augustus 2011
While effort reduction and quality increase are both commonly recognized benefits of MDE, the former particularly has become its trademark, thanks to numerous generative uses in model-driven software development (MDSD). Examples include generation of code and configurations from models written in UML, DSLs and XML.

Figure: The effort in MDE approach with partial manual coding (adapted from [1])
The generative MDE automates well defined routine activities. An effective metric of depicting economical benefit thereof is effort. The above figure illustrates effort reduction due to automation and reuse in an MDE approach with partial manual coding. Of cause, the generative MDE improves quality as well: error reduction, enforced architecture conformance, and up-to-date documentation are common factors that have positive effect on software quality. But usually these are considered as icing on the cake that is effort reduction. In my experience this perspective on the economical value of MDE is common among both customers and MDE professionals. The perspective can be summarized as “the same with less”.
More with the same
Recently a client tasked me together with its domain experts to assess benefits of applying MDE to a difficult process within the organization. Having analyzed the before and after situations, we came up with estimated economical benefit expressed in effort savings. The estimate was hard to quantify, but “should” have been OK. Although I wanted to share this optimism, I felt that in practice the effort saving would be negligible if not even negative. This paradox was due to the fact that the largest activity in the problem domain was inherently creative and exploratory.
In the figure, the output of a single exploration in this activity is shown as intermediate result, corresponding to line ad. As the figure suggests, code generation directly from the output is not possible (this happens further downstream in development). You may have noticed that the modelling curve rises more steeply towards point a. This rise occurs because modelling requires increased level of domain understanding and more information is needed by semantically rich operations, such as simulation, verification, code generation (eventually), etc. On the other hand, the figure shows effort reduction indicated by distance cd, which is the result of providing end users with proper abstractions, faster access to right knowledge, separation of concerns, DRY modelling, maintained consistency and integrity.
While working efficiency per exploration is likely to increase (compare ab and cd), the leading concern is quality of the output. Here benefits are early detection of design errors, deep exploration of design choices, better communication and documentation, maximized reuse of domain-specific platforms in further development. Moreover, the domain experts noted that any saved effort would be re-invested in more alternative explorations in search of a more optimal output. This increased number of explorations, is likely to balance out any savings due to higher efficiency.
With these insights, economical benefits were expressed with quality metrics and linked to different business goals than initially thought.
Conclusion
The described MDE assessment targets a highly creative engineering activity that explores alternative choices. In extreme case, the main benefit is not effort reduction, but increased product and process quality. The icing on the cake is that processable models can open opportunities for generative uses as well.
In my experience, such and certainly less extreme quality-driven cases are not exotic. In recent years, quite a few MDE projects I’ve participated in, had benefits strongly linked to quality improvement. What are your MDE experiences with creative activities? What were the economical benefits and how were they conveyed?
References
[1] Thomas Stahl, Markus Voelter, Krzysztof Czarnecki. “Model-Driven Software Development: Technology, Engineering, Management”. Wiley; 1 edition (May 19, 2006)
How to build a custom model interpreter in a model-driven way
Geplaatst door Andriy Levytskyy in MDD, Uncategorized op 20 juli 2011
Blogs by Johan den Haan, Stefano Butti and Jordi Cabot raised interesting discussions about code generation (CG) and model interpretation (MI). One observation I took from these discussions is that MI is still little known. Previously I demonstrated operation of a custom-made model interpreter for a so-called weighbridge domain. Today I would like to share my experience of building this interpreter in a model-driven way.
MDE Approach
Two main choices underpin the process and technology used to develop the interpreter:
- Execution semantics of the interpreter is defined within the problem domain itself (weighbridge in this case), without translating it to another domain (e.g. .Net or Java) as it is the case with CG. Such definition of semantics is also known as operational semantics. The advantage is reduction of development complexity: out of at least 2 domains needed for CG, only one and the more abstract domain is sufficient.
- Operational semantics is defined within an MDE framework. This enables customization of modeling language for problem domains besides that of the weighbridge example. Moreover, transformation capabilities are used to define operational semantics.

Figure 1: Domain-specific, nested interpretation (DSNI) MDE framework
Figure 1 shows the MDA framework [1] after it has been adapted to reflect the above mentioned choices. (If you are confused between MDA and MDE, you might find this article useful.) In contrast to MDA, there is no PIM or PSM model, but single computational independent model (CIM) written in DSL. CIM is both source and target of Transformation Tool. Transformation Tool carries out transformation classified as same language, same model. Transformation Definition defines operational semantics. It is not important if Transformation Definition Language (TDL), extends the Metalanguage as in MDA or is customizable by means of meta-specification. Therefore TDL is omitted from the framework and TDL selection criteria are defined instead (see below). Finally, new concept System Context is connected to Transformation Tool. This is due to the fact that interpretation as system exhibits external behavior through communication with other systems.
This approach can be described as nested interpretation, where a domain-specific interpreter is executed (nested) by a generic interpreter. From this perspective, Transformation Tool assumes the role of a generic interpreter and execution of Transformation Definition fills in the role of the domain-specific interpreter.
TDL Selection Criteria
Selection criteria for transformation definition language are:
- declarative modeling
- support for domain-specific notation
These criteria help to reduce development complexity and improve communication with problem domain experts.
Selected MD Technology
AToM3 is a free language workbench written in Python and under development at the Modelling, Simulation and Design Lab (MSDL) in the School of Computer Science of McGill University. The workbench closely matches the DSNI framework and meets the TDL selection criteria.
In AToM3, DSLs and models are described as graphs. From a language specification written in the metalanguage (ER formalism), AToM3 generates a tool to visually manipulate (create and edit) models written in the specified DSL. Model transformations are performed by graph rewriting. The transformations themselves can thus be declaratively expressed as graph-grammar models. However, AToM3 provides no communication infrastructure as needed by the framework.
Proof of Concept
As demonstration, a language specification for the weighbridge domain was defined (see sections domain and weighbridge DSL here) and graph rewriting was used to model operational semantics (see below). Source code of AToM3 itself, being written in Python, was extended to support web services for the communication purpose.
Operational Semantics
As blueprint for operational semantics of the interpreter, we took πDemos [2], a small process-oriented discrete event simulation language. There is a number of πDemos events that change state of a weighbridge system. For each such event, [2] defined the transitions induced on system state. While the original used functional programming language, this work uses graph rewriting and a graph grammar (GG) rule is defined per event.
| Priority | GG Rule | Description |
|---|---|---|
| 50 | importProcess | Adds an external vehicle to EL |
| 25 | removeProcess | Deletes a vehicle that has completed its todos (events) |
| 40 | newR | Creates a new weighbridge |
| 40 | decP | Creates a new vehicle class |
| 40 | newP | Creates a vehicle from a vehicle class |
| 40 | getR | Acquires a non-busy weighbridge |
| 40 | blockProcess | Blocks a vehicle acquiring a busy weighbridge |
| 40 | promoteProcess | Unblocks a delayed vehicle |
| 40 | useR | Moves a vehicle on a weighbridge until service is complete |
| 30 | releaseResource | Moves a served vehicle from a weighbridge to EL |
| 41 | putR | Releases an occupied weighbridge |
Table 1: Graph grammar rules of weighbridge events
Table 1 lists the minimum set of required events and their corresponding GG rules. Execution of such rules needs to be globally orchestrated through proper sequencing. The rules, together with execution sequencing, form an operational semantics model of the interpreter.
For complete description of the model, please refer to [3]. In the following, we present a detailed description of an example rule, followed by the execution sequencing model.
Example GG Rule

a) Left-hand side (LHS)

b) Right-hand side (RHS)
Figure 2: Subgraphs of the promoteProcess rule
Rule promoteProcess releases a busy weighbridge (bluish box in Figure 2a) that delays at least one vehicle (yellow box labelled 5). In the new state, the weighbridge remains busy and the blocked vehicle (5) is removed from the head of queue Delay and inserted in waiting queue EL.
The rule is executed if:
- The left-hand side (LHS) shown in Figure 2a is matched in the host graph (the CIM model).
- Associated condition is true: the weighbridge in LHS is the one referred to in the imminent event putR (a todo) in the body (a todo list) of the first vehicle (label 21) in queue EL.
If the above holds, the matched part of the CIM model is substituted with the right-hand side (RHS) shown in Figure 2b. Note new objects are labelled 10, 11, 13. The entities and relationships in RHS are initialized as follows:
- Objects copied from LHS keep all their properties.
- Imminent event putR (a todo) of the current vehicle (21) is completed.
- All properties of blocked vehicle (5) are copied to vehicle (10).
Execution Sequencing
The execution sequencing is based on the next-event approach: Next event to execute is always the imminent event in the body of the current vehicle. Informally, the operational semantics of execution sequencing is as follows: if EL is empty, interpreter idles until at least one vehicle is inserted in EL. Such vehicle becomes current. If the body of the current vehicle is empty then it is removed from EL and EL is examined again. Otherwise, interpreter executes a GG rule corresponding to the imminent event of the current and EL is examined again. Note that whenever interpreter is idle, EL is being updated with new vehicles that meanwhile might have arrived from system context.
The execution sequencing is implemented by organizing GG rules into groups, each group having its own base priority. These groups, in the descending order of priority are: vehicle removal, weighing activities and vehicle arrival. Within a group, each rule is assigned a relative priority. If pattern matching of two and more rules within a group is deterministic on the basis of LHSs and conditions, then these rules can share the same priority level. Example rule priorities are given in Table 1.
Conclusion
The demonstrated development approach is characterized by a very high level of abstraction, direct involvement of problem domain experts and absence of software development. All these factors contribute to fast development times: The lead time of this one man project including research and development was 3 weeks. Admittedly, tests of the produced model interpreter showed noticeable performance penalty due to 1) repurposing of MD technology that was not designed for use as interpreter and 2) the overhead introduced by nested interpretation. In my opinion there is much room for performance improvement and I am wondering if MDE can prove useful again. An important message from this experience is that model interpretation does not have to be prerogative of big commercial tools and can get closer to code generation in terms of accessibility.
References
[1] Anneke G. Kleppe, Jos Warmer and Wim Bast. “MDA Explained: The Model Driven Architecture: Practice and Promise”. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, April 2003.
[2] Graham Birtwistle and Chris Tofts. “An operational semantics of process-oriented simulation languages: Part 1 πDemos”. ACM Transactions on Modeling and Com- puter Simulation, 10(4):299–333, December 1994.
[3] Andriy Levytskyy. “Model Driven Construction and Customization of Modeling & Simulation Web Applications”. PhD thesis, Delft University of Technology, Delft, The Netherlands, January 2009.



























Nowadays DSLs seem to be everywhere. If 5 years ago DSL was an exotic word in the UML dominated model driven world, today it has established a strong following. A recent research on how MDE is used in industry [1], indicated that nearly 40% of respondents use in-house DSLs (alongside of other languages). The in-house qualifier is important, as these DSLs are very likely to be developed with metamodels. In such cases, a quality benchmark may help language development. Yet, it is not easy to find such a benchmark, let alone one that is widely accepted.