private File predfinedFile(String path){ return ConfigUtils.getFileSystemAdapter().openFile(path); }
/** * Attempts to load a Configuration from the default location. * @return Configuration loaded from the default location */ public static Configuration getConfiguration(){ if(theConfiguration == null){ try{ File config = getFileSystemAdapter().openFile("./resources/main.properties"); theConfiguration = new PropertiesConfiguration(config); }catch(ConfigurationException t){ theLogger.log(Level.WARNING, "Cannont find main.properties", t); } } return theConfiguration; }
/** * Loads an XML file from the given path. * @param path location of the XML file * @return XML file at the given path */ public static HierarchicalConfiguration loadXMLConfig(String path){ File file = ConfigUtils.getFileSystemAdapter().openFile(path); try{ return new XMLConfiguration(file); }catch (ConfigurationException t){ theLogger.log(Level.WARNING, "Cannont open XML file at: " + path, t); return null; } }
}Configuration keyConfig = null; try{ File file = ConfigUtils.getFileSystemAdapter().openFile(path); keyConfig = new PropertiesConfiguration(file); }catch(ConfigurationException ex){
private ManagedService launchRobot( BundleContext context, Robot.Id robotId, String path){ File file = ConfigUtils.getFileSystemAdapter().openFile(path); if(file == null){ return null; } String paramId = "robot/" + robotId + "/config/param/xml"; launchRobotConfig(context, file, paramId); return loadRobotService(context, robotId, paramId); }
protected static Set<OSGiComponent> loadJointGroup( BundleContext context, Robot.Id robotId, String configPath){ Set comps = new HashSet<OSGiComponent>(2); File file = ConfigUtils.getFileSystemAdapter().openFile(configPath); if(file == null){ return null; } String paramId = "robot/" + robotId + "/jointgroup/config/param/xml"; comps.add(launchJointGroupConfig(context, file, paramId)); RobotJointGroupLifecycle<File> lifecycle = new RobotJointGroupLifecycle<File>(robotId, File.class, paramId, RobotJointGroupConfigXMLReader.VERSION); OSGiComponent jointGroupComp = new OSGiComponent(context, lifecycle); jointGroupComp.start(); comps.add(jointGroupComp); return comps; }