/** * Extract the RA name for a connector resource. Collecting for resource validation. * * @param resource * @return resource adapter name */ private String extractRAName(org.glassfish.resources.api.Resource resource) { if (resource.getType().equals(ADMIN_OBJECT_RESOURCE)) return (String)resource.getAttributes().get(RES_ADAPTER); else return (String)resource.getAttributes().get(RES_ADAPTER_NAME); }
new ArrayList<Resource>(); for (org.glassfish.resources.api.Resource resource : resourcesToRegister) { final HashMap attrList = resource.getAttributes(); final Properties props = resource.getProperties(); String desc = resource.getDescription(); if (desc != null) { attrList.put("description", desc);
if(existingRes.equals(res)){ if(existingRes.isAConflict(res)){
private boolean hasRAName(org.glassfish.resources.api.Resource resource) { return resource.getType().equals(ADMIN_OBJECT_RESOURCE) || resource.getType().equals(CONNECTOR_CONNECTION_POOL) || resource.getType().equals(RESOURCE_ADAPTER_CONFIG) || resource.getType().equals(CONNECTOR_WORK_SECURITY_MAP); }
/** * Extract the JNDI name from the resource. Collecting for resource valitation. * * @param resource * @return jndi name if present, null otherwise */ private String extractJNDIName(org.glassfish.resources.api.Resource resource) { HashMap attrs = resource.getAttributes(); return (String) attrs.get(JNDI_NAME); }
private static boolean isConnectorResource(org.glassfish.resources.api.Resource resource){ if(resource.getType().equals(ADMIN_OBJECT_RESOURCE) || resource.getType().equals(CONNECTOR_CONNECTION_POOL) || resource.getType().equals(CONNECTOR_RESOURCE) || resource.getType().equals(RESOURCE_ADAPTER_CONFIG) || resource.getType().equals(CONNECTOR_WORK_SECURITY_MAP)){ return true; }else{ return false; } }
private static boolean isEmbeddedRar(org.glassfish.resources.api.Resource resource, String attributeName) { boolean result = false; String raName = (String)resource.getAttributes().get(attributeName); if(raName != null && raName.contains(ResourceConstants.EMBEDDEDRAR_NAME_DELIMITER)){ result = true; } return result; }
private static org.glassfish.resources.api.Resource getPoolResource( String poolName, Collection<org.glassfish.resources.api.Resource> resources){ org.glassfish.resources.api.Resource result = null; for(org.glassfish.resources.api.Resource resource : resources){ if(resource.getType().equals(CONNECTOR_CONNECTION_POOL)){ String cpName = (String)resource.getAttributes().get(CONNECTION_POOL_NAME); if(poolName.equals(cpName)){ result = resource; break; } } } return result; }
String jndiName = extractJNDIName(resource); if (hasRAName(resource)) { raNames.add(new AbstractMap.SimpleEntry<>(extractRAName(resource), resource.getType())); String jndiName = extractJNDIName(resource); if (hasRAName(resource)) { raNames.add(new AbstractMap.SimpleEntry<>(extractRAName(resource), resource.getType()));
private static void logAttributes(Resource res) { StringBuffer message = new StringBuffer(); Set<Map.Entry> entries = res.getAttributes().entrySet(); Iterator<Map.Entry> entriesIter = entries.iterator(); while(entriesIter.hasNext()){ Map.Entry entry = entriesIter.next(); message.append(entry.getKey()); message.append("="); message.append(entry.getValue()); message.append(" "); } if (_logger.isLoggable(Level.FINE)) { _logger.fine(localStrings.getString("resource.attributes", message.toString())); } } }
private static boolean isEmbeddedResource(org.glassfish.resources.api.Resource resource, Collection<org.glassfish.resources.api.Resource> resources){ boolean result = false; if(isConnectorResource(resource)){ String attributeName = null; if(resource.getType().equals(ADMIN_OBJECT_RESOURCE)){ attributeName = RES_ADAPTER; } else if(resource.getType().equals(CONNECTOR_CONNECTION_POOL)){ attributeName = RES_ADAPTER_NAME; } else if(resource.getType().equals(CONNECTOR_RESOURCE)){ String poolName = (String)resource.getAttributes().get(POOL_NAME); if(poolName != null){ org.glassfish.resources.api.Resource poolResource = getPoolResource(poolName, resources); //point to poolResource resource = poolResource; attributeName = RES_ADAPTER_NAME; } }/* else if(resource.getType().equals(org.glassfish.resources.api.Resource.RESOURCE_ADAPTER_CONFIG)){ attributeName = ResourceConstants.RES_ADAPTER_NAME; } */else if(resource.getType().equals(CONNECTOR_WORK_SECURITY_MAP)){ attributeName = RES_ADAPTER_NAME; } if(attributeName != null && resource != null){ result = isEmbeddedRar(resource, attributeName); } } return result; }
private static String getIdToCompare(final Resource res) { final HashMap attrs = res.getAttributes(); final String type = res.getType(); String id; if (org.glassfish.resources.api.Resource.JDBC_CONNECTION_POOL.equals(type) || Resource.CONNECTOR_CONNECTION_POOL.equals(type)){ id = getNamedAttributeValue(attrs, CONNECTION_POOL_NAME); // this should come from refactored stuff TBD } else if (org.glassfish.resources.api.Resource.CONNECTOR_SECURITY_MAP.equals(type)) { id = getNamedAttributeValue(attrs, SECURITY_MAP_NAME); // this should come from refactored stuff TBD } else if (org.glassfish.resources.api.Resource.RESOURCE_ADAPTER_CONFIG.equals(type)) { id = getNamedAttributeValue(attrs, RESOURCE_ADAPTER_CONFIG_NAME); // this should come from refactored stuff TBD } else if(org.glassfish.resources.api.Resource.CONNECTOR_WORK_SECURITY_MAP.equals(type)){ id = getNamedAttributeValue(attrs, WORK_SECURITY_MAP_NAME); } else { //it is OK to assume that this Resource will one of the *RESOURCEs? id = getNamedAttributeValue(attrs, JNDI_NAME); // this should come from refactored stuff TBD } return ( id ); }