从公开的 RESTeasy 接口访问 @Local Session Bean
我想做的事情应该是非常直接的,但到目前为止是不可能的。有人可以告诉我如何从公开的 RESTeasy 接口访问 @Local Session Bean 吗?我已经搜索了互联网的长度和广度,我所能找到的只是同一示例的变体,
我试图找出如何使用 RESTeasy 以正常方式访问会话 bean。到目前为止,情况是这样的:
使用:
EJB 3
RESTeasy 2.1
已发布的 EJB 接口:
@Local
@Path("RequestReport")
public interface EReport {
@GET
@Produces({"application/xml"})
@Path("request")
public String requestReport(@QueryParam("reportId") @DefaultValue("") String reportId,
@QueryParam("reportName") @DefaultValue("") String reportName,
@QueryParam("reportType") @DefaultValue("") String reportType);
}
}
BEAN 1:
@Stateless
public class EReportRequest implements EReport {
@EJB
private ReplyStringLocal replyString; // THIS IS WHERE THE PROBLEM LIES.
public String requestReport(@QueryParam("reportId") @DefaultValue("") String reportId,
@QueryParam("reportName") @DefaultValue("") String reportName,
@QueryParam("reportType") @DefaultValue("") String reportType) {
return replyString.getReply(reportId, reportName, reportType);
}
}
未发布的 EJB 接口:
@Local
public interface ReplyStringLocal {
public String getReply(String reportId, String reportName, String reportType);
}
BEAN 2:
@Stateless
public class ReplyString implements ReplyStringLocal {
public String getReply(String reportId, String reportName, String reportType) {
return "<response><reportId>" + reportId + "</reportId><reportName>" + reportName +
"</reportName><reportType>" + reportType + "</reportType></response>";
}
}
为了演示我的问题,该示例经过了超级简化。预先感谢您的任何帮助。
What I am trying to do should be very straight forward BUT thus far has been impossible. Can someone tell me how to access a @Local Session Bean from an exposed RESTeasy interface? I have trawled the length and breadth of the internet and all I can find is variations of the same example
I am trying to find out how I can access a session bean in the normal way using RESTeasy. This is what things look like so far:
USING:
EJB 3
RESTeasy 2.1
PUBLISHED EJB INTERFACE:
@Local
@Path("RequestReport")
public interface EReport {
@GET
@Produces({"application/xml"})
@Path("request")
public String requestReport(@QueryParam("reportId") @DefaultValue("") String reportId,
@QueryParam("reportName") @DefaultValue("") String reportName,
@QueryParam("reportType") @DefaultValue("") String reportType);
}
}
BEAN 1:
@Stateless
public class EReportRequest implements EReport {
@EJB
private ReplyStringLocal replyString; // THIS IS WHERE THE PROBLEM LIES.
public String requestReport(@QueryParam("reportId") @DefaultValue("") String reportId,
@QueryParam("reportName") @DefaultValue("") String reportName,
@QueryParam("reportType") @DefaultValue("") String reportType) {
return replyString.getReply(reportId, reportName, reportType);
}
}
UNPUBLISHED EJB INTERFACE:
@Local
public interface ReplyStringLocal {
public String getReply(String reportId, String reportName, String reportType);
}
BEAN 2:
@Stateless
public class ReplyString implements ReplyStringLocal {
public String getReply(String reportId, String reportName, String reportType) {
return "<response><reportId>" + reportId + "</reportId><reportName>" + reportName +
"</reportName><reportType>" + reportType + "</reportType></response>";
}
}
This example is super simplified for the purposes of demonstrating my issue. Thanks in advance for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
适用于:JBoss 5、RESTeasy 2.1 和 EJB 3。
好的,我终于了解了有关 RESTeasy 的 EJB 的完整故事。所以这里是:
接口:
实现:
。
。
接口:
实现:
在 Application.xml 中:
然后您可以使用对 jar 的 JNDI 远程调用来引用它:
我希望 RESTeasy 的更高版本将提供更好的 EJB 集成。
For: JBoss 5, RESTeasy 2.1 and EJB 3.
Ok so I finally got the full story on EJBs with RESTeasy. So here it is:
INTERFACE:
IMPLEMENTATION:
.
.
INTERFACE:
IMPLEMENTATION:
In Application.xml:
You can then make reference to it using a JNDI remote call to your jar:
I am hoping that later versions of RESTeasy will provide better integration of EJBs.