2014-12-04 3 views
4

스프링 xml 파일을 더럽혀서 부트 스트랩 된 고유 한 컨텍스트를 가진 기존 Spring 응용 프로그램이 있습니다. Grizzly 웹 서버가 Soap 서비스를 게시하기 시작했습니다.jersey-spring3 및 기존 Spring 응용 프로그램 컨텍스트로 웹 서비스를 쉬십시오.

이제 같은 Grizzly의 Rest 요청을 제공하고 싶습니다. jersey-spring3을 사용하고 있지만 필요한 applicationContext.xml에서 별도의 응용 프로그램 컨텍스트를 시작합니다. (2 Spring 컨텍스트에 의해 생성)

//rest services 
    ResourceConfig resourceConfig = new ResourceConfig(
      RestService1.class, //these are 
      RestService2.class //jersey-spring services 
    ); 
    HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create("http://localhost:8080/rest"), resourceConfig, false); 

    //soap services 
    HttpHandler httpHandler = new JaxwsHandler(mySoapWebService, false); 
    httpServer.getServerConfiguration().addHttpHandler(httpHandler, myPath); 

    httpServer.start(); 

내 나머지 서비스

첫 번째 응용 프로그램 컨텍스트에서 분사 종속성이 :

은 휴식과 비누 웹 서비스 이 등록 된 그리즐리하는 HttpServer를 생성하는 코드입니다 . 이 주사는 분명히 작동하지 않습니다. Curryingly 나는 그들에게 직접 해킹 코드를 주입시키고있다.

저지가 기존 컨텍스트를 다시 사용하는 기존 응용 프로그램에서 Rest 요청 처리를 위해 Spring 서비스를 주입하는 올바른 방법은 무엇입니까?

답변

3

GitHub의 Jersey 프로젝트에서 helloworld-spring-annotations을 살펴보십시오. 당신은 그런 당신이 당신의 저지 구성 요소로 봄 구성 요소를 @Autowired 할 수 있어야합니다 값이 봄 ApplicationContext

resourceConfig.property("contextConfig", 
     new AnnotationConfigApplicationContext(SpringAnnotationConfig.class)); 

의 인스턴스 인 상태 저지 응용 프로그램에서 set the "contextConfig" property해야합니다.

항목 :