exports.create$ = function(_center) {
  var id = _center.id + "__built_in_hub__";
  var assemble = B.fs.read_json(B.path.resolve(__dirname, "./built_in_hub.json"));
  assemble.mnode.$params[1].id = id + "__mnode__";
  var hub;
  return Hub.start$({
    id: id, 
    assemble: assemble,
    config_path: B.path.abs("./built_in_hub.json", module.filename)
  }).then(function(objs) {
    hub = objs.hub;
    return hub;
  });
};
SessionManager.prototype.run_hub_script$ = function(script_path) {
  log("run_hub_script", script_path);
  var fs = require("fs");
  var vm = require("vm");
  var self = this;
  var sandbox = sb.create_hub_sandbox(self.service_cache.hub_shared,
    B.path.resolve(script_path, ".."));
  var context = fs.readFileSync(script_path);
  var func_string = "(function(){\n" + context + "\n})";
  var func_script = new vm.Script(func_string, 
        {filename: script_path + "__wrap"});
  return new Promise(function(resolve, reject) {
    sandbox.done = function(value)
    {
      log("hub script done", script_path);
      sandbox.fail = B.type.func_noop;
      sandbox.done = B.type.func_noop;
      resolve(value);
    };

    sandbox.fail = function(value)
    {
      log.warn("hub script fail", script_path);
      sandbox.done = B.type.func_noop;
      sandbox.fail = B.type.func_noop;
      reject(value);
    };

    sandbox.throwEXC = function(value)
    {
      log.warn("hub script throw exception", value);
      sandbox.fail(value);
    };

    try {
      var f = func_script.runInNewContext(sandbox);
      f();
    } catch(e) {
      log.warn("hub script catch exception", e);
      sandbox.fail(e);
    }
    
  });
};
function Config(file_path) {
  this.path = B.path.resolve(file_path);
  this.json = B.fs.read_json_with_comments(this.path);
  this.to_assemble = {};
  this.generated_config = {
    assemble: this.to_assemble
  };

  this.enable_log();

  this.parse_basic();

  this.gen_shared();

  if (this.type === "center") {
    this.gen_center_specific();
  } else if (this.type === "hub") {
    this.gen_hub_specific();
  }

}
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
var ES = require("../../entity-store");
var E = require("../../entity");
var M = require("../../message");
var B = require("hope-base");
var S = require("../../store");
var SM = require("../index");
var log = B.log.for_category("sm_sample");
//create the em, service_store and service_obj
var service_obj = {
  id: "sm_case1",
  name: "case1",
  spec: "no_need",
  thing: "no_need",
  path: B.path.resolve(__dirname, "./case/case1"),
  is_connect: true,
  own_spec: false,
  type: "hope_service"
};
var service_store = ES.create_servicestore("memory");
service_store.set$(service_obj.id, service_obj).done();
var em = E.create_entity_manager({service_store:service_store});


//create mnode
var route_table = M.create_route_table(S.create_store("memory"));
var router = M.create_router(route_table);
var mnode_master = M.create_mnode(router);
var mnode_slave = M.create_mnode(router);