├── .gitignore
├── .project
├── .settings
└── .gitignore
├── AUTHORS.md
├── LICENSE.md
├── README.md
├── common
├── .gitignore
├── .project
├── .settings
│ └── .gitignore
├── pom.xml
└── src
│ ├── .gitignore
│ ├── main
│ ├── .gitignore
│ └── java
│ │ └── org
│ │ └── jspace
│ │ ├── .gitignore
│ │ ├── ActualField.java
│ │ ├── FormalField.java
│ │ ├── PileSpace.java
│ │ ├── QueueSpace.java
│ │ ├── RandomSpace.java
│ │ ├── RemoteSpace.java
│ │ ├── SequentialSpace.java
│ │ ├── Space.java
│ │ ├── SpaceFactory.java
│ │ ├── SpaceRepository.java
│ │ ├── StackSpace.java
│ │ ├── Template.java
│ │ ├── TemplateField.java
│ │ ├── Tuple.java
│ │ ├── gate
│ │ ├── ClientGate.java
│ │ ├── ClientHandler.java
│ │ ├── ConnClientGate.java
│ │ ├── ConnClientHandler.java
│ │ ├── ConnServerGate.java
│ │ ├── ExceptionLogger.java
│ │ ├── GateBuilder.java
│ │ ├── GateFactory.java
│ │ ├── KeepClientGate.java
│ │ ├── KeepClientHandler.java
│ │ ├── KeepServerGate.java
│ │ ├── ServerGate.java
│ │ ├── TcpGateBuilder.java
│ │ ├── TcpServerGate.java
│ │ └── UdpGateBuilder.java
│ │ ├── io
│ │ ├── ClassDictionary.java
│ │ ├── JSonMarshaller.java
│ │ ├── MarshalFactory.java
│ │ ├── jSpaceMarshaller.java
│ │ └── json
│ │ │ ├── TemplateDeserializer.java
│ │ │ ├── TemplateSerializer.java
│ │ │ ├── TupleDeserializer.java
│ │ │ ├── TupleSerializer.java
│ │ │ └── jSonUtils.java
│ │ ├── protocol
│ │ ├── ClientMessage.java
│ │ ├── ClientMessageType.java
│ │ ├── InteractionMode.java
│ │ ├── PutRequest.java
│ │ ├── ServerMessage.java
│ │ ├── ServerMessageType.java
│ │ └── pSpaceMessage.java
│ │ └── util
│ │ └── Rendezvous.java
│ └── test
│ └── java
│ └── org
│ └── jspace
│ └── tests
│ ├── TestCloseKeepConnection.java
│ ├── TestFieldMatching.java
│ ├── TestGates.java
│ ├── TestRemoteSpace.java
│ ├── TestSpaceRepository.java
│ ├── TestSpaces.java
│ ├── TestTcpGates.java
│ ├── TestTemplate.java
│ ├── TestTuple.java
│ └── TestjSonMessageSerialization.java
├── docs
├── README.md
├── eclipse_jspace.md
├── figs
│ ├── README.md
│ ├── jspace_eclipse_tutorial_step1.png
│ ├── jspace_eclipse_tutorial_step2.png
│ ├── jspace_eclipse_tutorial_step3.png
│ ├── jspace_eclipse_tutorial_step4.png
│ ├── jspace_eclipse_tutorial_step5.png
│ ├── jspace_eclipse_tutorial_step6.png
│ ├── jspace_eclipse_tutorial_step7.png
│ └── jspace_eclipse_tutorial_step8.png
├── first_application_eclipse.md
├── first_application_maven.md
├── getting_started.md
└── jspace_serialization.md
├── examples
├── .gitignore
├── .project
├── .settings
│ └── .gitignore
├── DiningPhilosophers
│ ├── .gitignore
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── jspace
│ │ └── examples
│ │ └── df
│ │ ├── DiningPhilosophers.java
│ │ ├── DistributedDiningPhilosophers.java
│ │ └── Philosopher.java
├── HelloWorld
│ ├── .gitignore
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── jspace
│ │ └── examples
│ │ └── helloworld
│ │ ├── ConcurrentHelloWorld.java
│ │ ├── HelloWorld.java
│ │ └── RemoteHelloWorld.java
├── PingPong
│ ├── .gitignore
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── jspace
│ │ └── examples
│ │ └── pingpong
│ │ ├── PingAgent.java
│ │ ├── PingPong.java
│ │ ├── PingPongConn.java
│ │ ├── PingPongKeep.java
│ │ └── PongAgent.java
├── ProducerConsumer
│ ├── .gitignore
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── jspace
│ │ └── examples
│ │ └── pc
│ │ ├── ConsumerAgent.java
│ │ ├── DistributedProducerConsumer.java
│ │ ├── ProducerAgent.java
│ │ └── ProducerConsumer.java
└── pom.xml
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /.DS_Store
2 | /settings_xml
3 |
4 | .classpath
5 | .project
6 | .settings/
7 | bin/
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | jspace
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.settings/.gitignore:
--------------------------------------------------------------------------------
1 | /org.eclipse.core.resources.prefs
2 | /org.eclipse.m2e.core.prefs
3 |
--------------------------------------------------------------------------------
/AUTHORS.md:
--------------------------------------------------------------------------------
1 | The goSpace Developers:
2 |
3 | - [Michele Loreti](http://www.micheleloreti.comn/)
4 | - [Alberto Lluch Lafuente](http://www.imm.dtu.dk/~albl/)
5 | - Francesco Terrosi
6 | - [Lorenzo Crociani](https://github.com/lorecro)
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 Michele Loreti and the jSpace Developers (see and include the full [authors file](AUTHORS.md)).
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # jSpace
2 | jSpace is a Java library that supports programming of Concurrent and Distributed applications with Spaces.
3 |
4 | jSpace borns as a fork of jResp (https://github.com/michele-loreti/jResp).
5 |
6 | ## Requirements
7 | jSpace requires [Java 1.8](https://java.com/) (or higher). Moreover, jSpace is using [Maven](https://maven.apache.org/index.html) for dependency management and building (you can also use one of the IDE that supports it).
8 |
9 | ## Tutorial
10 |
11 | 1. [Building and Installing jSpace](./docs/getting_started.md)
12 | 2. [Import jSpace Code in Eclipse](./docs/eclipse_jspace.md)
13 | 3. [Your first jSpace App in Eclipse](./docs/first_application_eclipse.md)
14 | 4. [Your first jSpace App with Maven](./docs/first_application_maven.md)
15 | 5. [Configuring Serialization in jSpace](./docs/jspace_serialization.md)
16 |
--------------------------------------------------------------------------------
/common/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /.classpath
3 | /.DS_Store
4 |
--------------------------------------------------------------------------------
/common/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | common
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/common/.settings/.gitignore:
--------------------------------------------------------------------------------
1 | /org.eclipse.core.resources.prefs
2 | /org.eclipse.jdt.core.prefs
3 | /org.eclipse.m2e.core.prefs
4 |
--------------------------------------------------------------------------------
/common/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 |
6 | io.github.pspaces
7 | jspace
8 | 1.0-SNAPSHOT
9 | ..
10 |
11 |
12 | common
13 |
14 | Core API
15 | jSpace core API.
16 |
17 | io.github.pspaces.jspace
18 |
19 |
--------------------------------------------------------------------------------
/common/src/.gitignore:
--------------------------------------------------------------------------------
1 | /.DS_Store
2 |
--------------------------------------------------------------------------------
/common/src/main/.gitignore:
--------------------------------------------------------------------------------
1 | /.DS_Store
2 |
--------------------------------------------------------------------------------
/common/src/main/java/org/jspace/.gitignore:
--------------------------------------------------------------------------------
1 | /.DS_Store
2 |
--------------------------------------------------------------------------------
/common/src/main/java/org/jspace/ActualField.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 Michele Loreti and the jSpace Developers (see the included
3 | * authors file).
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | *******************************************************************************/
23 | package org.jspace;
24 |
25 | /**
26 | * Instances of this class identifies actual template fields.
27 | */
28 | public class ActualField implements TemplateField {
29 |
30 | /**
31 | *
32 | */
33 | private static final long serialVersionUID = 1L;
34 |
35 | /**
36 | * Field value.
37 | */
38 | private Object value;
39 |
40 | /**
41 | * Create an actual field with value value
42 | *
43 | * @param value
44 | * field value
45 | */
46 | public ActualField(Object value) {
47 | if (value == null) {
48 | throw new NullPointerException();
49 | }
50 | this.value = value;
51 | }
52 |
53 | /*
54 | * (non-Javadoc)
55 | *
56 | * @see org.cmg.scel.knowledge.TemplateField#match(java.lang.Object)
57 | */
58 | @Override
59 | public boolean match(Object o) {
60 | return (value == o) || ((value != null) && value.equals(o));
61 | }
62 |
63 | @Override
64 | public boolean equals(Object obj) {
65 | if (obj instanceof ActualField) {
66 | return value.equals(((ActualField) obj).value);
67 | }
68 | return false;
69 | }
70 |
71 | @Override
72 | public int hashCode() {
73 | return value.hashCode();
74 | }
75 |
76 | @Override
77 | public String toString() {
78 | return value.toString();
79 | }
80 |
81 | public Object getValue() {
82 | return value;
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/common/src/main/java/org/jspace/FormalField.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 Michele Loreti and the jSpace Developers (see the included
3 | * authors file).
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | *******************************************************************************/
23 |
24 | package org.jspace;
25 |
26 | /**
27 | * Identifies a formal template field.
28 | */
29 | public class FormalField implements TemplateField {
30 |
31 | /**
32 | *
33 | */
34 | private static final long serialVersionUID = 1L;
35 |
36 | /**
37 | * Type of matching value.
38 | */
39 | private Class> type;
40 |
41 | /**
42 | * Creates a template field matching any value of type type
.
43 | *
44 | * @param type Class of expected field.
45 | */
46 | public FormalField(Class> type) {
47 | this.type = type;
48 | }
49 |
50 | /***
51 | * Returns true
if parameters o
is instance of this.type
.
52 | *
53 | * @see org.pspaces.jspace.cmg.jresp.knowledge.TemplateField#match(java.lang.Object)
54 | */
55 | @Override
56 | public boolean match(Object o) {
57 | Object value = o;
58 | if (value == null) {//TODO: Are 'null' values allowed in Tuples?
59 | return false;
60 | }
61 | if (value instanceof ActualField) {
62 | value = ((ActualField) value).getValue();
63 | }
64 | return (o == null) || (type.isInstance(o));
65 | }
66 |
67 | @Override
68 | public boolean equals(Object obj) {
69 | if (obj instanceof FormalField) {
70 | return type.equals(((FormalField) obj).type);
71 | }
72 | return false;
73 | }
74 |
75 | @Override
76 | public int hashCode() {
77 | return type.hashCode();
78 | }
79 |
80 | @Override
81 | public String toString() {
82 | return "?{" + type.getName()+ "}";
83 | }
84 |
85 | public Class> getFormalFieldType() {
86 | return type;
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/common/src/main/java/org/jspace/PileSpace.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 Michele Loreti and the jSpace Developers (see the included
3 | * authors file).
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | *******************************************************************************/
23 |
24 | package org.jspace;
25 |
26 | public class PileSpace extends SequentialSpace {
27 |
28 | public PileSpace() {
29 | this(-1);
30 | }
31 |
32 | public PileSpace(int bound) {
33 | super(bound);
34 | }
35 |
36 | @Override
37 | protected void addTuple(Tuple tuple) {
38 | tuples.push(tuple);
39 | }
40 |
41 |
42 | }
--------------------------------------------------------------------------------
/common/src/main/java/org/jspace/QueueSpace.java:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2017 Michele Loreti and the jSpace Developers (see the included
3 | * authors file).
4 | *
5 | * Permission is hereby granted, free of charge, to any person obtaining a copy
6 | * of this software and associated documentation files (the "Software"), to deal
7 | * in the Software without restriction, including without limitation the rights
8 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | * copies of the Software, and to permit persons to whom the Software is
10 | * furnished to do so, subject to the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included in
13 | * all copies or substantial portions of the Software.
14 | *
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | * THE SOFTWARE.
22 | *******************************************************************************/
23 |
24 | package org.jspace;
25 |
26 | import java.util.Iterator;
27 | import java.util.LinkedList;
28 | import java.util.List;
29 |
30 |
31 | public class QueueSpace extends SequentialSpace {
32 |
33 | public QueueSpace() {
34 | this(-1);
35 | }
36 |
37 | public QueueSpace(int bound) {
38 | super(bound);
39 | }
40 |
41 | @Override
42 | protected void addTuple(Tuple tuple) {
43 | tuples.add(tuple);
44 | }
45 |
46 | @Override
47 | protected Tuple findTuple(Template template,boolean toRemove) {
48 | Tuple t = tuples.peek();
49 | if ((t!=null)&&(template.match(t))) {
50 | if (toRemove) {
51 | tuples.poll();
52 | }
53 | return t;
54 | } else {
55 | return null;
56 | }
57 | }
58 |
59 | @Override
60 | protected LinkedList