Skip to content

Commit

Permalink
Added serverConfigurationFunction.
Browse files Browse the repository at this point in the history
Allows access to the underlying Undertow.Builder if needed.
  • Loading branch information
noboomu committed May 15, 2017
1 parent 8450d2c commit 4052b6a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/io/sinistral/proteus/ProteusApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -81,6 +82,7 @@ public class ProteusApplication
protected HttpHandler rootHandler;
protected AtomicBoolean running = new AtomicBoolean(false);
protected List<Integer> ports = new ArrayList<>();
protected Function<Undertow.Builder,Undertow.Builder> serverConfigurationFunction = null;


public ProteusApplication()
Expand Down Expand Up @@ -245,6 +247,7 @@ public void buildServer()
.setWorkerThreads( config.getInt("undertow.workerThreads") )
.setHandler( handler );


ports.add(config.getInt("application.ports.http"));

if( config.getBoolean("undertow.ssl.enabled") )
Expand All @@ -270,6 +273,11 @@ public void buildServer()
}
}

if( serverConfigurationFunction != null )
{
undertowBuilder = serverConfigurationFunction.apply(undertowBuilder);
}

this.undertow = undertowBuilder.build();

}
Expand Down Expand Up @@ -309,6 +317,15 @@ public Undertow getUndertow()
}


/**
* Allows direct access to the Undertow.Builder for custom configuration
* @param serverConfigurationFunction the serverConfigurationFunction
*/
public void setServerConfigurationFunction(Function<Undertow.Builder, Undertow.Builder> serverConfigurationFunction)
{
this.serverConfigurationFunction = serverConfigurationFunction;
}

/**
* @return the serviceManager
*/
Expand Down

0 comments on commit 4052b6a

Please sign in to comment.