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.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;
33 * for recreating Module.
36 public DynamicReadableWrapper(Module module, AutoCloseable instance,
37 ModuleIdentifier moduleIdentifier, MBeanServer internalServer,
38 MBeanServer configMBeanServer) {
39 super(module, false, moduleIdentifier, ObjectNameUtil
40 .createReadOnlyModuleON(moduleIdentifier),
41 getEmptyOperations(), internalServer, configMBeanServer);
42 this.instance = instance;
46 public Module getModule() {
51 public AutoCloseable getInstance() {
56 public Object invoke(String actionName, Object[] params, String[] signature)
57 throws MBeanException, ReflectionException {
58 if ("getInstance".equals(actionName)
59 && (params == null || params.length == 0)
60 && (signature == null || signature.length == 0)) {
63 return super.invoke(actionName, params, signature);
67 public Object getAttribute(String attributeName)
68 throws AttributeNotFoundException, MBeanException,
70 if ("getInstance".equals(attributeName)) {
73 return super.getAttribute(attributeName);
77 public void setAttribute(Attribute attribute)
78 throws AttributeNotFoundException, InvalidAttributeValueException,
79 MBeanException, ReflectionException {
80 throw new UnsupportedOperationException(
81 "setAttributes is not supported on " + moduleIdentifier);
85 public AttributeList setAttributes(AttributeList attributes) {
86 throw new UnsupportedOperationException(
87 "setAttributes is not supported on " + moduleIdentifier);