【问题标题】:Netbeans 8.1 how to expose a ejb in restful serviceNetbeans 8.1如何在restful服务中公开ejb
【发布时间】:2016-11-12 08:29:09
【问题描述】:

我使用 Netbeans 8.1。我想在 Restful 服务中转换 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?。有什么办法吗?

【问题讨论】:

    标签: service ejb netbeans-8 restful-architecture


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-10
      • 2012-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多