Projet

Général

Profil

SpeADL Minus Reference » Historique » Version 49

Anonyme, 15/10/2014 17:30

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