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;
18 import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
19 import org.opendaylight.controller.config.api.ModuleIdentifier;
20 import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
21 import org.opendaylight.controller.config.spi.Module;
24 * Wraps {@link org.opendaylight.controller.config.spi.Module} in a
25 * {@link DynamicMBeanWithInstance}. Setting attributes is disabled.
27 public class DynamicReadableWrapper extends AbstractDynamicWrapper implements
28 DynamicMBeanWithInstance {
29 private final AutoCloseable instance;
34 * for recreating Module.
37 public DynamicReadableWrapper(Module module, AutoCloseable instance,
38 ModuleIdentifier moduleIdentifier, MBeanServer internalServer,
39 MBeanServer configMBeanServer) {
40 super(module, false, moduleIdentifier, ObjectNameUtil
41 .createReadOnlyModuleON(moduleIdentifier),
42 getEmptyOperations(), internalServer, configMBeanServer);
43 this.instance = instance;
47 public Module getModule() {
52 public AutoCloseable getInstance() {
57 public Object invoke(String actionName, Object[] params, String[] signature)
58 throws MBeanException, ReflectionException {
59 if ("getInstance".equals(actionName)
60 && (params == null || params.length == 0)
61 && (signature == null || signature.length == 0)) {
64 return super.invoke(actionName, params, signature);
68 public Object getAttribute(String attributeName)
69 throws AttributeNotFoundException, MBeanException,
71 if (attributeName.equals("getInstance")) {
74 return super.getAttribute(attributeName);
78 public void setAttribute(Attribute attribute)
79 throws AttributeNotFoundException, InvalidAttributeValueException,
80 MBeanException, ReflectionException {
81 throw new UnsupportedOperationException(
82 "setAttributes is not supported on " + moduleIdentifier);
86 public AttributeList setAttributes(AttributeList attributes) {
87 throw new UnsupportedOperationException(
88 "setAttributes is not supported on " + moduleIdentifier);