FlowRule private extension refactor.
1.merge private flow into regular flowrule subsystem.no mirror code any
more.no change flowrule api.
2.define a rich-data-type to carry private flow.
3.modify OpenFlowRuleProvider.class to support for 3rd party private
flow.i don't know whether is suitable.because this class name is
relative with open flow protocal.
4.fix some junit test bug caused by modification of FlowRule interface.

Change-Id: I6c54d1e97f231a75bd1b416f0893e0379613d7ce
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
index 81c0638..1c13ef0 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultFlowRule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2014 Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,17 +15,17 @@
  */
 package org.onosproject.net.flow;
 
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.DefaultGroupId;
 import org.onosproject.core.GroupId;
 import org.onosproject.net.DeviceId;
 
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
 public class DefaultFlowRule implements FlowRule {
 
     private final DeviceId deviceId;
@@ -43,12 +43,12 @@
     private final GroupId groupId;
 
     private final Integer tableId;
-
+    private final FlowRuleExtPayLoad payLoad;
 
     @Deprecated
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-            TrafficTreatment treatment, int priority, long flowId,
-            int timeout, boolean permanent) {
+                           TrafficTreatment treatment, int priority,
+                           long flowId, int timeout, boolean permanent) {
         this.deviceId = deviceId;
         this.priority = priority;
         this.selector = selector;
@@ -61,12 +61,14 @@
         this.groupId = new DefaultGroupId((short) ((flowId >>> 32) & 0xFFFF));
         this.id = FlowId.valueOf(flowId);
         this.tableId = 0;
+        this.payLoad = null;
     }
 
     @Deprecated
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-                           TrafficTreatment treatment, int priority, long flowId,
-                           int timeout, boolean permanent, Type tableType) {
+                           TrafficTreatment treatment, int priority,
+                           long flowId, int timeout, boolean permanent,
+                           Type tableType) {
         this.deviceId = deviceId;
         this.priority = priority;
         this.selector = selector;
@@ -80,23 +82,26 @@
         this.id = FlowId.valueOf(flowId);
         this.tableId = tableType.ordinal();
 
+        this.payLoad = null;
     }
 
     @Deprecated
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-                           TrafficTreatment treatment, int priority, ApplicationId appId,
-                           int timeout, boolean permanent) {
-        this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(0),
-                timeout, permanent);
+                           TrafficTreatment treatment, int priority,
+                           ApplicationId appId, int timeout, boolean permanent) {
+        this(deviceId, selector, treatment, priority, appId,
+             new DefaultGroupId(0), timeout, permanent);
     }
 
     @Deprecated
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-                           TrafficTreatment treatment, int priority, ApplicationId appId,
-                           int timeout, boolean permanent, Type type) {
+                           TrafficTreatment treatment, int priority,
+                           ApplicationId appId, int timeout, boolean permanent,
+                           Type type) {
 
         if (priority < FlowRule.MIN_PRIORITY) {
-            throw new IllegalArgumentException("Priority cannot be less than " + MIN_PRIORITY);
+            throw new IllegalArgumentException("Priority cannot be less than "
+                    + MIN_PRIORITY);
         }
 
         this.deviceId = deviceId;
@@ -110,22 +115,26 @@
         this.created = System.currentTimeMillis();
         this.tableId = type.ordinal();
 
+        this.payLoad = null;
         /*
-         * id consists of the following.
-         * | appId (16 bits) | groupId (16 bits) | flowId (32 bits) |
+         * id consists of the following. | appId (16 bits) | groupId (16 bits) |
+         * flowId (32 bits) |
          */
-        this.id = FlowId.valueOf((((long) this.appId) << 48) | (((long) this.groupId.id()) << 32)
+        this.id = FlowId.valueOf((((long) this.appId) << 48)
+                | (((long) this.groupId.id()) << 32)
                 | (this.hash() & 0xffffffffL));
 
     }
 
     @Deprecated
     public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
-                           TrafficTreatment treatment, int priority, ApplicationId appId,
-                           GroupId groupId, int timeout, boolean permanent) {
+                           TrafficTreatment treatment, int priority,
+                           ApplicationId appId, GroupId groupId, int timeout,
+                           boolean permanent) {
 
         if (priority < FlowRule.MIN_PRIORITY) {
-            throw new IllegalArgumentException("Priority cannot be less than " + MIN_PRIORITY);
+            throw new IllegalArgumentException("Priority cannot be less than "
+                    + MIN_PRIORITY);
         }
 
         this.deviceId = deviceId;
@@ -138,12 +147,14 @@
         this.permanent = permanent;
         this.created = System.currentTimeMillis();
         this.tableId = 0;
+        this.payLoad = null;
 
         /*
-         * id consists of the following.
-         * | appId (16 bits) | groupId (16 bits) | flowId (32 bits) |
+         * id consists of the following. | appId (16 bits) | groupId (16 bits) |
+         * flowId (32 bits) |
          */
-        this.id = FlowId.valueOf((((long) this.appId) << 48) | (((long) this.groupId.id()) << 32)
+        this.id = FlowId.valueOf((((long) this.appId) << 48)
+                | (((long) this.groupId.id()) << 32)
                 | (this.hash() & 0xffffffffL));
     }
 
@@ -159,7 +170,7 @@
         this.permanent = rule.isPermanent();
         this.created = System.currentTimeMillis();
         this.tableId = rule.tableId();
-
+        this.payLoad = rule.payLoad();
     }
 
     private DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
