1 /*
2  * Copyright 2013-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  *  http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */

15 package com.amazonaws.jmx;
16
17 import org.apache.commons.logging.LogFactory;
18
19 import com.amazonaws.jmx.spi.SdkMBeanRegistry;
20 import com.amazonaws.metrics.MetricAdmin;
21
22 public class SdkMBeanRegistrySupport implements SdkMBeanRegistry {
23     ;
24     @Override
25     public boolean registerMetricAdminMBean(String objectName) {
26         try {
27             return MBeans.registerMBean(objectName, new MetricAdmin());
28         } catch(Exception ex) {
29             LogFactory.getLog(SdkMBeanRegistrySupport.class).warn("", ex);
30         }
31         return false;
32     }
33
34     @Override
35     public boolean unregisterMBean(String objectName) {
36         try {
37             return MBeans.unregisterMBean(objectName);
38         } catch(Exception ex) {
39             LogFactory.getLog(SdkMBeanRegistrySupport.class).warn("", ex);
40         }
41         return false;
42     }
43
44     @Override
45     public boolean isMBeanRegistered(String objectName) {
46         return MBeans.isRegistered(objectName);
47     }
48 }
49