Cleaning up and enhancing driver subsystem and the flow objective subsystem.
Change-Id: Ica600ef1aaa46d19e764cd7a197454a4e0f85a08
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/DefaultDrivers.java b/drivers/src/main/java/org/onosproject/driver/pipeline/DefaultDrivers.java
index e42e346..580691b 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/DefaultDrivers.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/DefaultDrivers.java
@@ -27,6 +27,7 @@
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.io.InputStream;
/**
* Bootstrap for built in drivers.
@@ -36,6 +37,8 @@
private final Logger log = LoggerFactory.getLogger(getClass());
+ private static final String DRIVERS_XML = "/onos-drivers.xml";
+
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DriverAdminService driverService;
@@ -43,25 +46,23 @@
@Activate
protected void activate() {
- XmlDriverLoader xmlDriverLoader =
- new XmlDriverLoader(getClass().getClassLoader());
+ ClassLoader classLoader = getClass().getClassLoader();
try {
- provider = xmlDriverLoader.loadDrivers(
- getClass().getResourceAsStream("/default.xml"));
- driverService.registerProvider(
- provider);
+ InputStream stream = classLoader.getResourceAsStream(DRIVERS_XML);
+ provider = new XmlDriverLoader(classLoader).loadDrivers(stream);
+ driverService.registerProvider(provider);
} catch (IOException e) {
- log.warn("Unable to load drivers");
+ log.error("Unable to load default drivers", e);
}
-
log.info("Started");
}
@Deactivate
protected void deactivate() {
- driverService.unregisterProvider(provider);
+ if (provider != null) {
+ driverService.unregisterProvider(provider);
+ }
log.info("Stopped");
}
-
}
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/DefaultSingleTablePipeline.java b/drivers/src/main/java/org/onosproject/driver/pipeline/DefaultSingleTablePipeline.java
index 48114ab..6e99b35 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/DefaultSingleTablePipeline.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/DefaultSingleTablePipeline.java
@@ -20,6 +20,7 @@
import org.onosproject.core.DefaultGroupId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.Pipeliner;
+import org.onosproject.net.behaviour.PipelinerContext;
import org.onosproject.net.driver.DriverData;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.FlowRule;
@@ -49,8 +50,8 @@
private DeviceId deviceId;
@Override
- public void init(DeviceId deviceId, ServiceDirectory serviceDirectory) {
- this.serviceDirectory = serviceDirectory;
+ public void init(DeviceId deviceId, PipelinerContext context) {
+ this.serviceDirectory = context.directory();
this.deviceId = deviceId;
flowRuleService = serviceDirectory.get(FlowRuleService.class);
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/OVSCorsaPipeline.java b/drivers/src/main/java/org/onosproject/driver/pipeline/OVSCorsaPipeline.java
index 84dd5db..2ac846c 100644
--- a/drivers/src/main/java/org/onosproject/driver/pipeline/OVSCorsaPipeline.java
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/OVSCorsaPipeline.java
@@ -23,6 +23,7 @@
import org.onosproject.core.CoreService;
import org.onosproject.net.DeviceId;
import org.onosproject.net.behaviour.Pipeliner;
+import org.onosproject.net.behaviour.PipelinerContext;
import org.onosproject.net.driver.DriverData;
import org.onosproject.net.flow.DefaultFlowRule;
import org.onosproject.net.flow.DefaultTrafficSelector;
@@ -61,8 +62,8 @@
private ApplicationId appId;
@Override
- public void init(DeviceId deviceId, ServiceDirectory serviceDirectory) {
- this.serviceDirectory = serviceDirectory;
+ public void init(DeviceId deviceId, PipelinerContext context) {
+ this.serviceDirectory = context.directory();
this.deviceId = deviceId;
diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/package-info.java b/drivers/src/main/java/org/onosproject/driver/pipeline/package-info.java
new file mode 100644
index 0000000..880acf5
--- /dev/null
+++ b/drivers/src/main/java/org/onosproject/driver/pipeline/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementations of the pipeline driver behaviours.
+ */
+package org.onosproject.driver.pipeline;
\ No newline at end of file