1 23 24 29 package com.sun.enterprise.admin.dottedname; 30 31 32 import java.util.Set ; 33 import java.util.HashSet ; 34 import java.util.Iterator ; 35 import java.util.HashMap ; 36 37 import javax.management.ObjectName ; 38 39 46 public final class DottedNameRegistry1To1Impl implements DottedNameRegistry 47 { 48 final HashMap mDottedNameStringsToObjectNames; 49 50 final HashMap mObjectNamesToDottedNameStrings; 51 52 private final static int INITIAL_CAPACITY = 300; 53 54 public 55 DottedNameRegistry1To1Impl( ) 56 { 57 61 mDottedNameStringsToObjectNames = new HashMap ( INITIAL_CAPACITY ); 62 mObjectNamesToDottedNameStrings = new HashMap ( INITIAL_CAPACITY ); 63 } 64 65 public synchronized ObjectName 66 dottedNameToObjectName( String dottedName ) 67 { 68 return( (ObjectName )mDottedNameStringsToObjectNames.get( dottedName ) ); 69 } 70 71 public synchronized String 72 objectNameToDottedName( ObjectName objectName ) 73 { 74 return( (String )mObjectNamesToDottedNameStrings.get( objectName ) ); 75 } 76 77 private Set 78 copySet( Set input ) 79 { 80 final HashSet newSet = new HashSet (); 81 82 newSet.addAll( input ); 83 84 return( newSet ); 85 } 86 87 public synchronized Set 88 allDottedNameStrings( ) 89 { 90 return( copySet( mDottedNameStringsToObjectNames.keySet() ) ); 91 } 92 93 public synchronized Set 94 allObjectNames( ) 95 { 96 return( copySet( mObjectNamesToDottedNameStrings.keySet() ) ); 97 } 98 99 public synchronized void 100 add( String dottedName, ObjectName objectName ) 101 { 102 new DottedName( dottedName ); 103 110 if ( objectNameToDottedName( objectName ) != null ) 111 { 112 remove( objectName ); 113 } 114 115 mDottedNameStringsToObjectNames.put( dottedName, objectName ); 116 mObjectNamesToDottedNameStrings.put( objectName, dottedName ); 117 } 118 119 synchronized void 120 remove( String dottedName, ObjectName objectName ) 121 { 122 if ( dottedName != null && objectName != null ) 123 { 124 mDottedNameStringsToObjectNames.remove( dottedName ); 125 mObjectNamesToDottedNameStrings.remove( objectName ); 126 } 127 } 128 129 public void 130 remove( String dottedName ) 131 { 132 remove( dottedName, dottedNameToObjectName( dottedName ) ); 133 } 134 135 public void 136 remove( ObjectName objectName ) 137 { 138 remove( objectNameToDottedName( objectName ), objectName ); 139 } 140 } 141 142 143 144 | Popular Tags |