Java Code Examples for org.mortbay.jetty.servlet.ServletHolder#setInitParameter()

The following examples show how to use org.mortbay.jetty.servlet.ServletHolder#setInitParameter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JackrabbitMain.java    From commons-vfs with Apache License 2.0 6 votes vote down vote up
private void prepareWebapp(final File file, final File repository, final File tmp) {
    webapp.setContextPath("/");
    webapp.setWar(file.getPath());
    webapp.setClassLoader(JackrabbitMain.class.getClassLoader());
    // we use a modified web.xml which has some servlets remove (which produce random empty directories)
    final URL res = getResource("/jcrweb.xml");
    if (res != null) {
        webapp.setDescriptor(res.toString());
    }
    webapp.setExtractWAR(false);
    webapp.setTempDirectory(tmp);

    final ServletHolder servlet = new ServletHolder(JackrabbitRepositoryServlet.class);
    servlet.setInitOrder(1);
    servlet.setInitParameter("repository.home", repository.getAbsolutePath());
    final String conf = command.getOptionValue("conf");
    if (conf != null) {
        servlet.setInitParameter("repository.config", conf);
    }
    webapp.addServlet(servlet, "/repository.properties");
}
 
Example 2
Source File: CacheReplicationTestCase.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected void setupPspMithraService()
    {
        server = new Server(this.getApplicationPort1());
        Context context = new Context (server,"/",Context.SESSIONS);
        ServletHolder holder = context.addServlet(PspServlet.class, "/PspServlet");
        holder.setInitParameter("serviceInterface.MasterCacheService", "com.gs.fw.common.mithra.cache.offheap.MasterCacheService");
        holder.setInitParameter("serviceClass.MasterCacheService", "com.gs.fw.common.mithra.cache.offheap.MasterCacheServiceImpl");
        holder.setInitOrder(10);
//        System.out.println(holder.getServlet().getClass().getName());

        try
        {
            server.start();
        }
        catch (Exception e)
        {
            throw new RuntimeException("could not start server", e);
        }
        finally
        {
        }
    }
 
Example 3
Source File: PspTestCase.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected void setupServerWithHandler(
        Handler handler) throws Exception
{
    this.port = (int) (Math.random() * 10000.0 + 10000.0);
    this.pspUrl = "http://localhost:" + this.port + "/PspServlet";
    this.server = new Server(this.port);
    Context context = new Context(server, "/", Context.SESSIONS);
    if (handler != null)
    {
        context.addHandler(handler);
    }
    ServletHolder holder = context.addServlet(PspServlet.class, "/PspServlet");
    holder.setInitParameter("serviceInterface.Echo", "com.gs.fw.common.mithra.test.tinyproxy.Echo");
    holder.setInitParameter("serviceClass.Echo", "com.gs.fw.common.mithra.test.tinyproxy.EchoImpl");
    holder.setInitOrder(10);

    this.server.start();
    this.servlet = (PspServlet) holder.getServlet();
}
 
Example 4
Source File: RemoteMithraServerTestCase.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected void setupPspMithraService()
{
    server = new Server(this.getApplicationPort1());
    Context context = new Context (server,"/",Context.SESSIONS);
    ServletHolder holder = context.addServlet(PspServlet.class, "/PspServlet");
    holder.setInitParameter("serviceInterface.RemoteMithraService", "com.gs.fw.common.mithra.remote.RemoteMithraService");
    holder.setInitParameter("serviceClass.RemoteMithraService", "com.gs.fw.common.mithra.remote.RemoteMithraServiceImpl");
    holder.setInitOrder(10);

    try
    {
        server.start();
    }
    catch (Exception e)
    {
        throw new RuntimeException("could not start server", e);
    }
    finally
    {
    }
}
 
Example 5
Source File: StaticResourceServlet.java    From nomulus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a servlet holder for this servlet so it can be used with Jetty.
 *
 * @param prefix servlet path starting with a slash and ending with {@code "/*"} if {@code root}
 *     is a directory
 * @param root file or root directory to serve
 */
