experimental: make BenkoBox not extend Destination
authoradam <adam@megacz.com>
Wed, 28 Feb 2007 11:04:33 +0000 (12:04 +0100)
committeradam <adam@megacz.com>
Wed, 28 Feb 2007 11:04:33 +0000 (12:04 +0100)
src/edu/berkeley/fleet/api/BenkoBox.java
src/edu/berkeley/fleet/api/Destination.java
src/edu/berkeley/fleet/interpreter/InterpreterBenkoBox.java
src/edu/berkeley/fleet/interpreter/InterpreterDestination.java
src/edu/berkeley/fleet/slipway/SlipwayBenkoBox.java

index e9a8cc4..7f6cf8e 100644 (file)
@@ -1,7 +1,7 @@
 package edu.berkeley.fleet.api;
 import java.util.*;
 
-public abstract class BenkoBox extends Destination {
+public abstract class BenkoBox {
 
     public BenkoBox() { }
 
@@ -22,11 +22,7 @@ public abstract class BenkoBox extends Destination {
     public abstract boolean isOutbox();
 
     /** get all destinations associated with this BenkoBox; default implementation: just itself */
-    public Iterable<Destination> getDestinations() {
-        HashSet<Destination> self = new HashSet<Destination>();
-        self.add(this);
-        return self;
-    }
+    public abstract Iterable<Destination> getDestinations();
 
     /** default implementation: the empty string */
     public String getDestinationName() { return ""; }
index c7a0686..c89ae92 100644 (file)
@@ -1,16 +1,14 @@
 package edu.berkeley.fleet.api;
 
-public abstract class Destination {
-
-    public Destination() { }
+public interface Destination {
 
     /** return the Ship to which this BenkoBox belongs */
-    public abstract Ship   getShip();
+    public Ship   getShip();
 
     /**
      *  this returns the third component of the name; that is in
      *  "ship.port.foo", it returns "foo", and in "ship.port" it
      *  returns ""
      */
-    public abstract String getDestinationName();
+    public String getDestinationName();
 }            
index 70fb7e2..f8525c8 100644 (file)
@@ -47,7 +47,7 @@ public abstract class InterpreterBenkoBox extends BenkoBox implements Interprete
 
     private static int max_addr;
 
-    private class InterpreterBenkoBoxDestination extends Destination implements InterpreterDestination {
+    private class InterpreterBenkoBoxDestination implements InterpreterDestination {
         public String name;
         public long addr = max_addr++;
         public InterpreterBenkoBoxDestination(String name)          { this.name = name; }
index 445a8eb..bde33bc 100644 (file)
@@ -2,7 +2,7 @@ package edu.berkeley.fleet.interpreter;
 import edu.berkeley.fleet.api.*;
 import java.util.*;
 
-interface InterpreterDestination {
+interface InterpreterDestination extends Destination {
     public long getDestAddr();
     public void addDataFromFabric(Packet packet);
     public String getDestinationName();
index a43a659..fb6082d 100644 (file)
@@ -59,7 +59,7 @@ public class SlipwayBenkoBox extends BenkoBox {
         ports = newports;
     }
 
-    public class VirtualPort extends Destination {
+    public class VirtualPort implements Destination {
         public String name;
         public VirtualPort(String name) { this.name = name; }
         public String getDestinationName() { return name; }