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