KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jmx > export > metadata > JmxMetadataUtils


1 /*
2  * Copyright 2002-2005 the original author or authors.
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  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.jmx.export.metadata;
18
19 import javax.management.modelmbean.ModelMBeanNotificationInfo JavaDoc;
20
21 import org.springframework.util.StringUtils;
22
23 /**
24  * Utility methods for converting Spring JMX metadata into their plain JMX equivalents.
25  *
26  * @author Rob Harrop
27  * @author Juergen Hoeller
28  * @since 2.0
29  */

30 public abstract class JmxMetadataUtils {
31
32     /**
33      * Convert the supplied {@link ManagedNotification} into the corresponding
34      * {@link javax.management.modelmbean.ModelMBeanNotificationInfo}.
35      */

36     public static ModelMBeanNotificationInfo JavaDoc convertToModelMBeanNotificationInfo(ManagedNotification notificationInfo) {
37         String JavaDoc name = notificationInfo.getName();
38         if (!StringUtils.hasText(name)) {
39             throw new IllegalArgumentException JavaDoc("Must specify notification name");
40         }
41
42         String JavaDoc[] notifTypes = notificationInfo.getNotificationTypes();
43         if (notifTypes == null || notifTypes.length == 0) {
44             throw new IllegalArgumentException JavaDoc("Must specify at least one notification type");
45         }
46
47         String JavaDoc description = notificationInfo.getDescription();
48         return new ModelMBeanNotificationInfo JavaDoc(notifTypes, name, description);
49     }
50
51 }
52
Popular Tags