ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject [2/4] git commit: Removing JacobObject to a minimum.
Date Thu, 15 Aug 2013 22:52:03 GMT
Removing JacobObject to a minimum.

It's only purpose is now to have an abstract class that combines Serializable and Runnable.


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

Branch: refs/heads/master
Commit: 561ab317dbca4923f2e21ee46fd667ad6eb0bc09
Parents: 941f6c4
Author: Tammo van Lessen <vanto@apache.org>
Authored: Fri Aug 16 00:31:12 2013 +0200
Committer: Tammo van Lessen <vanto@apache.org>
Committed: Fri Aug 16 00:31:12 2013 +0200

----------------------------------------------------------------------
 .../java/org/apache/ode/jacob/JacobObject.java    | 18 ------------------
 .../org/apache/ode/jacob/MessageListener.java     |  4 +++-
 .../org/apache/ode/jacob/oo/ChannelListener.java  |  8 ++++++--
 .../java/org/apache/ode/jacob/oo/ClassUtil.java   |  3 +--
 .../soup/jackson/JacobTypeResolverBuilder.java    |  5 ++---
 .../java/org/apache/ode/jacob/vpu/JacobVPU.java   | 15 +++++++--------
 6 files changed, 19 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/561ab317/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 cdad900..5dab505 100644
--- a/src/main/java/org/apache/ode/jacob/JacobObject.java
+++ b/src/main/java/org/apache/ode/jacob/JacobObject.java
@@ -19,10 +19,6 @@
 package org.apache.ode.jacob;
 
 import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Set;
