1 23 24 29 package com.sun.enterprise.admin.dottedname; 30 31 import java.util.HashMap ; 32 import java.util.Set ; 33 import java.util.Iterator ; 34 import java.util.Collections ; 35 36 import javax.management.ObjectName ; 37 38 45 public class DottedNameServerInfoCache implements DottedNameServerInfo 46 { 47 final DottedNameServerInfo mSrc; 48 49 Set mConfigNames; 50 Set mServerNames; 51 HashMap mServerToConfig; 52 HashMap mConfigToServers; 53 54 public 55 DottedNameServerInfoCache( final DottedNameServerInfo src ) 56 { 57 mSrc = src; 58 59 mConfigNames = Collections.EMPTY_SET; 62 mServerNames = Collections.EMPTY_SET; 63 mServerToConfig = mConfigToServers = new HashMap (); 64 } 65 66 public synchronized Set 67 getConfigNames() 68 throws DottedNameServerInfo.UnavailableException 69 { 70 return( mConfigNames ); 71 } 72 73 public synchronized Set 74 getServerNames() 75 throws DottedNameServerInfo.UnavailableException 76 { 77 return( mServerNames ); 78 } 79 80 public synchronized String 81 getConfigNameForServer( String serverName ) 82 throws DottedNameServerInfo.UnavailableException 83 { 84 return( (String )mServerToConfig.get( serverName ) ); 85 } 86 87 public synchronized String [] 88 getServerNamesForConfig( String configName ) 89 throws DottedNameServerInfo.UnavailableException 90 { 91 return( (String [])mConfigToServers.get( configName ) ); 92 } 93 94 void 95 _refresh() 96 throws DottedNameServerInfo.UnavailableException 97 { 98 mConfigNames = mSrc.getConfigNames(); 99 mServerNames = mSrc.getServerNames(); 100 101 Iterator iter = mServerNames.iterator(); 103 while ( iter.hasNext() ) 104 { 105 final String serverName = (String )iter.next(); 106 107 final String configName = mSrc.getConfigNameForServer( serverName ); 108 109 if ( configName != null ) 110 { 111 mServerToConfig.put( serverName, configName ); 112 } 113 } 114 115 iter = mConfigNames.iterator(); 117 while ( iter.hasNext() ) 118 { 119 final String configName = (String )iter.next(); 120 121 final String [] serverNames = mSrc.getServerNamesForConfig( configName ); 122 123 if ( serverNames != null ) 124 { 125 mConfigToServers.put( configName, serverNames ); 126 } 127 } 128 } 129 130 public synchronized void 131 refresh() 132 { 133 try 134 { 135 _refresh(); 136 } 137 catch( DottedNameServerInfo.UnavailableException e ) 138 { 139 DottedNameLogger.logException( e ); 140 } 141 } 142 } 143 144 145 146 147 148 149 150 151 152 | Popular Tags |