X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fapi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcore%2FNodeConnector.java;h=85a6c22c568cd97894c420c2850eeb848a6a1b14;hb=refs%2Fchanges%2F36%2F1036%2F3;hp=6245c9be8a79d8c17d256f1dd274b6b386a309bf;hpb=2699e9c1550b01d72fea94cc24bb89837edc0d76;p=controller.git diff --git a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java index 6245c9be8a..85a6c22c56 100644 --- a/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java +++ b/opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/core/NodeConnector.java @@ -27,9 +27,10 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.tuple.ImmutablePair; +import org.opendaylight.controller.sal.utils.INodeConnectorFactory; +import org.opendaylight.controller.sal.utils.INodeFactory; +import org.opendaylight.controller.sal.utils.ServiceHelper; /** * Describe a generic network element attachment points, @@ -53,14 +54,14 @@ public class NodeConnector implements Serializable { ConcurrentHashMap, String>> compatibleType = new ConcurrentHashMap, String>>(); /** - * Represents the OFPP_CONTROLLER reserved port to forward a - * packet to the controller, this is to send data packets - * to the controller from the data plane triggering + * Represents the OFPP_CONTROLLER reserved port to forward a + * packet to the controller, this is to send data packets + * to the controller from the data plane triggering * a packet_in event. */ public static String CONTROLLER = "CTRL"; /** - * Represents the OFPP_ALL reserved OF port + * Represents the OFPP_ALL reserved OF port * to forward to ALL the ports in the system , * should be used for flooding like mechanism to * be used cautiously to avoid excessive flooding. @@ -74,8 +75,8 @@ public class NodeConnector implements Serializable { */ public static String SWSTACK = "SW"; /** - * Describes OFPP_Normal reserved port destination that invokes - * the traditional native L2/L3 HW normal forwarding functionality + * Describes OFPP_Normal reserved port destination that invokes + * the traditional native L2/L3 HW normal forwarding functionality * if supported on the forwarding element. */ public static String HWPATH = "HW"; @@ -278,7 +279,7 @@ public class NodeConnector implements Serializable { * * @return the NodeConnectorType of this object */ - @XmlAttribute(name = "type") + @XmlElement(name = "type") public String getType() { return this.nodeConnectorType; } @@ -332,10 +333,10 @@ public class NodeConnector implements Serializable { } } - /** + /** * Private setter for nodeConnectorType to be called by JAXB not by anyone * else, NodeConnector is immutable - * + * * @param type of node to be set */ private void setType(String type) { @@ -361,14 +362,14 @@ public class NodeConnector implements Serializable { * * @return the NodeConnector ID of this object in String format */ - @XmlAttribute(name = "id") + @XmlElement(name = "id") public String getNodeConnectorIDString() { return this.nodeConnectorID.toString(); } - /** + /** * private setter to be used by JAXB - * + * * @param nodeConnectorIDString String representation for NodeConnectorID */ private void setNodeConnectorIDString(String IDStr) { @@ -390,26 +391,46 @@ public class NodeConnector implements Serializable { @Override public int hashCode() { - return new HashCodeBuilder(63389, 4951) - .append(nodeConnectorType) - .append(nodeConnectorID) - .append(nodeConnectorNode) - .hashCode(); + final int prime = 31; + int result = 1; + result = prime * result + + ((nodeConnectorID == null) ? 0 : nodeConnectorID.hashCode()); + result = prime + * result + + ((nodeConnectorNode == null) ? 0 : nodeConnectorNode + .hashCode()); + result = prime + * result + + ((nodeConnectorType == null) ? 0 : nodeConnectorType + .hashCode()); + return result; } @Override public boolean equals(Object obj) { - if (obj == null) { return false; } - if (obj == this) { return true; } - if (obj.getClass() != getClass()) { + if (this == obj) + return true; + if (obj == null) return false; - } - NodeConnector rhs = (NodeConnector)obj; - return new EqualsBuilder() - .append(this.getType(), rhs.getType()) - .append(this.getID(), rhs.getID()) - .append(this.getNode(), rhs.getNode()) - .isEquals(); + if (getClass() != obj.getClass()) + return false; + NodeConnector other = (NodeConnector) obj; + if (nodeConnectorID == null) { + if (other.nodeConnectorID != null) + return false; + } else if (!nodeConnectorID.equals(other.nodeConnectorID)) + return false; + if (nodeConnectorNode == null) { + if (other.nodeConnectorNode != null) + return false; + } else if (!nodeConnectorNode.equals(other.nodeConnectorNode)) + return false; + if (nodeConnectorType == null) { + if (other.nodeConnectorType != null) + return false; + } else if (!nodeConnectorType.equals(other.nodeConnectorType)) + return false; + return true; } @Override @@ -584,8 +605,13 @@ public class NodeConnector implements Serializable { return null; } } else { - // Lookup via OSGi service registry + //Use INodeConnectorFactory to create a NodeConnector of registered type. + //The protocol plugin being used depends on typeStr. + INodeConnectorFactory f = (INodeConnectorFactory) ServiceHelper + .getGlobalInstance(INodeConnectorFactory.class, new NodeConnector(), "(protocolName="+typeStr+")"); + if(f==null) + return null; + return f.fromStringNoNode(typeStr, IDStr, n); } - return null; } }