public static ServletHolder create(String prefix, Path root) {
  root = root.toAbsolutePath();
  checkArgument(Files.exists(root), "Root must exist: %s", root);
  checkArgument(prefix.startsWith("/"), "Prefix must start with a slash: %s", prefix);
  ServletHolder holder = new ServletHolder(StaticResourceServlet.class);
  holder.setInitParameter("root", root.toString());
  if (Files.isDirectory(root)) {
    checkArgument(prefix.endsWith("/*"),
        "Prefix (%s) must end with /* since root (%s) is a directory", prefix, root);
    holder.setInitParameter("prefix", prefix.substring(0, prefix.length() - 1));
  } else {
    holder.setInitParameter("prefix", prefix);
  }
  return holder;
}
 
Example 6
Source File: TestServer.java    From nomulus with Apache License 2.0 6 votes vote down vote up
private Context createHandler(
    Map<String, Path> runfiles,
    ImmutableList<Route> routes,
    ImmutableList<Class<? extends Filter>> filters) {
  Context context = new Context(server, CONTEXT_PATH, Context.SESSIONS);
  context.addServlet(new ServletHolder(HealthzServlet.class), "/healthz");
  for (Map.Entry<String, Path> runfile : runfiles.entrySet()) {
    context.addServlet(
        StaticResourceServlet.create(runfile.getKey(), runfile.getValue()),
        runfile.getKey());
  }
  for (Route route : routes) {
    context.addServlet(
        new ServletHolder(wrapServlet(route.servletClass(), filters)), route.path());
  }
  ServletHolder holder = new ServletHolder(DefaultServlet.class);
  holder.setInitParameter("aliases", "1");
  context.addServlet(holder, "/*");
  return context;
}
 
Example 7
Source File: JettyContainer.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();
    
    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }
    
    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);
    
    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
Example 8
Source File: RestServer.java    From hraven with Apache License 2.0 5 votes vote down vote up
@Override
protected void startUp() throws Exception {
  // setup the jetty config
  ServletHolder sh = new ServletHolder(ServletContainer.class);
  sh.setInitParameter("com.sun.jersey.config.property.packages", "com.twitter.hraven.rest");
  sh.setInitParameter(JSONConfiguration.FEATURE_POJO_MAPPING, "true");

  server = new Server();

  Connector connector = new SelectChannelConnector();
  connector.setPort(this.port);
  connector.setHost(address);

  server.addConnector(connector);

  // TODO: in the future we may want to provide settings for the min and max threads
  // Jetty sets the default max thread number to 250, if we don't set it.
  //
  QueuedThreadPool threadPool = new QueuedThreadPool();
  server.setThreadPool(threadPool);

  server.setSendServerVersion(false);
  server.setSendDateHeader(false);
  server.setStopAtShutdown(true);
  // set up context
  Context context = new Context(server, "/", Context.SESSIONS);
  context.addServlet(sh, "/*");

  // start server
  server.start();
}
 
Example 9
Source File: TestObjectFactory.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
public static Server getJettyServer() {
  Server server = new Server();
  ServletHandler context = new ServletHandler();
  ServletHolder holder = new ServletHolder(DefaultServlet.class);
  holder.setInitParameter("resourceBase", System.getProperty("user.dir"));
  holder.setInitParameter("dirAllowed", "true");
  context.setServer(server);
  context.addServlet(holder);
  server.setHandler(context);    

  return server;
}
 
Example 10
Source File: JettyContainer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();
    
    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }
    
    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);
    
    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
Example 11
Source File: JettyContainer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();
    
    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }
    
    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);
    
    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
Example 12
Source File: HttpServer2.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Add a Jersey resource package.
 * @param packageName The Java package name containing the Jersey resource.
 * @param pathSpec The path spec for the servlet
 */
public void addJerseyResourcePackage(final String packageName,
    final String pathSpec) {
  LOG.info("addJerseyResourcePackage: packageName=" + packageName
      + ", pathSpec=" + pathSpec);
  final ServletHolder sh = new ServletHolder(ServletContainer.class);
  sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
      "com.sun.jersey.api.core.PackagesResourceConfig");
  sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
  webAppContext.addServlet(sh, pathSpec);
}
 
