Return-Path: X-Original-To: apmail-ode-commits-archive@www.apache.org Delivered-To: apmail-ode-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 75A2E10996 for ; Wed, 14 Aug 2013 23:43:14 +0000 (UTC) Received: (qmail 95606 invoked by uid 500); 14 Aug 2013 23:43:14 -0000 Delivered-To: apmail-ode-commits-archive@ode.apache.org Received: (qmail 95535 invoked by uid 500); 14 Aug 2013 23:43:14 -0000 Mailing-List: contact commits-help@ode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ode.apache.org Delivered-To: mailing list commits@ode.apache.org Received: (qmail 95371 invoked by uid 99); 14 Aug 2013 23:43:13 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Aug 2013 23:43:13 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 4CBE5836922; Wed, 14 Aug 2013 23:43:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vanto@apache.org To: commits@ode.apache.org Date: Wed, 14 Aug 2013 23:43:19 -0000 Message-Id: <9587320cd4864e70bba55a232070a1d0@git.apache.org> In-Reply-To: <88cb137e7fa94d13818b5781657d9986@git.apache.org> References: <88cb137e7fa94d13818b5781657d9986@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [7/7] git commit: Moving convenience methods from JacobObject to Jacob. Moving convenience methods from JacobObject to Jacob. Project: http://git-wip-us.apache.org/repos/asf/ode-jacob/repo Commit: http://git-wip-us.apache.org/repos/asf/ode-jacob/commit/32d23050 Tree: http://git-wip-us.apache.org/repos/asf/ode-jacob/tree/32d23050 Diff: http://git-wip-us.apache.org/repos/asf/ode-jacob/diff/32d23050 Branch: refs/heads/master Commit: 32d2305098da64c14e0265eeb27bb41d00e0c187 Parents: 93755e4 Author: Tammo van Lessen Authored: Thu Aug 15 01:42:54 2013 +0200 Committer: Tammo van Lessen Committed: Thu Aug 15 01:42:54 2013 +0200 ---------------------------------------------------------------------- src/main/java/org/apache/ode/jacob/Jacob.java | 115 +++++++++++++++++++ .../java/org/apache/ode/jacob/JacobObject.java | 67 ----------- .../apache/ode/jacob/examples/cell/CELL_.java | 2 + .../ode/jacob/examples/cell/JacobCellTest.java | 1 + .../ode/jacob/examples/eratosthenes/Sieve.java | 2 + .../jacob/examples/helloworld/HelloWorld.java | 2 + .../ode/jacob/examples/sequence/Sequence.java | 2 + .../ode/jacob/examples/synch/SynchPrinter.java | 1 + 8 files changed, 125 insertions(+), 67 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/32d23050/src/main/java/org/apache/ode/jacob/Jacob.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/ode/jacob/Jacob.java b/src/main/java/org/apache/ode/jacob/Jacob.java new file mode 100644 index 0000000..680c383 --- /dev/null +++ b/src/main/java/org/apache/ode/jacob/Jacob.java @@ -0,0 +1,115 @@ +package org.apache.ode.jacob; + +import java.util.Set; + +import org.apache.ode.jacob.oo.Channel; +import org.apache.ode.jacob.oo.ChannelListener; +import org.apache.ode.jacob.soup.CommChannel; +import org.apache.ode.jacob.vpu.JacobVPU; + +public class Jacob { + + public static Object getExtension(Class extensionClass) { + return JacobVPU.activeJacobThread().getExtension(extensionClass); + } + + @SuppressWarnings("unchecked") + public static T importChannel(String channelId, Class channelClass) { + return (T) JacobVPU.activeJacobThread().importChannel(channelId, channelClass); + } + + /** + * Instantiation; the Java code instance(new F(x,y,z)) is + * equivalent to F(x,y,z) in the process calculus. + * + * @param concretion the concretion of a process template + */ + public static void instance(Runnable concretion) { + JacobVPU.activeJacobThread().instance(concretion); + } + + public static T newChannel(Class channelType) + throws IllegalArgumentException { + return newChannel(channelType, null); + } + + /** + * Channel creation; the Java code Channel x = newChannel(XChannel.class) ... + * is equivalent to (new x) ... in the process calculus. + */ + @SuppressWarnings("unchecked") + public static T newChannel(Class channelType, String description) + throws IllegalArgumentException + { + return (T) JacobVPU.activeJacobThread().newChannel(channelType, null, description); + } + + /** + * Object; the Java code "object(x, ChannelListener)" is equivalent to + * x ? ChannelListener in the process algebra. + * + * @param methodList method list for the communication reduction + * @see JacobThread#object + */ + public static void object(ChannelListener methodList) { + JacobVPU.activeJacobThread().object(false, methodList); + } + + public static void object(boolean replication, ChannelListener methodList) { + JacobVPU.activeJacobThread().object(replication, methodList); + } + + public static void object(boolean replication, Set methodLists) { + JacobVPU.activeJacobThread().object(replication, + methodLists.toArray(new ChannelListener[methodLists.size()])); + } + + // calculus API + + /** + * DOCUMENT ME + * @param channel + * @return + */ + public static CommChannel newCommChannel(Class channelType, String description) { + return JacobVPU.activeJacobThread().newCommChannel(channelType, null, description); + } + + /** + * DOCUMENT ME + * @param channel + * @return + */ + public static String exportCommChannel(CommChannel channel) { + return JacobVPU.activeJacobThread().exportCommChannel(channel); + } + + /** + * DOCUMENT ME + * @param channel + * @return + */ + public static CommChannel importCommChannel(String channelId, Class channelType) { + return JacobVPU.activeJacobThread().importCommChannel(channelId, channelType); + } + + /** + * Send a message. + * + * @param message + * self-contained message + */ + public static void sendMessage(Message message) { + JacobVPU.activeJacobThread().sendMessage(message); + } + + public static void subscribe(boolean replicate, CommChannel channel, MessageListener messageListener) throws IllegalArgumentException { + JacobVPU.activeJacobThread().subscribe(replicate, channel, messageListener); + } + + public static void subscribe(boolean replicate, CommChannel channel, MessageListener[] messageListeners) throws IllegalArgumentException { + JacobVPU.activeJacobThread().subscribe(replicate, channel, messageListeners); + } + + +} http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/32d23050/src/main/java/org/apache/ode/jacob/JacobObject.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/ode/jacob/JacobObject.java b/src/main/java/org/apache/ode/jacob/JacobObject.java index 73505d7..e3817c3 100644 --- a/src/main/java/org/apache/ode/jacob/JacobObject.java +++ b/src/main/java/org/apache/ode/jacob/JacobObject.java @@ -44,73 +44,6 @@ public abstract class JacobObject implements Serializable { return getClass().getSimpleName(); } - protected static Object getExtension(Class extensionClass) { - return JacobVPU.activeJacobThread().getExtension(extensionClass); - } - - @SuppressWarnings("unchecked") - protected static T importChannel(String channelId, Class channelClass) { - return (T) JacobVPU.activeJacobThread().importChannel(channelId, channelClass); - } - - /** - * Instantiation; the Java code instance(new F(x,y,z)) is - * equivalent to F(x,y,z) in the process calculus. - * - * @param concretion the concretion of a process template - */ - protected static void instance(Runnable concretion) { - JacobVPU.activeJacobThread().instance(concretion); - } - - protected T newChannel(Class channelType) - throws IllegalArgumentException - { - return newChannel(channelType, null); - } - - /** - * Channel creation; the Java code Channel x = newChannel(XChannel.class) ... - * is equivalent to (new x) ... in the process calculus. - */ - @SuppressWarnings("unchecked") - protected T newChannel(Class channelType, String description) - throws IllegalArgumentException - { - return (T) JacobVPU.activeJacobThread().newChannel(channelType, getClassName(), description); - } - - /** - * Object; the Java code "object(x, ChannelListener)" is equivalent to - * x ? ChannelListener in the process algebra. - * - * @param methodList method list for the communication reduction - * @see JacobThread#object - */ - protected static void object(ChannelListener methodList) { - JacobVPU.activeJacobThread().object(false, methodList); - } - - protected static void object(boolean replication, ChannelListener methodList) { - JacobVPU.activeJacobThread().object(replication, methodList); - } - - protected static void object(boolean replication, Set methodLists) { - JacobVPU.activeJacobThread().object(replication, - methodLists.toArray(new ChannelListener[methodLists.size()])); - } - - - /** - * Obtain a replicated channel broadcaster. - * - * @param channel target channel - * @return replicated channel broadcaster - */ - protected static T replication(T channel) { - // TODO: we should create a replicated wrapper here. - return channel; - } public Method getMethod(String methodName) { Set implementedMethods = getImplementedMethods(); http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/32d23050/src/test/java/org/apache/ode/jacob/examples/cell/CELL_.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/ode/jacob/examples/cell/CELL_.java b/src/test/java/org/apache/ode/jacob/examples/cell/CELL_.java index 35917b7..a6426f9 100644 --- a/src/test/java/org/apache/ode/jacob/examples/cell/CELL_.java +++ b/src/test/java/org/apache/ode/jacob/examples/cell/CELL_.java @@ -22,6 +22,8 @@ import org.apache.ode.jacob.JacobObject; import org.apache.ode.jacob.oo.ReceiveProcess; import org.apache.ode.jacob.oo.Val; +import static org.apache.ode.jacob.Jacob.*; + /** * Cell process template Java representation. This class is equivalent to the * following process calculus expression: http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/32d23050/src/test/java/org/apache/ode/jacob/examples/cell/JacobCellTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/ode/jacob/examples/cell/JacobCellTest.java b/src/test/java/org/apache/ode/jacob/examples/cell/JacobCellTest.java index 5ab4015..a6381bb 100644 --- a/src/test/java/org/apache/ode/jacob/examples/cell/JacobCellTest.java +++ b/src/test/java/org/apache/ode/jacob/examples/cell/JacobCellTest.java @@ -19,6 +19,7 @@ package org.apache.ode.jacob.examples.cell; import static org.apache.ode.jacob.oo.ProcessUtil.receive; +import static org.apache.ode.jacob.Jacob.*; import java.io.ByteArrayOutputStream; import java.io.IOException; http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/32d23050/src/test/java/org/apache/ode/jacob/examples/eratosthenes/Sieve.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/ode/jacob/examples/eratosthenes/Sieve.java b/src/test/java/org/apache/ode/jacob/examples/eratosthenes/Sieve.java index ae55528..61b1438 100644 --- a/src/test/java/org/apache/ode/jacob/examples/eratosthenes/Sieve.java +++ b/src/test/java/org/apache/ode/jacob/examples/eratosthenes/Sieve.java @@ -18,6 +18,8 @@ */ package org.apache.ode.jacob.examples.eratosthenes; +import static org.apache.ode.jacob.Jacob.*; + import org.apache.ode.jacob.JacobObject; import org.apache.ode.jacob.oo.ReceiveProcess; import org.apache.ode.jacob.oo.Synch; http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/32d23050/src/test/java/org/apache/ode/jacob/examples/helloworld/HelloWorld.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/ode/jacob/examples/helloworld/HelloWorld.java b/src/test/java/org/apache/ode/jacob/examples/helloworld/HelloWorld.java index afda12a..5c4b78b 100644 --- a/src/test/java/org/apache/ode/jacob/examples/helloworld/HelloWorld.java +++ b/src/test/java/org/apache/ode/jacob/examples/helloworld/HelloWorld.java @@ -18,6 +18,8 @@ */ package org.apache.ode.jacob.examples.helloworld; +import static org.apache.ode.jacob.Jacob.*; + import org.apache.ode.jacob.JacobObject; import org.apache.ode.jacob.examples.sequence.Sequence; import org.apache.ode.jacob.oo.Channel; http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/32d23050/src/test/java/org/apache/ode/jacob/examples/sequence/Sequence.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/ode/jacob/examples/sequence/Sequence.java b/src/test/java/org/apache/ode/jacob/examples/sequence/Sequence.java index aa7ae05..17ee867 100644 --- a/src/test/java/org/apache/ode/jacob/examples/sequence/Sequence.java +++ b/src/test/java/org/apache/ode/jacob/examples/sequence/Sequence.java @@ -18,6 +18,8 @@ */ package org.apache.ode.jacob.examples.sequence; +import static org.apache.ode.jacob.Jacob.*; + import org.apache.ode.jacob.JacobObject; import org.apache.ode.jacob.oo.ReceiveProcess; import org.apache.ode.jacob.oo.Synch; http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/32d23050/src/test/java/org/apache/ode/jacob/examples/synch/SynchPrinter.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/ode/jacob/examples/synch/SynchPrinter.java b/src/test/java/org/apache/ode/jacob/examples/synch/SynchPrinter.java index 22a82f6..2b07dfa 100644 --- a/src/test/java/org/apache/ode/jacob/examples/synch/SynchPrinter.java +++ b/src/test/java/org/apache/ode/jacob/examples/synch/SynchPrinter.java @@ -19,6 +19,7 @@ package org.apache.ode.jacob.examples.synch; import static org.apache.ode.jacob.oo.ProcessUtil.receive; +import static org.apache.ode.jacob.Jacob.*; import org.apache.ode.jacob.JacobObject; import org.apache.ode.jacob.oo.ReceiveProcess;