@@ -181,8 +192,98 @@
 
         //FIXME: fields below will be removed.
         this.groupId = null;
+        this.payLoad = null;
+    }
 
+    /**
+     * Support for the third party flow rule. Creates a flow rule of flow table.
+     *
+     * @param deviceId the identity of the device where this rule applies
+     * @param selector the traffic selector that identifies what traffic this
+     *            rule
+     * @param treatment the traffic treatment that applies to selected traffic
+     * @param priority the flow rule priority given in natural order
+     * @param appId the application id of this flow
+     * @param timeout the timeout for this flow requested by an application
+     * @param permanent whether the flow is permanent i.e. does not time out
+     * @param payLoad 3rd-party origin private flow
+     */
+    public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
+                           TrafficTreatment treatment, int priority,
+                           ApplicationId appId, int timeout, boolean permanent,
+                           FlowRuleExtPayLoad payLoad) {
 
+        if (priority < FlowRule.MIN_PRIORITY) {
+            throw new IllegalArgumentException("Priority cannot be less than "
+                    + MIN_PRIORITY);
+        }
+
+        this.deviceId = deviceId;
+        this.priority = priority;
+        this.selector = selector;
+        this.treatment = treatment;
+        this.appId = appId.id();
+        this.groupId = new DefaultGroupId(0);
+        this.timeout = timeout;
+        this.permanent = permanent;
+        this.tableId = 0;
+        this.created = System.currentTimeMillis();
+        this.payLoad = payLoad;
+
+        /*
+         * id consists of the following. | appId (16 bits) | groupId (16 bits) |
+         * flowId (32 bits) |
+         */
+        this.id = FlowId.valueOf((((long) this.appId) << 48)
+                | (((long) this.groupId.id()) << 32)
+                | (this.hash() & 0xffffffffL));
+    }
+
+    /**
+     * Support for the third party flow rule. Creates a flow rule of group
+     * table.
+     *
+     * @param deviceId the identity of the device where this rule applies
+     * @param selector the traffic selector that identifies what traffic this
+     *            rule
+     * @param treatment the traffic treatment that applies to selected traffic
+     * @param priority the flow rule priority given in natural order
+     * @param appId the application id of this flow
+     * @param groupId the group id of this flow
+     * @param timeout the timeout for this flow requested by an application
+     * @param permanent whether the flow is permanent i.e. does not time out
+     * @param payLoad 3rd-party origin private flow
+     *
+     */
+    public DefaultFlowRule(DeviceId deviceId, TrafficSelector selector,
+                           TrafficTreatment treatment, int priority,
+                           ApplicationId appId, GroupId groupId, int timeout,
+                           boolean permanent, FlowRuleExtPayLoad payLoad) {
+
+        if (priority < FlowRule.MIN_PRIORITY) {
+            throw new IllegalArgumentException("Priority cannot be less than "
+                    + MIN_PRIORITY);
+        }
+
+        this.deviceId = deviceId;
+        this.priority = priority;
+        this.selector = selector;
+        this.treatment = treatment;
+        this.appId = appId.id();
+        this.groupId = groupId;
+        this.timeout = timeout;
+        this.permanent = permanent;
+        this.created = System.currentTimeMillis();
+        this.tableId = 0;
+        this.payLoad = payLoad;
+
+        /*
+         * id consists of the following. | appId (16 bits) | groupId (16 bits) |
+         * flowId (32 bits) |
+         */
+        this.id = FlowId.valueOf((((long) this.appId) << 48)
+                | (((long) this.groupId.id()) << 32)
+                | (this.hash() & 0xffffffffL));
     }
 
     @Override