Example 13
Source File: HttpServer.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** 
 * Add a Jersey resource package.
 * @param packageName The Java package name containing the Jersey resource.
 * @param pathSpec The path spec for the servlet
 */
public void addJerseyResourcePackage(final String packageName,
    final String pathSpec) {
  LOG.info("addJerseyResourcePackage: packageName=" + packageName
      + ", pathSpec=" + pathSpec);
  final ServletHolder sh = new ServletHolder(ServletContainer.class);
  sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
      "com.sun.jersey.api.core.PackagesResourceConfig");
  sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
  webAppContext.addServlet(sh, pathSpec);
}
 
Example 14
Source File: HttpServer2.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Add a Jersey resource package.
 * @param packageName The Java package name containing the Jersey resource.
 * @param pathSpec The path spec for the servlet
 */
public void addJerseyResourcePackage(final String packageName,
    final String pathSpec) {
  LOG.info("addJerseyResourcePackage: packageName=" + packageName
      + ", pathSpec=" + pathSpec);
  final ServletHolder sh = new ServletHolder(ServletContainer.class);
  sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
      "com.sun.jersey.api.core.PackagesResourceConfig");
  sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
  webAppContext.addServlet(sh, pathSpec);
}
 
Example 15
Source File: HttpServer.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/** 
 * Add a Jersey resource package.
 * @param packageName The Java package name containing the Jersey resource.
 * @param pathSpec The path spec for the servlet
 */
public void addJerseyResourcePackage(final String packageName,
    final String pathSpec) {
  LOG.info("addJerseyResourcePackage: packageName=" + packageName
      + ", pathSpec=" + pathSpec);
  final ServletHolder sh = new ServletHolder(ServletContainer.class);
  sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass",
      "com.sun.jersey.api.core.PackagesResourceConfig");
  sh.setInitParameter("com.sun.jersey.config.property.packages", packageName);
  webAppContext.addServlet(sh, pathSpec);
}
 
Example 16
Source File: JettyContainer.java    From dubbox with Apache License 2.0 5 votes vote down vote up
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();
    
    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }
    
    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);
    
    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
Example 17
Source File: WebServer.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public WebServer(int httpport, DataStore data, MetadataStore metadata) throws IOException, URISyntaxException {
    super(httpport);

    extractWebUI();

    this.data = data;
    this.metadata = metadata;

    // Initialize Velocity template engine
    try {
        Velocity.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.Log4JLogChute");
        Velocity.setProperty("runtime.log.logsystem.log4j.logger", "edu.berkeley.xtrace.server.XTraceServer");
        Velocity.setProperty("file.resource.loader.path", webui + "/templates");
        Velocity.setProperty("file.resource.loader.cache", "true");
        Velocity.init();
    } catch (Exception e) {
        LOG.warn("Failed to initialize Velocity", e);
    }

    // Create Jetty server
    Context context = new Context(this, "/");

    // Create a CGI servlet for scripts in webui/cgi-bin
    ServletHolder cgiHolder = new ServletHolder(new CGI());
    cgiHolder.setInitParameter("cgibinResourceBase", webui + "/cgi-bin");

    // Pass any special PATH setting on to the execution environment
    if (System.getenv("PATH") != null)
        cgiHolder.setInitParameter("Path", System.getenv("PATH"));

    context.addServlet(cgiHolder, "*.cgi");
    context.addServlet(cgiHolder, "*.pl");
    context.addServlet(cgiHolder, "*.py");
    context.addServlet(cgiHolder, "*.rb");
    context.addServlet(cgiHolder, "*.tcl");
    context.addServlet(new ServletHolder(new GetReportsServlet()), "/reports/*");
    context.addServlet(new ServletHolder(new TagServlet()), "/tag/*");
    context.addServlet(new ServletHolder(new TitleServlet()), "/title/*");
    context.addServlet(new ServletHolder(new TitleLikeServlet()), "/titleLike/*");

    // JSON APIs for interactive visualization
    context.addServlet(new ServletHolder(new GetJSONReportsServlet()), "/interactive/reports/*");
    context.addServlet(new ServletHolder(new GetOverlappingTasksServlet()), "/interactive/overlapping/*");
    context.addServlet(new ServletHolder(new GetTagsForTaskServlet()), "/interactive/tags/*");
    context.addServlet(new ServletHolder(new GetTasksForTags()), "/interactive/taggedwith/*");

    context.setResourceBase(webui + "/html");
    context.addServlet(new ServletHolder(new IndexServlet()), "/");
}
 
