agave-common/common-core/src/main/java/org/iplantc/service/common/discovery/ServiceCapabilityConfiguration.java
/**
	 * Reads in a JSON Array of serialized {@link DiscoverableService}s from a file named
	 * capabilities.json. If that is not found, it looks for a capabilities.txt file
	 * which contains  
	 */
Reads in a JSON Array of serialized  DiscoverableServices from a file named
capabilities.json. If that is not found, it looks for a capabilities.txt file
which contains
Reads in a JSON Array of serialized DiscoverableServices from a file named capabilities . json . If that is not found it looks for a capabilities . txt file which contains
private void readCapabilitiesFromDisk()
	{
		ObjectMapper mapper = new ObjectMapper();
		JsonNode json;
		InputStream capabilitiesStream = null;
		try 
		{
			capabilitiesStream = 
				ServiceDiscoveryFactory.class.getClassLoader().getResourceAsStream("capabilities.json");
			json = mapper.readTree(capabilitiesStream);
			if (json != null)
			{
				if (json.isArray()) 
				{
					JsonNode jsonService = null;
					for (Iterator<JsonNode> iter = json.iterator(); iter.hasNext(); jsonService = iter.next()) {
						getLocalCapabilities().add(mapper.treeToValue(jsonService, ServiceCapability.class));
					}	
				} 
				else 
				{
					getLocalCapabilities().add(mapper.treeToValue(json, ServiceCapability.class));
				}
			}
			else 
			{
				InputStream in = null;
				try {
					in = ServiceDiscoveryFactory.class.getClassLoader().getResourceAsStream("capabilities.txt");
					if (in != null) {
						List<String> lines = IOUtils.readLines(in, "UTF-8");
						for (String line: lines) {
							line = StringUtils.trim(line);
							if (StringUtils.isNotEmpty(line) && !StringUtils.startsWith(line, "#")) {
								getLocalCapabilities().add(ServiceCapabilityFactory.getInstance(line));
							}
						}
					}
				}
				catch (Exception e) {
					log.error("Unable to load capabilities text file.", e);
				}
				finally {
					if (in != null) try { in.close(); } catch (Exception e) {}
				}
			} 
		} catch (Exception e) {
			log.error("Failed to read service discovery file from disk. Checking environment...", e);
		} finally {
			if (capabilitiesStream != null) try {capabilitiesStream.close();} catch (Exception e){}
		}
	}
private void readCapabilitiesFromDisk ( ) { ObjectMapper mapper = new ObjectMapper ( ) ; JsonNode json ; InputStream capabilitiesStream = null ; try { capabilitiesStream = ServiceDiscoveryFactory . class . getClassLoader ( ) . getResourceAsStream ( "capabilities.json" ) ; json = mapper . readTree ( capabilitiesStream ) ; if ( json != null ) { if ( json . isArray ( ) ) { JsonNode jsonService = null ; for ( Iterator < JsonNode > iter = json . iterator ( ) ; iter . hasNext ( ) ; jsonService = iter . next ( ) ) { getLocalCapabilities ( ) . add ( mapper . treeToValue ( jsonService , ServiceCapability . class ) ) ; } } else { getLocalCapabilities ( ) . add ( mapper . treeToValue ( json , ServiceCapability . class ) ) ; } } else { InputStream in = null ; try { in = ServiceDiscoveryFactory . class . getClassLoader ( ) . getResourceAsStream ( "capabilities.txt" ) ; if ( in != null ) { List < String > lines = IOUtils . readLines ( in , "UTF-8" ) ; for ( String line : lines ) { line = StringUtils . trim ( line ) ; if ( StringUtils . isNotEmpty ( line ) && ! StringUtils . startsWith ( line , "#" ) ) { getLocalCapabilities ( ) . add ( ServiceCapabilityFactory . getInstance ( line ) ) ; } } } } catch ( Exception e ) { log . error ( "Unable to load capabilities text file." , e ) ; } finally { if ( in != null ) try { in . close ( ) ; } catch ( Exception e ) { } } } } catch ( Exception e ) { log . error ( "Failed to read service discovery file from disk. Checking environment..." , e ) ; } finally { if ( capabilitiesStream != null ) try { capabilitiesStream . close ( ) ; } catch ( Exception e ) { } } }
Reads in a JSON Array of serialized {@link DiscoverableService}s from a file named
 capabilities.json.
Reads in a JSON Array of serialized { @link DiscoverableService } s from a file named capabilities . json .
// read in json list of capabilities // is there an array of json capabilities? // nope, just one  // no json capability file, so look for a txt file 