23035f6f by Senio Caires

criacao do projeto noticias-recentes

1 parent 84e7301f
1 /.classpath
2 /.project
3 /.settings/
4 /target/
5
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2 <modelVersion>4.0.0</modelVersion>
3 <groupId>br.com.seniocaires.noticias</groupId>
4 <artifactId>noticias-recentes</artifactId>
5 <version>1.0.0</version>
6 <packaging>war</packaging>
7 <dependencies>
8 <dependency>
9 <groupId>javax.ws.rs</groupId>
10 <artifactId>jsr311-api</artifactId>
11 <version>1.1.1</version>
12 </dependency>
13 <dependency>
14 <groupId>com.google.code.gson</groupId>
15 <artifactId>gson</artifactId>
16 <version>2.7</version>
17 </dependency>
18 </dependencies>
19 <build>
20 <finalName>noticias</finalName>
21 <plugins>
22 <plugin>
23 <groupId>org.apache.maven.plugins</groupId>
24 <artifactId>maven-compiler-plugin</artifactId>
25 <version>3.1</version>
26 <configuration>
27 <source>1.8</source>
28 <target>1.8</target>
29 </configuration>
30 </plugin>
31 </plugins>
32 </build>
33 </project>
...\ No newline at end of file ...\ No newline at end of file
1 package br.com.seniocaires.noticias;
2
3 import java.net.InetAddress;
4 import java.net.UnknownHostException;
5 import java.util.logging.Level;
6 import java.util.logging.Logger;
7
8 import javax.ws.rs.GET;
9 import javax.ws.rs.Path;
10 import javax.ws.rs.Produces;
11 import javax.ws.rs.core.MediaType;
12
13 @Path("/news")
14 @Produces({ MediaType.APPLICATION_JSON + ";charset=utf-8" })
15 public class Recentes {
16
17 @GET
18 @Path("/all")
19 public String noticiasRecentes() {
20 try {
21 return "{\"noticias\":[{\"titulo\":\"Governo desiste de nomear deputado tucano depois de presso\"},{\"titulo\": \"Secretrio do Audiovisual Alfredo Bertini pede demisso do MinC\"}], \"server\": {\"nome\":\"" + InetAddress.getLocalHost().getHostName() + "\"}}";
22 } catch (UnknownHostException e) {
23 Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, e.getMessage(), e);
24 return "";
25 }
26 }
27 }
1 <?xml version="1.0" encoding="UTF-8"?>
2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
3 <display-name>noticias</display-name>
4 <servlet-mapping>
5 <servlet-name>javax.ws.rs.core.Application</servlet-name>
6 <url-pattern>/*</url-pattern>
7 </servlet-mapping>
8 </web-app>
...\ No newline at end of file ...\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!