ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject [2/3] git commit: some clean up.
Date Thu, 15 Aug 2013 21:18:08 GMT
some clean up.


Project: http://git-wip-us.apache.org/repos/asf/ode-jacob/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode-jacob/commit/018d158f
Tree: http://git-wip-us.apache.org/repos/asf/ode-jacob/tree/018d158f
Diff: http://git-wip-us.apache.org/repos/asf/ode-jacob/diff/018d158f

Branch: refs/heads/master
Commit: 018d158fd2752a5fc62908d446aa79761052b6ff
Parents: e820dc1
Author: Tammo van Lessen <vanto@apache.org>
Authored: Thu Aug 15 22:01:05 2013 +0200
Committer: Tammo van Lessen <vanto@apache.org>
Committed: Thu Aug 15 22:01:05 2013 +0200

----------------------------------------------------------------------
 src/main/java/org/apache/ode/jacob/ChannelRef.java     |  9 +++++++++
 src/main/java/org/apache/ode/jacob/Jacob.java          |  2 +-
 src/main/java/org/apache/ode/jacob/JacobObject.java    | 13 +------------
 src/main/java/org/apache/ode/jacob/JacobThread.java    |  2 +-
 .../java/org/apache/ode/jacob/oo/ReceiveProcess.java   |  2 +-
 src/main/java/org/apache/ode/jacob/vpu/JacobVPU.java   |  4 ++--
 .../ode/jacob/examples/helloworld/HelloWorld.java      | 10 +++++++---
 7 files changed, 22 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/018d158f/src/main/java/org/apache/ode/jacob/ChannelRef.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/ode/jacob/ChannelRef.java b/src/main/java/org/apache/ode/jacob/ChannelRef.java
index 70b6a1f..78fff21 100644
--- a/src/main/java/org/apache/ode/jacob/ChannelRef.java
+++ b/src/main/java/org/apache/ode/jacob/ChannelRef.java
@@ -21,6 +21,7 @@ package org.apache.ode.jacob;
 import java.io.Serializable;
 
 import org.apache.ode.jacob.soup.CommChannel;
+import org.apache.ode.jacob.vpu.JacobVPU;
 
 
 
@@ -54,6 +55,14 @@ public class ChannelRef implements Serializable {
     public Type getType() {
         return type;
     }
+    
+    public String export() {
+        if (type == Type.CHANNEL) {
+            return JacobVPU.activeJacobThread().exportCommChannel(((CommChannel)target));
+        } else {
+            throw new UnsupportedOperationException("Cannot export channels of type " + type.toString());
+        }
+    }
 
     @SuppressWarnings("unchecked")
     public <T> T getEndpoint(Class<T> clazz) {

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/018d158f/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
index f963efb..eda96fe 100644
--- a/src/main/java/org/apache/ode/jacob/Jacob.java
+++ b/src/main/java/org/apache/ode/jacob/Jacob.java
@@ -89,7 +89,7 @@ public class Jacob {
      * @param channel
      * @return
      */
-    public static CommChannel importCommChannel(String channelId, Class<?> channelType)
{
+    public static ChannelRef importCommChannel(String channelId, Class<?> channelType)
{
         return JacobVPU.activeJacobThread().importCommChannel(channelId, channelType);
     }
     

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/018d158f/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 e3817c3..cdad900 100644
--- a/src/main/java/org/apache/ode/jacob/JacobObject.java
+++ b/src/main/java/org/apache/ode/jacob/JacobObject.java
@@ -22,10 +22,7 @@ import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.Set;
 
-import org.apache.ode.jacob.oo.Channel;
-import org.apache.ode.jacob.oo.ChannelListener;
 import org.apache.ode.jacob.oo.ClassUtil;
-import org.apache.ode.jacob.vpu.JacobVPU;
 
 /**
  * Base class for constructs which rely on a Java method body to represent some
@@ -37,14 +34,6 @@ public abstract class JacobObject implements Serializable {
     	return null;
     }
 
-    /**
-     * Get the unadorned (no package) name of this class.
-     */
-    protected String getClassName() {
-        return getClass().getSimpleName();
-    }
-
-
     public Method getMethod(String methodName) {
         Set<Method> implementedMethods = getImplementedMethods();
         implementedMethods = implementedMethods == null ? ClassUtil.runMethodSet() : implementedMethods;
@@ -57,7 +46,7 @@ public abstract class JacobObject implements Serializable {
     }
 
     public String toString() {
-        return "<JacobObject:" + getClassName() + ">";
+        return "<JacobObject:" + getClass().getSimpleName() + ">";
     }
 
 }

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/018d158f/src/main/java/org/apache/ode/jacob/JacobThread.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/ode/jacob/JacobThread.java b/src/main/java/org/apache/ode/jacob/JacobThread.java
index d89168a..95a86a7 100644
--- a/src/main/java/org/apache/ode/jacob/JacobThread.java
+++ b/src/main/java/org/apache/ode/jacob/JacobThread.java
@@ -61,7 +61,7 @@ public interface JacobThread {
      * @param channel
      * @return
      */
-    public CommChannel importCommChannel(String channelId, Class<?> channelType);
+    public ChannelRef importCommChannel(String channelId, Class<?> channelType);
     
     /**
      * Send a message. 

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/018d158f/src/main/java/org/apache/ode/jacob/oo/ReceiveProcess.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/ode/jacob/oo/ReceiveProcess.java b/src/main/java/org/apache/ode/jacob/oo/ReceiveProcess.java
index 5dc0a05..9334def 100644
--- a/src/main/java/org/apache/ode/jacob/oo/ReceiveProcess.java
+++ b/src/main/java/org/apache/ode/jacob/oo/ReceiveProcess.java
@@ -63,7 +63,7 @@ public abstract class ReceiveProcess extends ChannelListener {
 
     public String toString() {
         // TODO: needs improvement
-        StringBuffer buf = new StringBuffer(getClassName());
+        StringBuffer buf = new StringBuffer(getClass().getSimpleName());
         buf.append('{');
         for (Method m : getImplementedMethods()) {
             buf.append(m.getName());

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/018d158f/src/main/java/org/apache/ode/jacob/vpu/JacobVPU.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/ode/jacob/vpu/JacobVPU.java b/src/main/java/org/apache/ode/jacob/vpu/JacobVPU.java
index d0114e6..3b709e4 100644
--- a/src/main/java/org/apache/ode/jacob/vpu/JacobVPU.java
+++ b/src/main/java/org/apache/ode/jacob/vpu/JacobVPU.java
@@ -325,8 +325,8 @@ public final class JacobVPU {
             return ChannelFactory.createChannel(cframe, channelType);
         }
 
-        public CommChannel importCommChannel(String channelId, Class<?> channelType)
{
-            return _executionQueue.consumeExport(channelId);
+        public ChannelRef importCommChannel(String channelId, Class<?> channelType)
{
+            return new ChannelRef(_executionQueue.consumeExport(channelId));
         }
         
         public void object(boolean replicate, ChannelListener[] ml) {

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/018d158f/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 15587ac..0c6ef73 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,7 +18,12 @@
  */
 package org.apache.ode.jacob.examples.helloworld;
 
-import static org.apache.ode.jacob.Jacob.*;
+import static org.apache.ode.jacob.Jacob.instance;
+import static org.apache.ode.jacob.Jacob.newChannel;
+import static org.apache.ode.jacob.Jacob.newCommChannel;
+import static org.apache.ode.jacob.Jacob.object;
+import static org.apache.ode.jacob.Jacob.sendMessage;
+import static org.apache.ode.jacob.Jacob.subscribe;
 
 import org.apache.ode.jacob.ChannelRef;
 import org.apache.ode.jacob.JacobObject;
@@ -29,7 +34,6 @@ import org.apache.ode.jacob.oo.Channel;
 import org.apache.ode.jacob.oo.ReceiveProcess;
 import org.apache.ode.jacob.oo.Synch;
 import org.apache.ode.jacob.oo.Val;
-import org.apache.ode.jacob.soup.CommChannel;
 import org.apache.ode.jacob.soup.jackson.JacksonExecutionQueueImpl;
 import org.apache.ode.jacob.soup.jackson.JacobModule;
 import org.apache.ode.jacob.vpu.JacobVPU;
@@ -316,7 +320,7 @@ public class HelloWorld extends JacobObject implements Runnable {
 
     @Override
     public void run() {
-//        simpleHelloWorld();
+        simpleHelloWorld();
 //        reliableHelloWorld();
 //        sequencedHelloWorld();
         calculusHelloWorld();


Mime
View raw message