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.manager.impl.dynamicmbean;
10 import javax.management.Attribute;
11 import javax.management.AttributeList;
12 import javax.management.AttributeNotFoundException;
13 import javax.management.InvalidAttributeValueException;
14 import javax.management.MBeanException;
15 import javax.management.MBeanServer;
16 import javax.management.ReflectionException;
17 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
18 import org.opendaylight.controller.config.api.ModuleIdentifier;
19 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
20 import org.opendaylight.controller.config.spi.Module;
23 * Wraps {@link org.opendaylight.controller.config.spi.Module} in a
24 * {@link DynamicMBeanWithInstance}. Setting attributes is disabled.
26 public class DynamicReadableWrapper extends AbstractDynamicWrapper implements
27 DynamicMBeanWithInstance {
28 private final AutoCloseable instance;
30 public DynamicReadableWrapper(final Module module, final AutoCloseable instance,
31 final ModuleIdentifier moduleIdentifier, final MBeanServer internalServer,
32 final MBeanServer configMBeanServer) {
33 super(module, false, moduleIdentifier, ObjectNameUtil
34 .createReadOnlyModuleON(moduleIdentifier),
35 getEmptyOperations(), internalServer, configMBeanServer);
36 this.instance = instance;
40 public Module getModule() {
45 public AutoCloseable getInstance() {
50 public Object invoke(final String actionName, final Object[] params, final String[] signature)
51 throws MBeanException, ReflectionException {
52 if ("getInstance".equals(actionName)
53 && (params == null || params.length == 0)
54 && (signature == null || signature.length == 0)) {
57 return super.invoke(actionName, params, signature);
61 public Object getAttribute(final String attributeName)
62 throws AttributeNotFoundException, MBeanException,
64 if ("getInstance".equals(attributeName)) {
67 return super.getAttribute(attributeName);
71 public void setAttribute(final Attribute attribute)
72 throws AttributeNotFoundException, InvalidAttributeValueException,
73 MBeanException, ReflectionException {
74 throw new UnsupportedOperationException(
75 "setAttributes is not supported on " + moduleIdentifier);
79 public AttributeList setAttributes(final AttributeList attributes) {
80 throw new UnsupportedOperationException(
81 "setAttributes is not supported on " + moduleIdentifier);