Jboss Spring与RESTEasy的集成

Jboss Spring与RESTEasy的集成,jboss,spring-integration,resteasy,Jboss,Spring Integration,Resteasy,在我们现有的集成中,我们计划用RESTEasy服务取代Queue作为集成处理的入口点 我们正在处理HTTP请求,如下所示: 1 GET的异步HTTP请求处理 2邮政异步作业服务 我知道spring集成为HTTP请求提供和。但这不是我们想要的,因为请求处理是由RESTEasy处理的 软件堆栈: RESTEasy 3.0.9框架 Spring集成4.1.2.1版本 JBossEAP6.4 是否有一个组件可用于将RESTEasy服务与spring集成集成?没有明确的组件存在,所有API工作都有待完成。

在我们现有的集成中,我们计划用RESTEasy服务取代Queue作为集成处理的入口点

我们正在处理HTTP请求,如下所示:

1 GET的异步HTTP请求处理 2邮政异步作业服务

我知道spring集成为HTTP请求提供和。但这不是我们想要的,因为请求处理是由RESTEasy处理的

软件堆栈: RESTEasy 3.0.9框架 Spring集成4.1.2.1版本 JBossEAP6.4


是否有一个组件可用于将RESTEasy服务与spring集成集成?

没有明确的组件存在,所有API工作都有待完成。您需要使用依赖jar文件和集成代码

下面是在使用ant或maven的工作区环境中要使用的最小Jar文件路径:

org.jboss.resteasy:resteasy-jaxrs:3.0.10.Final
org.jboss.resteasy:resteasy-spring:3.0.10.Final
org.springframework.boot:spring-boot-starter-web:1.2.2.RELEASE
org.jboss.resteasy:resteasy-jackson2-provider:3.0.10.Final
要在web.xml中执行以下侦听器条目:

   <context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/project</param-value>
   </context-param>
   <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
   </context-param>
   <listener>
    <listener- class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
    </listener>
   <listener>
    <listener-class>org.jboss.resteasy.plugins.spring.SpringContextLoaderListener</listener-class>
    </listener>
    <servlet>
    <servlet-name>RESTEasyService</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
     <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>com.concretepage.Application</param-value>
     </init-param>
    </servlet>
    <servlet-mapping>
     <servlet-name>RESTEasyService</servlet-name>
     <url-pattern>/project/*</url-pattern>
    </servlet-mapping>
调度Servlet可以放入WEB-INF

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">
       <context:component-scan base-package="com.concretepage" />
</beans>
Java服务代码示例:

import java.util.Map;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Path("/manage" )
@Component
public class ExService {
    @Autowired
    private ExRepository repository;

    @GET
    @Path("/{id}")
    @Produces("application/json")
    public Response getEmp(@PathParam("id") String id) {
        Map<String,String> map = repository.getEmpDetail(id);
        return Response.ok(map).build();
    }
}

有关更多详细信息,请参阅

我知道RestEasy如何与Spring MVC集成。我面临的问题是找到一种公开现有RestEasy服务API的方法。我希望使用Spring集成重用而不是重写现有的API。理想情况下,使用RESTEasy的HTTP请求并将其转发到Spring集成层。e、 在spring集成层中为这些HTTP请求提供一个入站适配器。。看起来消息网关可以完成这项工作。。我将尝试进行POC,以确保满足我们的要求!!现有的RestEasy api可以使用,除非它们被弃用。我相信您只需要更新配置和api。看来我的问题没有被理解。我说的是将RESTEasy服务与Spring集成一起使用,仅此而已。我能够使用来进行集成。谢谢简而言之,我完全理解您的问题,有没有一个组件可以用于将RESTEasy服务与spring集成集成?答案是否定的。如果你可以要求任何特定的插件,那么这个问题可以在很久以前得到回答。如果你已经得到答案,那就好了。
Use  <int:gateway> to do the integration with spring. 

    <int:gateway id="providerGateway" service-interface="com.stack.overflow.TestInterface"
        default-request-channel="requestChannel">
        <int:method name="getDataByID" request-channel="requestChannel"/>
        <int:method name="postDataByID" request-channel="requestChannel"/>
    </int:gateway>

Where com.stack.overflow.TestInterface is the Resource Interface see below:

    @Path(RestConstants.SERVICES)
    public interface TestInterface {

    @Path(RestConstants.TEST1)
    @GET
    @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
    public Response getDataByID();



    @Path(RestConstants.TEST2)
    @POST
    @Produces({ MediaType.TEXT_PLAIN  })
    public Response postDataByID(String edi);

}

You can have different message channel if desired (see the gateway above)  for a request. e.g. a request to getDataByID, will be put on the  requestChannel. You can read from this channel and do the required processing as you require and then send a response back.