+++ /dev/null
-/*
- * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.manager.impl.dynamicmbean;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.ReflectionException;
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
-import org.opendaylight.controller.config.spi.Module;
-
-/**
- * Wraps {@link org.opendaylight.controller.config.spi.Module} in a
- * {@link DynamicMBeanWithInstance}. Setting attributes is disabled.
- */
-public class DynamicReadableWrapper extends AbstractDynamicWrapper implements
- DynamicMBeanWithInstance {
- private final AutoCloseable instance;
-
- public DynamicReadableWrapper(final Module module, final AutoCloseable instance,
- final ModuleIdentifier moduleIdentifier, final MBeanServer internalServer,
- final MBeanServer configMBeanServer) {
- super(module, false, moduleIdentifier, ObjectNameUtil
- .createReadOnlyModuleON(moduleIdentifier),
- getEmptyOperations(), internalServer, configMBeanServer);
- this.instance = instance;
- }
-
- @Override
- public Module getModule() {
- return module;
- }
-
- @Override
- public AutoCloseable getInstance() {
- return instance;
- }
-
- @Override
- public Object invoke(final String actionName, final Object[] params, final String[] signature)
- throws MBeanException, ReflectionException {
- if ("getInstance".equals(actionName)
- && (params == null || params.length == 0)
- && (signature == null || signature.length == 0)) {
- return getInstance();
- }
- return super.invoke(actionName, params, signature);
- }
-
- @Override
- public Object getAttribute(final String attributeName)
- throws AttributeNotFoundException, MBeanException,
- ReflectionException {
- if ("getInstance".equals(attributeName)) {
- return getInstance();
- }
- return super.getAttribute(attributeName);
- }
-
- @Override
- public void setAttribute(final Attribute attribute)
- throws AttributeNotFoundException, InvalidAttributeValueException,
- MBeanException, ReflectionException {
- throw new UnsupportedOperationException(
- "setAttributes is not supported on " + moduleIdentifier);
- }
-
- @Override
- public AttributeList setAttributes(final AttributeList attributes) {
- throw new UnsupportedOperationException(
- "setAttributes is not supported on " + moduleIdentifier);
- }
-}