-
-import org.apache.ode.jacob.oo.ClassUtil;
 
 /**
  * Base class for constructs which rely on a Java method body to represent some
@@ -30,20 +26,6 @@ import org.apache.ode.jacob.oo.ClassUtil;
  */
 @SuppressWarnings("serial")
 public abstract class JacobObject implements Serializable {
-    public Set<Method> getImplementedMethods() {
-    	return null;
-    }
-
-    public Method getMethod(String methodName) {
-        Set<Method> implementedMethods = getImplementedMethods();
-        implementedMethods = implementedMethods == null ? ClassUtil.runMethodSet() : implementedMethods;
-        for (Method m : implementedMethods) {
-            if (m.getName().equals(methodName)) {
-                return m;
-            }
-        }
-        throw new IllegalArgumentException("No such method \"" + methodName + "\"!");
-    }
 
     public String toString() {
         return "<JacobObject:" + getClass().getSimpleName() + ">";

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/561ab317/src/main/java/org/apache/ode/jacob/MessageListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/ode/jacob/MessageListener.java b/src/main/java/org/apache/ode/jacob/MessageListener.java
index 5e5282a..629cf43 100644
--- a/src/main/java/org/apache/ode/jacob/MessageListener.java
+++ b/src/main/java/org/apache/ode/jacob/MessageListener.java
@@ -18,11 +18,13 @@
  */
 package org.apache.ode.jacob;
 
+import java.io.Serializable;
+
 
 /**
  * TODO: Document...
  */
 
-public interface MessageListener {
+public interface MessageListener extends Serializable {
 	void onMessage(Message msg);
 }

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/561ab317/src/main/java/org/apache/ode/jacob/oo/ChannelListener.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/ode/jacob/oo/ChannelListener.java b/src/main/java/org/apache/ode/jacob/oo/ChannelListener.java
index d863f31..3cd6916 100644
--- a/src/main/java/org/apache/ode/jacob/oo/ChannelListener.java
+++ b/src/main/java/org/apache/ode/jacob/oo/ChannelListener.java
@@ -20,8 +20,8 @@ package org.apache.ode.jacob.oo;
 
 
 import java.lang.reflect.Method;
+import java.util.Set;
 
-import org.apache.ode.jacob.JacobObject;
 import org.apache.ode.jacob.Message;
 import org.apache.ode.jacob.MessageListener;
 
@@ -31,7 +31,7 @@ import org.apache.ode.jacob.MessageListener;
  * class <em>and</em> implement one <code>Channel</code> interface.
  */
 @SuppressWarnings("serial")
-public abstract class ChannelListener extends JacobObject implements MessageListener {
+public abstract class ChannelListener implements MessageListener {
 
 	public void onMessage(Message msg) {
 		Method action = ClassUtil.findActionMethod(getImplementedMethods()).evaluate(msg, Method.class);
@@ -44,5 +44,9 @@ public abstract class ChannelListener extends JacobObject implements MessageList
 			e.printStackTrace();
 		}
 	}
+	
+	public Set<Method> getImplementedMethods() {
+	    return null;
+	}
 
 }

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/561ab317/src/main/java/org/apache/ode/jacob/oo/ClassUtil.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/ode/jacob/oo/ClassUtil.java b/src/main/java/org/apache/ode/jacob/oo/ClassUtil.java
index e1336ee..24d6701 100644
--- a/src/main/java/org/apache/ode/jacob/oo/ClassUtil.java
+++ b/src/main/java/org/apache/ode/jacob/oo/ClassUtil.java
@@ -24,7 +24,6 @@ import java.util.Set;
 
 import org.apache.ode.jacob.ChannelRef;
 import org.apache.ode.jacob.Expression;
-import org.apache.ode.jacob.JacobObject;
 import org.apache.ode.jacob.Message;
 import org.apache.ode.jacob.soup.CommChannel;
 import org.slf4j.Logger;
@@ -57,7 +56,7 @@ public final class ClassUtil {
     	return RUN_METHOD_SET;
     }
 
-    public static Message createMessage(JacobObject target, String action, Object[] args,
Channel replyTo) {
+    public static Message createMessage(Runnable target, String action, Object[] args, Channel
replyTo) {
     	Message message = new Message();
         message.setTo(new ChannelRef(target));
         message.setReplyTo(replyTo == null ? null : new ChannelRef(replyTo));

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/561ab317/src/main/java/org/apache/ode/jacob/soup/jackson/JacobTypeResolverBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/ode/jacob/soup/jackson/JacobTypeResolverBuilder.java
b/src/main/java/org/apache/ode/jacob/soup/jackson/JacobTypeResolverBuilder.java
index c2e36ee..399be8f 100644
--- a/src/main/java/org/apache/ode/jacob/soup/jackson/JacobTypeResolverBuilder.java
+++ b/src/main/java/org/apache/ode/jacob/soup/jackson/JacobTypeResolverBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
+R * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
  * regarding copyright ownership.  The ASF licenses this file
@@ -21,7 +21,6 @@ package org.apache.ode.jacob.soup.jackson;
 import java.util.Collection;
 
 import org.apache.ode.jacob.ChannelRef;
-import org.apache.ode.jacob.JacobObject;
 import org.apache.ode.jacob.MessageListener;
 import org.apache.ode.jacob.oo.Channel;
 import org.apache.ode.jacob.oo.ChannelProxy;
@@ -83,7 +82,7 @@ public class JacobTypeResolverBuilder extends StdTypeResolverBuilder {
     }
 
     private boolean useForType(JavaType t) {
-        if (JacobObject.class.isAssignableFrom(t.getRawClass())) {
+        if (Runnable.class.isAssignableFrom(t.getRawClass())) {
             return true;
         }
         

http://git-wip-us.apache.org/repos/asf/ode-jacob/blob/561ab317/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 5b8a07d..ae4db3a 100644
--- a/src/main/java/org/apache/ode/jacob/vpu/JacobVPU.java
+++ b/src/main/java/org/apache/ode/jacob/vpu/JacobVPU.java
@@ -24,7 +24,6 @@ import java.util.Map;
 import java.util.Stack;
 
 import org.apache.ode.jacob.ChannelRef;
-import org.apache.ode.jacob.JacobObject;
 import org.apache.ode.jacob.JacobThread;
 import org.apache.ode.jacob.Message;
 import org.apache.ode.jacob.MessageListener;
@@ -143,7 +142,7 @@ public final class JacobVPU {
     /**
      * Add an item to the run queue.
      */
-    public void addReaction(JacobObject jo, String action, Object[] args, String desc) {
+    public void addReaction(Runnable jo, String action, Object[] args, String desc) {
         LOG.trace(">> addReaction (jo={}, method={}, args={}, desc={})", jo, action,
args, desc);
 
         _executionQueue.enqueueMessage(ClassUtil.createMessage(jo, action, args, null));
@@ -166,7 +165,7 @@ public final class JacobVPU {
      */
     public void inject(Runnable concretion) {
         LOG.debug("injecting {}", concretion);
-        addReaction((JacobObject)concretion, ClassUtil.RUN_METHOD_ACTION, new Class[]{},
+        addReaction(concretion, ClassUtil.RUN_METHOD_ACTION, new Class[]{},
             (LOG.isInfoEnabled() ? concretion.toString() : null));
     }
 
@@ -252,7 +251,7 @@ public final class JacobVPU {
             LOG.trace(">> [{}] : {}", _cycle, template);
 
             _statistics.numReductionsStruct++;
-            addReaction((JacobObject)template, ClassUtil.RUN_METHOD_ACTION, new Class[]{},

+            addReaction(template, ClassUtil.RUN_METHOD_ACTION, new Class[]{}, 
                 LOG.isInfoEnabled() ? template.toString() : null);
         }
 
@@ -300,8 +299,8 @@ public final class JacobVPU {
             return ret;
         }
 
-        public ChannelRef newCommChannel(Class<?> channelType, String creator, String
description) {
-            CommChannel chnl = new CommChannel(channelType);
+        public ChannelRef newCommChannel(String description) {
+            CommChannel chnl = new CommChannel();
             chnl.setDescription(description);
             _executionQueue.add(chnl);
 
@@ -477,8 +476,8 @@ public final class JacobVPU {
                 switch (message.getTo().getType()) {
                     case CHANNEL:
                         throw new UnsupportedOperationException();
-                    case JACOB_OBJECT:
-                        JacobObject target = message.getTo().getEndpoint(JacobObject.class);
+                    case RUNNABLE:
+                        Runnable target = message.getTo().getEndpoint(Runnable.class);
                         if (target instanceof ReceiveProcess) {
                             ((ReceiveProcess)target).onMessage(message);
                         } else {


Mime
View raw message