Netbeans 8.1如何在restful服务中公开ejb

时间:2016-11-12 08:29:09

标签: service ejb netbeans-8 restful-architecture

我使用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?有什么选择吗?

1 个答案:

答案 0 :(得分:0)

您唯一需要做的就是在您的应用程序中启用休息:

@ApplicationPath("/rest")
public class JaxRsActivator extends Application {
    /* class body intentionally left blank */
}