Last active
November 15, 2016 17:23
-
-
Save daichan4649/48056855c5246141616006ac49ff1f86 to your computer and use it in GitHub Desktop.
AndroidStudio+GAE/J+Jersey sample
This file contains 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
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.google.appengine:gradle-appengine-plugin:1.9.18' | |
} | |
} | |
repositories { | |
jcenter(); | |
} | |
apply plugin: 'java' | |
apply plugin: 'war' | |
apply plugin: 'appengine' | |
sourceCompatibility = JavaVersion.VERSION_1_7 | |
targetCompatibility = JavaVersion.VERSION_1_7 | |
dependencies { | |
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.18' | |
compile 'javax.servlet:servlet-api:2.5' | |
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.22.2' | |
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.22.2' | |
} | |
appengine { | |
downloadSdk = true | |
appcfg { | |
oauth2 = true | |
} | |
} |
This file contains 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 daichan4649.jersey; | |
public class Event { | |
private String ymd; | |
private String name; | |
public Event(String ymd, String name) { | |
this.ymd = ymd; | |
this.name = name; | |
} | |
public String getYmd() { | |
return ymd; | |
} | |
public void setYmd(String ymd) { | |
this.ymd = ymd; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
} |
This file contains 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 daichan4649.jersey; | |
import java.util.ArrayList; | |
import java.util.List; | |
import javax.ws.rs.GET; | |
import javax.ws.rs.Path; | |
import javax.ws.rs.Produces; | |
import javax.ws.rs.core.MediaType; | |
@Path("/") | |
public class JerseySample { | |
@GET | |
@Path("events") | |
@Produces(MediaType.APPLICATION_JSON) | |
public List<Event> getEvents() { | |
List<Event> list = new ArrayList<>(); | |
list.add(new Event("20160415", "AKBAR")); | |
list.add(new Event("20160514", "CIRCLE'16")); | |
list.add(new Event("20160903", "SunsetLive2016")); | |
return list; | |
} | |
} |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"> | |
<servlet> | |
<servlet-name>JerseySample</servlet-name> | |
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> | |
<init-param> | |
<param-name>jersey.config.server.provider.classnames</param-name> | |
<param-value>daichan4649.jersey.JerseySample</param-value> | |
</init-param> | |
</servlet> | |
<servlet-mapping> | |
<servlet-name>JerseySample</servlet-name> | |
<url-pattern>/jersey/*</url-pattern> | |
</servlet-mapping> | |
</web-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment