2 * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.config.api;
10 import javax.management.AttributeNotFoundException;
11 import javax.management.InstanceNotFoundException;
12 import javax.management.MBeanException;
13 import javax.management.ObjectName;
14 import javax.management.ReflectionException;
15 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
16 import org.opendaylight.yangtools.concepts.Identifiable;
17 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
20 * Each new {@link org.opendaylight.controller.config.spi.Module} can receive
21 * resolver from {@link org.opendaylight.controller.config.spi.ModuleFactory}
22 * for looking up dependencies during validation and second phase commit.
24 * @see org.opendaylight.controller.config.spi.Module
26 public interface DependencyResolver extends Identifiable<ModuleIdentifier> {
29 * To be used during validation phase to validate service interface of dependent
32 * @param expectedServiceInterface
33 * MBean/MXBean interface which will back the proxy object.
35 * ObjectName of dependent module without transaction name
39 * @throws IllegalArgumentException
40 * when module is not found
41 * @throws IllegalStateException
42 * if module does not export this service interface.
44 void validateDependency(Class<? extends AbstractServiceInterface> expectedServiceInterface, ObjectName objectName,
45 JmxAttribute jmxAttribute);
48 * To be used during commit phase to wire actual dependencies.
50 * @return dependency instance using
51 * {@link org.opendaylight.controller.config.spi.Module#getInstance()}
52 * @throws IllegalArgumentException
53 * when module is not found
55 <T> T resolveInstance(Class<T> expectedType, ObjectName objectName, JmxAttribute jmxAttribute);
58 * To be used during commit phase to resolve identity-ref config attributes.
60 * @return actual class object generated from identity
62 <T extends BaseIdentity> Class<? extends T> resolveIdentity(IdentityAttributeRef identityRef,
63 Class<T> expectedBaseClass);
66 * Validate identity-ref config attribute.
68 <T extends BaseIdentity> void validateIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass,
69 JmxAttribute jmxAttribute);
72 * Can be used during validation or commit phase to get attribute value of
76 * either direct ObjectName of a Module (type=Module) or service
77 * reference (type=ServiceReference) of dependent Module
79 * String identifying attribute name in JMX. Note that attributes
80 * start with upper case. See
81 * {@link org.opendaylight.controller.config.api.JmxAttribute#getAttributeName()}
83 Object getAttribute(ObjectName name, String attribute)
84 throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException;
87 * Helper method around.
88 * {@link javax.management
89 * .JMX#newMXBeanProxy(javax.management.MBeanServerConnection, javax.management.ObjectName, Class)}}.
91 * Returns MXBean proxy for dependent module. Can be used during validation or
92 * commit phase to inspect dependent module's attributes.
95 * either direct ObjectName of a Module (type=Module) or service
96 * reference (type=ServiceReference) of dependent Module
97 * @param interfaceClass
98 * MXBean interface to be used as a proxy
100 * type of proxy for type safe return value
101 * @return instance of MXBean proxy
103 <T> T newMXBeanProxy(ObjectName objectName, Class<T> interfaceClass);
106 * Check whether a dependency will be reused or (re)created. Useful when
107 * deciding if current module could be also reused.
110 * ObjectName ID of a dependency
111 * @param jmxAttribute
112 * JMXAttribute ID of a dependency
113 * @return true if the dependency will be reused false otherwise
115 boolean canReuseDependency(ObjectName objectName, JmxAttribute jmxAttribute);