Skip to content

Commit

Permalink
added the ability to configure the API Gateway public endpoint via ap…
Browse files Browse the repository at this point in the history
…iman.properties
  • Loading branch information
EricWittmann committed Dec 22, 2014
1 parent 0d2284b commit 3c5ddf1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 15 deletions.
36 changes: 26 additions & 10 deletions gateway/platforms/vertx/pom.xml
Expand Up @@ -14,23 +14,19 @@
<name>apiman-gateway-platforms-vertx</name>

<properties>
<!-- Set pullInDeps to true if you want any modules specified in
the 'includes' and 'deploys' fields in your mod.json to be automatically
pulled in during packaging and added inside your module. Doing this means
your module won't download and install those dependencies at run-time when
they're first requested. -->
<!-- Set pullInDeps to true if you want any modules specified in the 'includes' and 'deploys' fields in your
mod.json to be automatically pulled in during packaging and added inside your module. Doing this means your module
won't download and install those dependencies at run-time when they're first requested. -->
<vertx.pullInDeps>false</vertx.pullInDeps>

<!-- Set createFatJar to true if you want to create a fat executable
jar which contains the Vert.x binaries along with the module so it can be
run with java -jar <jarname> -->
<!-- Set createFatJar to true if you want to create a fat executable jar which contains the Vert.x binaries
along with the module so it can be run with java -jar <jarname> -->
<vertx.createFatJar>false</vertx.createFatJar>

<!--Vertx module name -->
<module.name>${project.groupId}~${project.artifactId}~${project.version}</module.name>

<!-- The directory where the module will be assembled - you can override
this on the command line with -Dmods.directory=mydir -->
<!-- The directory where the module will be assembled - you can override this on the command line with -Dmods.directory=mydir -->
<mods.directory>target/mods</mods.directory>
</properties>

Expand Down Expand Up @@ -236,4 +232,24 @@
</plugin>
</plugins>
</reporting>
<profiles>
<profile>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Expand Up @@ -75,6 +75,16 @@ public Configuration getConfig() {
return config;
}

/**
* Returns the given configuration property name or the provided default
* value if not found.
* @param propertyName
* @param defaultValue
*/
public String getConfigProperty(String propertyName, String defaultValue) {
return getConfig().getString(propertyName, defaultValue);
}

/**
* @return the class to use as the {@link IRegistry}
*/
Expand Down
Expand Up @@ -16,7 +16,6 @@
package io.apiman.gateway.platforms.war;

import io.apiman.gateway.engine.IEngine;
import io.apiman.gateway.engine.IEngineConfig;
import io.apiman.gateway.engine.impl.ConfigDrivenEngineFactory;

/**
Expand All @@ -27,13 +26,14 @@
*/
public class WarGateway {

public static WarEngineConfig config;
public static IEngine engine;

/**
* Initialize the gateway.
*/
public static void init() {
IEngineConfig config = new WarEngineConfig();
config = new WarEngineConfig();
ConfigDrivenEngineFactory factory = new ConfigDrivenEngineFactory(config);
engine = factory.createEngine();
}
Expand Down
Expand Up @@ -17,6 +17,7 @@

import io.apiman.gateway.api.rest.impl.IPlatform;
import io.apiman.gateway.engine.beans.ServiceEndpoint;
import io.apiman.gateway.platforms.war.WarGateway;
import io.apiman.gateway.platforms.war.filters.HttpRequestThreadLocalFilter;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -41,7 +42,7 @@ public Wildfly8Platform() {
*/
@Override
public ServiceEndpoint getServiceEndpoint(String organizationId, String serviceId, String version) {
String endpoint = System.getProperty(APIMAN_GATEWAY_ENDPOINT, null);
String endpoint = WarGateway.config.getConfigProperty(APIMAN_GATEWAY_ENDPOINT, null);
StringBuilder builder = new StringBuilder();
if (endpoint == null) {
HttpServletRequest currentRequest = HttpRequestThreadLocalFilter.getCurrentRequest();
Expand Down
Expand Up @@ -25,7 +25,7 @@
*
* @author eric.wittmann@redhat.com
*/
public class EngineAccessor implements IEngineAccessor {
public class TestEngineAccessor implements IEngineAccessor {

/**
* @see io.apiman.gateway.api.rest.impl.IEngineAccessor#getEngine()
Expand Down
@@ -1 +1 @@
io.apiman.gateway.test.server.EngineAccessor
io.apiman.gateway.test.server.TestEngineAccessor

0 comments on commit 3c5ddf1

Please sign in to comment.