Projet

Général

Profil

SpeADL Reference » Historique » Version 27

Anonyme, 13/10/2014 17:28

1 1 Anonyme
h1. SpeADL Full Reference
2
3 27 Anonyme
{{>toc}}
4 4 Anonyme
5 20 Anonyme
In SpeADL, a set of abstractions are provided to describe [[SpeADL Minus Reference|typical component-oriented architectures]].
6 21 Anonyme
On top of these, SpeADL introduces additional abstractions that complete them in order to describe dynamic architectures, in particular for Multi-Agent Systems.
7
The motivations behind these abstractions are fully discussed in the "Ph.D. thesis":http://www.irit.fr/~Victor.Noel/PhD/Dissertation that led to the creation of MAY, here we stay at the user level.
8 1 Anonyme
9 21 Anonyme
The main idea with these abstractions is to define software components, called ecosystems, that are able to dynamically create other software components, called species, and to link such components to their ecosystem in a safe and controlled manner.
10 15 Anonyme
For example, one could define a Bank component containing a Database and that creates Account component which themselves requires access to the Database.
11 21 Anonyme
Or one could define a MAS component that creates Agent components (themselves architectured as desired) connected to simulated situated entities living in a common 2D environment.
12 1 Anonyme
13 25 Anonyme
With these abstractions, one can actually implement its own interconnection mechanism between the dynamically created components and their creating component.
14
This enables for example to cleanly and easily implement any needed interaction mechanism in a MAS when there exists no agent-oriented framework proposing it, to develop domain-specific relations between the agents and their environment or more generally to easily separate concerns (the agents architecture, the simulated agents, the communication) by composing them while explicitly taking into account the 1..N relation existing between an ecosystem and its species.
15 12 Anonyme
16 1 Anonyme
h2. SpeADL⁻
17
18
It is needed to understand the content of the [[SpeADL Minus Reference|SpeADL⁻ Reference Guide]] before reading the current document.
19
20 25 Anonyme
h2. Ecosystem and Species Definition
21 6 Anonyme
22 1 Anonyme
From an external point of view, an ecosystem is exactly similar to a component: it has provided ports that can be accessed and required ports that must be connected.
23 6 Anonyme
It has a name, can have type parameters and be a specialisation of another component.
24 1 Anonyme
It has an implementation in Java, it can be used as a part of another component (or ecosystem) or instantiated directly if it has no required ports.
25
26 15 Anonyme
Its only specificity is that it can contain what is called species, a special type of component class that can only be defined in an ecosystem.
27 1 Anonyme
Actually, a component is just an ecosystem without any species.
28 7 Anonyme
29 14 Anonyme
Species are to ecosystems what Java non-static inner classes are to Java classes: they are components class that can only be instantiated from within an ecosystem instance.
30 22 Anonyme
Because of this particular relation to ecosystems, species can access elements inside the ecosystem in two different ways:
31 12 Anonyme
* Directly to the parts and ports of the ecosystem.
32 15 Anonyme
* Indirectly through a special construct called _uses_ that enables to take into account the dynamic creation aspects of the species to:
33 1 Anonyme
** Build tailored ecosystem-species relations.
34 15 Anonyme
** Build tailored inter-species relations mediated by the ecosystem.
35 1 Anonyme
36 15 Anonyme
Uses are discussed [[SpeADL Full Reference#The Use Abstraction|below]].
37
38 9 Anonyme
h3. Keywords
39 1 Anonyme
40
An ecosystem class definition is declared with the keyword *ecosystem* followed by a name, optional type parameters and optional specialization.
41
Provided and required ports can be declared as with normal component classes with the keywords *provides* and *requires*.
42
Parts can be declared as with normal component classes with the keyword *part*.
43 25 Anonyme
A part can reference a typical component or an ecosystem.
44 12 Anonyme
45
A species is declared inside an ecosystem with the keyword *species* followed by a name starting with a capital.
46 25 Anonyme
It can't have type parameters but follows those of its ecosystem, and cannot specialise another component.
47
A species can have parameters (for initialisation) inbetween *( * and * )* and separated by *, *: they are of the form _name: Type, name2: Type2_.
48 15 Anonyme
Provided and required ports can be declared as with normal component classes with the keywords *provides* and *requires*.
49 17 Anonyme
Parts can be declared as with normal component classes with the keyword *part*.
50 15 Anonyme
51 25 Anonyme
Uses are declared with the keyword *use* as discussed [[SpeADL Full Reference#The Use Abstraction|below]].
52
53 1 Anonyme
h3. Details
54
55 15 Anonyme
Declaring a species means that an instance of the ecosystem  containing it will be able to create new instances of the species at runtime.
56 1 Anonyme
Such species will be considered strongly linked to the containing ecosystem instance that created them: this is a thus 1..N relation.
57
58
The bindings of the parts can point to ports inside the species, as with a normal component, but also to ports inside the ecosystem containing the species.
59 25 Anonyme
They can NOT point to other species of the ecosystem (for inter-species connection, one must exploit the use abstraction detailed [[SpeADL Full Reference#The Use Abstraction|below]]).
60 1 Anonyme
61
h3. Example
62
63
<pre>
64
namespace simple.ecos {	
65
	ecosystem MyFirstEco {
66
67 15 Anonyme
		species S(name: String) {
68 1 Anonyme
			provides p1: AJavaInterface = c.portName
69 15 Anonyme
			provides p2: AJavaInterface
70
			requires p3: AnotherJavaInterface
71 1 Anonyme
			
72 15 Anonyme
			part c: MyBeautifulComponent {
73 1 Anonyme
				bind anotherPortName to p3
74
			}
75
		}
76
	}
77
}
78
</pre>
79 15 Anonyme
80 25 Anonyme
h2. Ecosystem and Species Implementation
81 1 Anonyme
82 15 Anonyme
Implementing an ecosystem is similar to implementing a component.
83 26 Anonyme
The only difference is with the species: there are methods to implement to provide for an implementation of the species and there are methods that can be used to create instances of species from within the implementation of the ecosystem.
84 15 Anonyme
85 25 Anonyme
The idea is that the only way of instantiating a species is from within an ecosystem: if one needs to do it from the exterior of the component, some ports must be defined whose implementation does the actual species instantiation.
86 15 Anonyme
87
h3. Special Method to Implement
88
89
Each species *S* must be implemented by overriding a method called *S make_S()* where S is also the name of an static inner class of the ecosystem generated abstract class.
90 25 Anonyme
It means that in order to implement the method *make_S()*, it is necessary to extends the class S in any way desired.
91
The implementation of the species can either directly subclass S in an anonymous way in the *make_S()* method, be defined in its own file, or, as it is often done, defined as an inner class of the ecosystem.
92 15 Anonyme
This last possibility can be useful to access to some Java class member of the ecosystem class for example.
93
94
h3. Special Methods to Exploit
95 1 Anonyme
96 26 Anonyme
Each species *S* can be instantiated as many times as desired by calling the method *S.Component newS()* which will also take arguments for the parameters declared in the species.
97
This method is accessible only from within the ecosystem implementation, it can be done for example in the implementation of one of its provided ports or in its *start()* method.
98 15 Anonyme
99
From the implementation of the species, the required and provided ports as well as the parts can be accessed through the same methods as normal component class implementations: *requires()*, *provides()* and *parts()*.
100
On top of this, the required and provided ports, and the parts, of the ecosystem containing the species can be accessed respectively with *eco_requires()*, *eco_provides()* and *eco_parts*.
101
102 1 Anonyme
h3. Example
103 15 Anonyme
104
<pre>
105
package testpackage;
106
107
import my.interfaces.AJavaInterface;
108
import simple.ecos.MyFirstEco;
109 1 Anonyme
import simple.stuffs.MyBeautifulComponent;
110 15 Anonyme
111
public class MyFirstEco1 extends MyFirstEco {
112
113
	@Override
114 25 Anonyme
	protected S make_S(final String name) {
115 15 Anonyme
		return new S() {
116
			
117
			@Override
118
			protected AJavaInterface make_p2() {
119
				return new AJavaInterface() {
120
					@Override
121
					public String aMethod(Integer param1) {
122 25 Anonyme
						return name+"/"+param1;
123 15 Anonyme
					}
124
				};
125
			}
126
			
127
			@Override
128
			protected MyBeautifulComponent make_c() {
129
				return new MyComponentImpl();
130
			}
131
		};
132
	}
133
}
134
</pre>
135
136
Of course, one can extract the implementation of the species, either as an inner class of the ecosystem implementation, or even put it in another Java file if desired.
137
<pre>
138
public class MyFirstEco1 extends MyFirstEco {
139 1 Anonyme
140 15 Anonyme
	@Override
141
	protected S make_S(String name) {
142 26 Anonyme
		return new SImpl(name);
143 1 Anonyme
	}
144
	
145
	private final class SImpl extends S {
146 26 Anonyme
		
147
		private final String name;
148
		
149
		public SImpl(String name) {
150
			this.name = name;
151
		}
152
		
153 15 Anonyme
		@Override
154 1 Anonyme
		protected AJavaInterface make_p2() {
155 15 Anonyme
			return new AJavaInterface() {
156
				@Override
157
				public String aMethod(Integer param1) {
158 26 Anonyme
					return name+""+param1;
159 15 Anonyme
				}
160
			};
161
		}
162
163
		@Override
164
		protected MyBeautifulComponent make_c() {
165
			return new MyComponentImpl();
166
		}
167
	}
168 3 Anonyme
}
169 1 Anonyme
</pre>
170
171
h2. The Use Abstraction
172
173
As we said previously, species can only be defined inside ecosystems.
174
Such a relation can be exploited either:
175 26 Anonyme
* At the SpeADL level with the bindings and delegation from the species to the ecosystem as described [[SpeADL Full Reference#Ecosystem and Species Definition|above]].
176
* At a higher-level using advanced interconnection mechanisms between ecosystem and their species.
177 15 Anonyme
178 26 Anonyme
We focus on the second point in this section with the *use* abstraction.
179
It is a construct that enables to:
180
* Build tailored ecosystem-species relations.
181
* Build tailored inter-species relations mediated by the ecosystem.
182
183 1 Anonyme
h3. Keywords
184 11 Anonyme
185 26 Anonyme
Inside a species, a special type of part (and for the rest it behave exactly as a part) can be declared using the keyword *use* followed by a name without capital letter.
186 11 Anonyme
It follows the syntax _use name: partName.SpeciesName_ where:
187
* _partName_ is the name of a part in the ecosystem containing the current species and whose type is an ecosystem.
188
* _SpeciesName_ is the name of a species declared in the ecosystem of _partName_.
189 19 Anonyme
* And optionally a list of arguments for the species parameters: one can refer to the parameters of the containing species only.
190 11 Anonyme
191
h3. Details
192
193
The important point about the *use* abstraction is that it relies on the definition of ecosystem and species: it is a way to recursively exploit an ecosystem and its species in another ecosystem and its species.
194
The contained ecosystem and its parts are instantiated with the containing ecosystem, and its species instantiated with the species that use them.
195
196
h3. Example
197
198
<pre>
199
namespace simple.ecos {	
200
	ecosystem MySecondEco {
201
		
202
		part e: MyFirstEco
203
		
204 15 Anonyme
		species S(name: String) {
205 11 Anonyme
			
206
			part c: MySimpleComponent
207
			
208 1 Anonyme
			use s: e.S(name) {
209
				bind p3 to c.p1
210
			}
211
		}
212
	}
213
}
214
</pre>
215 26 Anonyme
216
h2. Lifecycle of Species Initialisation at Instantiation
217
218
For a species *S*, when *newS(params...)* is called from the ecosystem implementation, this is what happens:
219
# The species implementation is instantiated (see below).
220
# The species is instantiated from the implementation (see below).
221
# The instance is started (see below).
222
223
h3. Species Implementation Instantiation
224
225
# The implementation of S is instantiated with the *make_S(params...)* method.
226
# For each part *useX* of *S* in the order of declaration:
227
## The species implementation is instantiated from the ecosystem part following the current procedure.
228
229
h3. Species Instantiation
230
231
# For each part *partX* or use *useX* in the order of declaration
232
** If it is a part:
233
### The implementation is instantiated with the *make_partX()* method.
234
### The component is instantiated from the implementation following the [[SpeADL Minus Reference#Component Instantiation 2|Component Instantiation procedure]].
235
** If it is a use:
236
### The use's species is instantiated from the implementation following the current procedure.
237
# For each provided port *portX* in the order of declaration:
238
## The interface implementation is instantiated with the *make_portX()* method.
239
240
h3. Species Instance Start
241
242
# For each part *partX* or use *useX* in the order of declaration:
243
** If it is a part:
244
### The part is started following the [[SpeADL Minus Reference#Component Instance Start|Component Instantiation procedure]].
245
** If it is a use:
246
### The use is instantiated following the current procedure.
247
# The implementation *start()* method is called.