Skip to content

Instantly share code, notes, and snippets.

@alphamikevictor
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save alphamikevictor/3b15c131e035f92daa8b to your computer and use it in GitHub Desktop.

Select an option

Save alphamikevictor/3b15c131e035f92daa8b to your computer and use it in GitHub Desktop.
REST + EJB example
package com.alosfogones.REST;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/rest")
public class JaxRSActivator extends Application {
}
package com.alosfogones.REST;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import com.alosfogones.EJB.ServiceImpl;
@RequestScoped
@Path("/current")
public class ServiceFacade {
@EJB
ServiceImpl service;
@GET
public String getDate(){
return service.getCurrentDate().toString();
}
}
package com.alosfogones.EJB;
import java.util.Date;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
/**
* Session Bean implementation class ServiceImpl
*/
@Stateless
@LocalBean
public class ServiceImpl {
/**
* Default constructor.
*/
public ServiceImpl() {
}
public Date getCurrentDate(){
return new Date();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment