Projet

Général

Profil

SpeADL Minus Reference » Historique » Version 55

Anonyme, 16/10/2014 09:53

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 54 Anonyme
The syntax is similar to Java: it uses the keyword *import*.
59 5 Anonyme
60
h3. Details
61
62 53 Anonyme
Imports are always situated at the top of a SpeADL file.
63
The namespace of component definitions can also be imported.
64 5 Anonyme
65
h3. Example
66 1 Anonyme
67
<pre>
68
import java.util.Collection
69
import java.util.*
70
import simple.stuffs.*
71
</pre>
72
73 33 Anonyme
h2. Component Definition
74 1 Anonyme
75 33 Anonyme
A software component is made of a definition and an implementation: an instance can then be created from the implementation.
76
A component definition has provided and required ports, as well as parts which are themselves components.
77 1 Anonyme
A part is structurally similar to a class member in Java.
78 5 Anonyme
For each required port of a part, there must be a binding declaring what is providing the required port.
79 1 Anonyme
80
h3. Keywords
81
82 33 Anonyme
A component definition is declared with the keyword *component* followed by a name starting with a capital letter.
83 55 Anonyme
The name must be unique in its namespace, but many components can be declared in the same namespace in the same SpeADL file.
84 1 Anonyme
85 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 *: *.
86 1 Anonyme
It takes the form _provides name: Interface_ or _requires name: Interface_, where _Interface_ is a Java type.
87
88 31 Anonyme
The keyword *part* is used to declare a part in a component.
89 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 *: *.
90 31 Anonyme
It takes the form _part name: ComponentName_.
91 5 Anonyme
92 33 Anonyme
For each part, bindings are used to declare for each of its required port what is fulfilling the requirement.
93
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.
94 5 Anonyme
Such a reference can either be:
95 31 Anonyme
* To another part's provided port, taking the form _bind req to name.port_.
96
* A provided or a required port of the current containing component, taking the form _bind req to port_.
97 5 Anonyme
98 31 Anonyme
A delegation is used to declare for the provided port of a component what other port will provides its implementation.
99 33 Anonyme
It is done using the keyword * =  * followed by a reference to a port available in the current containing component (as with bindings).
100 31 Anonyme
It takes the form _provides name: Interface = name.port_ or _provides name: Interface = port_.
101 5 Anonyme
102
h3. Details
103
104 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.
105 5 Anonyme
106 33 Anonyme
All the required of a part must be bound for the component definition to be valid.
107 1 Anonyme
108 5 Anonyme
h3. Example
109
110 50 Anonyme
Component definitions:
111 1 Anonyme
<pre>
112
import my.interfaces.*
113
114
namespace simple.stuffs {
115
116
	component MySimpleComponent {
117
		provides p1: AnotherJavaInterface
118
	}
119
120
	component MyBeautifulComponent {
121
		provides portName: AJavaInterface
122
		requires anotherPortName: AnotherJavaInterface
123
	}
124
125 5 Anonyme
	component MyComplexComponent {
126
		
127
		provides p1: AnotherJavaInterface
128
		provides p2: AnotherJavaInterface = s.p1
129
		requires p3: AnotherJavaInterface
130 1 Anonyme
131 5 Anonyme
		part b1: MyBeautifulComponent {
132
			bind anotherPortName to s.p1 
133
		}
134 1 Anonyme
135 5 Anonyme
		part b2: MyBeautifulComponent {
136
			bind anotherPortName to p1
137
		}
138
139
		part b3: MyBeautifulComponent {
140
			bind anotherPortName to p3
141
		}
142
		
143
		part s: MySimpleComponent
144
		
145
	}
146
}
147
</pre>
148
149
Interface definition in Java:
150 1 Anonyme
<pre>
151
package my.interfaces;
152
153
public interface AJavaInterface {
154
  public String aMethod(Integer param1);
155
}
156
</pre>
157
158
<pre>
159
package my.interfaces;
160
161
public interface AnotherJavaInterface {
162
	public Integer test();
163
}
164
</pre>
165
166 39 Anonyme
h2. Component Specialisation
167 16 Anonyme
168
In SpeADL, a basic mechanism exists for specialisation of components.
169
170
h3. Keyword
171
172 50 Anonyme
When declaring a component definition, after the name, the keyword *specializes*, followed by a reference to another component name, can be used.
173 1 Anonyme
174 16 Anonyme
h3. Details
175
176 33 Anonyme
An implementation of a specialising component can be used in place of the implementation of the specialised component.
177
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.
178
179
The specialisation rules are as follow:
180 1 Anonyme
* A component can specialise only a component without parts (i.e., only a pure definition with provided and required ports).
181 31 Anonyme
* A component can override provided ports (while respecting the interface or specialising it) to define delegation.
182 28 Anonyme
* A component can add provided ports.
183 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).
184 30 Anonyme
185 16 Anonyme
h3. Examples
186
187
<pre>
188
namespace simple.stuffs {
189 26 Anonyme
	component S specializes MySimpleComponent {
190
		provides p2: AnotherJavaInterface
191 16 Anonyme
	}
192
}
193
</pre>
194
195 15 Anonyme
h2. Type Parameters
196
197 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.
198 1 Anonyme
199
h3. Keywords
200
201 34 Anonyme
Type parameters are enclosed between *[ * and * ]* (contrary to Java where * <* and *> * are used).
202 1 Anonyme
203
A type parameter can be declared only in a component definition, just after the name declaration.
204 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.
205 1 Anonyme
206 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.
207 1 Anonyme
It must respect the type parameters declared in the referenced component.
208
209 33 Anonyme
A type parameter can also be used as an argument when referencing an interface by its name in a port declaration.
210 1 Anonyme
Again it must respect the type parameters declared in the interface.
211
212
h3. Details
213
214
The possibilities of expressiveness are equivalent to what can be done in Java.
215
216
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.
217
218
Of course interface and component definition references can be parametrised with existing concrete classes.
219
220
h3. Example
221
222
<pre>
223
namespace simple.stuffs {
224
	component ParameterisedComponent1[T extends Number] {
225
		
226
		provides p1: java.util.concurrent.Callable[T]
227
		provides p2: java.util.concurrent.Callable[String]
228
	}
229
	
230
	component ParameterisedComponent2[T1,T2 extends Number] {
231
		
232
		part p1: ParameterisedComponent1[T2] {
233
			
234
		}
235
		
236
		part p2: ParameterisedComponent1[Integer] {
237
			
238
		}
239
		
240
	}
241
}
242
</pre>