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 <vanto@apache.org>
Authored: Thu Aug 15 01:42:54 2013 +0200
Committer: Tammo van Lessen <vanto@apache.org>
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 extends Channel> T importChannel(String channelId, Class<T>
channelClass) {
+ return (T) JacobVPU.activeJacobThread().importChannel(channelId, channelClass);
+ }
+
+ /**
+ * Instantiation; the Java code <code>instance(new F(x,y,z))</code> is
+ * equivalent to <code>F(x,y,z)</code> 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 extends Channel> T newChannel(Class<T> channelType)
+ throws IllegalArgumentException {
+ return newChannel(channelType, null);
+ }
+
+ /**
+ * Channel creation; the Java code <code>Channel x = newChannel(XChannel.class)
...</code>
+ * is equivalent to <code>(new x) ... </code> in the process calculus.
+ */
+ @SuppressWarnings("unchecked")
+ public static <T extends Channel> T newChannel(Class<T> channelType, String
description)
+ throws IllegalArgumentException
+ {
+ return (T) JacobVPU.activeJacobThread().newChannel(channelType, null, description);
+ }
+
+ /**
+ * Object; the Java code "object(x, ChannelListener)" is equivalent to
+ * <code>x ? ChannelListener</code> 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<ChannelListener> 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 extends Channel> T importChannel(String channelId, Class<T>
channelClass) {
- return (T) JacobVPU.activeJacobThread().importChannel(channelId, channelClass);
- }
-
- /**
- * Instantiation; the Java code <code>instance(new F(x,y,z))</code> is
- * equivalent to <code>F(x,y,z)</code> in the process calculus.
- *
- * @param concretion the concretion of a process template
- */
- protected static void instance(Runnable concretion) {
- JacobVPU.activeJacobThread().instance(concretion);
- }
-
- protected <T extends Channel> T newChannel(Class<T> channelType)
- throws IllegalArgumentException
- {
- return newChannel(channelType, null);
- }
-
- /**
- * Channel creation; the Java code <code>Channel x = newChannel(XChannel.class)
...</code>
- * is equivalent to <code>(new x) ... </code> in the process calculus.
- */
- @SuppressWarnings("unchecked")
- protected <T extends Channel> T newChannel(Class<T> channelType, String description)
- throws IllegalArgumentException
- {
- return (T) JacobVPU.activeJacobThread().newChannel(channelType, getClassName(), description);
- }
-
- /**
- * Object; the Java code "object(x, ChannelListener)" is equivalent to
- * <code>x ? ChannelListener</code> 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<ChannelListener> 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 extends Channel> T replication(T channel) {
- // TODO: we should create a replicated wrapper here.
- return channel;
- }
public Method getMethod(String methodName) {
Set<Method> 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;
|