Projet

Général

Profil

SpeADL Minus Reference » Historique » Version 64

Anonyme, 16/10/2014 10:08

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 58 Anonyme
A component definition has provided and required ports. 
77 59 Anonyme
Optionally,  a composite component definition contains parts that are themselves components.
78 1 Anonyme
79
h3. Keywords
80
81 33 Anonyme
A component definition is declared with the keyword *component* followed by a name starting with a capital letter.
82 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.
83 1 Anonyme
84 57 Anonyme
The keywords *provides* and *requires* are used to declare, respectively, provided and required ports.
85
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 60 Anonyme
The keyword *part* is used to declare a part in a composite component definition
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 60 Anonyme
For a composite component definition to be considered valid, all the required ports of its parts must be bound.
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 61 Anonyme
	component MyCompositeComponent {
126 5 Anonyme
		
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 62 Anonyme
  public String anotherMethod();
156 1 Anonyme
}
157
</pre>
158
159
<pre>
160
package my.interfaces;
161
162
public interface AnotherJavaInterface {
163
	public Integer test();
164
}
165
</pre>
166
167 39 Anonyme
h2. Component Specialisation
168 16 Anonyme
169
In SpeADL, a basic mechanism exists for specialisation of components.
170
171
h3. Keyword
172
173 63 Anonyme
When declaring a component definition, after the name, the keyword *specializes*, followed by component definition name, can be used.
174 1 Anonyme
175 16 Anonyme
h3. Details
176
177 33 Anonyme
An implementation of a specialising component can be used in place of the implementation of the specialised component.
178
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.
179
180
The specialisation rules are as follow:
181 63 Anonyme
* A component can specialise only a component without parts.
182
* A component can override provided ports (while respecting the interface constraint) to define delegation.
183 28 Anonyme
* A component can add provided ports.
184 64 Anonyme
* A component CAN'T add required ports.
185 1 Anonyme
186 30 Anonyme
h3. Examples
187 16 Anonyme
188 63 Anonyme
Specialising, adding a provided port and overriding a provided port:
189 16 Anonyme
<pre>
190 1 Anonyme
namespace simple.stuffs {
191 16 Anonyme
	component S specializes MySimpleComponent {
192 26 Anonyme
		provides p2: AnotherJavaInterface
193 63 Anonyme
		provides p1: AnotherJavaInterface = p2
194 16 Anonyme
	}
195
}
196
</pre>
197
198 15 Anonyme
h2. Type Parameters
199
200 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.
201 1 Anonyme
202
h3. Keywords
203
204 34 Anonyme
Type parameters are enclosed between *[ * and * ]* (contrary to Java where * <* and *> * are used).
205 1 Anonyme
206
A type parameter can be declared only in a component definition, just after the name declaration.
207 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.
208 1 Anonyme
209 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.
210 1 Anonyme
It must respect the type parameters declared in the referenced component.
211
212 33 Anonyme
A type parameter can also be used as an argument when referencing an interface by its name in a port declaration.
213 1 Anonyme
Again it must respect the type parameters declared in the interface.
214
215
h3. Details
216
217
The possibilities of expressiveness are equivalent to what can be done in Java.
218
219
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.
220
221
Of course interface and component definition references can be parametrised with existing concrete classes.
222
223
h3. Example
224
225
<pre>
226
namespace simple.stuffs {
227
	component ParameterisedComponent1[T extends Number] {
228
		
229
		provides p1: java.util.concurrent.Callable[T]
230
		provides p2: java.util.concurrent.Callable[String]
231
	}
232
	
233
	component ParameterisedComponent2[T1,T2 extends Number] {
234
		
235
		part p1: ParameterisedComponent1[T2] {
236
			
237
		}
238
		
239
		part p2: ParameterisedComponent1[Integer] {
240
			
241
		}
242
		
243
	}
244
}
245
</pre>