*/
package org.opendaylight.ovsdb.openstack.netvirt;
-import org.opendaylight.controller.sal.utils.Status;
-import org.opendaylight.controller.sal.utils.StatusCode;
+import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
+import org.opendaylight.ovsdb.openstack.netvirt.api.Status;
+import org.opendaylight.ovsdb.openstack.netvirt.api.StatusCode;
+import com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.HttpURLConnection;
/**
- * Abstract class for utility functions used by neutron handlers.
+ * OpenStack related events originate from multiple north callbacks as well as south.
+ * This interface provides a layer of abstraction between the event dispatcher and the
+ * handlers.
*/
public abstract class AbstractHandler {
*/
static final Logger logger = LoggerFactory.getLogger(AbstractHandler.class);
+ // The implementation for each of these services is resolved by the OSGi Service Manager
+ private volatile EventDispatcher eventDispatcher;
+
+ void init() {
+ logger.info(">>>>> init {}", this.getClass());
+ }
+
/**
* Convert failure status returned by the manager into
* neutron API service errors.
return result;
}
+
+ /**
+ * Enqueue the event.
+ *
+ * @param abstractEvent the {@link org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent} event to be handled.
+ * @see org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher
+ */
+ protected void enqueueEvent(AbstractEvent abstractEvent) {
+ Preconditions.checkNotNull(eventDispatcher);
+ eventDispatcher.enqueueEvent(abstractEvent);
+ }
+
+ /**
+ * Process the event.
+ *
+ * @param abstractEvent the {@link org.opendaylight.ovsdb.openstack.netvirt.AbstractEvent} event to be handled.
+ * @see org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher
+ */
+ public abstract void processEvent(AbstractEvent abstractEvent);
+
}