我正在开发一个所有配置都保存在 XML 文件中的项目。我即将开始这个项目的一小部分,为此我将使用 Restlet。基本上,我想做的是创建一些ServerResource
.
我可以使用注释来指定哪些类方法接受哪些 HTTP 方法,但是由于我使用 XML 来处理其他所有内容,所以我有点不情愿。有没有办法将 HTTP 方法映射到 Restlet 资源的类方法?
Spring 和 Restlet 之间的实际集成仅是 XML (webcontext.xml):
<bean id="apiComponent" class="org.restlet.ext.spring.SpringComponent">
<property name="defaultTarget" ref="apiAppliction" />
</bean>
<bean id="apiAppliction" class="com.company.api.ApiApplication">
<property name="inboundRoot" ref="router" />
</bean>
<!-- Define the router -->
<bean name="router" class="org.restlet.ext.spring.SpringBeanRouter" />
<!-- Define all the routes -->
<bean name="/track/{trackId}" class="com.company.api.resource.TrackResource" scope="prototype" autowire="byName">
<constructor-arg index="0" ref="serviceFactory"/>
</bean>
<bean name="/album" class="com.company.api.resource.AlbumResource" scope="prototype" autowire="byName"/>
<bean name="/album/{albumId}/tracks" class="com.company.api.resource.AlbumTracksResource" scope="prototype" autowire="byName" />
有没有办法可以添加到上述配置并将 HTTP 方法映射到类方法?