KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > util > jmx > stringifier > MBeanOperationInfoStringifier


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.appserv.management.util.jmx.stringifier;
24
25 import javax.management.MBeanOperationInfo JavaDoc;
26
27 import com.sun.appserv.management.util.stringifier.Stringifier;
28
29 public class MBeanOperationInfoStringifier
30     extends MBeanFeatureInfoStringifier implements Stringifier
31 {
32     public static final MBeanOperationInfoStringifier DEFAULT = new MBeanOperationInfoStringifier();
33     
34         public
35     MBeanOperationInfoStringifier()
36     {
37         super( );
38     }
39     
40         public
41     MBeanOperationInfoStringifier( MBeanFeatureInfoStringifierOptions options )
42     {
43         super( options );
44     }
45     
46         public static String JavaDoc
47     getImpact( MBeanOperationInfo JavaDoc info )
48     {
49         String JavaDoc impactStr = null;
50         
51         switch( info.getImpact() )
52         {
53             default: impactStr = "unknown"; break;
54             case MBeanOperationInfo.INFO: impactStr = "info"; break;
55             case MBeanOperationInfo.ACTION: impactStr = "action"; break;
56             case MBeanOperationInfo.ACTION_INFO: impactStr = "action-info";break;
57         }
58         
59         return( impactStr );
60     }
61     
62         public static String JavaDoc
63     getSignature( MBeanOperationInfo JavaDoc info )
64     {
65         return( getSignature( info, MBeanFeatureInfoStringifierOptions.DEFAULT ) );
66     }
67     
68         public static String JavaDoc
69     getSignature( MBeanOperationInfo JavaDoc info, MBeanFeatureInfoStringifierOptions options )
70     {
71         return( ParamsToString( info.getSignature(), options ) );
72     }
73     
74         public static String JavaDoc
75     getDescription( MBeanOperationInfo JavaDoc info )
76     {
77         return( sOperationDelimiter + "\"" + info.getDescription() + "\"" );
78     }
79     
80         public String JavaDoc
81     stringify( Object JavaDoc o )
82     {
83         assert( o != null );
84         final MBeanOperationInfo JavaDoc op = (MBeanOperationInfo JavaDoc)o;
85         
86         String JavaDoc result = getPresentationTypeString( op.getReturnType() ) + " " + op.getName() + "(";
87         
88         // create the signature string
89
result = result + getSignature( op, mOptions ) + ")";
90                     
91         String JavaDoc impactStr = getImpact( op );
92         
93         result = result + sOperationDelimiter + "impact=" +impactStr;
94             
95         if ( mOptions.mIncludeDescription )
96         {
97             result = result + getDescription( op );
98         }
99         
100         return( result );
101     }
102 }
Popular Tags