-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/newgen' into newgen-iliasg
- Loading branch information
Showing
15 changed files
with
883 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
jdeeco-core/src/cz/cuni/mff/d3s/deeco/knowledge/CloningKnowledgeManagerContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cz.cuni.mff.d3s.deeco.knowledge; | ||
|
||
import com.rits.cloning.Cloner; | ||
|
||
/** | ||
* @author Michal Kit <kit@d3s.mff.cuni.cz> | ||
* | ||
*/ | ||
public class CloningKnowledgeManagerContainer extends KnowledgeManagerContainer { | ||
|
||
private final Cloner cloner; | ||
|
||
public CloningKnowledgeManagerContainer() { | ||
this.cloner = new Cloner(); | ||
} | ||
|
||
@Override | ||
public synchronized KnowledgeManager createReplicaFor(KnowledgeManager km) { | ||
if (!replicas.contains(km)) { | ||
KnowledgeManager result = cloner.deepClone(km); | ||
replicas.add(result); | ||
for (ReplicaListener listener : replicaListeners) | ||
listener.replicaCreated(result); | ||
return result; | ||
} | ||
return null; | ||
} | ||
|
||
} |
68 changes: 43 additions & 25 deletions
68
jdeeco-core/src/cz/cuni/mff/d3s/deeco/knowledge/KnowledgeManagerContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,78 @@ | ||
package cz.cuni.mff.d3s.deeco.knowledge; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Michal Kit <kit@d3s.mff.cuni.cz> | ||
* | ||
*/ | ||
public class KnowledgeManagerContainer implements | ||
public abstract class KnowledgeManagerContainer implements | ||
ReplicaKnowledgeManagerContainer, LocalKnowledgeManagerContainer { | ||
|
||
@Override | ||
public KnowledgeManager createLocal() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
protected final List<KnowledgeManager> locals; | ||
protected final List<KnowledgeManager> replicas; | ||
protected final List<LocalListener> localListeners; | ||
protected final List<ReplicaListener> replicaListeners; | ||
|
||
public KnowledgeManagerContainer() { | ||
this.locals = new LinkedList<>(); | ||
this.replicas = new LinkedList<>(); | ||
this.localListeners = new LinkedList<>(); | ||
this.replicaListeners = new LinkedList<>(); | ||
} | ||
|
||
@Override | ||
public KnowledgeManager removeLocal(KnowledgeManager km) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
public synchronized KnowledgeManager createLocal() { | ||
KnowledgeManager result = new CloningKnowledgeManager(); | ||
locals.add(result); | ||
for (LocalListener listener : localListeners) | ||
listener.localCreated(result); | ||
return result; | ||
} | ||
|
||
@Override | ||
public List<KnowledgeManager> getLocals() { | ||
// TODO Auto-generated method stub | ||
public synchronized KnowledgeManager removeLocal(KnowledgeManager km) { | ||
if (locals.contains(km)) { | ||
locals.remove(km); | ||
for (LocalListener listener : localListeners) | ||
listener.localRemoved(km); | ||
return km; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void registerListener(LocalListener listener) { | ||
// TODO Auto-generated method stub | ||
|
||
public synchronized List<KnowledgeManager> getLocals() { | ||
return new LinkedList<>(locals); | ||
} | ||
|
||
@Override | ||
public KnowledgeManager createReplicaFor(KnowledgeManager km) { | ||
// TODO Auto-generated method stub | ||
return null; | ||
public synchronized void registerLocalListener(LocalListener listener) { | ||
if (!localListeners.contains(listener)) | ||
localListeners.add(listener); | ||
} | ||
|
||
@Override | ||
public KnowledgeManager removeReplicaFor(KnowledgeManager km) { | ||
// TODO Auto-generated method stub | ||
public synchronized KnowledgeManager removeReplica(KnowledgeManager km) { | ||
if (replicas.contains(km)) { | ||
replicas.remove(km); | ||
for (ReplicaListener listener : replicaListeners) | ||
listener.replicaRemoved(km); | ||
return km; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<KnowledgeManager> getReplicas() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
public synchronized List<KnowledgeManager> getReplicas() { | ||
return new LinkedList<>(replicas); | ||
} | ||
|
||
@Override | ||
public void registerListener(ReplicaListener listener) { | ||
// TODO Auto-generated method stub | ||
|
||
public synchronized void registerReplicaListener(ReplicaListener listener) { | ||
if (!replicaListeners.contains(listener)) | ||
replicaListeners.add(listener); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.