import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
import org.opendaylight.controller.sal.core.IContainerListener;
+import org.opendaylight.controller.sal.utils.INodeFactory;
import org.opendaylight.controller.sal.core.Node;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.discovery.IDiscoveryService;
}
public Object[] getGlobalImplementations() {
- Object[] res = { FlowProgrammerService.class };
+ Object[] res = { FlowProgrammerService.class, StubNodeFactory.class };
return res;
}
props.put("protocolPluginType", "STUB");
c.setInterface(IPluginInFlowProgrammerService.class.getName(), props);
}
+ if (imp.equals(StubNodeFactory.class)) {
+ // export the service to be used by SAL
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ // Set the protocolPluginType property which will be used
+ // by SAL
+ props.put("protocolPluginType", "STUB");
+ props.put("protocolName", "STUB");
+ c.setInterface(INodeFactory.class.getName(), props);
+ }
}
}
--- /dev/null
+package org.opendaylight.controller.protocol_plugins.stub.internal;
+
+import org.opendaylight.controller.sal.core.ConstructionException;
+import org.opendaylight.controller.sal.utils.INodeFactory;
+import org.opendaylight.controller.sal.core.Node;
+
+public class StubNodeFactory implements INodeFactory
+ {
+ void init() {
+ }
+
+ /**
+ * Function called by the dependency manager when at least one dependency
+ * become unsatisfied or when the component is shutting down because for
+ * example bundle is being stopped.
+ *
+ */
+ void destroy() {
+ }
+
+ /**
+ * Function called by dependency manager after "init ()" is called and after
+ * the services provided by the class are registered in the service registry
+ *
+ */
+ void start() {
+ }
+
+ /**
+ * Function called by the dependency manager before the services exported by
+ * the component are unregistered, this will be followed by a "destroy ()"
+ * calls
+ *
+ */
+ void stop() {
+ }
+
+ public Node fromString(String nodeId, String nodeType){
+ if(nodeType.equals("STUB"))
+ try{
+ return new Node("STUB", Integer.parseInt(nodeId));
+ } catch(ConstructionException e)
+ {
+ return null;
+ }
+ return null;
+ }
+}
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
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;
}
}
--- /dev/null
+
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.sal.utils;
+
+import org.opendaylight.controller.sal.core.Node;
+
+/**
+ * @file INodeFactory.java
+ *
+ * @brief Define the interface to be called when looking up custom node types
+ *
+ */
+
+public interface INodeFactory {
+ /**
+ * Method to get custom node types from protocol plugins
+ *
+ */
+ public Node fromString(String nodeId, String nodeType);
+}