1 23 24 29 package com.sun.enterprise.admin.dottedname; 30 31 import java.util.Set ; 32 import java.util.HashSet ; 33 34 import com.sun.enterprise.admin.util.ArrayConversion; 35 36 37 public class DottedNameAliasSupport 38 { 39 public DottedNameAliasSupport( ) 40 { 41 42 } 43 44 45 public final static String DOMAIN_SCOPE = "domain"; 46 public final static String DOMAIN_SCOPE_DOT = DOMAIN_SCOPE + "."; 47 48 49 static public boolean 50 scopeIsDomain( String scope ) 51 { 52 return( scope.equals( DOMAIN_SCOPE ) || scope.startsWith( DOMAIN_SCOPE_DOT ) ); 53 } 54 55 56 57 60 static public final Set DOMAIN_PARTS = ArrayConversion.toSet( new String [] 61 { 62 "applications", 64 "resources" 65 } ); 66 67 public static boolean 68 isAliasedDomain( final DottedName dn ) 69 { 70 boolean isAliased = false; 71 72 final java.util.List parts = dn.getParts(); 73 74 if ( parts.size() >= 1 ) 75 { 76 isAliased = DOMAIN_PARTS.contains( parts.get( 0 ) ); 77 } 78 79 return( isAliased ); 80 } 81 82 83 84 88 static private final Set NON_ALIASED_PARTS_SET = ArrayConversion.toSet( new String [] 89 { 90 "application-ref", 92 "resource-ref", 93 "config-ref", 94 "node-agent-ref", 95 "server-ref", 96 97 "property", 99 "name" 100 } ); 101 102 protected static boolean 103 isNonAliasedServer( final DottedName dn ) 104 { 105 boolean isNonAliased = false; 106 107 final java.util.List parts = dn.getParts(); 108 109 if ( parts.size() >= 1 ) 110 { 111 isNonAliased = NON_ALIASED_PARTS_SET.contains( parts.get( 0 ) ); 112 } 113 114 return( isNonAliased ); 115 } 116 117 126 public static String 127 resolveScope( final DottedNameServerInfo serverInfo, final DottedName dn ) 128 throws DottedNameServerInfo.UnavailableException 129 { 130 final String scopeNameIn = dn.getScope(); 131 String actualScopeName = scopeNameIn; 132 133 if ( scopeIsDomain( scopeNameIn ) ) 134 { 135 } 137 else 138 { 139 final boolean scopeIsServerName = serverInfo.getServerNames().contains( actualScopeName ); 140 141 if ( scopeIsServerName ) 142 { 143 if ( isAliasedDomain( dn ) ) 144 { 145 actualScopeName = DottedNameAliasSupport.DOMAIN_SCOPE; 146 } 147 else if ( isNonAliasedServer( dn ) ) 148 { 149 } 151 else 152 { 153 actualScopeName = serverInfo.getConfigNameForServer( scopeNameIn ); 156 } 157 } 158 } 159 160 return( actualScopeName ); 161 } 162 163 164 165 166 static java.util.logging.Logger sLogger = null; 167 static void 168 dm( Object o ) 169 { 170 if (sLogger == null ) 171 { 172 sLogger = java.util.logging.Logger.getLogger( "DottedNameGetSetMBeanImplLogger" ); 173 sLogger.setLevel( java.util.logging.Level.INFO ); 174 } 175 176 sLogger.info( o.toString() ); 177 } 178 } 179 180 181 182 183 | Popular Tags |