KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > OldPropertiesImpl


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
24 /*
25  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28  
29 /*
30  * $Header: /cvs/glassfish/admin/mbeanapi-impl/src/java/com/sun/enterprise/management/config/OldPropertiesImpl.java,v 1.2 2005/12/25 03:39:34 tcfujii Exp $
31  * $Revision: 1.2 $
32  * $Date: 2005/12/25 03:39:34 $
33  */

34
35 package com.sun.enterprise.management.config;
36
37 import javax.management.Attribute JavaDoc;
38 import javax.management.AttributeList JavaDoc;
39
40
41 import com.sun.appserv.management.util.misc.ThrowableMapper;
42
43 import com.sun.enterprise.management.support.oldconfig.OldProperties;
44 import com.sun.enterprise.management.support.Delegate;
45 import com.sun.enterprise.management.support.DelegateBase;
46
47 final class OldPropertiesImpl implements OldProperties
48 {
49     final Delegate mDelegate;
50     
51     private final static String JavaDoc[] EMPTY_SIG = new String JavaDoc[ 0 ];
52     private final static String JavaDoc[] GET_PROPERTY_VALUE_SIG = new String JavaDoc[]{ String JavaDoc.class.getName() };
53     private final static String JavaDoc[] SET_PROPERTY_SIG = new String JavaDoc[]{ Attribute JavaDoc.class.getName() };
54
55
56         public
57     OldPropertiesImpl( Delegate delegate )
58     {
59         mDelegate = delegate;
60     }
61     
62     /**
63         We want to avoid throwing anything that is not standard on the client
64         side.
65      */

66         private void
67     rethrowThrowable( final Throwable JavaDoc t )
68     {
69         final Throwable JavaDoc result = new ThrowableMapper( t ).map();
70         
71         if ( result instanceof Error JavaDoc )
72         {
73             throw (Error JavaDoc)result;
74         }
75         else if ( result instanceof RuntimeException JavaDoc )
76         {
77             throw (RuntimeException JavaDoc)result;
78         }
79         else
80         {
81             throw new RuntimeException JavaDoc( result );
82         }
83     }
84     
85         public AttributeList JavaDoc
86     getProperties()
87     {
88         try
89         {
90             return( (AttributeList JavaDoc)mDelegate.invoke( "getProperties", null, EMPTY_SIG ) );
91         }
92         catch( RuntimeException JavaDoc e )
93         {
94             rethrowThrowable( e );
95         }
96         return( null );
97     }
98
99         public String JavaDoc
100     getPropertyValue( final String JavaDoc propertyName )
101     {
102         try
103         {
104             return( (String JavaDoc)mDelegate.invoke( "getPropertyValue",
105                         new Object JavaDoc[] { propertyName }, GET_PROPERTY_VALUE_SIG ) );
106         }
107         catch( RuntimeException JavaDoc e )
108         {
109             rethrowThrowable( e );
110         }
111         return( null );
112     }
113
114         public void
115     setProperty( Attribute JavaDoc attr )
116     {
117         try
118         {
119             mDelegate.invoke( "setProperty", new Object JavaDoc[] { attr }, SET_PROPERTY_SIG );
120         }
121         catch( RuntimeException JavaDoc e )
122         {
123             rethrowThrowable( e );
124         }
125     }
126 }
127
128
129
Popular Tags