    public void activate(ComponentContext context) throws Exception {
        server = new Server(8081);
        URL cfg = null;
        String cfgName = Framework.getProperty("org.nuxeo.jetty.config");
        if (cfgName != null) {
            if (cfgName.contains(":/")) {
                cfg = new URL(cfgName);
            } else { 
                File file = new File(cfgName);
                if (file.isFile()) {
                    cfg = file.toURI().toURL();
                }
            }
        } else {
            File file = new File(Environment.getDefault().getConfig(), "jetty.xml");
            if (file.isFile()) {
                cfg = file.toURI().toURL();
            }
        }
        if (cfg != null) {
            XmlConfiguration configuration = new XmlConfiguration(cfg);
            configuration.configure(server);
        }
        Handler[] handlers = server.getHandlers();
        if (handlers != null && handlers.length > 0 && handlers[0] instanceof ContextHandlerCollection) {
            contexts = (ContextHandlerCollection)handlers[0];
        } else if (handlers == null || handlers.length == 0) {
            contexts = new ContextHandlerCollection();
            RequestLogHandler requestLogHandler = new RequestLogHandler();
            File logDir = Environment.getDefault().getLog();
            logDir.mkdirs();
            File logFile = new File(logDir, "jetty.log");
            NCSARequestLog requestLog = new NCSARequestLog(logFile.getAbsolutePath());
            requestLogHandler.setRequestLog(requestLog);
            handlers = new Handler[] {contexts, new DefaultHandler(), requestLogHandler};
            server.setHandlers(handlers);
            server.setSendServerVersion(true);
            server.setStopAtShutdown(true);
        } else { 
            contexts = new ContextHandlerCollection();
            Handler[] newHandlers = new Handler[handlers.length+1];
            newHandlers[0] = contexts;
            System.arraycopy(handlers, 0, newHandlers, 0, handlers.length);
            server.setHandlers(newHandlers);
        }
        server.start();
    }

    public void activate(ComponentContext context) throws Exception {
        URL cfg = null;
        String cfgName = Framework.getProperty("org.nuxeo.jetty.config");
        if (cfgName != null) {
            if (cfgName.contains(":/")) {
                cfg = new URL(cfgName);
            } else { 
                File file = new File(cfgName);
                if (file.isFile()) {
                    cfg = file.toURI().toURL();
                }
            }
        } else {
            File file = new File(Environment.getDefault().getConfig(), "jetty.xml");
            if (file.isFile()) {
                cfg = file.toURI().toURL();
            }
        }
        if (cfg != null) {
            XmlConfiguration configuration = new XmlConfiguration(cfg);
            server = (Server)configuration.configure();
        } else {
            int p = 8080;
            String port = Environment.getDefault().getProperty("http_port");
            if (port != null) {
                try {
                p = Integer.parseInt(port);
                } catch (NumberFormatException e) {
                }
            }
            server = new Server(p);
        }
        Handler[] handlers = server.getHandlers();
        if (handlers != null && handlers.length > 0 && handlers[0] instanceof ContextHandlerCollection) {
            contexts = (ContextHandlerCollection)handlers[0];
        } else if (handlers == null || handlers.length == 0) {
            contexts = new ContextHandlerCollection();
            RequestLogHandler requestLogHandler = new RequestLogHandler();
            File logDir = Environment.getDefault().getLog();
            logDir.mkdirs();
            File logFile = new File(logDir, "jetty.log");
            NCSARequestLog requestLog = new NCSARequestLog(logFile.getAbsolutePath());
            requestLogHandler.setRequestLog(requestLog);
            handlers = new Handler[] {contexts, new DefaultHandler(), requestLogHandler};
            server.setHandlers(handlers);
            server.setSendServerVersion(true);
            server.setStopAtShutdown(true);
        } else { 
            contexts = new ContextHandlerCollection();
            Handler[] newHandlers = new Handler[handlers.length+1];
            newHandlers[0] = contexts;
            System.arraycopy(handlers, 0, newHandlers, 0, handlers.length);
            server.setHandlers(newHandlers);
        }
        server.start();
    }
