-
Notifications
You must be signed in to change notification settings - Fork 1
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
Davide Cerbo
committed
Nov 6, 2016
1 parent
5c4849a
commit abf4d33
Showing
13 changed files
with
470 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,32 @@ | ||
<?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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.nutcore</groupId> | ||
<artifactId>orientdb-microservices-archetype</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>maven-archetype</packaging> | ||
|
||
<name>orientdb-microservices-archetype</name> | ||
|
||
<build> | ||
<extensions> | ||
<extension> | ||
<groupId>org.apache.maven.archetype</groupId> | ||
<artifactId>archetype-packaging</artifactId> | ||
<version>2.4</version> | ||
</extension> | ||
</extensions> | ||
|
||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-archetype-plugin</artifactId> | ||
<version>2.4</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
|
||
<url>http://maven.apache.org</url> | ||
</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,20 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="orientdb-microservices" | ||
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<fileSets> | ||
<fileSet filtered="true" packaged="true" encoding="UTF-8"> | ||
<directory>src/main/java</directory> | ||
<includes> | ||
<include>**/*.java</include> | ||
</includes> | ||
</fileSet> | ||
<fileSet filtered="true" encoding="UTF-8"> | ||
<directory>src/main/resources</directory> | ||
<includes> | ||
<include>**/*.xml</include> | ||
<include>**/*.properties</include> | ||
</includes> | ||
</fileSet> | ||
</fileSets> | ||
</archetype-descriptor> |
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,148 @@ | ||
<?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/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>${groupId}</groupId> | ||
<artifactId>${artifactId}</artifactId> | ||
<packaging>jar</packaging> | ||
<version>${version}</version> | ||
<name>OrientDB Microservices</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
<properties> | ||
<resteasy.version>3.0.13.Final</resteasy.version> | ||
<undertow.version>1.3.5.Final</undertow.version> | ||
<orientdb.version>2.2.12</orientdb.version> | ||
<weld.version>2.4.0.Final</weld.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.nutcore</groupId> | ||
<artifactId>orientdb-javaee</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-jaxrs</artifactId> | ||
<version>${resteasy.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>async-http-servlet-3.0</artifactId> | ||
<version>${resteasy.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.undertow</groupId> | ||
<artifactId>undertow-servlet</artifactId> | ||
<version>${undertow.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-undertow</artifactId> | ||
<version>${resteasy.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-cdi</artifactId> | ||
<version>${resteasy.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-jackson-provider</artifactId> | ||
<version>${resteasy.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.undertow</groupId> | ||
<artifactId>undertow-core</artifactId> | ||
<version>${undertow.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.orientechnologies</groupId> | ||
<artifactId>orientdb-core</artifactId> | ||
<version>${orientdb.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.orientechnologies</groupId> | ||
<artifactId>orientdb-graphdb</artifactId> | ||
<version>${orientdb.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.orientechnologies</groupId> | ||
<artifactId>orientdb-server</artifactId> | ||
<version>${orientdb.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.orientechnologies</groupId> | ||
<artifactId>orientdb-tools</artifactId> | ||
<version>${orientdb.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.orientechnologies</groupId> | ||
<artifactId>orientdb-client</artifactId> | ||
<version>${orientdb.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.orientechnologies</groupId> | ||
<artifactId>orientdb-object</artifactId> | ||
<version>${orientdb.version}</version> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>javassist</artifactId> | ||
<groupId>org.javassist</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<artifactId>javassist</artifactId> | ||
<groupId>org.javassist</groupId> | ||
<version>3.18.2-GA</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.weld</groupId> | ||
<artifactId>weld-core</artifactId> | ||
<version>${weld.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.weld.servlet</groupId> | ||
<artifactId>weld-servlet-core</artifactId> | ||
<version>${weld.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swagger-jaxrs</artifactId> | ||
<version>1.5.0</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>${artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>3.0.0</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>1.2.1</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>java</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<mainClass>${groupId}.Main</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
27 changes: 27 additions & 0 deletions
27
src/main/resources/archetype-resources/src/main/java/CORSFilter.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,27 @@ | ||
#set( $symbol_pound = '#' ) | ||
#set( $symbol_dollar = '$' ) | ||
#set( $symbol_escape = '\' ) | ||
package ${package}; | ||
|
||
import javax.ws.rs.container.ContainerRequestContext; | ||
import javax.ws.rs.container.ContainerResponseContext; | ||
import javax.ws.rs.container.ContainerResponseFilter; | ||
import javax.ws.rs.ext.Provider; | ||
import java.io.IOException; | ||
|
||
@Provider | ||
public class CORSFilter implements ContainerResponseFilter | ||
{ | ||
|
||
@Override | ||
public void filter(final ContainerRequestContext requestContext, | ||
final ContainerResponseContext cres) throws IOException | ||
{ | ||
cres.getHeaders().add("Access-Control-Allow-Origin", "*"); | ||
cres.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization"); | ||
cres.getHeaders().add("Access-Control-Allow-Credentials", "true"); | ||
cres.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS, HEAD"); | ||
cres.getHeaders().add("Access-Control-Max-Age", "1209600"); | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
src/main/resources/archetype-resources/src/main/java/Main.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,62 @@ | ||
#set( $symbol_pound = '#' ) | ||
#set( $symbol_dollar = '$' ) | ||
#set( $symbol_escape = '\' ) | ||
package ${package}; | ||
|
||
import com.nutcore.orientdb.javaee.orientdb.OrientDBFilter; | ||
import com.nutcore.orientdb.javaee.orientdb.OrientDBJacksonProvider; | ||
import com.nutcore.orientdb.javaee.orientdb.OrientDBServletContextListener; | ||
import io.undertow.Undertow; | ||
import io.undertow.servlet.Servlets; | ||
import io.undertow.servlet.api.DeploymentInfo; | ||
import io.undertow.servlet.api.FilterInfo; | ||
import org.jboss.resteasy.plugins.server.undertow.UndertowJaxrsServer; | ||
import org.jboss.resteasy.spi.ResteasyDeployment; | ||
|
||
import javax.servlet.DispatcherType; | ||
import java.util.Arrays; | ||
|
||
public class Main | ||
{ | ||
private static final String ORIENTDB_FILTER = "orientdb"; | ||
|
||
public static void main(String[] args) throws Exception | ||
{ | ||
startWebServer(args); | ||
} | ||
|
||
private static void startWebServer(String[] args) | ||
{ | ||
String host = "0.0.0.0"; | ||
int port = 8080; | ||
if (args.length > 0) | ||
{ | ||
host = args[0]; | ||
} | ||
if (args.length > 1) | ||
{ | ||
port = Integer.parseInt(args[1]); | ||
} | ||
|
||
ResteasyDeployment deployment = new ResteasyDeployment(); | ||
deployment.setProviderClasses(Arrays.asList(OrientDBJacksonProvider.class.getName())); | ||
deployment.setInjectorFactoryClass("org.jboss.resteasy.cdi.CdiInjectorFactory"); | ||
deployment.setApplicationClass(MyApplication.class.getName()); | ||
|
||
Undertow.Builder builder = Undertow.builder().addHttpListener(port, host); | ||
|
||
UndertowJaxrsServer server = new UndertowJaxrsServer().start(builder); | ||
DeploymentInfo deploymentInfo = server | ||
.undertowDeployment(deployment) | ||
.setClassLoader(Main.class.getClassLoader()) | ||
.addListener(Servlets.listener(OrientDBServletContextListener.class)) | ||
.addListeners(Servlets.listener(org.jboss.weld.environment.servlet.Listener.class)) | ||
.setContextPath("/api") | ||
.setDeploymentName("${artifactId}") | ||
.addFilter(new FilterInfo(ORIENTDB_FILTER, OrientDBFilter.class)) | ||
.addFilterUrlMapping(ORIENTDB_FILTER, "/*", DispatcherType.REQUEST); | ||
server.deploy(deploymentInfo); | ||
|
||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/resources/archetype-resources/src/main/java/MyApplication.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,37 @@ | ||
#set( $symbol_pound = '#' ) | ||
#set( $symbol_dollar = '$' ) | ||
#set( $symbol_escape = '\' ) | ||
package ${package}; | ||
|
||
import ${package}.resource.HelloResource; | ||
import io.swagger.jaxrs.config.BeanConfig; | ||
|
||
import javax.ws.rs.core.Application; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class MyApplication extends Application | ||
{ | ||
|
||
public MyApplication() | ||
{ | ||
BeanConfig beanConfig = new BeanConfig(); | ||
beanConfig.setVersion("1.0.0"); | ||
beanConfig.setSchemes(new String[]{"http"}); | ||
beanConfig.setHost("localhost:8080"); | ||
beanConfig.setBasePath("/api"); | ||
beanConfig.setResourcePackage("${package}.resource"); | ||
beanConfig.setScan(true); | ||
} | ||
|
||
@Override | ||
public Set<Class<?>> getClasses() | ||
{ | ||
HashSet<Class<?>> classes = new HashSet<Class<?>>(); | ||
classes.add(HelloResource.class); | ||
classes.add(CORSFilter.class); | ||
classes.add(io.swagger.jaxrs.listing.ApiListingResource.class); | ||
classes.add(io.swagger.jaxrs.listing.SwaggerSerializers.class); | ||
return classes; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/resources/archetype-resources/src/main/java/domain/User.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,34 @@ | ||
#set( $symbol_pound = '#' ) | ||
#set( $symbol_dollar = '$' ) | ||
#set( $symbol_escape = '\' ) | ||
package ${package}.domain; | ||
|
||
import javax.persistence.Id; | ||
|
||
public class User | ||
{ | ||
@Id | ||
private String id; | ||
private String name; | ||
|
||
public String getId() | ||
{ | ||
return id; | ||
} | ||
|
||
public void setId(String id) | ||
{ | ||
this.id = id; | ||
} | ||
|
||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
public void setName(String name) | ||
{ | ||
this.name = name; | ||
} | ||
|
||
} |
Oops, something went wrong.