Example 18
Source File: HbaseRestLocalCluster.java    From hadoop-mini-clusters with Apache License 2.0 4 votes vote down vote up
@Override
public void start() throws Exception {
    VersionInfo.logVersion();
    Configuration conf = builder.getHbaseConfiguration();

    conf.set("hbase.rest.port", hbaseRestPort.toString());
    conf.set("hbase.rest.readonly", (hbaseRestReadOnly == null) ? "true" : hbaseRestReadOnly.toString());
    conf.set("hbase.rest.info.port", (hbaseRestInfoPort == null) ? "8085" : hbaseRestInfoPort.toString());
    String hbaseRestHost = (this.hbaseRestHost == null) ? "0.0.0.0" : this.hbaseRestHost;

    Integer hbaseRestThreadMax = (this.hbaseRestThreadMax == null) ? 100 : this.hbaseRestThreadMax;
    Integer hbaseRestThreadMin = (this.hbaseRestThreadMin == null) ? 2 : this.hbaseRestThreadMin;

    UserProvider userProvider = UserProvider.instantiate(conf);
    Pair<FilterHolder, Class<? extends ServletContainer>> pair = loginServerPrincipal(userProvider, conf);
    FilterHolder authFilter = pair.getFirst();
    Class<? extends ServletContainer> containerClass = pair.getSecond();
    RESTServlet.getInstance(conf, userProvider);

    // set up the Jersey servlet container for Jetty
    ServletHolder sh = new ServletHolder(containerClass);
    sh.setInitParameter("com.sun.jersey.config.property.resourceConfigClass", ResourceConfig.class.getCanonicalName());
    sh.setInitParameter("com.sun.jersey.config.property.packages", "jetty");
    ServletHolder shPojoMap = new ServletHolder(containerClass);
    Map<String, String> shInitMap = sh.getInitParameters();
    for (Map.Entry<String, String> e : shInitMap.entrySet()) {
        shPojoMap.setInitParameter(e.getKey(), e.getValue());
    }
    shPojoMap.setInitParameter(JSONConfiguration.FEATURE_POJO_MAPPING, "true");

    // set up Jetty and run the embedded server

    server = new Server();

    Connector connector = new SelectChannelConnector();
    if (conf.getBoolean(RESTServer.REST_SSL_ENABLED, false)) {
        SslSelectChannelConnector sslConnector = new SslSelectChannelConnector();
        String keystore = conf.get(RESTServer.REST_SSL_KEYSTORE_STORE);
        String password = HBaseConfiguration.getPassword(conf, RESTServer.REST_SSL_KEYSTORE_PASSWORD, null);
        String keyPassword = HBaseConfiguration.getPassword(conf, RESTServer.REST_SSL_KEYSTORE_KEYPASSWORD, password);
        sslConnector.setKeystore(keystore);
        sslConnector.setPassword(password);
        sslConnector.setKeyPassword(keyPassword);
        connector = sslConnector;
    }
    connector.setPort(hbaseRestPort);
    connector.setHost(hbaseRestHost);
    connector.setHeaderBufferSize(8192);


    server.addConnector(connector);

    QueuedThreadPool threadPool = new QueuedThreadPool(hbaseRestThreadMax);
    threadPool.setMinThreads(hbaseRestThreadMin);
    server.setThreadPool(threadPool);

    server.setSendServerVersion(false);
    server.setSendDateHeader(false);
    server.setStopAtShutdown(true);
    // set up context
    Context context = new Context(server, "/", Context.SESSIONS);
    context.addServlet(shPojoMap, "/status/cluster");
    context.addServlet(sh, "/*");
    if (authFilter != null) {
        context.addFilter(authFilter, "/*", 1);
    }

    HttpServerUtil.constrainHttpMethods(context);

    // Put up info server.
    int port = (hbaseRestInfoPort == null) ? 8085 : hbaseRestInfoPort;
    if (port >= 0) {
        conf.setLong("startcode", System.currentTimeMillis());
        String a = hbaseRestHost;
        infoServer = new InfoServer("rest", a, port, false, conf);
        infoServer.setAttribute("hbase.conf", conf);
        infoServer.start();
    }
    // start server
    server.start();
}
 
