我使用Netbeans 8.1。我想在一个宁静的服务中转换EJB。
我的EJB是
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package paqueteservicio;
import javax.ejb.Stateless;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
/**
*
* @author Carlota
*/
@Stateless
@Path("/collatz")
public class CollatzResource {
@GET
public String collatz(@QueryParam("base")long base){
int num = (int)base;
String secuencia = "Inicio"+num+"\n";
while (num != 1){
if (num %2 == 0){
num = num / 2;
}
else {
num = num * 3 + 1;
}
secuencia += num + "\n";
}
return secuencia;
}
}
如何在Restful Service中转换此EJB?有什么选择吗?
答案 0 :(得分:0)
您唯一需要做的就是在您的应用程序中启用休息:
@ApplicationPath("/rest")
public class JaxRsActivator extends Application {
/* class body intentionally left blank */
}