Skip to content

Commit

Permalink
Code cleanup. Added support for injecting session attachment handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
noboomu committed Nov 29, 2018
1 parent 341bb46 commit ee3a38a
Show file tree
Hide file tree
Showing 31 changed files with 3,025 additions and 2,927 deletions.
25 changes: 13 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.sinistral</groupId>
<artifactId>proteus-core</artifactId>
<version>0.3.5</version>
<version>0.3.6-SNAPSHOT</version>
<name>proteus core</name>
<description>Proteus is an extremely light, fast, and flexible Java REST API framework built atop Undertow.</description>
<url>http://github.com/noboomu/proteus</url>
Expand Down Expand Up @@ -231,7 +231,17 @@
</exclusions>
</dependency>


<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>1.7.25</version>
</dependency>

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
Expand Down Expand Up @@ -294,16 +304,7 @@
<version>4.4.10</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<version>1.7.25</version>
</dependency>


<dependency>
<groupId>org.fusesource.jansi</groupId>
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/sinistral/proteus/ProteusApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.RoutingHandler;
import io.undertow.server.session.SessionAttachmentHandler;
import io.undertow.util.Headers;
import io.undertow.util.Methods;

Expand Down Expand Up @@ -86,6 +87,9 @@ public class ProteusApplication

@Inject
public Config config;

@Inject(optional=true)
public SessionAttachmentHandler sessionAttachmentHandler;

public List<Class<? extends Module>> registeredModules = new ArrayList<>();

Expand Down Expand Up @@ -276,6 +280,14 @@ public void buildServer()
handler = rootHandler;
}

if(sessionAttachmentHandler != null)
{
log.info("Using session attachment handler.");

sessionAttachmentHandler.setNext(handler);
handler = sessionAttachmentHandler;
}

int httpPort = config.getInt("application.ports.http");

if(System.getProperty("http.port") != null)
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/io/sinistral/proteus/annotations/Blocking.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@

/**
*
*
*/
package io.sinistral.proteus.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* Indicates that this route should use a BlockingHandler
*/
@Retention(RUNTIME)
@Target({ TYPE, METHOD })
public @interface Blocking
{
boolean value() default true;
boolean value() default true;
}




14 changes: 8 additions & 6 deletions src/main/java/io/sinistral/proteus/annotations/Chain.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@

/**
*
*
*/
package io.sinistral.proteus.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import io.undertow.server.HandlerWrapper;

/**
Expand All @@ -19,7 +20,8 @@
@Target({ TYPE, METHOD })
public @interface Chain
{
Class<? extends HandlerWrapper>[] value();
Class<? extends HandlerWrapper>[] value();
}




14 changes: 8 additions & 6 deletions src/main/java/io/sinistral/proteus/annotations/Debug.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@

/**
*
*
*/
package io.sinistral.proteus.annotations;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* Indicates that this route should use a RequestDumpingHandler
*/
@Retention(RUNTIME)
@Target({ TYPE, METHOD })
public @interface Debug
{
boolean value() default true;
boolean value() default true;
}




Loading

0 comments on commit ee3a38a

Please sign in to comment.