KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > client > handler > ConverterHandler


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.client.handler;
24
25 import java.io.IOException JavaDoc;
26
27 import java.lang.reflect.Method JavaDoc;
28
29 import javax.management.ObjectName JavaDoc;
30
31
32 import com.sun.appserv.management.base.Util;
33 import com.sun.appserv.management.client.ConnectionSource;
34
35 /**
36     Base class for specialize proxy handlers.
37     @see AMXProxyHandlerconvertResult
38  */

39 class ConverterHandler extends AMXProxyHandler
40 {
41         protected
42      ConverterHandler(
43         final ConnectionSource connectionSource,
44         final ObjectName JavaDoc proxiedMBeanObjectName )
45         throws IOException JavaDoc
46      {
47         super( connectionSource, proxiedMBeanObjectName );
48      }
49      
50      
51     /**
52         Optionally, transform any arguments. The number of arguments must
53         not be changed, and the original array must not be modified.
54      */

55         protected Object JavaDoc[]
56     convertArgs(
57         final Object JavaDoc myProxy,
58         final Method JavaDoc method,
59         final Object JavaDoc[] argsIn )
60     {
61         return argsIn; // no change
62
}
63     
64     /**
65         Optionally, transform any result.
66      */

67         protected Object JavaDoc
68     convertResult(
69         final Method JavaDoc method,
70         final Object JavaDoc resultIn )
71     {
72         return resultIn; // no change
73
}
74     
75         protected final Object JavaDoc
76     _invoke(
77         final Object JavaDoc myProxy,
78         final Method JavaDoc method,
79         final Object JavaDoc[] argsIn )
80         throws java.lang.Throwable JavaDoc
81     {
82         final Object JavaDoc[] args = convertArgs( myProxy, method, argsIn );
83         
84         final Object JavaDoc temp = super._invoke( myProxy, method, args );
85         
86         final Object JavaDoc result = (temp == null) ? null : convertResult( method, temp );
87         
88         if ( result != temp && temp != null )
89         {
90 // System.out.println( "Convert occured from class " + temp.getClass().getName() +
91
// " to " + result.getClass().getName() );
92
}
93         
94         return( result );
95     }
96    
97 }
98
99
100
101
102
103
Popular Tags