Friday, March 30, 2012

Eheheh just jocking with interfaces

Any other idea about how to expose a component?

ui... rest... ws... ejb...

package net.sixdeex.jpc.services;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebParam.Mode;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import net.sixdeex.jpc.CalculateDescendCommand;
import net.sixdeex.jpc.framework.CalculateCommand;
import net.sixdeex.jpc.framework.OutputData;

@Path("/x737")
@Produces(MediaType.APPLICATION_JSON)
@Stateless
@Local(X737Calculation.class)
@Remote(RemoteX737Calculation.class)
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
@WebService
public class X737CalculationBean implements RemoteX737Calculation {

    @GET
    @Path("/descend/{from}/{to}")
    @Override
    @WebMethod(operationName = "descend")
    public @WebResult(name = "outputData")
    OutputData descend(
            @PathParam("from") @WebParam(name = "fromLevel", mode = Mode.IN) int fromLevel,
            @PathParam("to") @WebParam(name = "toLevel", mode = Mode.IN) int toLevel) {

        final CalculateCommand calculateDescend = new CalculateDescendCommand(
                null, fromLevel, toLevel);

        return calculateDescend.execute();
    }
}

No comments: