發現這裏的示例應用程序演示瞭如何在一個簡單的Java應用程序中使用嵌入式碼頭運行HttpInvoker。你應該能夠適應這些代碼,以使它在一個合適的環境中工作。
http://code.google.com/p/jianwikis/wiki/SpringHttpRemotingWithEmbeddedJettyServer
再現來自該代碼/配置的相關章節削減到這裏
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
Context context = new Context(server, "/", Context.SESSIONS);
DispatcherServlet dispatcherServlet = new DispatcherServlet();
dispatcherServlet.setContextConfigLocation("classpath:com/mycompany/config/DefaultServlet-servlet.xml");
ServletHolder servletHolder = new ServletHolder(dispatcherServlet);
context.addServlet(servletHolder, "/*")
DefaultServlet-servlet.xml中
<!-- This default handler takes care of each of the services enumerated below -->
<bean id="defaultHandlerMapping"
class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<bean id="helloService" class="com.mycompany.service.impl.HelloServiceImpl"/>
<!-- SpringHTTP Service Exposure -->
<bean name="/HelloService"
class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"
lazy-init="true">
<property name="service" ref="helloService" />
<property name="serviceInterface"
value="com.mycompany.service.iface.HelloService" />
</bean>