X Tutup
Skip to content

Commit 578bbd2

Browse files
committed
SparkJava demo.
Signed-off-by: daniel-dos <daniel.dias.analistati@gmail.com>
1 parent e9521f3 commit 578bbd2

File tree

10 files changed

+309
-1
lines changed

10 files changed

+309
-1
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
charset = utf-8
9+
10+
# 4 space indentation
11+
[*.{java,html,js,xml}]
12+
indent_style = tab
13+
tab_width = 4

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Binaries
2+
*.7z
3+
*.dmg
4+
*.gz
5+
*.iso
6+
*.jar
7+
*.rar
8+
*.tar
9+
*.zip
10+
*.war
11+
*.ear
12+
*.sar
13+
*.class
14+
15+
# Maven
16+
target/
17+
18+
# IntelliJ project files
19+
*.iml
20+
*.iws
21+
*.ipr
22+
.idea/
23+
24+
# eclipse project file
25+
.settings/
26+
.classpath
27+
.project
28+
29+
# NetBeans specific
30+
nbproject/private/
31+
build/
32+
nbbuild/
33+
dist/
34+
nbdist/
35+
nbactions.xml
36+
nb-configuration.xml

spark-samples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Aqui estão contribuições de projetos que usam Spark
33

44
## Projetos
5-
5+
[SparkJava-hello-world](https://github.com/SouJava-Rio/soujava-rio-labs/tree/master/spark-samples/hello-world/) | Projeto utilizando SparkJava
66

77
## Links informativos
88

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
# Unix-style newlines with a newline ending every file
5+
[*]
6+
end_of_line = lf
7+
insert_final_newline = true
8+
charset = utf-8
9+
10+
# 4 space indentation
11+
[*.{java,html,js,xml}]
12+
indent_style = tab
13+
tab_width = 4
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Binaries
2+
*.7z
3+
*.dmg
4+
*.gz
5+
*.iso
6+
*.jar
7+
*.rar
8+
*.tar
9+
*.zip
10+
*.war
11+
*.ear
12+
*.sar
13+
*.class
14+
15+
# Maven
16+
target/
17+
18+
# IntelliJ project files
19+
*.iml
20+
*.iws
21+
*.ipr
22+
.idea/
23+
24+
# eclipse project file
25+
.settings/
26+
.classpath
27+
.project
28+
29+
# NetBeans specific
30+
nbproject/private/
31+
build/
32+
nbbuild/
33+
dist/
34+
nbdist/
35+
nbactions.xml
36+
nb-configuration.xml
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM jboss/base-jdk:8
2+
3+
ADD /target/SparkJava-sample.jar /opt/SparkJava-sample.jar
4+
ADD /target/dependency-jars/ /opt/dependency-jars/
5+
6+
ENTRYPOINT ["java", "-jar", "/opt/SparkJava-sample.jar", "-Djava.net.preferIPv4Stack=true"]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SparkJava
2+
Projeto utilizado para exemplificar a utilização do SparkJava
3+
4+
## Tech Stack
5+
* Java 8
6+
* Maven 3(Versão mínima)
7+
* SparkJava 2.7.1
8+
* Docker
9+
10+
## Executando o projeto
11+
12+
mvn clean package
13+
14+
java -jar SparkJava-sample.jar dentro da pasta target/
15+
16+
depoois -> http://localhost:8080/hello
17+
18+
# Docker
19+
20+
No local do Dockerfile executar :
21+
22+
## BUILD
23+
24+
sudo docker build -t sparkJava-demo .
25+
26+
logo depois :http://localhost:8080/hello
27+
28+
## executar
29+
30+
sudo docker run --name demo sparkJava-demo
31+
32+
## Para e remover o Container
33+
34+
sudo docker stop demo
35+
36+
sudo docker rm demo

spark-samples/hello-world/pom.xml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>br.org.soujava.rio</groupId>
5+
<artifactId>SparkJava-Sample</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<name>SparkJava-Sample</name>
8+
<description>Hello World com SparkJava</description>
9+
10+
<organization>
11+
<name>SouJava { Rio }</name>
12+
<url>http://soujava-rio.github.io</url>
13+
</organization>
14+
15+
<properties>
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<maven.compiler.target>1.8</maven.compiler.target>
18+
</properties>
19+
20+
<developers>
21+
<developer>
22+
<name>Daniel Dias</name>
23+
<email>daniel.dias@soujava.org.br</email>
24+
<organization>SouJava { Rio }</organization>
25+
</developer>
26+
</developers>
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>org.projectlombok</groupId>
31+
<artifactId>lombok</artifactId>
32+
<version>1.16.14</version>
33+
<scope>provided</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>com.sparkjava</groupId>
37+
<artifactId>spark-core</artifactId>
38+
<version>2.7.1</version>
39+
</dependency>
40+
</dependencies>
41+
42+
<build>
43+
<finalName>SparkJava-sample</finalName>
44+
<plugins>
45+
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-jar-plugin</artifactId>
49+
<configuration>
50+
<archive>
51+
<manifest>
52+
<addClasspath>true</addClasspath>
53+
<mainClass>br.org.soujava.rio.app.Main</mainClass>
54+
<classpathPrefix>dependency-jars/</classpathPrefix>
55+
</manifest>
56+
</archive>
57+
</configuration>
58+
</plugin>
59+
60+
<!-- Copy project dependency -->
61+
<plugin>
62+
<groupId>org.apache.maven.plugins</groupId>
63+
<artifactId>maven-dependency-plugin</artifactId>
64+
<version>2.5.1</version>
65+
<executions>
66+
<execution>
67+
<id>copy-dependencies</id>
68+
<phase>package</phase>
69+
<goals>
70+
<goal>copy-dependencies</goal>
71+
</goals>
72+
<configuration>
73+
<!-- exclude junit, we need runtime dependency only -->
74+
<includeScope>runtime</includeScope>
75+
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
76+
</configuration>
77+
</execution>
78+
</executions>
79+
</plugin>
80+
</plugins>
81+
</build>
82+
</project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* The MIT License
3+
* Copyright © 2017 Daniel Dias
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package br.org.soujava.rio.app;
24+
25+
import java.util.List;
26+
27+
import lombok.AllArgsConstructor;
28+
import lombok.Data;
29+
30+
/**
31+
* @author Daniel Dias
32+
* github:Daniel-Dos
33+
* daniel.dias@soujava.org.br
34+
* twitter:@danieldiasjava
35+
*/
36+
@Data
37+
@AllArgsConstructor
38+
public class JUG {
39+
40+
private String jug;
41+
private List<String> lideres;
42+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* The MIT License
3+
* Copyright © 2017 Daniel Dias
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package br.org.soujava.rio.app;
24+
25+
import static spark.Spark.*;
26+
27+
import java.util.Arrays;
28+
29+
/**
30+
* @author Daniel Dias
31+
* github:Daniel-Dos
32+
* daniel.dias@soujava.org.br
33+
* twitter:@danieldiasjava
34+
*/
35+
public class Main {
36+
public static void main(String[] args) {
37+
38+
port(8080);
39+
get("/hello",(req, res) -> {
40+
JUG jug = new JUG("SouJava-Rio",Arrays.asList("Daniel","Paulo","Ulisses"));
41+
return jug ;
42+
});
43+
}
44+
}

0 commit comments

Comments
 (0)
X Tutup