public function registerFactory($factory, $class)
    {
        $this[$factory] = $this->factory(function ($app) use ($class) {
            $obj = new $class;
            if ($obj instanceof FactoryInterface) {
                return $obj->create($app);
            } else {
                return $obj;
            }
        });
    }