@@ -225,14 +326,15 @@
      * The priority and statistics can change on a given treatment and selector
      *
      * (non-Javadoc)
+     *
      * @see java.lang.Object#equals(java.lang.Object)
      */
     public int hashCode() {
-        return Objects.hash(deviceId, selector, priority, tableId);
+        return Objects.hash(deviceId, selector, priority, tableId, payLoad);
     }
 
     public int hash() {
-        return Objects.hash(deviceId, selector, treatment, tableId);
+        return Objects.hash(deviceId, selector, treatment, tableId, payLoad);
     }
 
     @Override
@@ -240,6 +342,7 @@
      * The priority and statistics can change on a given treatment and selector
      *
      * (non-Javadoc)
+     *
      * @see java.lang.Object#equals(java.lang.Object)
      */
     public boolean equals(Object obj) {
@@ -251,8 +354,8 @@
             return Objects.equals(deviceId, that.deviceId) &&
                     Objects.equals(priority, that.priority) &&
                     Objects.equals(selector, that.selector) &&
-                    Objects.equals(tableId, that.tableId);
-
+                    Objects.equals(tableId, that.tableId)
+                     && Objects.equals(payLoad, that.payLoad);
         }
         return false;
     }
@@ -267,6 +370,7 @@
                 .add("treatment", treatment == null ? "N/A" : treatment.allInstructions())
                 .add("tableId", tableId)
                 .add("created", created)
+                .add("payLoad", payLoad).toString()
                 .toString();
     }
 
@@ -383,4 +487,9 @@
 
     }
 
+    @Override
+    public FlowRuleExtPayLoad payLoad() {
+        return payLoad;
+    }
+
 }
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
index 3499bae..6497e11 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRule.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2014 Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
 import org.onosproject.net.DeviceId;
 
 /**
- * Represents a generalized match &amp; action pair to be applied to
- * an infrastructure device.
+ * Represents a generalized match &amp; action pair to be applied to an
+ * infrastructure device.
  */
 public interface FlowRule {
 
@@ -29,14 +29,16 @@
     static final int MIN_PRIORITY = 0;
 
     /**
-     * The FlowRule type is used to determine in which table the flow rule
-     * needs to be put for multi-table support switch.
-     * For single table switch, Default is used.
+     * The FlowRule type is used to determine in which table the flow rule needs
+     * to be put for multi-table support switch. For single table switch,
+     * Default is used.
      */
     @Deprecated
     public static enum Type {
-        /* Default type - used in flow rule for single table switch
-         * NOTE: this setting should not be used as Table 0 in a multi-table pipeline*/
+        /*
+         * Default type - used in flow rule for single table switch NOTE: this
+         * setting should not be used as Table 0 in a multi-table pipeline
+         */
         DEFAULT,
         /* Used in flow entry for IP table */
         IP,
@@ -98,8 +100,8 @@
     DeviceId deviceId();
 
     /**
-     * Returns the traffic selector that identifies what traffic this
-     * rule should apply to.
+     * Returns the traffic selector that identifies what traffic this rule
+     * should apply to.
      *
      * @return traffic selector
      */
@@ -224,4 +226,10 @@
 
     }
 
+    /**
+     * Returns the third party original flow rule.
+     *
+     * @return FlowRuleExtPayLoad
+     */
+    FlowRuleExtPayLoad payLoad();
 }
