1 23 24 28 29 34 35 package com.sun.enterprise.management.config; 36 37 import javax.management.Attribute ; 38 import javax.management.AttributeList ; 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 [] EMPTY_SIG = new String [ 0 ]; 51 private final static String [] GET_PROPERTY_VALUE_SIG = new String []{ String .class.getName() }; 52 private final static String [] SET_PROPERTY_SIG = new String []{ Attribute .class.getName() }; 53 54 55 public 56 OldSystemPropertiesImpl( Delegate delegate ) 57 { 58 mDelegate = delegate; 59 } 60 61 65 private void 66 rethrowThrowable( final Throwable t ) 67 { 68 final Throwable result = new ThrowableMapper( t ).map(); 69 70 if ( result instanceof Error ) 71 { 72 throw (Error )result; 73 } 74 else if ( result instanceof RuntimeException ) 75 { 76 throw (RuntimeException )result; 77 } 78 else 79 { 80 throw new RuntimeException ( result ); 81 } 82 } 83 84 public AttributeList 85 getSystemProperties() 86 { 87 try 88 { 89 return( (AttributeList )mDelegate.invoke( "getSystemProperties", null, EMPTY_SIG ) ); 90 } 91 catch( RuntimeException e ) 92 { 93 rethrowThrowable( e ); 94 } 95 return( null ); 96 } 97 98 public String 99 getSystemPropertyValue( final String propertyName ) 100 { 101 try 102 { 103 return( (String )mDelegate.invoke( "getSystemPropertyValue", 104 new Object [] { propertyName }, GET_PROPERTY_VALUE_SIG ) ); 105 } 106 catch( RuntimeException e ) 107 { 108 rethrowThrowable( e ); 109 } 110 return( null ); 111 } 112 113 public void 114 setSystemProperty( Attribute attr ) 115 { 116 try 117 { 118 mDelegate.invoke( "setSystemProperty", new Object [] { attr }, SET_PROPERTY_SIG ); 119 } 120 catch( RuntimeException e ) 121 { 122 rethrowThrowable( e ); 123 } 124 } 125 } 126 127 128 | Popular Tags |