Projet

Général

Profil

SpeADL Minus Reference » Historique » Version 58

Anonyme, 16/10/2014 09:55

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