X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fapi%2FDependencyResolver.java;h=813e55426b203bc1a679f4daa1d221bff1a6650b;hb=dd4468c48a1a0e807f4dffba879c939006c99086;hp=b020000d3d742b93ec71ea602c30e902e759fb27;hpb=07c30f447bd1366ba18e6f0f41ac768a16dbc901;p=controller.git 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 index b020000d3d..813e55426b 100644 --- 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 @@ -7,12 +7,15 @@ */ package org.opendaylight.controller.config.api; +import javax.management.AttributeNotFoundException; +import javax.management.InstanceNotFoundException; +import javax.management.MBeanException; +import javax.management.ObjectName; +import javax.management.ReflectionException; import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface; import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import javax.management.ObjectName; - /** * Each new {@link org.opendaylight.controller.config.spi.Module} can receive * resolver from {@link org.opendaylight.controller.config.spi.ModuleFactory} @@ -23,18 +26,16 @@ import javax.management.ObjectName; public interface DependencyResolver extends Identifiable { /** - * To be used during validation phase to validate serice interface of + * To be used during validation phase to validate service 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. + * @param expectedServiceInterface MBean/MXBean interface which will back the proxy object. + * @param objectName ObjectName of dependent module without transaction name + * (platformON). + * @param jmxAttribute for reporting + * @throws IllegalArgumentException when module is not found + * @throws IllegalStateException if module does not export this + * service interface. */ void validateDependency( Class expectedServiceInterface, @@ -44,13 +45,12 @@ public interface DependencyResolver extends Identifiable { * 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 + * {@link org.opendaylight.controller.config.spi.Module#getInstance()} + * @throws IllegalArgumentException when module is not found */ T resolveInstance(Class expectedType, ObjectName objectName, - JmxAttribute jmxAttribute); + JmxAttribute jmxAttribute); - // TODO finish javadoc /** * To be used during commit phase to resolve identity-ref config attributes. @@ -59,6 +59,40 @@ public interface DependencyResolver extends Identifiable { */ Class resolveIdentity(IdentityAttributeRef identityRef, Class expectedBaseClass); + + /** + * Validate identity-ref config attribute. + */ void validateIdentity(IdentityAttributeRef identityRef, Class expectedBaseClass, JmxAttribute jmxAttribute); + /** + * Can be used during validation or commit phase to get attribute value of dependent module. + * + * @param name either direct ObjectName of a Module (type=Module) or service reference (type=ServiceReference) of dependent Module + * @param attribute String identifying attribute name in JMX. Note that attributes start with upper case. See {@link org.opendaylight.controller.config.api.JmxAttribute#getAttributeName()} + */ + Object getAttribute(ObjectName name, String attribute) + throws MBeanException, AttributeNotFoundException, + InstanceNotFoundException, ReflectionException; + + + /** + * Helper method around {@link javax.management.JMX#newMXBeanProxy(javax.management.MBeanServerConnection, javax.management.ObjectName, Class)} }. + * Returns MXBean proxy for dependent module. Can be used during validation or commit phase to inspect dependent module's attributes. + * + * @param objectName either direct ObjectName of a Module (type=Module) or service reference (type=ServiceReference) of dependent Module + * @param interfaceClass MXBean interface to be used as a proxy + * @param type of proxy for type safe return value + * @return instance of MXBean proxy + */ + T newMXBeanProxy(ObjectName objectName, Class interfaceClass); + + /** + * Check whether a dependency will be reused or (re)created. Useful when deciding if current module could be also reused. + * + * @param objectName ObjectName ID of a dependency + * @param jmxAttribute JMXAttribute ID of a dependency + * @return true if the dependency will be reused false otherwise + */ + boolean canReuseDependency(ObjectName objectName, JmxAttribute jmxAttribute); }