ODE-987. Refactor Channel classes to not rely on code generation (step 1)
git-svn-id: https://svn.apache.org/repos/asf/ode/trunk@1433800 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/ode/jacob/ap/ChannelType.java b/src/main/java/org/apache/ode/jacob/ChannelType.java
similarity index 76%
rename from src/main/java/org/apache/ode/jacob/ap/ChannelType.java
rename to src/main/java/org/apache/ode/jacob/ChannelType.java
index 5d18bc0..5279d08 100644
--- a/src/main/java/org/apache/ode/jacob/ap/ChannelType.java
+++ b/src/main/java/org/apache/ode/jacob/ChannelType.java
@@ -16,12 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.ode.jacob.ap;
+package org.apache.ode.jacob;
+
+import java.io.Serializable;
/**
- * Annotation used to indicate that an interface is a JACOB channel interface.
- * @author Maciej Szefler <mszefler at gmail dot com>
+ * Marker interface extended by channel interfaces.
+ * TODO: evaluate if an annotation, although slower, would offer a more elegant approach
*/
-public @interface ChannelType {
-
+public interface ChannelType extends Serializable {
}
diff --git a/src/main/java/org/apache/ode/jacob/ap/ChannelType.java b/src/main/java/org/apache/ode/jacob/ProcessUtil.java
similarity index 67%
copy from src/main/java/org/apache/ode/jacob/ap/ChannelType.java
copy to src/main/java/org/apache/ode/jacob/ProcessUtil.java
index 5d18bc0..e11a34d 100644
--- a/src/main/java/org/apache/ode/jacob/ap/ChannelType.java
+++ b/src/main/java/org/apache/ode/jacob/ProcessUtil.java
@@ -16,12 +16,19 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.ode.jacob.ap;
+package org.apache.ode.jacob;
-/**
- * Annotation used to indicate that an interface is a JACOB channel interface.
- * @author Maciej Szefler <mszefler at gmail dot com>
- */
-public @interface ChannelType {
+public final class ProcessUtil {
+ private ProcessUtil() {
+ // Utility class
+ }
+
+ public static String exportChannel(ChannelType channel) {
+ if (channel instanceof Channel) {
+ return ((Channel)channel).export();
+ }
+ // TODO: add a check for null?
+ throw new RuntimeException("Invalid proxy type " + channel.getClass());
+ }
}
diff --git a/src/main/java/org/apache/ode/jacob/Synch.java b/src/main/java/org/apache/ode/jacob/Synch.java
index cebb64a..dbe6507 100644
--- a/src/main/java/org/apache/ode/jacob/Synch.java
+++ b/src/main/java/org/apache/ode/jacob/Synch.java
@@ -18,9 +18,6 @@
*/
package org.apache.ode.jacob;
-import java.io.Serializable;
-
-import org.apache.ode.jacob.ap.ChannelType;
/**
* Synch represents a synchronous invocation callback notification.
@@ -30,7 +27,8 @@
* @author Maciej Szefler <a href="mailto:mbs@fivesight.com">mbs</a>
*/
-@ChannelType
-public interface Synch extends Serializable {
- public void ret();
+public interface Synch extends ChannelType {
+
+ public void ret();
+
}
diff --git a/src/main/java/org/apache/ode/jacob/Val.java b/src/main/java/org/apache/ode/jacob/Val.java
index bc86732..2db6f7e 100644
--- a/src/main/java/org/apache/ode/jacob/Val.java
+++ b/src/main/java/org/apache/ode/jacob/Val.java
@@ -18,14 +18,12 @@
*/
package org.apache.ode.jacob;
-import java.io.Serializable;
-
-import org.apache.ode.jacob.ap.ChannelType;
/**
* Generic return-value channel type.
*/
-@ChannelType
-public interface Val extends Serializable {
- public void val(Object retVal);
+public interface Val extends ChannelType {
+
+ public void val(Object retVal);
+
}
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 14089e0..0058b39 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
@@ -18,27 +18,25 @@
*/
package org.apache.ode.jacob.examples.cell;
-import org.apache.ode.jacob.Val;
-import org.apache.ode.jacob.ap.ChannelType;
+import org.apache.ode.jacob.ChannelType;
+import org.apache.ode.jacob.Val;
/**
* Channel type for a cell. The channel allows reading of and setting the values of a cell.
- *
- * @jacob.kind
*/
-@ChannelType
-public interface Cell {
+public interface Cell extends ChannelType {
- /**
- * Read the value of the cell.
- * @param replyTo channel to which the value of the cell is sent
- */
- public void read(Val replyTo);
+ /**
+ * Read the value of the cell.
+ * @param replyTo channel to which the value of the cell is sent
+ */
+ public void read(Val replyTo);
- /**
- * Write the value of the cell.
- * @param newVal new value of the cell
- */
- public void write(Object newVal);
+ /**
+ * Write the value of the cell.
+ * @param newVal new value of the cell
+ */
+ public void write(Object newVal);
+
}
diff --git a/src/test/java/org/apache/ode/jacob/examples/eratosthenes/NaturalNumberStream.java b/src/test/java/org/apache/ode/jacob/examples/eratosthenes/NaturalNumberStream.java
index 55272b8..8b911ed 100644
--- a/src/test/java/org/apache/ode/jacob/examples/eratosthenes/NaturalNumberStream.java
+++ b/src/test/java/org/apache/ode/jacob/examples/eratosthenes/NaturalNumberStream.java
@@ -18,8 +18,9 @@
*/
package org.apache.ode.jacob.examples.eratosthenes;
+
+import org.apache.ode.jacob.ChannelType;
import org.apache.ode.jacob.SynchChannel;
-import org.apache.ode.jacob.ap.ChannelType;
/**
* DOCUMENTME.
@@ -28,7 +29,8 @@
* @jacob.kind
* @author Maciej Szefler <a href="mailto:mbs@fivesight.com">mbs</a>
*/
-@ChannelType
-public interface NaturalNumberStream {
- public void val(int n, SynchChannel ret);
+public interface NaturalNumberStream extends ChannelType {
+
+ public void val(int n, SynchChannel ret);
+
}
diff --git a/src/test/java/org/apache/ode/jacob/examples/synch/SynchPrint.java b/src/test/java/org/apache/ode/jacob/examples/synch/SynchPrint.java
index 3e32e79..a4b6cfe 100644
--- a/src/test/java/org/apache/ode/jacob/examples/synch/SynchPrint.java
+++ b/src/test/java/org/apache/ode/jacob/examples/synch/SynchPrint.java
@@ -18,8 +18,8 @@
*/
package org.apache.ode.jacob.examples.synch;
+import org.apache.ode.jacob.ChannelType;
import org.apache.ode.jacob.SynchChannel;
-import org.apache.ode.jacob.ap.ChannelType;
/**
* DOCUMENTME.
@@ -27,7 +27,8 @@
*
* @author Maciej Szefler <a href="mailto:mbs@fivesight.com">mbs</a>
*/
-@ChannelType
-public interface SynchPrint {
- public SynchChannel print(String msg);
+public interface SynchPrint extends ChannelType {
+
+ public SynchChannel print(String msg);
+
}