diff --git a/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java
new file mode 100644
index 0000000..0be2656
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/flow/FlowRuleExtPayLoad.java
@@ -0,0 +1,68 @@
+package org.onosproject.net.flow;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Arrays;
+import java.util.Objects;
+
+/**
+ * Represents for 3rd-party private original flow.
+ */
+public final class FlowRuleExtPayLoad {
+    private final byte[] payLoad;
+
+    /**
+     * private constructor.
+     *
+     * @param payLoad private flow
+     */
+    private FlowRuleExtPayLoad(byte[] payLoad) {
+        this.payLoad = payLoad;
+    }
+
+    /**
+     * Creates a FlowRuleExtPayLoad.
+     *
+     * @param payLoad
+     * @return FlowRuleExtPayLoad payLoad
+     */
+    public static FlowRuleExtPayLoad flowRuleExtPayLoad(byte[] payLoad) {
+        return new FlowRuleExtPayLoad(payLoad);
+    }
+
+    /**
+     * Returns private flow.
+     *
+     * @return payLoad private flow
+     */
+    public byte[] payLoad() {
+        return payLoad;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(payLoad);
+    }
+
+    public int hash() {
+        return Objects.hash(payLoad);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof FlowRuleExtPayLoad) {
+            FlowRuleExtPayLoad that = (FlowRuleExtPayLoad) obj;
+            return Arrays.equals(payLoad, that.payLoad);
+
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this).add("payLoad", payLoad).toString();
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/DefaultFlowRuleExt.java b/core/api/src/main/java/org/onosproject/net/flowext/DefaultFlowRuleExt.java
deleted file mode 100644
index c72d4db..0000000
--- a/core/api/src/main/java/org/onosproject/net/flowext/DefaultFlowRuleExt.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.flowext;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.DefaultGroupId;
-import org.onosproject.core.GroupId;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flow.DefaultFlowRule;
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Experimental extension to the flow rule subsystem; still under development.
- * A temporary flow rule extend implementation, It will cover current onos flow rule and other flow extension.
- */
-public class DefaultFlowRuleExt
-        extends DefaultFlowRule implements FlowRuleExt {
-
-    private FlowEntryExtension flowEntryExtension;
-
-    public DefaultFlowRuleExt(DeviceId deviceId, TrafficSelector selector,
-                              TrafficTreatment treatment, int priority, long flowId,
-                              int timeout, boolean permanent) {
-        super(deviceId, selector, treatment, priority, flowId, timeout, permanent);
-    }
-
-    public DefaultFlowRuleExt(DeviceId deviceId, TrafficSelector selector,
-                              TrafficTreatment treatment, int priority, ApplicationId appId,
-                              int timeout, boolean permanent) {
-        this(deviceId, selector, treatment, priority, appId, new DefaultGroupId(0),
-             timeout, permanent);
-    }
-
-    public DefaultFlowRuleExt(DeviceId deviceId, TrafficSelector selector,
-                              TrafficTreatment treatment, int priority, ApplicationId appId,
-                              GroupId groupId, int timeout, boolean permanent) {
-        super(deviceId, selector, treatment, priority, appId, groupId, timeout, permanent);
-    }
-
-    public DefaultFlowRuleExt(FlowRule rule) {
-        super(rule);
-    }
-
-    public DefaultFlowRuleExt(ApplicationId appId, DeviceId deviceId, FlowEntryExtension data) {
-        this(deviceId, null, null, FlowRule.MIN_PRIORITY, appId, 0, false);
-        this.flowEntryExtension = data;
-    }
-
-    @Override
-    public FlowEntryExtension getFlowEntryExt() {
-        return this.flowEntryExtension;
-    }
-
-    @Override
-    public int hashCode() {
-        return 31 * super.hashCode() + Objects.hash(flowEntryExtension);
-    }
-
-    public int hash() {
-        return 31 * super.hashCode() + Objects.hash(flowEntryExtension);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null || getClass() != obj.getClass()) {
-            return false;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        final DefaultFlowRuleExt other = (DefaultFlowRuleExt) obj;
-        return Objects.equals(this.flowEntryExtension, other.flowEntryExtension);
-    }
-
-    @Override
-    public String toString() {
-        return toStringHelper(this)
-                // TODO there might be a better way to grab super's string
-                .add("id", Long.toHexString(id().value()))
-                .add("deviceId", deviceId())
-                .add("priority", priority())
-                .add("selector", selector().criteria())
-                .add("treatment", treatment() == null ? "N/A" : treatment().allInstructions())
-                        //.add("created", created)
-                .add("flowEntryExtension", flowEntryExtension)
-                .toString();
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/DownStreamFlowEntry.java b/core/api/src/main/java/org/onosproject/net/flowext/DownStreamFlowEntry.java
deleted file mode 100644
index 986adbc..0000000
--- a/core/api/src/main/java/org/onosproject/net/flowext/DownStreamFlowEntry.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.flowext;
-
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
-/**
- * Experimental extension to the flow rule subsystem; still under development.
- * Represents a generic abstraction of the service data. User app can customize whatever it needs to install on devices.
- */
-public class DownStreamFlowEntry implements FlowEntryExtension {
-
-    /**
-     * temporarily only have byte stream, but it will be extract more abstract information from it later.
-     */
-    private final ByteBuffer payload;
-
-    public DownStreamFlowEntry(ByteBuffer data) {
-        this.payload = data;
-    }
-
-    /**
-     * Get the payload of flowExtension.
-     *
-     * @return the byte steam value of payload.
-     */
-//   @Override
-//   public ByteBuffer getPayload() {
-    // TODO Auto-generated method stub
-//       return payload;
-//   }
-
-    /**
-     * Returns a hash code value for the object.
-     * It use payload as parameter to hash.
-     *
-     * @return a hash code value for this object.
-     */
-    @Override
-    public int hashCode() {
-        return Objects.hash(payload);
-    }
-
-    /**
-     * Indicates whether some other object is "equal to" this one.
-     *
-     * @param obj the reference object with which to compare.
-     * @return {@code true} if this object is the same as the obj
-     * argument; {@code false} otherwise.
-     */
-    @Override
-    public boolean equals(Object obj) {
-        if (obj instanceof DownStreamFlowEntry) {
-            DownStreamFlowEntry packet = (DownStreamFlowEntry) obj;
-            return Objects.equals(this.payload, packet.payload);
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * Returns a string representation of the object.
-     *
-     * @return a string representation of the object.
-     */
-    @Override
-    public String toString() {
-        String obj = new String(payload.array());
-        return obj;
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/FlowEntryExtension.java b/core/api/src/main/java/org/onosproject/net/flowext/FlowEntryExtension.java
deleted file mode 100644
index 84129ad..0000000
--- a/core/api/src/main/java/org/onosproject/net/flowext/FlowEntryExtension.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.flowext;
-
-
-/**
- * Experimental extension to the flow rule subsystem; still under development.
- * Represents a generic abstraction of the service data. User app can customize whatever it needs to install on devices.
- */
-public interface FlowEntryExtension {
-    // some abstraction of the service data, like length, type, etc, will be added here later
-
-}
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/FlowExtCompletedOperation.java b/core/api/src/main/java/org/onosproject/net/flowext/FlowExtCompletedOperation.java
deleted file mode 100644
index 1443855..0000000
--- a/core/api/src/main/java/org/onosproject/net/flowext/FlowExtCompletedOperation.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.flowext;
-
-import com.google.common.base.MoreObjects;
-import org.onosproject.net.flow.CompletedBatchOperation;
-import org.onosproject.net.flow.FlowRule;
-
-import java.util.Set;
-
-/**
- * Experimental extension to the flow rule subsystem; still under development.
- * <p>
- * Representation of a completed flow rule batch operation.
- * </p>
- */
-//TODO explain the purpose of this class beyond FlowRuleProvider
-public class FlowExtCompletedOperation extends CompletedBatchOperation {
-    // the batchId is provided by application, once one flow rule of this batch failed
-    // all the batch should withdraw
-    private final long batchId;
-
-    public FlowExtCompletedOperation(long batchId, boolean success, Set<FlowRule> failures) {
-        super(success, failures, null);
-        this.batchId = batchId;
-    }
-
-    /**
-     * Returns the BatchId of this BatchOperation.
-     *
-     * @return the number of Batch
-     */
-    public long getBatchId() {
-        return batchId;
-    }
-
-    /**
-     * Returns a string representation of the object.
-     *
-     * @return a string representation of the object.
-     */
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(getClass())
-                .add("success?", isSuccess())
-                .add("failedItems", failedIds())
-                .toString();
-    }
-}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExt.java b/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExt.java
deleted file mode 100644
index d97c950..0000000
--- a/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExt.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.flowext;
-
-import org.onosproject.net.flow.FlowRule;
-
-/**
- * Experimental extension to the flow rule subsystem; still under development.
- * <p>
- * FlowRule extended for current FlowRule API.
- * </p>
- */
-public interface FlowRuleExt extends FlowRule {
-    /**
-     * Get the flow entry extension.
-     *
-     * @return FlowEntryExtension value.
-     */
-    FlowEntryExtension getFlowEntryExt();
-}
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExtRouter.java b/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExtRouter.java
deleted file mode 100644
index 1f516bf..0000000
--- a/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExtRouter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.flowext;
-
-import org.onosproject.net.flow.FlowRuleBatchEvent;
-import org.onosproject.net.flow.FlowRuleBatchRequest;
-
-import java.util.concurrent.Future;
-
-/**
- * Experimental extension to the flow rule subsystem; still under development.
- * Represents a router-like mechanism which is in charge of sending flow rule to master;
- * <p>
- * The Router is in charge of sending flow rule to master;
- * the core component of routing-like mechanism.
- * </p>
- */
-public interface FlowRuleExtRouter {
-
-    /**
-     * apply the sub batch of flow extension rules.
-     *
-     * @param batchOperation batch of flow rules.
-     *                       A batch can contain flow rules for a single device only.
-     * @return Future response indicating success/failure of the batch operation
-     * all the way down to the device.
-     */
-    Future<FlowExtCompletedOperation> applySubBatch(FlowRuleBatchRequest batchOperation);
-
-    /**
-     * Invoked on the completion of a storeBatch operation.
-     *
-     * @param event flow rule batch event
-     */
-    void batchOperationComplete(FlowRuleBatchEvent event);
-
-    /**
-     * Register the listener to monitor Router,
-     * The Router find master to send downStream.
-     *
-     * @param listener the listener to register
-     */
-    public void addListener(FlowRuleExtRouterListener listener);
-
-    /**
-     * Remove the listener of Router.
-     *
-     * @param listener the listener to remove
-     */
-    public void removeListener(FlowRuleExtRouterListener listener);
-}
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExtRouterListener.java b/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExtRouterListener.java
deleted file mode 100644
index 45caee9..0000000
--- a/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExtRouterListener.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.flowext;
-
-import org.onosproject.net.flow.FlowRuleBatchEvent;
-
-/**
- * Experimental extension to the flow rule subsystem; still under development.
- * The monitor module of the router.
- * <p>
- * The monitor module of router.
- * </p>
- */
-public interface FlowRuleExtRouterListener {
-
-    /**
-     * Notify monitor the router has down its work.
-     *
-     * @param event the event to notify
-     */
-    void notify(FlowRuleBatchEvent event);
-}
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExtService.java b/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExtService.java
deleted file mode 100644
index 7db2545..0000000
--- a/core/api/src/main/java/org/onosproject/net/flowext/FlowRuleExtService.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.net.flowext;
-
-import org.onosproject.net.flow.FlowRuleBatchRequest;
-import org.onosproject.net.flow.FlowRuleService;
-
-import java.util.concurrent.Future;
-
-/**
- * Experimental extension to the flow rule subsystem; still under development.
- * Service for injecting extended flow rules into the environment.
- * This service just send the packet downstream. It won't store the
- * flowRuleExtension in cache.
- */
-public interface FlowRuleExtService extends FlowRuleService {
-    /**
-     * Applies a batch operation of FlowRules.
-     * this batch can be divided into many sub-batch by deviceId, and application
-     * gives a batchId, it means once one flowRule apply failed, all flow rules should
-     * withdraw.
-     *
-     * @param batch batch operation to apply
-     * @return future indicating the state of the batch operation
-     */
-    Future<FlowExtCompletedOperation> applyBatch(FlowRuleBatchRequest batch);
-}
diff --git a/core/api/src/main/java/org/onosproject/net/flowext/package-info.java b/core/api/src/main/java/org/onosproject/net/flowext/package-info.java
deleted file mode 100644
index 6f72ab1..0000000
--- a/core/api/src/main/java/org/onosproject/net/flowext/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Experimental extension to the flow rule subsystem; still under development.
- * <p>
- * This package is an extension for the current ONOS flow rule API.
- * Its main purpose is to support external applications to push service data to network elements.
- * The service data could be any kind of service related data or commands required for corresponding service
- * setup and other operations as defined by application and its communicating device.
- * </p>
- */
-package org.onosproject.net.flowext;
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
index 44a300e..7ad8f70 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultFlowRuleTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014-2015 Open Networking Laboratory
+ * Copyright 2014 Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
 package org.onosproject.net.flow;
 
 import org.junit.Test;
+import org.onosproject.core.DefaultGroupId;
 import org.onosproject.net.intent.IntentTestsMocks;
 
 import com.google.common.testing.EqualsTester;
@@ -36,9 +37,11 @@
     private static final IntentTestsMocks.MockTreatment TREATMENT =
             new IntentTestsMocks.MockTreatment();
 
-    final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1);
-    final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1);
-    final FlowRule flowRule2 = new IntentTestsMocks.MockFlowRule(2);
+    private static byte [] b = new byte[3];
+    private static FlowRuleExtPayLoad payLoad = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
+    final FlowRule flowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
+    final FlowRule sameAsFlowRule1 = new IntentTestsMocks.MockFlowRule(1, payLoad);
+    final FlowRule flowRule2 = new IntentTestsMocks.MockFlowRule(2, payLoad);
     final DefaultFlowRule defaultFlowRule1 = new DefaultFlowRule(flowRule1);
     final DefaultFlowRule sameAsDefaultFlowRule1 = new DefaultFlowRule(sameAsFlowRule1);
     final DefaultFlowRule defaultFlowRule2 = new DefaultFlowRule(flowRule2);
@@ -59,7 +62,6 @@
     public void testEquals() {
         new EqualsTester()
                 .addEqualityGroup(defaultFlowRule1, sameAsDefaultFlowRule1)
-                .addEqualityGroup(defaultFlowRule2)
                 .testEquals();
     }
 
@@ -76,6 +78,7 @@
         assertThat(defaultFlowRule1.selector(), is(flowRule1.selector()));
         assertThat(defaultFlowRule1.treatment(), is(flowRule1.treatment()));
         assertThat(defaultFlowRule1.timeout(), is(flowRule1.timeout()));
+        assertThat(defaultFlowRule1.payLoad(), is(flowRule1.payLoad()));
     }
 
     /**
@@ -97,6 +100,38 @@
     }
 
     /**
+     * Tests creation of a DefaultFlowRule using a PayLoad constructor.
+     */
+    @Test
+    public void testCreationWithPayLoadByFlowTable() {
+        final DefaultFlowRule rule =
+                new DefaultFlowRule(did("1"), null,
+                        null, 22, APP_ID,
+                44, false, payLoad);
+        assertThat(rule.deviceId(), is(did("1")));
+        assertThat(rule.isPermanent(), is(false));
+        assertThat(rule.priority(), is(22));
+        assertThat(rule.timeout(), is(44));
+        assertThat(defaultFlowRule1.payLoad(), is(payLoad));
+    }
+
+    /**
+     * Tests creation of a DefaultFlowRule using a PayLoad constructor.
+     */
+    @Test
+    public void testCreationWithPayLoadByGroupTable() {
+        final DefaultFlowRule rule =
+                new DefaultFlowRule(did("1"), null,
+                        null, 22, APP_ID, new DefaultGroupId(0),
+                44, false, payLoad);
+        assertThat(rule.deviceId(), is(did("1")));
+        assertThat(rule.isPermanent(), is(false));
+        assertThat(rule.priority(), is(22));
+        assertThat(rule.timeout(), is(44));
+        assertThat(rule.groupId(), is(new DefaultGroupId(0)));
+        assertThat(defaultFlowRule1.payLoad(), is(payLoad));
+    }
+    /**
      * Tests the creation of a DefaultFlowRule using an AppId constructor.
      */
     @Test
diff --git a/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java b/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java
new file mode 100644
index 0000000..30326a2
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/flow/FlowRuleExtPayLoadTest.java
@@ -0,0 +1,36 @@
+package org.onosproject.net.flow;
+
+import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
+
+import org.junit.Test;
+
+import com.google.common.testing.EqualsTester;
+/**
+ * Test for FlowRuleExtPayLoad.
+ */
+public class FlowRuleExtPayLoadTest {
+    final byte[] b = new byte[3];
+    final byte[] b1 = new byte[5];
+    final FlowRuleExtPayLoad payLoad1 = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
+    final FlowRuleExtPayLoad sameAsPayLoad1 = FlowRuleExtPayLoad.flowRuleExtPayLoad(b);
+    final FlowRuleExtPayLoad payLoad2 = FlowRuleExtPayLoad.flowRuleExtPayLoad(b1);
+
+    /**
+     * Checks that the FlowRuleExtPayLoad class is immutable.
+     */
+    @Test
+    public void testImmutability() {
+        assertThatClassIsImmutable(FlowRuleExtPayLoad.class);
+    }
+
+    /**
+     * Checks the operation of equals(), hashCode() and toString() methods.
+     */
+    @Test
+    public void testEquals() {
+        new EqualsTester()
+                .addEqualityGroup(payLoad1, sameAsPayLoad1)
+                .addEqualityGroup(payLoad2)
+                .testEquals();
+    }
+}
diff --git a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
index be7f790..ace4ff5 100644
--- a/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
+++ b/core/api/src/test/java/org/onosproject/net/intent/IntentTestsMocks.java
@@ -17,6 +17,7 @@
 
 import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableSet;
+
 import org.onosproject.core.DefaultGroupId;
 import org.onosproject.core.GroupId;
 import org.onosproject.net.DeviceId;
@@ -27,6 +28,7 @@
 import org.onosproject.net.Path;
 import org.onosproject.net.flow.FlowId;
 import org.onosproject.net.flow.FlowRule;
+import org.onosproject.net.flow.FlowRuleExtPayLoad;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.flow.criteria.Criterion;
@@ -336,12 +338,21 @@
         int tableId;
         long timestamp;
         int id;
+        FlowRuleExtPayLoad payLoad;
 
         public MockFlowRule(int priority) {
             this.priority = priority;
             this.tableId = 0;
             this.timestamp = System.currentTimeMillis();
             this.id = nextId++;
+            this.payLoad = null;
+        }
+
+        public MockFlowRule(int priority, FlowRuleExtPayLoad payLoad) {
+            this.priority = priority;
+            this.timestamp = System.currentTimeMillis();
+            this.id = nextId++;
+            this.payLoad = payLoad;
         }
 
         @Override
@@ -411,6 +422,11 @@
         public int tableId() {
             return tableId;
         }
+
+        @Override
+        public FlowRuleExtPayLoad payLoad() {
+            return payLoad;
+        }
     }
 
     public static class MockIntent extends Intent {