1 23 package com.sun.enterprise.management.offline; 24 25 import java.util.Map ; 26 import java.util.HashMap ; 27 import java.util.Set ; 28 import java.util.HashSet ; 29 import java.util.Collections ; 30 31 import javax.management.ObjectName ; 32 import javax.management.MBeanServer ; 33 34 import com.sun.appserv.management.base.DottedNames; 35 import com.sun.appserv.management.base.AMXDebug; 36 37 38 40 public final class OfflineDottedNamesMgr 41 { 42 private final OfflineDottedNamesRegistry mRegistry; 43 private final OfflineDottedNamePrefixes mPrefixes; 44 private final MBeanServer mServer; 45 46 public 47 OfflineDottedNamesMgr( final MBeanServer server ) 48 { 49 mServer = server; 50 51 mRegistry = new OfflineDottedNamesRegistry(); 52 mPrefixes = OfflineDottedNamePrefixes.getInstance(); 53 } 54 55 private void 56 debug( final Object o ) 57 { 58 AMXDebug.getInstance().getOutput( "OfflineDottedNamesMgr" ).println( o ); 59 } 60 61 private String 62 getPrefix( final String dottedName ) 63 { 64 final int idx = dottedName.lastIndexOf( dottedName ); 65 if ( idx <= 0 ) 66 { 67 throw new IllegalArgumentException ( dottedName ); 68 } 69 return dottedName.substring( 0, idx - 1 ); 70 } 71 72 private String 73 getAttrName( final String dottedName ) 74 { 75 final String prefix = getPrefix( dottedName ); 76 77 return dottedName.substring( prefix.length() + 1, dottedName.length() ); 78 } 79 80 public void 81 refresh() 82 { 83 } 85 86 public Object [] 87 dottedNameGet( final String [] names ) 88 { 89 final Object [] results = new Object [ names.length ]; 90 91 for( int i = 0; i < names.length; ++i ) 92 { 93 try 94 { 95 results[ i ] = dottedNameGet( names[ i ] ); 96 } 97 catch( Exception e ) 98 { 99 results[ i ] = e; 100 } 101 } 102 103 return results; 104 } 105 106 private final String WILD_ALL = "*"; 107 108 public Object 109 dottedNameGet( final String dottedName ) 110 { 111 final String prefix = getPrefix( dottedName ); 112 final ObjectName objectName = mRegistry.getObjectName( prefix ); 113 114 if ( objectName == null ) 115 { 116 throw new IllegalArgumentException ( dottedName ); 117 } 118 119 final String attrName = getAttrName( dottedName ); 120 121 debug( "dottedNameGet: " + dottedName + ", prefix = " + prefix + 122 "attrName = " + attrName ); 123 124 Object value = null; 125 try 126 { 127 value = mServer.getAttribute( objectName, attrName ); 128 } 129 catch( Exception e ) 130 { 131 value = e; 132 } 133 debug( "dottedNameGet: " + dottedName + " = " + value ); 134 return value; 135 } 136 137 public Object [] 138 dottedNameList( final String [] names ) 139 { 140 return new String [0]; 141 } 142 143 public Object [] 144 dottedNameSet( final String [] nameValuePairs ) 145 { 146 for( final String pair : nameValuePairs ) 147 { 148 } 149 throw new UnsupportedOperationException ( "dottedNameSet" ); 150 } 151 152 } 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | Popular Tags |