For ilustrating StackOverFlow case
Last active
August 29, 2015 14:16
-
-
Save alphamikevictor/3b15c131e035f92daa8b to your computer and use it in GitHub Desktop.
REST + EJB example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.alosfogones.REST; | |
| import javax.ws.rs.ApplicationPath; | |
| import javax.ws.rs.core.Application; | |
| @ApplicationPath("/rest") | |
| public class JaxRSActivator extends Application { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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