KickJava   Java API By Example, From Geeks To Geeks.

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


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/OldSystemPropertiesImpl.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 import com.sun.appserv.management.util.misc.ThrowableMapper;
41
42 import com.sun.enterprise.management.support.oldconfig.OldSystemProperties;
43 import com.sun.enterprise.management.support.Delegate;
44 import com.sun.enterprise.management.support.DelegateBase;
45
46 final class OldSystemPropertiesImpl implements OldSystemProperties
47 {
48     final Delegate mDelegate;
49     
50     private final static String JavaDoc[] EMPTY_SIG = new String JavaDoc[ 0 ];
51     private final static String JavaDoc[] GET_PROPERTY_VALUE_SIG = new String JavaDoc[]{ String JavaDoc.class.getName() };
52     private final static String JavaDoc[] SET_PROPERTY_SIG = new String JavaDoc[]{ Attribute JavaDoc.class.getName() };
53
54
55         public
56     OldSystemPropertiesImpl( Delegate delegate )
57     {
58         mDelegate = delegate;
59     }
60     
61     /**
62         We want to avoid throwing anything that is not standard on the client
63         side.
64      */

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