-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
484 additions
and
268 deletions.
There are no files selected for viewing
72 changes: 36 additions & 36 deletions
72
klab.core.api/src/main/java/org/integratedmodelling/klab/api/identities/TaskIdentity.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,36 +1,36 @@ | ||
/* | ||
* This file is part of k.LAB. | ||
* | ||
* k.LAB is free software: you can redistribute it and/or modify it under the terms of the Affero | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* A copy of the GNU Affero General Public License is distributed in the root directory of the k.LAB | ||
* distribution (LICENSE.txt). If this cannot be found see <http://www.gnu.org/licenses/>. | ||
* | ||
* Copyright (C) 2007-2018 integratedmodelling.org and any authors mentioned in author tags. All | ||
* rights reserved. | ||
*/ | ||
package org.integratedmodelling.klab.api.identities; | ||
|
||
import org.integratedmodelling.klab.api.scope.ContextScope; | ||
|
||
/** | ||
* The Interface ITaskIdentity. | ||
* | ||
* @author ferdinando.villa | ||
* @version $Id: $Id | ||
*/ | ||
public interface TaskIdentity extends RuntimeIdentity { | ||
|
||
/** Constant <code>type</code> */ | ||
Type type = Type.TASK; | ||
|
||
/** | ||
* All tasks happen in a context, which may be null for root tasks (which create the root | ||
* context). | ||
* | ||
* @return | ||
*/ | ||
ContextScope getScope(); | ||
} | ||
///* | ||
// * This file is part of k.LAB. | ||
// * | ||
// * k.LAB is free software: you can redistribute it and/or modify it under the terms of the Affero | ||
// * GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
// * License, or (at your option) any later version. | ||
// * | ||
// * A copy of the GNU Affero General Public License is distributed in the root directory of the k.LAB | ||
// * distribution (LICENSE.txt). If this cannot be found see <http://www.gnu.org/licenses/>. | ||
// * | ||
// * Copyright (C) 2007-2018 integratedmodelling.org and any authors mentioned in author tags. All | ||
// * rights reserved. | ||
// */ | ||
//package org.integratedmodelling.klab.api.identities; | ||
// | ||
//import org.integratedmodelling.klab.api.scope.ContextScope; | ||
// | ||
///** | ||
// * The Interface ITaskIdentity. | ||
// * | ||
// * @author ferdinando.villa | ||
// * @version $Id: $Id | ||
// */ | ||
//public interface TaskIdentity extends RuntimeIdentity { | ||
// | ||
// /** Constant <code>type</code> */ | ||
// Type type = Type.TASK; | ||
// | ||
// /** | ||
// * All tasks happen in a context, which may be null for root tasks (which create the root | ||
// * context). | ||
// * | ||
// * @return | ||
// */ | ||
// ContextScope getScope(); | ||
//} |
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
40 changes: 20 additions & 20 deletions
40
klab.core.api/src/main/java/org/integratedmodelling/klab/api/services/runtime/Task.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,20 +1,20 @@ | ||
package org.integratedmodelling.klab.api.services.runtime; | ||
|
||
import org.integratedmodelling.klab.api.scope.ContextScope; | ||
|
||
import java.util.concurrent.Future; | ||
|
||
/** | ||
* A task is a future for an object that exists in a | ||
* {@link org.integratedmodelling.klab.api.scope.ContextScope}, exposes a tracking URN for the object of | ||
* interest and admits k.LAB-aware listeners for any messages contextualized to it or any sub-tasks. | ||
* | ||
* @param <T> | ||
*/ | ||
public interface Task<T> extends Future<T> { | ||
|
||
ContextScope getScope(); | ||
|
||
String getUrn(); | ||
|
||
} | ||
//package org.integratedmodelling.klab.api.services.runtime; | ||
// | ||
//import org.integratedmodelling.klab.api.scope.ContextScope; | ||
// | ||
//import java.util.concurrent.Future; | ||
// | ||
///** | ||
// * A task is a future for an object that exists in a | ||
// * {@link org.integratedmodelling.klab.api.scope.ContextScope}, exposes a tracking URN for the object of | ||
// * interest and admits k.LAB-aware listeners for any messages contextualized to it or any sub-tasks. | ||
// * | ||
// * @param <T> | ||
// */ | ||
//public interface Task<T> extends Future<T> { | ||
// | ||
// ContextScope getScope(); | ||
// | ||
// String getUrn(); | ||
// | ||
//} |
77 changes: 77 additions & 0 deletions
77
...e.api/src/main/java/org/integratedmodelling/klab/api/services/runtime/impl/MatchImpl.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,77 @@ | ||
package org.integratedmodelling.klab.api.services.runtime.impl; | ||
|
||
import org.integratedmodelling.klab.api.services.runtime.Message; | ||
|
||
import java.util.EnumSet; | ||
import java.util.Set; | ||
import java.util.function.Consumer; | ||
|
||
public class MatchImpl implements Message.Match { | ||
|
||
private Set<Message.MessageClass> applicableClasses = EnumSet.noneOf(Message.MessageClass.class); | ||
private Set<Message.MessageType> applicableTypes = EnumSet.noneOf(Message.MessageType.class); | ||
private Set<Message.Queue> applicableQueues = EnumSet.noneOf(Message.Queue.class); | ||
private Consumer<Message> messageConsumer; | ||
private Object payloadMatch; | ||
boolean persistent = false; | ||
|
||
@Override | ||
public Message.Match persistent(boolean persistent) { | ||
this.persistent = persistent; | ||
return this; | ||
} | ||
|
||
@Override | ||
public Message.Match thenDo(Consumer<Message> consumer) { | ||
this.messageConsumer = consumer; | ||
return this; | ||
} | ||
|
||
@Override | ||
public Set<Message.MessageClass> getApplicableClasses() { | ||
return applicableClasses; | ||
} | ||
|
||
@Override | ||
public Set<Message.MessageType> getApplicableTypes() { | ||
return applicableTypes; | ||
} | ||
|
||
@Override | ||
public Set<Message.Queue> getApplicableQueues() { | ||
return applicableQueues; | ||
} | ||
|
||
@Override | ||
public Consumer<Message> getMessageConsumer() { | ||
return messageConsumer; | ||
} | ||
|
||
@Override | ||
public boolean isPersistent() { | ||
return persistent; | ||
} | ||
|
||
@Override | ||
public Object getPayloadMatch() { | ||
return payloadMatch; | ||
} | ||
|
||
public static MatchImpl create(Object... args) { | ||
var ret = new MatchImpl(); | ||
if (args != null) { | ||
for (var arg : args) { | ||
if (arg instanceof Message.MessageType type) { | ||
ret.applicableTypes.add(type); | ||
} else if (arg instanceof Message.MessageClass type) { | ||
ret.applicableClasses.add(type); | ||
} else if (arg instanceof Message.Queue queue) { | ||
ret.applicableQueues.add(queue); | ||
} else { | ||
ret.payloadMatch = arg; | ||
} | ||
} | ||
} | ||
return ret; | ||
} | ||
} |
Oops, something went wrong.