org.apache.commons.collections4.keyvalue.DefaultKeyValue Java Examples

The following examples show how to use org.apache.commons.collections4.keyvalue.DefaultKeyValue. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FelixGoPluginOSGiFramework.java    From gocd with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, List<String>> getExtensionsInfoFromThePlugin(String pluginId) {
    if (framework == null) {
        LOGGER.warn("[Plugin Framework] Plugins are not enabled, so cannot do an action on all implementations of {}", GoPlugin.class);
        return null;
    }

    final BundleContext bundleContext = framework.getBundleContext();
    final ServiceQuery serviceQuery = ServiceQuery.newQuery(pluginId);
    final Collection<ServiceReference<GoPlugin>> serviceReferences = new HashSet<>(listServices(bundleContext, GoPlugin.class, serviceQuery));

    ActionWithReturn<GoPlugin, DefaultKeyValue<String, List<String>>> action = (goPlugin, descriptor) -> new DefaultKeyValue<>(goPlugin.pluginIdentifier().getExtension(), goPlugin.pluginIdentifier().getSupportedExtensionVersions());

    return serviceReferences.stream()
            .map(serviceReference -> {
                GoPlugin service = bundleContext.getService(serviceReference);
                return executeActionOnTheService(action, service, registry.getPlugin(pluginId));
            }).collect(toMap(AbstractKeyValue::getKey, AbstractKeyValue::getValue));
}
 
Example #2
Source File: CouchDBBlockLogger.java    From exo-demo with MIT License 4 votes vote down vote up
/**
 * Configures a CouchDBBlockLogger instance from a list of 
 * key-value parameters loaded from an exo-config file.
 * 
 * Expected parameters are:  
 * databaseName		The name of the CouchDB database to log to
 * useAsPrefix		When true, the logger will append the node's 
 * 					name to the "databaseName" value when determining 
 * 					the database name
 * host				Identifies the CouchDB instance hostname
 * port				Identifies the CouchDB listener port
 * prototcol			(optional) Should be "http" or "https" depending on your 
 * 					CouchDB configuration.  Defaults to "http"
 * username			(optional) Specifies the username to log into couchDB with
 * password			(optional) Specifies the password to log into couchDB with
 * blockSize			(optional) Determines the number of transactions in 
 * 					a block.  Defaults to 4.
 * createDb			(optional) Create the database if it doesn't already exist
 */
@Override
public void configure(DefaultKeyValue<String, String>[] parameters) {
	//Organize parameters into a map for easy access
	Map<String, String> parameterMap = new HashMap<String, String>();
	for (DefaultKeyValue<String, String> parameter : parameters) {
		parameterMap.put(parameter.getKey(), parameter.getValue());
	}
	
	//Determine database name
	String databaseName = parameterMap.get("databaseName");
	if (parameterMap.containsKey("useAsPrefix") && parameterMap.get("useAsPrefix").equals("true")) {
		databaseName = databaseName + ExoPlatformLocator.getPlatform().getAddress().getSelfName().toLowerCase();
	}
	
	//Determine protocol
	String protocol;
	if (parameterMap.containsKey("protocol")) {
		protocol = parameterMap.get("protocol");
	} else {
		protocol = "http";
	}
	
	//Determine if we should create the database, if it doesn't exist
	boolean createDB = parameterMap.containsKey("createDb") && parameterMap.get("createDb").equals("true");
	
	//See if a block size is defined in the config
	if (parameterMap.containsKey("blockSize")) {
		BLOCK_SIZE = Integer.parseInt(parameterMap.get("blockSize"));
	}
	
	this.client = new CouchDbClient(
		databaseName, 
		createDB, 
		protocol, 
		parameterMap.get("host"), 
		Integer.parseInt(parameterMap.get("port")),
		parameterMap.get("username"),
		parameterMap.get("password")
	);
	
	this.initialize();
	
}
 
Example #3
Source File: NullBlockLogger.java    From exo-demo with MIT License 4 votes vote down vote up
@Override
public void configure(DefaultKeyValue<String, String>[] parameters) {
	return;
}
 
Example #4
Source File: IBlockLogger.java    From exo-demo with MIT License 2 votes vote down vote up
/**
 * Used to configure a logger from an exo-config file.  The contents 
 * of the parameter list will be specific to each logger
 * @param parameters
 */
public void configure(DefaultKeyValue<String, String>[] parameters);