@Override
 public void deactivate(ComponentContext context) throws Exception {
   notifier.stop();
   notifier.removeListener(this);
   deployer.removeConfigurationChangedListener(this);
   engine.destroy();
   engine = null;
   deployer = null;
   notifier = null;
   ctx = null;
   super.deactivate(context);
 }
  @Override
  public void activate(ComponentContext context) throws Exception {
    super.activate(context);
    ctx = context;
    String webDir = Framework.getProperty("org.nuxeo.ecm.web.root");
    File root = null;
    if (webDir != null) {
      root = new File(webDir);
    } else {
      root = new File(Framework.getRuntime().getHome(), "web");
    }
    root = root.getCanonicalFile();
    log.info("Using web root: " + root);
    if (!new File(root, "default").exists()) {
      try {
        root.mkdirs();
        // runtime predeployment is not supporting conditional unziping so we do the predeployment
        // here:
        deployWebDir(context.getRuntimeContext().getBundle(), root);
      } catch (Exception e) { // delete incomplete files
        FileUtils.deleteTree(root);
        throw e;
      }
    }
    // register contrib managers
    registerContributionManager(APPLICATION_XP, new ContributionManager(this));
    registerContributionManager(WEB_OBJ_XP, new ContributionManager(this));

    // load message bundle
    notifier = new FileChangeNotifier();
    notifier.start();
    notifier.addListener(this);

    engine = new DefaultWebEngine(root, notifier);
    deployer = new ConfigurationDeployer(notifier);
    deployer.addConfigurationChangedListener(this);
  }