如何更好地组织我的REST端点。使用apache cxf REST框架

时间:2016-05-02 12:15:57

标签: java spring rest jax-rs cxf

我试图找出如何组织我的REST API。我有很多终点 以下列方式:

public interface MyService {    
@GET
@Path("/A")
@Produces("application/json")
Response status();

@GET
@Path("/A/x")
@Produces("application/json")
Response getX();

@GET
@Path("/B")
@Produces("application/json")
Response getB() throws Exception;

@GET
@Path("/B/y")
@Produces("application/json")
Response getY() throws Exception;   
...
...
}

我使用Spring来配置

<jaxrs:server id="platform" address="/platform">
        <jaxrs:serviceBeans>
           <ref bean="myService" />
        </jaxrs:serviceBeans>
        <jaxrs:providers>
            <bean class="com.x.Y"/>
        </jaxrs:providers>
</jaxrs:server>

现在因为我有大量的端点,我想以下列方式组织我的端点:

    @Path("/A")
    public interface NotificationEventService extends MyService{    

    @GET
    @Produces("application/json")
    Response status();

    @GET
    @Path("/x")
    @Produces("application/json")
    Response getX();

  }


@Path("/B")
public interface NotificationEventService extends MyService{    

    @GET
    @Produces("application/json")
    Response getB() throws Exception;

    @GET
    @Path("/y")
    @Produces("application/json")
    Response getY() throws Exception;
  }

问题是我如何实例化我的bean并进行请求映射?

代码有点遗留,我对apache CXf

并不是那么彻底

0 个答案:

没有答案