ONOS-3503 Remove OchPort out of core.

- Implementation of a Behavior OpticalDevice has the knowledge of
  translating annotations into optical specific port.
- OpticalDeviceServiceView checks if the Device is a OpticalDevice
  and translate all the Ports to optical specific port before returning.

- This commit contains feedbacks, issues, and fixes by Michele Santuari.

- Note: 3 more Port types to go (OduClt, Oms, Otu)

Change-Id: I4cbda8bc1922fbdd4dac8de8d02294bad74b8058
diff --git a/core/api/src/main/java/org/onosproject/net/OchPort.java b/core/api/src/main/java/org/onosproject/net/OchPort.java
index 1997a88..1b544e6 100644
--- a/core/api/src/main/java/org/onosproject/net/OchPort.java
+++ b/core/api/src/main/java/org/onosproject/net/OchPort.java
@@ -24,7 +24,10 @@
  * Implementation of OCh port (Optical Channel).
  * Also referred to as a line side port (L-port) or narrow band port.
  * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ *
+ * @deprecated in Goldeneye (1.6.0)
  */
+@Deprecated
 public class OchPort extends DefaultPort {
 
     private final OduSignalType signalType;
diff --git a/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java b/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java
index 1b2fd34..a507e49 100644
--- a/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/device/DefaultPortDescription.java
@@ -37,7 +37,7 @@
     private final long portSpeed;
 
     /**
-     * Creates a port description using the supplied information.
+     * Creates a DEFAULT_SPEED COPPER port description using the supplied information.
      *
      * @param number      port number
      * @param isEnabled   port enabled state
diff --git a/core/api/src/main/java/org/onosproject/net/device/OchPortDescription.java b/core/api/src/main/java/org/onosproject/net/device/OchPortDescription.java
index b6398f4..6397764 100644
--- a/core/api/src/main/java/org/onosproject/net/device/OchPortDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/device/OchPortDescription.java
@@ -16,6 +16,7 @@
 package org.onosproject.net.device;
 
 import com.google.common.base.MoreObjects;
+
 import org.onosproject.net.OchSignal;
 import org.onosproject.net.OduSignalType;
 import org.onosproject.net.Port;
@@ -26,7 +27,10 @@
 
 /**
  * Default implementation of immutable OCh port description.
+ *
+ * @deprecated in Goldeneye (1.6.0)
  */
+@Deprecated
 public class OchPortDescription extends DefaultPortDescription {
 
     private final OduSignalType signalType;
@@ -42,7 +46,10 @@
      * @param isTunable   tunable wavelength capability
      * @param lambda      OCh signal
      * @param annotations optional key/value annotations map
+     *
+     * @deprecated in Goldeneye (1.6.0)
      */
+    @Deprecated
     public OchPortDescription(PortNumber number, boolean isEnabled, OduSignalType signalType,
                               boolean isTunable, OchSignal lambda, SparseAnnotations... annotations) {
         super(number, isEnabled, Port.Type.OCH, 0, annotations);
@@ -59,7 +66,10 @@
      * @param isTunable   tunable wavelength capability
      * @param lambda      OCh signal
      * @param annotations optional key/value annotations map
+     *
+     * @deprecated in Goldeneye (1.6.0)
      */
+    @Deprecated
     public OchPortDescription(PortDescription base, OduSignalType signalType, boolean isTunable,
                               OchSignal lambda, SparseAnnotations annotations) {
         super(base, annotations);
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OchPort.java b/core/api/src/main/java/org/onosproject/net/optical/OchPort.java
new file mode 100644
index 0000000..8d19889
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/OchPort.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2016 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.optical;
+
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OCh port (Optical Channel).
+ * Also referred to as a line side port (L-port) or narrow band port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ */
+@Beta
+public interface OchPort extends Port {
+
+    /**
+     * Returns ODU signal type.
+     *
+     * @return ODU signal type
+     */
+    public OduSignalType signalType();
+
+    /**
+     * Returns true if port is wavelength tunable.
+     *
+     * @return tunable wavelength capability
+     */
+    public boolean isTunable();
+
+    /**
+     * Returns OCh signal.
+     *
+     * @return OCh signal
+     */
+    public OchSignal lambda();
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/OpticalDevice.java b/core/api/src/main/java/org/onosproject/net/optical/OpticalDevice.java
new file mode 100644
index 0000000..a1498ab
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/OpticalDevice.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016 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.optical;
+
+import java.util.Optional;
+
+import org.onosproject.net.Device;
+import org.onosproject.net.Port;
+import org.onosproject.net.driver.Behaviour;
+
+import com.google.common.annotations.Beta;
+
+
+// TODO consider more fine grained device type. e.g., Transponder, WSS, ROADM
+/**
+ * Representation of a optical network infrastructure device.
+ */
+@Beta
+public interface OpticalDevice extends Device, Behaviour {
+
+    /**
+     * Returns true if {@code port} is capable of being projected as the
+     * specified class.
+     *
+     * @param port Port instance to test
+     * @param portClass requested projection class
+     * @param <T> type of Port
+     * @return true if the requested projection is supported
+     */
+    <T extends Port> boolean portIs(Port port, Class<T> portClass);
+
+    /**
+     * Returns the specified projection of the {@code port} if such projection
+     * is supported.
+     *
+     * @param port Port instance to project
+     * @param portClass requested projection class
+     * @param <T> type of Port
+     * @return projection instance or empty if not supported.
+     */
+    <T extends Port> Optional<T> portAs(Port port, Class<T> portClass);
+
+    /**
+     * Returns most specific projection of the {@code port} or the {@code port}
+     * itself.
+     *
+     * @param port Port instance
+     * @return projection instance or {@code port} itself
+     */
+    Port port(Port port);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/DefaultOpticalDevice.java b/core/api/src/main/java/org/onosproject/net/optical/device/DefaultOpticalDevice.java
new file mode 100644
index 0000000..5a30cf7
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/DefaultOpticalDevice.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2016 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.optical.device;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Map;
+import java.util.Optional;
+import org.onlab.osgi.DefaultServiceDirectory;
+import org.onosproject.net.Device;
+import org.onosproject.net.Port;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.driver.AbstractBehaviour;
+import org.onosproject.net.driver.DriverData;
+import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OpticalDevice;
+import org.onosproject.net.optical.device.port.OchPortMapper;
+import org.onosproject.net.optical.device.port.PortMapper;
+import org.onosproject.net.optical.utils.ForwardingDevice;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableMap;
+
+// FIXME This needs to be moved back to org.onosproject.net.optical.impl
+// after optical driver package separation process is complete.
+/**
+ * Implementation of {@link OpticalDevice}.
+ * <p>
+ * Currently supports
+ * <ul>
+ *  <li> {@link OchPort}
+ * </ul>
+ */
+@Beta
+public class DefaultOpticalDevice
+        extends AbstractBehaviour
+        implements OpticalDevice, ForwardingDevice {
+
+    private static final Logger log = getLogger(DefaultOpticalDevice.class);
+
+    // shared Port type handler map.
+    // TODO Is there a use case, where we need to differentiate this map per Device?
+    private static final Map<Class<? extends Port>, PortMapper<? extends Port>> MAPPERS
+        = ImmutableMap.<Class<? extends Port>, PortMapper<? extends Port>>builder()
+            .put(OchPort.class, new OchPortMapper())
+            // TODO add other optical port type here
+            .build();
+
+
+
+    // effectively final
+    private Device delegate;
+
+    // Default constructor required as a Behaviour.
+    public DefaultOpticalDevice() {}
+
+    @Override
+    public Device delegate() {
+        if (delegate == null) {
+            // dirty work around.
+            // wanted to pass delegate Device at construction,
+            // but was not possible. A Behaviour requires no-arg constructor.
+            checkState(data() != null, "DriverData must exist");
+            DriverData data = data();
+            DeviceService service = DefaultServiceDirectory.getService(DeviceService.class);
+            delegate = checkNotNull(service.getDevice(data.deviceId()),
+                                    "No Device found for %s", data.deviceId());
+        }
+        return delegate;
+    }
+
+    @Override
+    public <T extends Port> boolean portIs(Port port, Class<T> portClass) {
+
+        PortMapper<? extends Port> mapper = MAPPERS.get(portClass);
+        if (mapper != null) {
+            return mapper.is(port);
+        }
+        return false;
+    }
+
+    @Override
+    public <T extends Port> Optional<T> portAs(Port port, Class<T> portClass) {
+        PortMapper<? extends Port> mapper = MAPPERS.get(portClass);
+        if (mapper != null) {
+            return (Optional<T>) (mapper.as(port));
+        }
+        return Optional.empty();
+    }
+
+    @Override
+    public Port port(Port port) {
+        for (PortMapper<? extends Port> mapper : MAPPERS.values()) {
+            if (mapper.is(port)) {
+                return mapper.as(port).map(Port.class::cast).orElse(port);
+            }
+        }
+        return port;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return delegate().equals(obj);
+    }
+
+    @Override
+    public int hashCode() {
+        return delegate().hashCode();
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("delegate", delegate)
+                .toString();
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OchPortHelper.java b/core/api/src/main/java/org/onosproject/net/optical/device/OchPortHelper.java
new file mode 100644
index 0000000..50dc98c
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/OchPortHelper.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2016 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.optical.device;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.io.IOException;
+import java.util.Optional;
+
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultAnnotations.Builder;
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.impl.DefaultOchPort;
+import org.onosproject.net.optical.json.OchSignalCodec;
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.annotations.Beta;
+
+/**
+ * OCh port related helpers.
+ */
+@Beta
+public final class OchPortHelper {
+
+    private static final Logger log = getLogger(OchPortHelper.class);
+
+    private static final ObjectMapper MAPPER = new ObjectMapper();
+
+    // Annotation keys
+    private static final String SIGNAL_TYPE = "signalType";
+    private static final String TUNABLE = "tunable";
+    private static final String LAMBDA = "lambda";
+
+    /**
+     * Creates OCh port DefaultPortDescription based on the supplied information.
+     *
+     * @param number      port number
+     * @param isEnabled   port enabled state
+     * @param signalType  ODU signal type
+     * @param isTunable   tunable wavelength capability
+     * @param lambda      OCh signal
+     * @return OCh port DefaultPortDescription with OCh annotations
+     */
+    public static PortDescription ochPortDescription(PortNumber number,
+                                                     boolean isEnabled,
+                                                     OduSignalType signalType,
+                                                     boolean isTunable,
+                                                     OchSignal lambda) {
+        return ochPortDescription(number, isEnabled, signalType, isTunable, lambda, DefaultAnnotations.EMPTY);
+    }
+
+    /**
+     * Creates OCh port DefaultPortDescription based on the supplied information.
+     *
+     * @param number      port number
+     * @param isEnabled   port enabled state
+     * @param signalType  ODU signal type
+     * @param isTunable   tunable wavelength capability
+     * @param lambda      OCh signal
+     * @param annotationsIn key/value annotations map
+     * @return OCh port DefaultPortDescription with OCh annotations
+     */
+    public static PortDescription ochPortDescription(PortNumber number,
+                                                     boolean isEnabled,
+                                                     OduSignalType signalType,
+                                                     boolean isTunable,
+                                                     OchSignal lambda,
+                                                     SparseAnnotations annotationsIn) {
+
+        Builder builder = DefaultAnnotations.builder();
+        builder.putAll(annotationsIn);
+
+        builder.set(TUNABLE, String.valueOf(isTunable));
+        builder.set(LAMBDA, OchSignalCodec.encode(lambda).toString());
+        builder.set(SIGNAL_TYPE, signalType.toString());
+
+        DefaultAnnotations annotations = builder.build();
+        long portSpeed = 0; // FIXME assign appropriate value
+        return new DefaultPortDescription(number, isEnabled, Port.Type.OCH, portSpeed, annotations);
+    }
+
+    /**
+     * Creates OCh port DefaultPortDescription based on the supplied information.
+     *
+     * @param base        PortDescription to get basic information from
+     * @param signalType  ODU signal type
+     * @param isTunable   tunable wavelength capability
+     * @param lambda      OCh signal
+     * @param annotations key/value annotations map
+     * @return OCh port DefaultPortDescription with OCh annotations
+     */
+    public static PortDescription ochPortDescription(PortDescription base,
+                                                     OduSignalType signalType,
+                                                     boolean isTunable,
+                                                     OchSignal lambda,
+                                                     SparseAnnotations annotations) {
+        return ochPortDescription(base.portNumber(), base.isEnabled(), signalType, isTunable, lambda, annotations);
+    }
+
+
+    public static Optional<OchPort> asOchPort(Port port) {
+        if (port instanceof OchPort) {
+            return Optional.of((OchPort) port);
+        }
+
+        try {
+            Annotations an = port.annotations();
+
+            OduSignalType signalType = Enum.valueOf(OduSignalType.class,
+                                                    an.value(SIGNAL_TYPE));
+
+            boolean isTunable = Boolean.valueOf(an.value(TUNABLE));
+
+            ObjectNode obj = (ObjectNode) MAPPER.readTree(an.value(LAMBDA));
+            OchSignal lambda = OchSignalCodec.decode(obj);
+
+            // Note: OCh specific annotations is not filtered-out here.
+            //       DefaultOchPort should filter them, if necessary.
+            return Optional.of(new DefaultOchPort(port, signalType, isTunable, lambda));
+
+            // TODO: it'll be better to verify each inputs properly
+            // instead of catching all these Exceptions.
+        } catch (IOException | NullPointerException
+                | IllegalArgumentException | ClassCastException e) {
+
+            log.warn("{} was not well-formed OCh port.", port, e);
+            return Optional.empty();
+        }
+    }
+
+    // not meant to be instantiated
+    private OchPortHelper() {}
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java b/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java
new file mode 100644
index 0000000..c898f70
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2016 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.optical.device;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.optical.OpticalDevice;
+import org.onosproject.net.optical.utils.ForwardingDeviceService;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Element;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+
+
+// TODO replace places using DeviceService expecting Optical specific ports.
+// with this
+
+/**
+ * Decorator, which provides a DeviceService view, which returns
+ * Ports in optical specific ports.
+ */
+@Beta
+public class OpticalDeviceServiceView
+    extends ForwardingDeviceService
+    implements DeviceService {
+
+    private static final Logger log = getLogger(OpticalDeviceServiceView.class);
+
+    /**
+     * DeviceListener to wrapped DeviceListener map.
+     * <p>
+     * {@literal original listener -> wrapped listener}
+     */
+    private final Map<DeviceListener, DeviceListener> wrapped = Maps.newIdentityHashMap();
+
+    // May need a way to monitor Drivers loaded on ONOS and
+    // invalidate this Cache if a driver was added/updated
+    /**
+     * Device to {@link OpticalDevice} map cache.
+     */
+    private final LoadingCache<Element, Optional<OpticalDevice>> optdev
+        = CacheBuilder.newBuilder()
+            .weakKeys() // == for Key comparison
+            .maximumSize(100)
+            .build(CacheLoader.from(elm -> {
+                if (elm.is(OpticalDevice.class)) {
+                    return Optional.of(elm.as(OpticalDevice.class));
+                } else {
+                    return Optional.empty();
+                }
+            }));
+
+    // Not intended to be instantiated directly
+    protected OpticalDeviceServiceView(DeviceService base) {
+        super(base);
+    }
+
+    /**
+     * Wraps the given DeviceService to provide a view,
+     * which returns port as optical specific Port class.
+     *
+     * @param base {@link DeviceService} view to use as baseline.
+     * @return Decorated view of {@code base}
+     */
+    public static OpticalDeviceServiceView opticalView(DeviceService base) {
+        // TODO might make sense to track and assign an instance for each `base`
+        return new OpticalDeviceServiceView(base);
+    }
+
+    /**
+     * Transform Port instance on the event to Optical specific port, if it is well-formed.
+     *
+     * @param event original event to transform
+     * @return transformed {@link DeviceEvent}
+     */
+    public DeviceEvent augment(DeviceEvent event) {
+        final Port port = augment(event.port());
+        if (port == event.port()) {
+            // If the Port not changed, pass through
+            return event;
+        }
+        return new DeviceEvent(event.type(), event.subject(), port, event.time());
+    }
+
+    /**
+     * Transform Port instance to Optical specific port, if it is well-formed.
+     *
+     * @param port Port instance to translate
+     * @return Optical specific port instance or original {@code port}.
+     */
+    public Port augment(Port port) {
+        if (port == null) {
+            return null;
+        }
+        return optdev.getUnchecked(port.element())
+            .map(odev -> odev.port(port))
+            .orElse(port);
+    }
+
+    @Override
+    public void addListener(DeviceListener listener) {
+        super.addListener(wrapped.computeIfAbsent(listener, OpticalDeviceListener::new));
+    }
+
+    @Override
+    public void removeListener(DeviceListener listener) {
+        DeviceListener wrappedListener = wrapped.remove(listener);
+        if (wrappedListener != null) {
+            super.removeListener(wrappedListener);
+        }
+    }
+
+
+    @Override
+    public List<Port> getPorts(DeviceId deviceId) {
+        return Lists.transform(super.getPorts(deviceId),
+                               this::augment);
+    }
+
+    @Override
+    public Port getPort(DeviceId deviceId, PortNumber portNumber) {
+        return augment(super.getPort(deviceId, portNumber));
+    }
+
+
+    /**
+     * DeviceListener, which translates generic Port to optical specific Port
+     * before passing.
+     */
+    class OpticalDeviceListener implements DeviceListener {
+
+        private final DeviceListener listener;
+
+        // shallow cache to reuse transformed event in isRelevant and event call
+        private Pair<DeviceEvent, DeviceEvent> cache;
+
+        public OpticalDeviceListener(DeviceListener listener) {
+            this.listener = listener;
+        }
+
+        private DeviceEvent opticalEvent(DeviceEvent event) {
+
+            Pair<DeviceEvent, DeviceEvent> entry = cache;
+            if (entry != null && entry.getLeft() == event) {
+                return entry.getRight();
+            }
+
+            DeviceEvent opticalEvent = augment(event);
+            cache = Pair.of(event, opticalEvent);
+            return opticalEvent;
+        }
+
+        @Override
+        public boolean isRelevant(DeviceEvent event) {
+            return listener.isRelevant(opticalEvent(event));
+        }
+
+        @Override
+        public void event(DeviceEvent event) {
+            listener.event(opticalEvent(event));
+        }
+    }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/device/package-info.java
new file mode 100644
index 0000000..20b6d33
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * Optical device models.
+ */
+package org.onosproject.net.optical.device;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/AbstractPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/AbstractPortMapper.java
new file mode 100644
index 0000000..8162dd3
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/port/AbstractPortMapper.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016-present 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.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+
+/**
+ * PortMapper which caches mapped Port instance.
+ */
+@Beta
+public abstract class AbstractPortMapper<P extends Port> implements PortMapper<P> {
+
+    private final LoadingCache<Port, Optional<P>> cache
+            = CacheBuilder.newBuilder()
+                .weakKeys() // use == to compare keys
+                .maximumSize(100)
+                .build(CacheLoader.from(this::mapPort));
+
+    /**
+     * {@inheritDoc}
+     *
+     * <p>
+     * Note: Subclasses should override and implement short-cut conditions
+     * and call {@code super.is(port)}.
+     */
+    @Override
+    public boolean is(Port port) {
+        return as(port).isPresent();
+    }
+
+    /**
+     * {@inheritDoc}
+     *
+     * <p>
+     * Note: Subclasses should override and check if {@code port} is
+     * already of type {@code P} and directly return {@code Optional.of((P) port)},
+     * if not call {@code super.as(port)}.
+     */
+    @Override
+    public Optional<P> as(Port port) {
+        if (port == null) {
+            return Optional.empty();
+        }
+        return cache.getUnchecked(port);
+    }
+
+    /**
+     * Returns {@code port} mapped to {@code <P>}.
+     *
+     * @param port Port to map
+     * @return {@code port} mapped to {@code <P>}
+     */
+    protected abstract Optional<P> mapPort(Port port);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/IdentityMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/IdentityMapper.java
new file mode 100644
index 0000000..40c25af
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/port/IdentityMapper.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016-present 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.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} which simply return given input.
+ */
+@Beta
+public class IdentityMapper implements PortMapper<Port> {
+
+    @Override
+    public boolean is(Port port) {
+        return true;
+    }
+
+    @Override
+    public Optional<Port> as(Port port) {
+        return Optional.of(port);
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/OchPortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/OchPortMapper.java
new file mode 100644
index 0000000..badca9d
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/port/OchPortMapper.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016-present 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.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.device.OchPortHelper;
+import org.onosproject.net.optical.impl.DefaultOchPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} to handler {@link OchPort} translation.
+ */
+@Beta
+public class OchPortMapper extends AbstractPortMapper<OchPort> {
+
+    @Override
+    public boolean is(Port port) {
+        return port != null &&
+               port.type() == Port.Type.OCH &&
+               super.is(port);
+    }
+
+    @Override
+    public Optional<OchPort> as(Port port) {
+        if (port instanceof OchPort) {
+            return Optional.of((OchPort) port);
+        }
+        return super.as(port);
+    }
+
+    @Override
+    protected Optional<OchPort> mapPort(Port port) {
+        if (port instanceof OchPort) {
+            return Optional.of((OchPort) port);
+        } else if (port instanceof org.onosproject.net.OchPort) {
+            // TODO remove after deprecation of old OchPort is complete
+
+            // translate to new OchPort
+            org.onosproject.net.OchPort old = (org.onosproject.net.OchPort) port;
+            return Optional.of(new DefaultOchPort(old,
+                                                  old.signalType(),
+                                                  old.isTunable(),
+                                                  old.lambda()));
+        }
+
+        return OchPortHelper.asOchPort(port);
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/PortMapper.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/PortMapper.java
new file mode 100644
index 0000000..90da7ae
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/port/PortMapper.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016-present 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.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Abstraction of a class capable of  translating generic-Port object
+ * as another domain-specific Port of type {@code P}.
+ *
+ * @param <P> Port type to map generic Port to
+ */
+@Beta
+public interface PortMapper<P extends Port> {
+
+    /**
+     * Returns true if this port is capable of being projected as {@code <P>}.
+     */
+    boolean is(Port port);
+
+    /**
+     * Returns {@code port} mapped to {@code <P>}.
+     *
+     * @param port Port to map
+     * @return {@code port} mapped to {@code <P>}
+     */
+    Optional<P> as(Port port);
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/device/port/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/device/port/package-info.java
new file mode 100644
index 0000000..4b53003
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/device/port/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2016-present 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.
+ */
+/**
+ * Optical device port related utilities.
+ */
+package org.onosproject.net.optical.device.port;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java
new file mode 100644
index 0000000..019f8c9
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java
@@ -0,0 +1,145 @@
+/*
+ * 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.optical.impl;
+
+import org.onosproject.net.Annotations;
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.utils.ForwardingPort;
+
+import com.google.common.annotations.Beta;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * Implementation of OCh port (Optical Channel).
+ * Also referred to as a line side port (L-port) or narrow band port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ */
+@Beta
+public class DefaultOchPort extends ForwardingPort implements OchPort {
+
+    // Note: try to avoid direct access to the field, use accessor.
+    // We might want to lazily parse annotation in the future
+    private final OduSignalType signalType;
+    private final boolean isTunable;
+    private final OchSignal lambda;
+
+    /**
+     * Creates an OCh port in the specified network element.
+     *
+     * @param base Port
+     * @param signalType  ODU signal type
+     * @param isTunable   tunable wavelength capability
+     * @param lambda      OCh signal
+     */
+    public DefaultOchPort(Port base,
+                          OduSignalType signalType,
+                          boolean isTunable,
+                          OchSignal lambda) {
+        super(base);
+        // TODO should this class be parsing annotation to instantiate signalType?
+        this.signalType = checkNotNull(signalType);
+        this.isTunable = isTunable;
+        this.lambda = checkNotNull(lambda);
+    }
+
+    @Override
+    public Type type() {
+        return Type.OCH;
+    }
+
+    @Override
+    public long portSpeed() {
+        return signalType.bitRate();
+    }
+
+
+    @Override
+    public Annotations annotations() {
+        // FIXME Filter OCh annotations, after confirming that
+        // it'll not result in information-loss
+        return super.annotations();
+    }
+
+    /**
+     * Returns ODU signal type.
+     *
+     * @return ODU signal type
+     */
+    @Override
+    public OduSignalType signalType() {
+        return signalType;
+    }
+
+    /**
+     * Returns true if port is wavelength tunable.
+     *
+     * @return tunable wavelength capability
+     */
+    @Override
+    public boolean isTunable() {
+        return isTunable;
+    }
+
+    /**
+     * Returns OCh signal.
+     *
+     * @return OCh signal
+     */
+    @Override
+    public OchSignal lambda() {
+        return lambda;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(super.hashCode(),
+                            signalType(),
+                            isTunable(),
+                            lambda());
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (obj != null && getClass() == obj.getClass()) {
+            final DefaultOchPort that = (DefaultOchPort) obj;
+            return super.toEqualsBuilder(that)
+                    .append(this.signalType(), that.signalType())
+                    .append(this.isTunable(), that.isTunable())
+                    .append(this.lambda(), that.lambda())
+                    .isEquals();
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return super.toStringHelper()
+                .add("signalType", signalType())
+                .add("isTunable", isTunable())
+                .add("lambda", lambda())
+                .toString();
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/impl/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/impl/package-info.java
new file mode 100644
index 0000000..8542c62
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/impl/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2016 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.
+ */
+
+// Note: All classes in this package is expected to be instance local, and
+// are not expected to be serialized (by Kryo, etc.)
+/**
+ * Implementation of Optical augmentation classes.
+ */
+package org.onosproject.net.optical.impl;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/json/OchSignalCodec.java b/core/api/src/main/java/org/onosproject/net/optical/json/OchSignalCodec.java
new file mode 100644
index 0000000..0fba4fa
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/json/OchSignalCodec.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2016 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.optical.json;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import org.onosproject.net.ChannelSpacing;
+import org.onosproject.net.GridType;
+import org.onosproject.net.OchSignal;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.annotations.Beta;
+
+// TODO define common interface for JsonCodec for annotation?
+// unlike existing JsonCodec, this use-case requires that encode/decode is
+// reversible.  (e.g., obj.equals(decode(encode(obj))))
+/**
+ * JSON codec for OchSignal.
+ */
+@Beta
+public abstract class OchSignalCodec {
+
+    // TODO should probably use shared mapper across optical codecs.
+    private static final ObjectMapper MAPPER = new ObjectMapper();
+
+    /**
+     * Creates an instance of {@link OchSignal} from JSON representation.
+     *
+     * @param obj JSON Object representing OchSignal
+     * @return OchSignal
+     * @throws IllegalArgumentException - if JSON object is ill-formed
+     * @see OchSignalCodec#encode(OchSignal)
+     */
+    public static OchSignal decode(ObjectNode obj) {
+        final GridType gridType;
+        final ChannelSpacing channelSpacing;
+        final int spacingMultiplier;
+        final int slotGranularity;
+
+        String s;
+        s = obj.get("channelSpacing").textValue();
+        checkArgument(s != null, "ill-formed channelSpacing");
+        channelSpacing = Enum.valueOf(ChannelSpacing.class, s);
+
+        s = obj.get("gridType").textValue();
+        checkArgument(s != null, "ill-formed gridType");
+        gridType = Enum.valueOf(GridType.class, s);
+
+        JsonNode node;
+        node = obj.get("spacingMultiplier");
+        checkArgument(node.canConvertToInt(), "ill-formed spacingMultiplier");
+        spacingMultiplier = node.asInt();
+
+        node = obj.get("slotGranularity");
+        checkArgument(node.canConvertToInt(), "ill-formed slotGranularity");
+        slotGranularity = node.asInt();
+
+        return new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity);
+    }
+
+    /**
+     * Returns a JSON Object representation of this instance.
+     *
+     * @return JSON Object representing OchSignal
+     */
+    public static ObjectNode encode(OchSignal j) {
+        ObjectNode obj = MAPPER.createObjectNode();
+        obj.put("channelSpacing", j.channelSpacing().toString());
+        obj.put("gridType", j.gridType().toString());
+        obj.put("slotGranularity", j.slotGranularity());
+        obj.put("spacingMultiplier", j.spacingMultiplier());
+        return obj;
+    }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/json/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/json/package-info.java
new file mode 100644
index 0000000..93f2ed3
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/json/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * JSON related utilities.
+ */
+package org.onosproject.net.optical.json;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/package-info.java
new file mode 100644
index 0000000..fbb4d4e
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2016 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.
+ */
+
+// Note: this package sub-tree will be moved out from onos-api bundle soon.
+/**
+ * Optical augmentation classes.
+ */
+package org.onosproject.net.optical;
diff --git a/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDevice.java b/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDevice.java
new file mode 100644
index 0000000..389f42b
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDevice.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2016 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.optical.utils;
+
+import org.onlab.packet.ChassisId;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.driver.Behaviour;
+import org.onosproject.net.provider.ProviderId;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * A Device which forwards all its method calls to another Device.
+ */
+@Beta
+public interface ForwardingDevice extends Device {
+
+    Device delegate();
+
+    @Override
+    default Annotations annotations() {
+        return delegate().annotations();
+    }
+
+    @Override
+    default ProviderId providerId() {
+        return delegate().providerId();
+    }
+
+    @Override
+    default <B extends Behaviour> B as(Class<B> projectionClass) {
+        return delegate().as(projectionClass);
+    }
+
+    @Override
+    default DeviceId id() {
+        return delegate().id();
+    }
+
+    @Override
+    default Type type() {
+        return delegate().type();
+    }
+
+    @Override
+    default <B extends Behaviour> boolean is(Class<B> projectionClass) {
+        return delegate().is(projectionClass);
+    }
+
+    @Override
+    default String manufacturer() {
+        return delegate().manufacturer();
+    }
+
+    @Override
+    default String hwVersion() {
+        return delegate().hwVersion();
+    }
+
+    @Override
+    default String swVersion() {
+        return delegate().swVersion();
+    }
+
+    @Override
+    default String serialNumber() {
+        return delegate().serialNumber();
+    }
+
+    @Override
+    default ChassisId chassisId() {
+        return delegate().chassisId();
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDeviceService.java b/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDeviceService.java
new file mode 100644
index 0000000..7bcec14
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingDeviceService.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2016 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.optical.utils;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+
+import org.onosproject.net.Device;
+import org.onosproject.net.Device.Type;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.device.PortStatistics;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * A DeviceService which forwards all its method calls to another DeviceService.
+ */
+@Beta
+public abstract class ForwardingDeviceService implements DeviceService {
+
+    private final DeviceService delegate;
+
+    protected ForwardingDeviceService(DeviceService delegate) {
+        this.delegate = checkNotNull(delegate);
+    }
+
+    protected final DeviceService delegate() {
+        return delegate;
+    }
+
+    @Override
+    public void addListener(DeviceListener listener) {
+        delegate.addListener(listener);
+    }
+
+    @Override
+    public void removeListener(DeviceListener listener) {
+        delegate.removeListener(listener);
+    }
+
+    @Override
+    public int getDeviceCount() {
+        return delegate.getDeviceCount();
+    }
+
+    @Override
+    public Iterable<Device> getDevices() {
+        return delegate.getDevices();
+    }
+
+    @Override
+    public Iterable<Device> getDevices(Type type) {
+        return delegate.getDevices(type);
+    }
+
+    @Override
+    public Iterable<Device> getAvailableDevices() {
+        return delegate.getAvailableDevices();
+    }
+
+    @Override
+    public Iterable<Device> getAvailableDevices(Type type) {
+        return delegate.getAvailableDevices(type);
+    }
+
+    @Override
+    public Device getDevice(DeviceId deviceId) {
+        return delegate.getDevice(deviceId);
+    }
+
+    @Override
+    public MastershipRole getRole(DeviceId deviceId) {
+        return delegate.getRole(deviceId);
+    }
+
+    @Override
+    public List<Port> getPorts(DeviceId deviceId) {
+        return delegate.getPorts(deviceId);
+    }
+
+    @Override
+    public List<PortStatistics> getPortStatistics(DeviceId deviceId) {
+        return delegate.getPortStatistics(deviceId);
+    }
+
+    @Override
+    public List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId) {
+        return delegate.getPortDeltaStatistics(deviceId);
+    }
+
+    @Override
+    public Port getPort(DeviceId deviceId, PortNumber portNumber) {
+        return delegate.getPort(deviceId, portNumber);
+    }
+
+    @Override
+    public boolean isAvailable(DeviceId deviceId) {
+        return delegate.isAvailable(deviceId);
+    }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingPort.java b/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingPort.java
new file mode 100644
index 0000000..f241625
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/utils/ForwardingPort.java
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2016 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.optical.utils;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.Element;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * A Port which forwards all its method calls to another Port.
+ */
+@Beta
+public abstract class ForwardingPort implements Port {
+
+    private final Port delegate;
+
+    protected ForwardingPort(Port delegate) {
+        this.delegate = checkNotNull(delegate);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(element().id(),
+                            number(),
+                            isEnabled(),
+                            type(),
+                            portSpeed(),
+                            annotations());
+    }
+
+    /**
+     * Returns {@link EqualsBuilder} comparing all Port attributes
+     * including annotations.
+     * <p>
+     * To add extra fields to equality,
+     * call {@code super.toEqualsBuilder(..)} and append fields.
+     * To remove field from comparison, override this method
+     * or manually implement equals().
+     */
+    protected EqualsBuilder toEqualsBuilder(Port that) {
+        if (that == null) {
+            return new EqualsBuilder().appendSuper(false);
+        }
+        return new EqualsBuilder()
+                .append(this.element().id(), that.element().id())
+                .append(this.number(), that.number())
+                .append(this.isEnabled(), that.isEnabled())
+                .append(this.type(), that.type())
+                .append(this.portSpeed(), that.portSpeed())
+                .append(this.annotations(), that.annotations());
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (obj != null && getClass() == obj.getClass()) {
+            final ForwardingPort that = (ForwardingPort) obj;
+            return toEqualsBuilder(that)
+                    .isEquals();
+        }
+        return false;
+    }
+
+    /**
+     * Returns {@link ToStringHelper} with Port attributes excluding annotations.
+     *
+     * @return {@link ToStringHelper}
+     */
+    protected ToStringHelper toStringHelper() {
+        return MoreObjects.toStringHelper(this)
+                .add("element", element().id())
+                .add("number", number())
+                .add("isEnabled", isEnabled())
+                .add("type", type())
+                .add("portSpeed", portSpeed());
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper()
+                .toString();
+    }
+
+    @Override
+    public Annotations annotations() {
+        return delegate.annotations();
+    }
+
+    @Override
+    public Element element() {
+        return delegate.element();
+    }
+
+    @Override
+    public PortNumber number() {
+        return delegate.number();
+    }
+
+    @Override
+    public boolean isEnabled() {
+        return delegate.isEnabled();
+    }
+
+    @Override
+    public Port.Type type() {
+        return delegate.type();
+    }
+
+    @Override
+    public long portSpeed() {
+        return delegate.portSpeed();
+    }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/optical/utils/package-info.java b/core/api/src/main/java/org/onosproject/net/optical/utils/package-info.java
new file mode 100644
index 0000000..ae8d0b5
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/optical/utils/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * Utility classes.
+ */
+package org.onosproject.net.optical.utils;