Projet

Général

Profil

SpeADL Reference » Historique » Version 25

Anonyme, 13/10/2014 11:43

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 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
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.
84
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
96 25 Anonyme
From the implementation of the ecosystem (for example in the implementation of one of its provided ports or in the *start()* method), each species *S* can be instantiated by calling the method *S.Component newS()* which will also take arguments for the parameters declared in the species.
97 15 Anonyme
98
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()*.
99
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*.
100
101 1 Anonyme
h3. Example
102 15 Anonyme
103
<pre>
104
package testpackage;
105
106
import my.interfaces.AJavaInterface;
107
import simple.ecos.MyFirstEco;
108 1 Anonyme
import simple.stuffs.MyBeautifulComponent;
109 15 Anonyme
110
public class MyFirstEco1 extends MyFirstEco {
111
112
	@Override
113 25 Anonyme
	protected S make_S(final String name) {
114 15 Anonyme
		return new S() {
115
			
116
			@Override
117
			protected AJavaInterface make_p2() {
118
				return new AJavaInterface() {
119
					@Override
120
					public String aMethod(Integer param1) {
121 25 Anonyme
						return name+"/"+param1;
122 15 Anonyme
					}
123
				};
124
			}
125
			
126
			@Override
127
			protected MyBeautifulComponent make_c() {
128
				return new MyComponentImpl();
129
			}
130
		};
131
	}
132
}
133
</pre>
134
135
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.
136
<pre>
137
public class MyFirstEco1 extends MyFirstEco {
138
139
	@Override
140
	protected S make_S(String name) {
141
		return new SImpl();
142
	}
143
	
144
	private final class SImpl extends S {
145
		@Override
146
		protected AJavaInterface make_p2() {
147
			return new AJavaInterface() {
148
				@Override
149
				public String aMethod(Integer param1) {
150
					return ""+param1;
151
				}
152
			};
153
		}
154
155
		@Override
156
		protected MyBeautifulComponent make_c() {
157
			return new MyComponentImpl();
158
		}
159
	}
160
}
161
</pre>
162
163 3 Anonyme
h2. The Use Abstraction
164 1 Anonyme
165 15 Anonyme
As we said previously, species can only be defined inside ecosystems.
166
Such a relation can be exploited either:
167 1 Anonyme
* At the SpeADL level with the bindings and delegation from the species to the ecosystem.
168 18 Anonyme
* At a higher-level using advanced interconnection mechanisms between ecosystem and their species as explained.
169 3 Anonyme
170 1 Anonyme
h3. Keywords
171 11 Anonyme
172 12 Anonyme
Inside a species, a special type of part can be declared using the keyword *use* followed by a name without capital letter.
173 11 Anonyme
It follows the syntax _use name: partName.SpeciesName_ where:
174
* _partName_ is the name of a part in the ecosystem containing the current species and whose type is an ecosystem.
175
* _SpeciesName_ is the name of a species declared in the ecosystem of _partName_.
176 19 Anonyme
* And optionally a list of arguments for the species parameters: one can refer to the parameters of the containing species only.
177 11 Anonyme
178
h3. Details
179
180
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.
181
The contained ecosystem and its parts are instantiated with the containing ecosystem, and its species instantiated with the species that use them.
182
183
h3. Example
184
185
<pre>
186
namespace simple.ecos {	
187
	ecosystem MySecondEco {
188
		
189
		part e: MyFirstEco
190
		
191 15 Anonyme
		species S(name: String) {
192 11 Anonyme
			
193
			part c: MySimpleComponent
194
			
195 15 Anonyme
			use s: e.S(name) {
196
				bind p3 to c.p1
197 11 Anonyme
			}
198
		}
199 1 Anonyme
	}
200
}
201
</pre>