BUG-8: migrate newMBeanProxy() -> newMXBeanProxy()
[controller.git] / opendaylight / commons / protocol-framework / src / test / java / org / opendaylight / controller / config / yang / protocol / framework / GlobalEventExecutorUtil.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.config.yang.protocol.framework;
9
10 import javax.management.InstanceAlreadyExistsException;
11 import javax.management.InstanceNotFoundException;
12 import javax.management.ObjectName;
13
14 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
15 import org.opendaylight.controller.config.yang.netty.eventexecutor.GlobalEventExecutorModuleFactory;
16
17 final class GlobalEventExecutorUtil {
18
19     private GlobalEventExecutorUtil() {
20         throw new UnsupportedOperationException();
21     }
22
23     public static ObjectName create(final ConfigTransactionJMXClient transaction) throws InstanceAlreadyExistsException {
24         try {
25             return transaction.lookupConfigBean(GlobalEventExecutorModuleFactory.NAME,
26                     GlobalEventExecutorModuleFactory.SINGLETON_NAME);
27         } catch (InstanceNotFoundException e) {
28             try {
29                 return transaction.createModule(GlobalEventExecutorModuleFactory.NAME,
30                         GlobalEventExecutorModuleFactory.SINGLETON_NAME);
31             } catch (InstanceAlreadyExistsException e1) {
32                 throw new IllegalStateException(e1);
33             }
34         }
35     }
36
37 }