@@ -0,0 +1,2648 @@
+/*******************************************************************************%0A * DIANNE  - Framework for distributed artificial neural networks%0A * Copyright (C) 2015  iMinds - IBCN - UGent%0A *%0A * This file is part of DIANNE.%0A *%0A * DIANNE is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as%0A * published by the Free Software Foundation, either version 3 of the%0A * License, or (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU Affero General Public License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with this program.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A *%0A * Contributors:%0A *     Tim Verbelen, Steven Bohez%0A *******************************************************************************/%0Apackage be.iminds.iot.dianne.command;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport org.apache.felix.service.command.Descriptor;%0Aimport org.osgi.framework.BundleContext;%0Aimport org.osgi.service.component.annotations.Activate;%0Aimport org.osgi.service.component.annotations.Component;%0Aimport org.osgi.service.component.annotations.Reference;%0Aimport org.osgi.service.component.annotations.ReferenceCardinality;%0Aimport org.osgi.service.component.annotations.ReferencePolicy;%0A%0Aimport be.iminds.iot.dianne.api.rl.environment.Environment;%0A%0A@Component(%0A%09%09service=Object.class,%0A%09%09property=%7B%22osgi.command.scope=dianne%22,%0A%09%09%09%09  %22osgi.command.function=environments%22%7D,%0A%09%09immediate=true)%0Apublic class DianneEnvironmentCommands %7B%0A%0A%09private Map%3CString, Environment%3E environments = new HashMap%3C%3E();%0A%09%0A%09@Activate%0A%09public void activate(BundleContext context)%7B%0A%09%7D%0A%09%0A%09@Descriptor(%22List the available environments.%22)%0A%09public void environments()%7B%0A%09%09if(environments.size()==0)%7B%0A%09%09%09System.out.println(%22No environments available%22);%0A%09%09%09return;%0A%09%09%7D%0A%09%09%0A%09%09System.out.println(%22Available environments:%22);%0A%09%09int i = 0;%0A%09%09for(String environment : environments.keySet())%7B%0A%09%09%09System.out.println(%22%5B%22+(i++)+%22%5D %22+environment);%0A%09%09%7D%0A%09%7D%0A%09%0A%09@Reference(cardinality=ReferenceCardinality.MULTIPLE, %0A%09%09%09policy=ReferencePolicy.DYNAMIC)%0A%09void addEnvironment(Environment env, Map%3CString, Object%3E properties)%7B%0A%09%09String name = (String) properties.get(%22name%22);%0A%09%09this.environments.put(name, env);%0A%09%7D%0A%09%0A%09void removeEnvironment(Environment env, Map%3CString, Object%3E properties)%7B%0A%09%09String name = (String) properties.get(%22name%22);%0A%09%09this.environments.remove(name);%0A%09%7D%0A%7D%0A

add command for listing environments available