2012-12-05 3 views
2

Restlet 2.1이 설치된 JSE 응용 프로그램을 실행하고 있습니다. 응용 프로그램 컨텍스트를 사용하려고 시도하고 있으며 응용 프로그램에서 항상 null임을 확인하고 있습니다. null이기 때문에 리소스를 호출 할 때 전달하는 모든 특성을 포함하여 아무 것도 액세스하지 못하는 것 같습니다.Restlet 2.1 응용 프로그램에 null 컨텍스트가 있습니다.

으로 Restlet 애플리케이션 클래스의 코드는 다음과 같습니다 다음 PageServerImpl가 ServerResource 것을

package net.factor3.mailapp; 

import net.factor3.mailapp.impl.PageServerImpl; 

import org.restlet.Application; 
import org.restlet.Context; 
import org.restlet.Request; 
import org.restlet.Response; 
import org.restlet.Restlet; 
import org.restlet.Server; 
import org.restlet.data.MediaType; 
import org.restlet.data.Protocol; 
import org.restlet.routing.Router; 
import org.restlet.routing.Template; 

public class MyServer extends Application 
{ 
    public MyServer() 
    { 
     setName("Test Application"); 
     setDescription("Testing use of Restlets"); 
    } 

    @Override 
    public Restlet createInboundRoot() 
    { 
     Context ctx = getContext(); 
     Router route = new Router(ctx); 

     route.setDefaultMatchingMode(Template.MODE_EQUALS); 
     route.attach("http://localhost:8100/",PageServerImpl.class); 
     route.attach("http://localhost:8100/{page}",PageServerImpl.class); 

     return(route); 
    } 

    public static void main(String[] args) throws Exception 
    { 
     Server asrv = new Server(Protocol.HTTP,8100); 
     asrv.setNext(new MyServer()); 
     asrv.start(); 
    } 

} 

참고. createInboundRoot()에서 getContext()를 사용하여 응용 프로그램의 컨텍스트를 가져 와서 ctx에 저장합니다. ctx는 항상 null이고, ServerResource에서 매개 변수와 속성이 손실 된 이유를 믿습니다.

JRE 버전의 Restlet 2.1의 버그입니까? 그렇다면 어디에보고해야합니까? Restlet 웹 사이트에는 버그 리포트에 대한 명확한 링크가 없습니다.

버그가 아닌 경우이 종류의 응용 프로그램에서 알맞은 컨텍스트를 얻으려면 어떻게해야합니까 ???

누군가의 조언을 바랍니다.

답변

1

사용하여 구성 요소 클래스는 statisfy 당신의 필요 만들 수 있습니다

public class MyServer extends Application 
{ 
    public MyServer() 
    { 
     setName("Test Application"); 
     setDescription("Testing use of Restlets"); 
    } 

    public static void main(String[] args) throws Exception 
    { 
     // Create a new Restlet component and add a HTTP server connector to it 
     Component component = new Component(); 
     component.getServers().add(Protocol.HTTP, 8182); 
     // Then attach it to the local host 
     component.getDefaultHost().attach("/trace", GenericResource.class); 
     // Now, let's start the component! 
     // Note that the HTTP server connector is also automatically started. 
     component.start(); 
    } 
}