Example 19
Source File: Main.java    From stanbol-freeling with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @param args
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
    CommandLineParser parser = new PosixParser();
    CommandLine line = parser.parse(options, args);
    args = line.getArgs();
    if(line.hasOption('h')){
        printHelp();
        System.exit(0);
    }
    //Parse the Freeling parameter and init the Freeling instance
    String sharedFolder = System.getenv(ENV_FREELING_SHARED_FOLDER);
    sharedFolder = System.getProperty(PROPERTY_FREELING_SHARED_FOLDER, sharedFolder);
    sharedFolder = line.getOptionValue('s', sharedFolder);
    if(sharedFolder == null){
        System.err.println("The Freeling shared Folder MUST BE set! \n");
        printHelp();
        System.exit(0);
    }
    File shared = new File(sharedFolder);
    if(!shared.isDirectory()){
        System.err.println("The configured Freeling shared folder '"
            + sharedFolder + "' is not a directory!\n");
        System.exit(1);
    }
    String configFolder = FilenameUtils.concat(sharedFolder, "config");
    configFolder = System.getProperty(PROPERTY_FREELING_CONFIG_FOLDER, configFolder);
    configFolder = line.getOptionValue('c', configFolder);
    File config = new File(configFolder);
    if(!config.isDirectory()){
        System.err.println("The configured Freeling config folder '"
            + configFolder + "' is not a directory!\n");
        System.exit(1);
    }
    String nativeLib = FilenameUtils.concat(sharedFolder, Freeling.DEFAULT_FREELING_LIB_PATH);
    if(new File(Freeling.DEFAULT_FREELING_LIB_PATH).isFile()){
        nativeLib = Freeling.DEFAULT_FREELING_LIB_PATH;
    }
    nativeLib = line.getOptionValue('l', nativeLib);
    if(!new File(nativeLib).isFile()){
        System.err.println("The configured Freeling native lib '"
                + nativeLib + "' is not a file!\n");
        System.exit(1);
    }
    Freeling freeling = new Freeling(
        config.getPath(), Freeling.DEFAULT_CONFIGURATION_FILENAME_SUFFIX, 
        shared.getPath(), nativeLib, Freeling.DEFAULT_FREELING_LOCALE, 
        getInt(line, 'i', DEFAULT_INIT_THREADS), 
        getInt(line, 'm', DEFAULT_MAX_POOL_SIZE), 
        getInt(line, 'q', DEFAULT_MIN_QUEUE_SIZE));
    
    
    //init the Jetty Server
    Server server = new Server();
    Connector con = new SelectChannelConnector();
    //we need the port
    con.setPort(getInt(line,'p',DEFAULT_PORT));
    server.addConnector(con);

    //init the Servlet and the ServletContext
    Context context = new Context(server, "/", Context.SESSIONS);
    ServletHolder holder = new ServletHolder(RestServlet.class);
    holder.setInitParameter("javax.ws.rs.Application", FreelingApplication.class.getName());
    context.addServlet(holder, "/*");
    
    //now initialise the servlet context
    context.setAttribute(Constants.SERVLET_ATTRIBUTE_CONTENT_ITEM_FACTORY, 
        lookupService(ContentItemFactory.class));
    context.setAttribute(Constants.SERVLET_ATTRIBUTE_FREELING, freeling);
    context.setAttribute(Constants.SERVLET_ATTRIBUTE_MAX_RESOURCE_WAIT_TIEM, 
        getLong(line,'w',Constants.DEFAULT_RESOURCE_WAIT_TIME));
    //Freeling
    
    server.start();
    try {
        server.join();
    }catch (InterruptedException e) {
    }
    System.err.println("Shutting down Freeling");
    freeling.close();
}