2 * Copyright (c) 2013 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 serice interface of
32 * @param expectedServiceInterface MBean/MXBean interface which will back the proxy object.
33 * @param objectName ObjectName of dependent module without transaction name
35 * @param jmxAttribute for reporting
36 * @throws IllegalArgumentException when module is not found
37 * @throws IllegalStateException if module does not export this
40 void validateDependency(
41 Class<? extends AbstractServiceInterface> expectedServiceInterface,
42 ObjectName objectName, JmxAttribute jmxAttribute);
45 * To be used during commit phase to wire actual dependencies.
47 * @return dependency instance using
48 * {@link org.opendaylight.controller.config.spi.Module#getInstance()}
49 * @throws IllegalArgumentException when module is not found
51 <T> T resolveInstance(Class<T> expectedType, ObjectName objectName,
52 JmxAttribute jmxAttribute);
55 * To be used during commit phase to resolve identity-ref config attributes.
57 * @return actual class object generated from identity
59 <T extends BaseIdentity> Class<? extends T> resolveIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass);
63 * Validate identity-ref config attribute.
65 <T extends BaseIdentity> void validateIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass, JmxAttribute jmxAttribute);
68 * Can be used during validation or commit phase to get attribute value of dependent module.
70 * @param name either direct ObjectName of a Module (type=Module) or service reference (type=ServiceReference) of dependent Module
71 * @param attribute String identifying attribute name in JMX. Note that attributes start with upper case. See {@link org.opendaylight.controller.config.api.JmxAttribute#getAttributeName()}
73 Object getAttribute(ObjectName name, String attribute)
74 throws MBeanException, AttributeNotFoundException,
75 InstanceNotFoundException, ReflectionException;
79 * Helper method around {@link javax.management.JMX#newMXBeanProxy(javax.management.MBeanServerConnection, javax.management.ObjectName, Class)} }.
80 * Returns MXBean proxy for dependent module. Can be used during validation or commit phase to inspect dependent module's attributes.
82 * @param objectName either direct ObjectName of a Module (type=Module) or service reference (type=ServiceReference) of dependent Module
83 * @param interfaceClass MXBean interface to be used as a proxy
84 * @param <T> type of proxy for type safe return value
85 * @return instance of MXBean proxy
87 <T> T newMXBeanProxy(ObjectName objectName, Class<T> interfaceClass);