Projet

Général

Profil

SpeADL Reference » Historique » Version 21

Anonyme, 10/10/2014 13:18

1 1 Anonyme
h1. SpeADL Full Reference
2
3 15 Anonyme
h1. ATTENTION: DRAFT Document
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 15 Anonyme
The important point with these abstractions is that one can actually implement its own interconnection mechanism between the dynamically created components and their creating component.
14 21 Anonyme
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 agent, the communication) by composing them while 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 15 Anonyme
h2. Ecosystem Class 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 15 Anonyme
Because of this particular relation to ecosystem, species can be 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 15 Anonyme
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 12 Anonyme
44
A species is declared inside an ecosystem with the keyword *species* followed by a name starting with a capital.
45 15 Anonyme
It has no type parameters but follows those of its ecosystem, and cannot specialise another component.
46 17 Anonyme
A species can have parameters needed for its initialisation inside *( * and * )* and separated by *, *: they are of the form _name: Type_.
47 15 Anonyme
Provided and required ports can be declared as with normal component classes with the keywords *provides* and *requires*.
48
Parts can be declared as with normal component classes with the keyword *part*.
49 1 Anonyme
50
h3. Details
51
52 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.
53 1 Anonyme
Such species will be considered strongly linked to the containing ecosystem instance that created them: this is a thus 1..N relation.
54
55
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.
56 15 Anonyme
They can NOT point to other species of the ecosystem (for inter-species connection, one must exploit the use abstraction detailed next).
57 1 Anonyme
58
h3. Example
59
60
<pre>
61
namespace simple.ecos {	
62
	ecosystem MyFirstEco {
63
64 15 Anonyme
		species S(name: String) {
65 1 Anonyme
			provides p1: AJavaInterface = c.portName
66 15 Anonyme
			provides p2: AJavaInterface
67
			requires p3: AnotherJavaInterface
68 1 Anonyme
			
69
			part c: MyBeautifulComponent {
70 15 Anonyme
				bind anotherPortName to p3
71 1 Anonyme
			}
72
		}
73
	}
74
}
75
</pre>
76
77 15 Anonyme
h2. Ecosystem Class and Species Implementation
78
79
Implementing an ecosystem is similar to implementing a component.
80
The only difference is with the species: there is methods to implement to provide for an implementation of the species and there is methods that can be used to create instances of species from within the implementation of the ecosystem.
81
82
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 allowing them to.
83
84
h3. Special Method to Implement
85
86
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.
87
It means that in order to implement the method *make_S()*, it is necessary to extends the class S in any way desired (anonymous, inner, static or not, or in its own file).
88
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 always done, defined as an inner class of the ecosystem.
89
This last possibility can be useful to access to some Java class member of the ecosystem class for example.
90
91
h3. Special Methods to Exploit
92
93
From the implementation of the ecosystem (for example in the implementation of one of its provided ports), each species *S* can be instantiated by calling the method *S.Component newS()* which will also have as parameters those declared in the species.
94
95
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()*.
96
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*.
97
98
h3. Example
99
100
<pre>
101
package testpackage;
102
103
import my.interfaces.AJavaInterface;
104
import simple.ecos.MyFirstEco;
105
import simple.stuffs.MyBeautifulComponent;
106
107
public class MyFirstEco1 extends MyFirstEco {
108
109
	@Override
110
	protected S make_S(String name) {
111
		return new S() {
112
			
113
			@Override
114
			protected AJavaInterface make_p2() {
115
				return new AJavaInterface() {
116
					@Override
117
					public String aMethod(Integer param1) {
118
						return ""+param1;
119
					}
120
				};
121
			}
122
			
123
			@Override
124
			protected MyBeautifulComponent make_c() {
125
				return new MyComponentImpl();
126
			}
127
		};
128
	}
129
}
130
</pre>
131
132
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.
133
<pre>
134
public class MyFirstEco1 extends MyFirstEco {
135
136
	@Override
137
	protected S make_S(String name) {
138
		return new SImpl();
139
	}
140
	
141
	private final class SImpl extends S {
142
		@Override
143
		protected AJavaInterface make_p2() {
144
			return new AJavaInterface() {
145
				@Override
146
				public String aMethod(Integer param1) {
147
					return ""+param1;
148
				}
149
			};
150
		}
151
152
		@Override
153
		protected MyBeautifulComponent make_c() {
154
			return new MyComponentImpl();
155
		}
156
	}
157
}
158
</pre>
159
160 3 Anonyme
h2. The Use Abstraction
161 1 Anonyme
162 15 Anonyme
As we said previously, species can only be defined inside ecosystems.
163
Such a relation can be exploited either:
164 1 Anonyme
* At the SpeADL level with the bindings and delegation from the species to the ecosystem.
165 18 Anonyme
* At a higher-level using advanced interconnection mechanisms between ecosystem and their species as explained.
166 3 Anonyme
167 1 Anonyme
h3. Keywords
168 11 Anonyme
169 12 Anonyme
Inside a species, a special type of part can be declared using the keyword *use* followed by a name without capital letter.
170 11 Anonyme
It follows the syntax _use name: partName.SpeciesName_ where:
171
* _partName_ is the name of a part in the ecosystem containing the current species and whose type is an ecosystem.
172
* _SpeciesName_ is the name of a species declared in the ecosystem of _partName_.
173 19 Anonyme
* And optionally a list of arguments for the species parameters: one can refer to the parameters of the containing species only.
174 11 Anonyme
175
h3. Details
176
177
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.
178
The contained ecosystem and its parts are instantiated with the containing ecosystem, and its species instantiated with the species that use them.
179
180
h3. Example
181
182
<pre>
183
namespace simple.ecos {	
184
	ecosystem MySecondEco {
185
		
186
		part e: MyFirstEco
187
		
188 15 Anonyme
		species S(name: String) {
189 11 Anonyme
			
190
			part c: MySimpleComponent
191
			
192 15 Anonyme
			use s: e.S(name) {
193
				bind p3 to c.p1
194 11 Anonyme
			}
195
		}
196 1 Anonyme
	}
197
}
198
</pre>