View Javadoc
1 /* 2 * Copyright (C) The Spice Group. All rights reserved. 3 * 4 * This software is published under the terms of the Spice 5 * Software License version 1.1, a copy of which has been included 6 * with this distribution in the LICENSE.txt file. 7 */ 8 package org.realityforge.metaclass.jmx; 9 10 import java.util.ArrayList; 11 import java.util.List; 12 import javax.management.modelmbean.ModelMBeanAttributeInfo; 13 import javax.management.modelmbean.ModelMBeanConstructorInfo; 14 import javax.management.modelmbean.ModelMBeanInfo; 15 import javax.management.modelmbean.ModelMBeanInfoSupport; 16 import javax.management.modelmbean.ModelMBeanNotificationInfo; 17 import javax.management.modelmbean.ModelMBeanOperationInfo; 18 19 /*** 20 * This is a class that helps the developer to incrementally 21 * build a ModelMBean. The developer adds various info objects 22 * and then at completion calls toModelMBean. 23 * 24 * @author <a href="mailto:peter at realityforge.org">Peter Donald</a> 25 * @version $Revision: 1.2 $ $Date: 2003/10/14 00:25:15 $ 26 */ 27 public class ModelInfoCreationHelper 28 { 29 /*** 30 * List of constructor info objects. 31 */ 32 private final List m_constructors = new ArrayList(); 33 34 /*** 35 * List of operation info objects. 36 */ 37 private final List m_operations = new ArrayList(); 38 39 /*** 40 * List of ttribute info objects. 41 */ 42 private final List m_attributes = new ArrayList(); 43 44 /*** 45 * List of notification info objects. 46 */ 47 private final List m_notifications = new ArrayList(); 48 49 /*** 50 * Classname representing ModelMBean. 51 */ 52 private String m_classname; 53 54 /*** 55 * Description of ModelMBean. 56 */ 57 private String m_description; 58 59 /*** 60 * Set the classname for ModelMBeanInfo. 61 * 62 * @param classname the classname for ModelMBeanInfo 63 */ 64 public void setClassname( final String classname ) 65 { 66 if( null == classname ) 67 { 68 throw new NullPointerException( "classname" ); 69 } 70 m_classname = classname; 71 } 72 73 /*** 74 * Set the description for ModelMBeanInfo. 75 * 76 * @param description the description for ModelMBeanInfo. 77 */ 78 public void setDescription( final String description ) 79 { 80 if( null == description ) 81 { 82 throw new NullPointerException( "description" ); 83 } 84 m_description = description; 85 } 86 87 /*** 88 * Add an attribute info. 89 * 90 * @param info the info 91 */ 92 public void addAttribute( final ModelMBeanAttributeInfo info ) 93 { 94 if( null == info ) 95 { 96 throw new NullPointerException( "info" ); 97 } 98 m_attributes.add( info ); 99 } 100 101 /*** 102 * Add a constructor info. 103 * 104 * @param info the info 105 */ 106 public void addConstructor( final ModelMBeanConstructorInfo info ) 107 { 108 if( null == info ) 109 { 110 throw new NullPointerException( "info" ); 111 } 112 m_constructors.add( info ); 113 } 114 115 /*** 116 * Add an operation info. 117 * 118 * @param info the info 119 */ 120 public void addOperation( final ModelMBeanOperationInfo info ) 121 { 122 if( null == info ) 123 { 124 throw new NullPointerException( "info" ); 125 } 126 m_operations.add( info ); 127 } 128 129 /*** 130 * Add a notification info. 131 * 132 * @param info the info 133 */ 134 public void addNotification( final ModelMBeanNotificationInfo info ) 135 { 136 if( null == info ) 137 { 138 throw new NullPointerException( "info" ); 139 } 140 m_notifications.add( info ); 141 } 142 143 /*** 144 * Create ModelMBeanInfo from values specified for class. 145 * 146 * @return the new ModelMBeanInfo object 147 */ 148 public ModelMBeanInfo toModelMBeanInfo() 149 { 150 if( null == m_classname ) 151 { 152 throw new NullPointerException( "classname" ); 153 } 154 if( null == m_description ) 155 { 156 throw new NullPointerException( "description" ); 157 } 158 return new ModelMBeanInfoSupport( m_classname, 159 m_description, 160 getAttributes(), 161 getConstructors(), 162 getOperations(), 163 getNotifications() ); 164 } 165 166 /*** 167 * Return the set of notification infos. 168 * 169 * @return the infos 170 */ 171 public ModelMBeanNotificationInfo[] getNotifications() 172 { 173 return (ModelMBeanNotificationInfo[])m_notifications. 174 toArray( new ModelMBeanNotificationInfo[ m_notifications.size() ] ); 175 } 176 177 /*** 178 * Return the set of operation infos. 179 * 180 * @return the infos 181 */ 182 public ModelMBeanOperationInfo[] getOperations() 183 { 184 return (ModelMBeanOperationInfo[])m_operations. 185 toArray( new ModelMBeanOperationInfo[ m_operations.size() ] ); 186 } 187 188 /*** 189 * Return the set of constructor infos. 190 * 191 * @return the infos 192 */ 193 public ModelMBeanConstructorInfo[] getConstructors() 194 { 195 return (ModelMBeanConstructorInfo[])m_constructors. 196 toArray( new ModelMBeanConstructorInfo[ m_constructors.size() ] ); 197 } 198 199 /*** 200 * Return the set of attribute infos. 201 * 202 * @return the infos 203 */ 204 public ModelMBeanAttributeInfo[] getAttributes() 205 { 206 return (ModelMBeanAttributeInfo[])m_attributes. 207 toArray( new ModelMBeanAttributeInfo[ m_attributes.size() ] ); 208 } 209 }

This page was automatically generated by Maven