Initial code drop of yang model driven configuration system
[controller.git] / opendaylight / config / config-api / src / main / java / org / opendaylight / controller / config / api / DependencyResolver.java
diff --git a/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/DependencyResolver.java b/opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/DependencyResolver.java
new file mode 100644 (file)
index 0000000..a2b171a
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.config.api;
+
+import javax.management.ObjectName;
+
+import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
+
+/**
+ * Each new {@link org.opendaylight.controller.config.spi.Module} can receive
+ * resolver from {@link org.opendaylight.controller.config.spi.ModuleFactory}
+ * for looking up dependencies during validation and second phase commit.
+ *
+ * @see org.opendaylight.controller.config.spi.Module
+ */
+public interface DependencyResolver {
+
+    /**
+     * To be used during validation phase to validate serice interface of
+     * dependent module.
+     *
+     * @param expectedServiceInterface
+     *            MBean/MXBean interface which will back the proxy object.
+     * @param objectName
+     *            ObjectName of dependent module without transaction name
+     *            (platformON).
+     * @param jmxAttribute
+     * @throws {@link IllegalArgumentException} when module is not found
+     * @throws {@link IllegalStateException} if module does not export this
+     *         service interface.
+     */
+    void validateDependency(
+            Class<? extends AbstractServiceInterface> expectedServiceInterface,
+            ObjectName objectName, JmxAttribute jmxAttribute);
+
+    @Deprecated
+    // TODO remove once all config code is generated
+    void validateDependency(
+            Class<? extends AbstractServiceInterface> expectedServiceInterface,
+            ObjectName objectName, String attributeNameForErrorReporting);
+
+    /**
+     * To be used during commit phase to wire actual dependencies.
+     *
+     * @return dependency instance using
+     *         {@link org.opendaylight.controller.config.spi.Module#getInstance()}
+     * @throws {@link IllegalArgumentException} when module is not found
+     */
+    <T> T resolveInstance(Class<T> expectedType, ObjectName objectName,
+            JmxAttribute jmxAttribute);
+
+    @Deprecated
+    <T> T resolveInstance(Class<T> expectedType, ObjectName objectName);
+
+}