forked from vert-x3/vertx-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4773271
Showing
27 changed files
with
1,229 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.DS_Store | ||
.gradle | ||
.idea | ||
.classpath | ||
.project | ||
.settings | ||
.yardoc | ||
.yardopts | ||
bin | ||
build | ||
target | ||
out | ||
*.iml | ||
*.ipr | ||
*.iws | ||
test-output | ||
Scratch.java | ||
ScratchTest.java | ||
test-results | ||
test-tmp | ||
*.class | ||
src/gen | ||
src/main/groovy/io/vertx/groovy/core/**/*.groovy | ||
src/test/groovy/io/vertx/groovy/codegen/**/*.groovy |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
= Vert.x examples | ||
|
||
This repository contains a range of examples so you can get up and running easily with Vert.x. | ||
|
||
== Maven users | ||
|
||
Start with the link:maven-simplest[simplest Maven example] to show you how setup a simple Vert.x project that uses Maven. | ||
|
||
Progress to the link:maven-verticle[simple Maven verticle example] to show you how to deploy your code as verticles in | ||
a Maven project. | ||
|
||
== Gradle users | ||
|
||
Start with the link:gradle-simplest[simplest Gradle example] to show you how setup a simple Vert.x project that uses Gradle. | ||
|
||
Progress to the link:gradle-verticle[simple Gradle verticle example] to show you how to deploy your code as verticles in | ||
a Gradle project | ||
|
||
== Neither Maven nor Gradle users | ||
|
||
That's fine too :) | ||
|
||
You can run all the examples at the command line using `vertx run` if you have Vert.x installed. | ||
|
||
== The examples | ||
|
||
The examples demonstrate how to use all different bits of Vert.x including Vert.x core, Apex (webapps) and various other | ||
services and features. | ||
|
||
=== Vert.x core examples | ||
|
||
The link:vertx-core/README.adoc[Vert.x core examples] contains a wide range of examples using just Vert.x Core. | ||
|
||
TODO | ||
|
||
=== Apex examples | ||
|
||
Apex is a toolkit for building web applications using Vert.x | ||
|
||
The link:vertx-apex/README.adoc[Vert.x Apex examples] contains a wide range of examples using Vert.x Apex | ||
|
||
TODO | ||
|
||
=== Data access examples | ||
|
||
==== Mongo DB examples | ||
|
||
|
||
==== JDBC examples | ||
|
||
|
||
etc | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<parent> | ||
<artifactId>apex-examples</artifactId> | ||
<groupId>io.vertx</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>hello-world</artifactId> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-core</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-apex</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-lang-js</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<build> | ||
|
||
<pluginManagement> | ||
<plugins> | ||
<!-- We specify the Maven compiler plugin as we need to set it to Java 1.8 --> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
|
||
<plugins> | ||
<!-- Fat executable jars | ||
If you want your project to output a fat executable standalone jar with all the dependencies in it you | ||
can use the shade plugin. --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.3</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<manifestEntries> | ||
<Main-Class>io.vertx.apex.example.HelloWorld</Main-Class> | ||
</manifestEntries> | ||
</transformer> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> | ||
<resource>META-INF/services/io.vertx.core.spi.VerticleFactory</resource> | ||
</transformer> | ||
</transformers> | ||
<artifactSet> | ||
<!-- By default all the deps go into the fat jar, but we don't need some so we can exclude them | ||
here --> | ||
<excludes> | ||
<exclude>io.vertx:vertx-codegen</exclude> | ||
<exclude>junit:junit</exclude> | ||
<exclude>org.mvel:mvel2</exclude> | ||
<exclude>log4j:log4j</exclude> | ||
<exclude>org.slf4j:slf4j-api</exclude> | ||
</excludes> | ||
</artifactSet> | ||
<outputFile>${project.build.directory}/${artifactId}-${version}-fat.jar</outputFile> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
</plugins> | ||
|
||
</build> | ||
|
||
|
||
</project> |
46 changes: 46 additions & 0 deletions
46
apex-examples/hello-world/src/main/java/io/vertx/example/ext/apex/HelloWorld.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2014 Red Hat, Inc. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* and Apache License v2.0 which accompanies this distribution. | ||
* | ||
* The Eclipse Public License is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* The Apache License v2.0 is available at | ||
* http://www.opensource.org/licenses/apache2.0.php | ||
* | ||
* You may elect to redistribute this code under either of these licenses. | ||
*/ | ||
|
||
package io.vertx.example.ext.apex; | ||
|
||
import io.vertx.core.Vertx; | ||
import io.vertx.ext.apex.Router; | ||
|
||
import java.io.File; | ||
import java.util.Properties; | ||
|
||
/** | ||
* @author <a href="http://tfox.org">Tim Fox</a> | ||
*/ | ||
public class HelloWorld { | ||
|
||
public static void main(String[] args) { | ||
|
||
System.out.println("cwd is " + (new File(".").getAbsolutePath())); | ||
//System.out.println(System.getProperties()); | ||
Properties props = System.getProperties(); | ||
props.forEach((k, v) -> { | ||
System.out.println(k + ": " + v); | ||
}); | ||
|
||
Vertx vertx = Vertx.vertx(); | ||
|
||
Router router = Router.router(vertx); | ||
router.route().handler(rc -> rc.response().putHeader("content-type", "text/plain").end("Hello World!")); | ||
|
||
vertx.createHttpServer().requestHandler(router::accept).listen(8080); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
apex-examples/hello-world/src/main/resources/helloworld.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
console.log("cwd:" + new java.io.File(".").getAbsolutePath()); | ||
|
||
var Router = require("vertx-apex-js/router"); | ||
|
||
var router = Router.router(vertx); | ||
|
||
router.route().handler(function(routingContext) { | ||
routingContext.response().putHeader("content-type", "text/plain").end("Hello World from JS!"); | ||
}); | ||
|
||
var server = vertx.createHttpServer(); | ||
|
||
server.requestHandler(router.accept).listen(8080); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<parent> | ||
<artifactId>vertx-examples</artifactId> | ||
<groupId>io.vertx</groupId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>apex-examples</artifactId> | ||
<packaging>pom</packaging> | ||
<modules> | ||
<module>hello-world</module> | ||
</modules> | ||
|
||
|
||
</project> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
= Vert.x 3.0 Simplest Gradle project | ||
|
||
This project shows a very simple hello world Vert.x 3.0 project using Gradle, which has a simple HTTP server which | ||
simply returns "Hello World!" to every request. | ||
|
||
In this example Vert.x is used embedded. I.e. we use the Vert.x APIs directly in our own classes rather than deploying | ||
the code in verticles. | ||
|
||
You can run or debug the example in your IDE by just right clicking the main class and run as.. or debug as... | ||
|
||
The build.gradle uses the Gradle shadowJar plugin to assemble the application and all it's dependencies into a single "fat" jar. | ||
|
||
To build the "fat jar" | ||
|
||
./gradlew shadowJar | ||
|
||
To run the fat jar: | ||
|
||
java -jar build/libs/gradle-simplest-3.0.0-SNAPSHOT-fat.jar | ||
|
||
(You can take that jar and run it anywhere there is a Java 8+ JDK. It contains all the dependencies it needs so you | ||
don't need to install Vert.x on the target machine). | ||
|
||
Now point your browser at http://localhost:8080 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
buildscript { | ||
repositories { jcenter() } | ||
dependencies { | ||
classpath 'com.github.jengelman.gradle.plugins:shadow:1.1.1' | ||
} | ||
} | ||
|
||
apply plugin: 'java' | ||
apply plugin: 'com.github.johnrengelman.shadow' | ||
|
||
version = '3.0.0-SNAPSHOT' | ||
|
||
if (!JavaVersion.current().java8Compatible) { | ||
throw new IllegalStateException('''A Haiku: | ||
| This needs Java 8, | ||
| You are using something else, | ||
| Refresh. Try again.'''.stripMargin()) | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { | ||
url = 'http://oss.sonatype.org/content/repositories/snapshots/' | ||
} | ||
} | ||
|
||
dependencies { | ||
compile 'io.vertx:vertx-core:3.0.0-SNAPSHOT' | ||
} | ||
|
||
shadowJar { | ||
classifier = 'fat' | ||
manifest { | ||
attributes 'Main-Class': 'io.vertx.example.HelloWorldEmbedded' | ||
} | ||
mergeServiceFiles { | ||
include 'META-INF/services/io.vertx.core.spi.VerticleFactory' | ||
} | ||
} | ||
|
||
task wrapper(type: Wrapper) { | ||
gradleVersion = '2.0' | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Thu Sep 25 11:30:31 BST 2014 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip |
Oops, something went wrong.