Projet

Général

Profil

SpeADL Minus Reference » Historique » Version 52

Anonyme, 16/10/2014 09:48

1 50 Anonyme
h1. SpeADL⁻ Reference Guide
2 1 Anonyme
3 2 Anonyme
{{>toc}}
4 1 Anonyme
5 44 Anonyme
In SpeADL, a subset of abstractions are provided to define traditional component-oriented architectures.
6
This subset of SpeADL is sometimes called SpeADL⁻ (pronounced SpeADL Minus).
7 45 Anonyme
With it, it is possible to define software components and compositions of components, called composites, implemented in Java.
8
A strong link between definition and implementation is kept by relying on an Eclipse plugin and automatic code generation.
9 1 Anonyme
10 48 Anonyme
A component is made of two elements: a definition using SpeADL and an implementation using Java.
11 45 Anonyme
The SpeADL definition acts a type declaration but can also describe a composition of components connected together.
12 48 Anonyme
13 51 Anonyme
For the implementation of components, the reader can refer to the [[SpeADL Minus Java Reference|Java for SpeADL⁻ reference guide]].
14 1 Anonyme
15 35 Anonyme
h2. Terminology
16
17
The reader can refer to the [[MAY Terminology]] document to get an overview of the different terms used in SpeADL.
18
19 1 Anonyme
h2. Namespaces
20
21 46 Anonyme
A namespace plays the same role as a package in Java except that it is not tied to a particular directory hierarchy.
22 5 Anonyme
23 4 Anonyme
h3. Keyword
24
25 31 Anonyme
Namespaces are declared using the keyword *namespace*.
26 1 Anonyme
27 4 Anonyme
h3. Details
28
29 52 Anonyme
In a SpeADL file, there can be many as namespaces as wanted.
30
They can also be nested ones.
31
Hence a namespace does not have to follow the name of the directory it is located in (as it is the case in Java).
32 4 Anonyme
33
h3. Example
34
35 1 Anonyme
<pre>
36
namespace simple {
37
38
	namespace things {
39 19 Anonyme
40 1 Anonyme
	}
41
}
42
43 19 Anonyme
namespace simple.things {
44
45
}
46
47 1 Anonyme
namespace simple.stuffs {
48 19 Anonyme
49 1 Anonyme
}
50
</pre>
51
52
h2. Imports
53
54 20 Anonyme
As in Java, it is possible to import existing names to avoid referring to them with their fully qualified name (i.e., including their package or namespace).
55 1 Anonyme
56 5 Anonyme
h3. Keyword and Role
57
58
As in Java, this is done with the keyword *import*.
59
60
h3. Details
61
62 49 Anonyme
The namespace of components are also considered for component definitions.
63 5 Anonyme
64 33 Anonyme
The imports can be automatically handled and reorganised in Eclipse using the *Ctrl-Shift-O* shortcut as with the Java editor.
65 5 Anonyme
66 33 Anonyme
They are always situated at the top of a SpeADL file.
67 5 Anonyme
68
h3. Example
69
70 1 Anonyme
The syntax is similar to Java:
71
<pre>
72
import java.util.Collection
73
import java.util.*
74
import simple.stuffs.*
75
</pre>
76
77 33 Anonyme
h2. Component Definition
78 1 Anonyme
79 33 Anonyme
A software component is made of a definition and an implementation: an instance can then be created from the implementation.
80
A component definition has provided and required ports, as well as parts which are themselves components.
81 1 Anonyme
A part is structurally similar to a class member in Java.
82 5 Anonyme
For each required port of a part, there must be a binding declaring what is providing the required port.
83 1 Anonyme
84
h3. Keywords
85
86 33 Anonyme
A component definition is declared with the keyword *component* followed by a name starting with a capital letter.
87
It must be unique in its namespace.
88 1 Anonyme
89 43 Frédéric Migeon
The keywords *provides* and *requires* are used to declare, respectively, provided and required ports. They are followed by a name (unique in the component and without capital letter) and an interface name separated by the character *: *.
90 1 Anonyme
It takes the form _provides name: Interface_ or _requires name: Interface_, where _Interface_ is a Java type.
91
92 31 Anonyme
The keyword *part* is used to declare a part in a component.
93 50 Anonyme
It is followed by a name for the part (unique in the component and without capital letter) and the name of a component definition separated by the character *: *.
94 31 Anonyme
It takes the form _part name: ComponentName_.
95 5 Anonyme
96 33 Anonyme
For each part, bindings are used to declare for each of its required port what is fulfilling the requirement.
97
It is done using the keywords *bind* and *to* in the form _bind ...1 to ...2_ where _...1_ is the name of the required port of the part and _...2_ is a reference to a port available in the component containing the part.
98 5 Anonyme
Such a reference can either be:
99 31 Anonyme
* To another part's provided port, taking the form _bind req to name.port_.
100
* A provided or a required port of the current containing component, taking the form _bind req to port_.
101 5 Anonyme
102 31 Anonyme
A delegation is used to declare for the provided port of a component what other port will provides its implementation.
103 33 Anonyme
It is done using the keyword * =  * followed by a reference to a port available in the current containing component (as with bindings).
104 31 Anonyme
It takes the form _provides name: Interface = name.port_ or _provides name: Interface = port_.
105 5 Anonyme
106
h3. Details
107
108 31 Anonyme
An interface is understood as a Java interface, i.e., a collection of methods, and must be visible in the classpath of the Java project.
109 5 Anonyme
110 33 Anonyme
All the required of a part must be bound for the component definition to be valid.
111 1 Anonyme
112 5 Anonyme
h3. Example
113
114 50 Anonyme
Component definitions:
115 1 Anonyme
<pre>
116
import my.interfaces.*
117
118
namespace simple.stuffs {
119
120
	component MySimpleComponent {
121
		provides p1: AnotherJavaInterface
122
	}
123
124
	component MyBeautifulComponent {
125
		provides portName: AJavaInterface
126
		requires anotherPortName: AnotherJavaInterface
127
	}
128
129 5 Anonyme
	component MyComplexComponent {
130
		
131
		provides p1: AnotherJavaInterface
132
		provides p2: AnotherJavaInterface = s.p1
133
		requires p3: AnotherJavaInterface
134 1 Anonyme
135 5 Anonyme
		part b1: MyBeautifulComponent {
136
			bind anotherPortName to s.p1 
137
		}
138 1 Anonyme
139 5 Anonyme
		part b2: MyBeautifulComponent {
140
			bind anotherPortName to p1
141
		}
142
143
		part b3: MyBeautifulComponent {
144
			bind anotherPortName to p3
145
		}
146
		
147
		part s: MySimpleComponent
148
		
149
	}
150
}
151
</pre>
152
153
Interface definition in Java:
154 1 Anonyme
<pre>
155
package my.interfaces;
156
157
public interface AJavaInterface {
158
  public String aMethod(Integer param1);
159
}
160
</pre>
161
162
<pre>
163
package my.interfaces;
164
165
public interface AnotherJavaInterface {
166
	public Integer test();
167
}
168
</pre>
169
170 39 Anonyme
h2. Component Specialisation
171 16 Anonyme
172
In SpeADL, a basic mechanism exists for specialisation of components.
173
174
h3. Keyword
175
176 50 Anonyme
When declaring a component definition, after the name, the keyword *specializes*, followed by a reference to another component name, can be used.
177 1 Anonyme
178 16 Anonyme
h3. Details
179
180 33 Anonyme
An implementation of a specialising component can be used in place of the implementation of the specialised component.
181
Only the specialising component needs to be implemented: its implementation will contain all the provided ports of the specialisation hierarchy as well as the parts of the specialising component.
182
183
The specialisation rules are as follow:
184 1 Anonyme
* A component can specialise only a component without parts (i.e., only a pure definition with provided and required ports).
185 31 Anonyme
* A component can override provided ports (while respecting the interface or specialising it) to define delegation.
186 28 Anonyme
* A component can add provided ports.
187 33 Anonyme
* A component CAN'T add required ports (for obvious reason: the specialising component wouldn't be usable in a configuration where the specialised component is used because some of its ports won't be bound).
188 30 Anonyme
189 16 Anonyme
h3. Examples
190
191
<pre>
192
namespace simple.stuffs {
193 26 Anonyme
	component S specializes MySimpleComponent {
194
		provides p2: AnotherJavaInterface
195 16 Anonyme
	}
196
}
197
</pre>
198
199 15 Anonyme
h2. Type Parameters
200
201 33 Anonyme
As in Java, it is possible to exploit type parameters (also called generics) when declaring and referencing components, as well as in the interfaces of the ports.
202 1 Anonyme
203
h3. Keywords
204
205 34 Anonyme
Type parameters are enclosed between *[ * and * ]* (contrary to Java where * <* and *> * are used).
206 1 Anonyme
207
A type parameter can be declared only in a component definition, just after the name declaration.
208 33 Anonyme
It has a unique name, a capital first letter, and can be constrained using the keyword *extends* and the name of a Java class it must be a subclass of.
209 1 Anonyme
210 33 Anonyme
A type parameter can be used as an argument when referencing a component by its name, in a part or in a specialisation declaration.
211 1 Anonyme
It must respect the type parameters declared in the referenced component.
212
213 33 Anonyme
A type parameter can also be used as an argument when referencing an interface by its name in a port declaration.
214 1 Anonyme
Again it must respect the type parameters declared in the interface.
215
216
h3. Details
217
218
The possibilities of expressiveness are equivalent to what can be done in Java.
219
220
The implementation can either keep the type parameters abstract as in the definition, or can concretise them as long as it respects the type parameter declaration.
221
222
Of course interface and component definition references can be parametrised with existing concrete classes.
223
224
h3. Example
225
226
<pre>
227
namespace simple.stuffs {
228
	component ParameterisedComponent1[T extends Number] {
229
		
230
		provides p1: java.util.concurrent.Callable[T]
231
		provides p2: java.util.concurrent.Callable[String]
232
	}
233
	
234
	component ParameterisedComponent2[T1,T2 extends Number] {
235
		
236
		part p1: ParameterisedComponent1[T2] {
237
			
238
		}
239
		
240
		part p2: ParameterisedComponent1[Integer] {
241
			
242
		}
243
		
244
	}
245
}
246
</pre>