1 22 23 package com.sun.enterprise.resource; 24 25 import com.sun.enterprise.config.ConfigBean; 26 import com.sun.enterprise.config.ConfigContext; 27 import com.sun.enterprise.config.ConfigException; 28 import com.sun.enterprise.config.serverbeans.ResourceHelper; 29 import java.util.HashSet ; 30 import java.util.Set ; 31 import javax.management.Attribute ; 32 import javax.management.AttributeList ; 33 import static com.sun.enterprise.resource.ResourceConstants.*; 34 35 40 public class ResourceUtilities { 41 private ResourceUtilities() { 42 } 43 44 58 public static Set <Resource> getResourceConfigConflicts(final Set <Resource> resSet, 59 final ConfigContext cc) throws ConfigException { 60 final Set <Resource> conflicts = new HashSet <Resource>(); 61 if (resSet != null) { 62 for (final Resource res : resSet) { 63 final String id = getIdToCompare(res); 64 final ConfigBean sb = ResourceHelper.findResource(cc, id); 65 if (sb != null) { 66 conflicts.add(res); 67 } 68 } 69 } 70 return ( conflicts ); 71 } 72 private static String getIdToCompare(final Resource res) { 73 final AttributeList attrs = res.getAttributes(); 74 final String type = res.getType(); 75 String id; 76 if (Resource.JDBC_CONNECTION_POOL.equals(type) || 77 Resource.CONNECTOR_CONNECTION_POOL.equals(type) || 78 Resource.RESOURCE_ADAPTER_CONFIG.equals(type) || 79 Resource.CONNECTOR_SECURITY_MAP.equals(type)) { 80 id = getNamedAttributeValue(attrs, CONNECTION_POOL_NAME); } 82 else if (Resource.RESOURCE_ADAPTER_CONFIG.equals(type)) { 83 id = getNamedAttributeValue(attrs, RESOURCE_ADAPTER_CONFIG_NAME); } 85 else { 86 id = getNamedAttributeValue(attrs, JNDI_NAME); } 89 return ( id ); 90 } 91 private static String getNamedAttributeValue(final AttributeList attrs, final String aName) { 92 String value = null; 93 for (final Object obj : attrs) { 94 if (obj instanceof Attribute ) { 95 final Attribute a = (Attribute ) obj; 96 if (aName.equals(a.getName())) { 97 value = a.getValue().toString(); 98 } 99 } 100 } 101 return ( value ); 102 } 103 } 104 | Popular Tags |