2012-10-27 2 views
2

나는 Heroku가의 사이트 ->다중 스레드 Jetty의 방법 Heroku의 RESTful 서비스?

http://arcane-chamber-8582.herokuapp.com/

주요 방법은 다음과 같습니다에 JAX-RS의 튜토리얼을 시작했다 : 나는 누군가가 나에게 설명 할 수 있을까요

package com.example; 

import org.eclipse.jetty.server.Server; 
import org.eclipse.jetty.webapp.WebAppContext; 

/** 
* 
* This class launches the web application in an embedded Jetty container. 
* This is the entry point to your application. The Java command that is used for 
* launching should fire this main method. 
* 
*/ 
public class Main { 

    /** 
    * @param args 
    */ 
    public static void main(String[] args) throws Exception{ 
     String webappDirLocation = "src/main/webapp/"; 

     // The port that we should run on can be set into an environment variable 
     // Look for that variable and default to 8080 if it isn't there. 
     String webPort = System.getenv("PORT"); 
     if (webPort == null || webPort.isEmpty()) { 
      webPort = "8080"; 
     } 

     Server server = new Server(Integer.valueOf(webPort)); 
     WebAppContext root = new WebAppContext(); 

     root.setContextPath("/"); 
     root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml"); 
     root.setResourceBase(webappDirLocation); 

     // Parent loader priority is a class loader setting that Jetty accepts. 
     // By default Jetty will behave like most web containers in that it will 
     // allow your application to replace non-server libraries that are part of the 
     // container. Setting parent loader priority to true changes this behavior. 
     // Read more here: http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading 
     root.setParentLoaderPriority(true); 

     server.setHandler(root); 

     server.start(); 
     server.join(); 
    } 

} 

무엇을거야 서버와 루트에? 이 프로세스에 dyno를 할당하면 RESTful 요청을 처리하기 위해 스레드 풀에 여러 요청 스레드가 자동으로 생성됩니까? 그렇다면 공유/공유하지 않는 부분은 무엇입니까?

감사합니다.

+0

을 구체적으로, 나는 그냥 모르는 어딘가에 설정되는 기본 스레드 풀 크기가? – Luke

답변

2

부두는 단지 그 시나리오 (부두의 기본값, Heroku의 것)에서 기본값을 사용하고 있습니다. 당신은 다음과 같이 변경할 수 있습니다 :

How to use setThreadPool() in Jetty