NodeFactory service
[controller.git] / opendaylight / sal / api / src / main / java / org / opendaylight / controller / sal / core / Node.java
index ea9d93bdb6f0774b2d5c72128648f4431c72b2a8..4c7f278209096e16c857f57c6f49d9da7ea94c9f 100644 (file)
@@ -30,6 +30,8 @@ import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.opendaylight.controller.sal.utils.HexEncode;
+import org.opendaylight.controller.sal.utils.INodeFactory;
+import org.opendaylight.controller.sal.utils.ServiceHelper;
 
 /**
  * Describe a generic network element in multiple SDNs technologies. A
@@ -437,9 +439,13 @@ public class Node implements Serializable {
                 return null;
             }
         } else {
-            // We need to lookup via OSGi service registry for an
-            // handler for this
+            //Use INodeFactory to create a Node of registered Node type.
+            //The protocol plugin being used depends on typeStr.
+            INodeFactory f = (INodeFactory) ServiceHelper
+                    .getGlobalInstance(INodeFactory.class, new Node(), "(protocolName="+typeStr+")");
+            if(f==null)
+                return null;
+            return f.fromString(IDStr, typeStr);
         }
-        return null;
     }
 }