Example #1
0
        public FileSessionSetup(Configuration conf, Dictionary<string, object> config) {
            if (config != null && config.ContainsKey("files")) {
                foreach (object fileObj in (List<object>)config["files"]) {
                    Dictionary<string, object> file = (Dictionary<string, object>)fileObj;
                    string relFileName = (string)file["path"];
                    string fileName = Path.Combine(Path.GetDirectoryName(conf.appPath), relFileName);

                    setups[fileName] = Convert.FromBase64String((string)file["data"]);
                    shouldRollback[fileName] = !file.ContainsKey("revert") || Convert.ToBoolean(file["revert"]);
                }
            }
        }
Example #2
0
        public void createConfigurations() {
            foreach (KeyValuePair<string, string> kv in servlet.Configuration) {
                if (!(kv.Key.StartsWith("app.") && kv.Key.EndsWith(".path")))
                    continue;

                string identifier = kv.Key.Substring("app.".Length);
                identifier = identifier.Substring(0, identifier.Length - ".path".Length);
                Configuration config;
                try {
                    config = new Configuration(identifier, kv.Value);
                } catch (FileNotFoundException ex) {
                    servlet.Log.Error("Skipping app '{0}' - executable does not exist: {1}", identifier, kv.Value);
                    servlet.Log.Trace(ex);
                    continue;
                }

                config.properties["rc"] = servlet.ExternalUri.ToString();
                string prefix = "app." + identifier + ".";
                foreach (KeyValuePair<string, string> pair in servlet.Configuration) {
                    if (pair.Key.StartsWith(prefix)) {
                        string property = pair.Key.Substring(prefix.Length);
                        switch (property) {
                            case "path": // handled
                                break;
                            case "name":
                                config.properties["applicationName"] = pair.Value;
                                break;
                            default:
                                config.properties[property] = pair.Value;
                                break;
                        }
                    }
                }
                if (!config.properties.ContainsKey("applicationName"))
                    config.properties["applicationName"] = config.identifier;

                Configurations.Add(config);
            }
            if (Configurations.Count == 0)
                servlet.Log.Error("Warning: No valid app configurations found");
        }
Example #3
0
        public Session(SessionFactory factory, Configuration config, Dictionary<string,object> sessionSetupInfo) {
            Factory = factory;
            Configuration = config;
            if (config.Capabilities.ContainsKey("sessionSetup.files") && Convert.ToBoolean(config.Capabilities["sessionSetup.files"]))
                sessionSetups.Add(new FileSessionSetup(config, sessionSetupInfo));

            foreach (SessionSetup setup in sessionSetups)
                setup.Before(this);

            try {
                Process = Launch(config.LaunchStrategy);
            } catch (Exception e) {
                foreach (SessionSetup setup in sessionSetups)
                    setup.After(this);
                throw e;
            }
        }