knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From su...@apache.org
Subject [5/6] knox git commit: Combined commits done for KNOX-481, KNOX-483, KNOX-487
Date Thu, 12 Feb 2015 17:49:50 GMT
Combined commits done for KNOX-481, KNOX-483, KNOX-487


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/ea28bf22
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/ea28bf22
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/ea28bf22

Branch: refs/heads/KNOX-481
Commit: ea28bf220574e52717e1424f730536acf988bbcc
Parents: 5abdde8
Author: Sumit Gupta <sumit@apache.org>
Authored: Tue Jan 6 12:07:29 2015 -0500
Committer: Sumit Gupta <sumit@apache.org>
Committed: Thu Feb 12 12:45:11 2015 -0500

----------------------------------------------------------------------
 .../ha/provider/HaServletContextListener.java   |   2 +-
 gateway-release/pom.xml                         |  43 ++-
 gateway-release/src/assembly.xml                |   7 +
 gateway-server/pom.xml                          |   8 +
 .../apache/hadoop/gateway/GatewayMessages.java  |   6 +
 .../gateway/config/impl/GatewayConfigImpl.java  |  16 +
 .../gateway/deploy/DeploymentFactory.java       | 147 +++----
 .../impl/DispatchDeploymentContributor.java     |   9 +-
 .../ServiceDefinitionDeploymentContributor.java | 216 +++++++++++
 .../gateway/dispatch/UrlConnectionDispatch.java |  29 +-
 .../interpreter/ServicePropertyInterpreter.java |   3 +-
 .../xml/KnoxFormatXmlTopologyRules.java         |   3 +
 .../gateway/util/ServiceDefinitionsLoader.java  |  95 +++++
 .../src/main/resources/build.properties         |   2 +-
 .../apache/hadoop/gateway/AuditLoggingTest.java |   2 +
 .../topology/xml/TopologyRulesModuleTest.java   |  17 +-
 .../xml/service-param-topology-knox-format.xml  |   1 +
 .../xml/simple-topology-knox-format.xml         |   1 +
 gateway-service-definitions/pom.xml             |  39 ++
 .../service/definition/CustomDispatch.java      |  69 ++++
 .../gateway/service/definition/Policy.java      |  45 +++
 .../gateway/service/definition/Rewrite.java     |  47 +++
 .../gateway/service/definition/Route.java       |  73 ++++
 .../service/definition/ServiceDefinition.java   | 142 +++++++
 .../resources/services/hbase/0.98.0/rewrite.xml |  62 +++
 .../resources/services/hbase/0.98.0/service.xml |  33 ++
 .../resources/services/hive/0.13.0/rewrite.xml  |  21 +
 .../resources/services/hive/0.13.0/service.xml  |  22 ++
 .../resources/services/oozie/4.0.0/rewrite.xml  | 122 ++++++
 .../resources/services/oozie/4.0.0/service.xml  |  30 ++
 .../services/webhcat/0.13.0/rewrite.xml         |  28 ++
 .../services/webhcat/0.13.0/service.xml         |  23 ++
 .../services/webhdfs/2.4.0/rewrite.xml          |  70 ++++
 .../services/webhdfs/2.4.0/service.xml          |  40 ++
 .../services/yarn-rm/2.5.0/rewrite.xml          | 193 ++++++++++
 .../services/yarn-rm/2.5.0/service.xml          |  54 +++
 .../definition/ServiceDefinitionTest.java       |  56 +++
 .../hbase/HBaseDeploymentContributor.java       | 133 -------
 .../HBaseDispatchDeploymentContributor.java     |  70 ----
 .../gateway/hbase/HBaseHttpClientDispatch.java  |   5 +-
 ...gateway.deploy.ProviderDeploymentContributor |  19 -
 ....gateway.deploy.ServiceDeploymentContributor |  19 -
 .../hbase/HBaseDeploymentContributorTest.java   |  45 ---
 .../HBaseDispatchDeploymentContributorTest.java |  45 ---
 .../gateway/hive/HiveDeploymentContributor.java |  84 ----
 .../hive/HiveDispatchDeploymentContributor.java |  75 ----
 .../gateway/hive/HiveHttpClientDispatch.java    |  23 +-
 ...gateway.deploy.ProviderDeploymentContributor |  19 -
 ....gateway.deploy.ServiceDeploymentContributor |  19 -
 .../HiveDispatchDeploymentContributorTest.java  |  44 ---
 gateway-service-oozie/pom.xml                   |  95 -----
 .../oozie/OozieDeploymentContributor.java       | 121 ------
 ....gateway.deploy.ServiceDeploymentContributor |  19 -
 .../OozieDeploymentContributor/rewrite.xml      | 122 ------
 .../oozie/OozieDeploymentContributorTest.java   | 130 -------
 gateway-service-webhcat/pom.xml                 |  57 ---
 .../webhcat/WebHCatDeploymentContributor.java   |  95 -----
 ....gateway.deploy.ServiceDeploymentContributor |  19 -
 .../WebHCatDeploymentContributor/rewrite.xml    |  28 --
 ...NameNodeHaDispatchDeploymentContributor.java |  12 +-
 .../hdfs/WebHdfsDeploymentContributor.java      | 173 ---------
 .../WebHdfsDispatchDeploymentContributor.java   |  47 ---
 .../hdfs/dispatch/WebHdfsHaDispatchFilter.java  |  36 ++
 .../dispatch/WebHdfsHaHttpClientDispatch.java   |  66 ++--
 ...gateway.deploy.ProviderDeploymentContributor |   1 -
 ....gateway.deploy.ServiceDeploymentContributor |   1 -
 .../WebHdfsHaHttpClientDispatchTest.java        |   9 +-
 gateway-service-yarn-rm/pom.xml                 |  61 ---
 .../ResourceManagerDeploymentContributor.java   | 150 --------
 ....gateway.deploy.ServiceDeploymentContributor |  19 -
 .../rewrite.xml                                 | 193 ----------
 ...esourceManagerDeploymentContributorTest.java |  45 ---
 gateway-spi/pom.xml                             |  10 +-
 .../config/FilterConfigurationAdapter.java      |  39 ++
 .../FilterConfigurationAdapterDescriptor.java   |  29 ++
 .../hadoop/gateway/config/GatewayConfig.java    |   6 +
 .../deploy/ServiceDeploymentContributor.java    |   3 +
 .../ServiceDeploymentContributorBase.java       |   6 +
 .../dispatch/AbstractGatewayDispatch.java       |  91 +----
 .../hadoop/gateway/dispatch/Dispatch.java       |  10 +
 .../gateway/dispatch/GatewayDispatchFilter.java | 152 ++++++++
 .../gateway/dispatch/HttpClientDispatch.java    |  63 ++-
 .../apache/hadoop/gateway/topology/Service.java |   9 +
 .../hadoop/gateway/topology/Topology.java       |  36 +-
 .../apache/hadoop/gateway/topology/Version.java | 130 +++++++
 ...ay.config.spi.ConfigurationAdapterDescriptor |  18 +
 .../dispatch/HttpClientDispatchTest.java        |   2 +
 .../hadoop/gateway/GatewayFuncTestDriver.java   |  13 +
 .../hadoop/gateway/GatewayTestConfig.java       |   6 +-
 .../deploy/DeploymentFactoryFuncTest.java       |  46 ++-
 .../WebHCatDeploymentContributorTest.java       |  45 ---
 gateway-util-configinjector/pom.xml             |  63 +++
 .../org/apache/hadoop/gateway/config/Alias.java |  31 ++
 .../gateway/config/ConfigurationAdapter.java    |  24 ++
 .../gateway/config/ConfigurationBinding.java    |  24 ++
 .../gateway/config/ConfigurationException.java  |  30 ++
 .../config/ConfigurationInjectorBuilder.java    | 107 ++++++
 .../apache/hadoop/gateway/config/Configure.java |  30 ++
 .../apache/hadoop/gateway/config/Default.java   |  31 ++
 .../apache/hadoop/gateway/config/Optional.java  |  30 ++
 .../config/impl/BeanConfigurationAdapter.java   |  40 ++
 .../BeanConfigurationAdapterDescriptor.java     |  30 ++
 .../impl/ConfigurationAdapterFactory.java       | 132 +++++++
 .../impl/DefaultConfigurationBinding.java       |  29 ++
 .../impl/DefaultConfigurationInjector.java      | 224 +++++++++++
 .../config/impl/MapConfigurationAdapter.java    |  37 ++
 .../impl/MapConfigurationAdapterDescriptor.java |  30 ++
 .../config/impl/MappedConfigurationBinding.java |  38 ++
 .../impl/PropertiesConfigurationAdapter.java    |  38 ++
 ...ropertiesConfigurationAdapterDescriptor.java |  30 ++
 .../AbstractConfigurationAdapterDescriptor.java |  42 ++
 .../spi/ConfigurationAdapterDescriptor.java     |  28 ++
 .../config/spi/ConfigurationInjector.java       |  27 ++
 ...ay.config.spi.ConfigurationAdapterDescriptor |  20 +
 ...oop.gateway.config.spi.ConfigurationInjector |  18 +
 .../gateway/config/AdapterSampleTest.java       |  57 +++
 .../apache/hadoop/gateway/config/FuncTest.java  | 379 +++++++++++++++++++
 .../gateway/config/MapFieldSampleTest.java      |  45 +++
 .../gateway/config/MapMethodSampleTest.java     |  49 +++
 .../config/PropertiesFactorySampleTest.java     |  40 ++
 .../config/PropertiesFieldSampleTest.java       |  39 ++
 .../config/PropertiesMethodSampleTest.java      |  57 +++
 .../apache/hadoop/gateway/config/UsageTest.java |  43 +++
 .../BeanConfigurationAdapterDescriptorTest.java |  57 +++
 .../impl/BeanConfigurationAdapterTest.java      |  40 ++
 hsso-release/pom.xml                            |  10 +-
 pom.xml                                         |  30 +-
 127 files changed, 4276 insertions(+), 2292 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-provider-ha/src/main/java/org/apache/hadoop/gateway/ha/provider/HaServletContextListener.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/main/java/org/apache/hadoop/gateway/ha/provider/HaServletContextListener.java b/gateway-provider-ha/src/main/java/org/apache/hadoop/gateway/ha/provider/HaServletContextListener.java
index 62dd684..b84e649 100644
--- a/gateway-provider-ha/src/main/java/org/apache/hadoop/gateway/ha/provider/HaServletContextListener.java
+++ b/gateway-provider-ha/src/main/java/org/apache/hadoop/gateway/ha/provider/HaServletContextListener.java
@@ -36,7 +36,7 @@ import java.util.List;
 
 public class HaServletContextListener implements ServletContextListener {
 
-   public static final String PROVIDER_ATTRIBUTE_NAME = HaProvider.class.getName();
+   public static final String PROVIDER_ATTRIBUTE_NAME = "haProvider";
 
    public static final String DESCRIPTOR_LOCATION_INIT_PARAM_NAME = "haDescriptorLocation";
 

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-release/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-release/pom.xml b/gateway-release/pom.xml
index 744242b..0f7a739 100644
--- a/gateway-release/pom.xml
+++ b/gateway-release/pom.xml
@@ -37,6 +37,7 @@
         </license>
     </licenses>
 
+
     <profiles>
         <profile>
             <id>release</id>
@@ -94,6 +95,36 @@
                             </dependency>
                         </dependencies>
                     </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-dependency-plugin</artifactId>
+                        <version>2.8</version>
+                        <executions>
+                            <execution>
+                                <id>unpack</id>
+                                <phase>generate-resources</phase>
+                                <goals>
+                                    <goal>unpack</goal>
+                                </goals>
+                                <configuration>
+                                    <artifactItems>
+                                        <artifactItem>
+                                            <groupId>${gateway-group}</groupId>
+                                            <artifactId>gateway-service-definitions</artifactId>
+                                            <type>jar</type>
+                                            <overWrite>true</overWrite>
+                                            <outputDirectory>${project.build.directory}</outputDirectory>
+                                            <includes>services/**/*</includes>
+                                            <!--<excludes>**/*.class</excludes>-->
+                                        </artifactItem>
+                                    </artifactItems>
+                                    <!--<outputDirectory>${project.build.directory}/data</outputDirectory>-->
+                                    <!--<overWriteReleases>false</overWriteReleases>-->
+                                    <!--<overWriteSnapshots>true</overWriteSnapshots>-->
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
                 </plugins>
             </build>
         </profile>
@@ -135,22 +166,10 @@
         </dependency>
         <dependency>
             <groupId>${gateway-group}</groupId>
-            <artifactId>gateway-service-oozie</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${gateway-group}</groupId>
-            <artifactId>gateway-service-webhcat</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${gateway-group}</groupId>
             <artifactId>gateway-service-tgs</artifactId>
         </dependency>
         <dependency>
             <groupId>${gateway-group}</groupId>
-            <artifactId>gateway-service-yarn-rm</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${gateway-group}</groupId>
             <artifactId>gateway-provider-rewrite</artifactId>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-release/src/assembly.xml
----------------------------------------------------------------------
diff --git a/gateway-release/src/assembly.xml b/gateway-release/src/assembly.xml
index 9a46f39..709d1f3 100644
--- a/gateway-release/src/assembly.xml
+++ b/gateway-release/src/assembly.xml
@@ -58,6 +58,13 @@
             </includes>
             <fileMode>0444</fileMode>
         </fileSet>
+        <fileSet>
+            <directory>${project.build.directory}/services</directory>
+            <outputDirectory>data/services</outputDirectory>
+            <includes>
+                <include>**/*</include>
+            </includes>
+        </fileSet>
     </fileSets>
     <dependencySets>
         <dependencySet>

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-server/pom.xml b/gateway-server/pom.xml
index 3f736f3..1304cd0 100644
--- a/gateway-server/pom.xml
+++ b/gateway-server/pom.xml
@@ -178,6 +178,14 @@
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.knox</groupId>
+            <artifactId>gateway-service-definitions</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.knox</groupId>
+            <artifactId>gateway-provider-rewrite</artifactId>
+        </dependency>
 
         <!-- ********** ********** ********** ********** ********** ********** -->
         <!-- ********** Test Dependencies                           ********** -->

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java
index 9325c02..4990ad1 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java
@@ -124,6 +124,9 @@ public interface GatewayMessages {
   @Message( level = MessageLevel.WARN, text = "Ignoring service deployment contributor with invalid null role: {0}" )
   void ignoringServiceContributorWithMissingRole( String className );
 
+  @Message( level = MessageLevel.WARN, text = "Ignoring service deployment contributor with invalid null version: {0}" )
+  void ignoringServiceContributorWithMissingVersion( String className );
+
   @Message( level = MessageLevel.WARN, text = "Ignoring provider deployment contributor with invalid null name: {0}" )
   void ignoringProviderContributorWithMissingName( String className );
 
@@ -325,4 +328,7 @@ public interface GatewayMessages {
 
   @Message( level = MessageLevel.INFO, text = "Computed roles/groups: {0} for principal: {1}" )
   void lookedUpUserRoles(Set<String> roleNames, String userName);
+
+  @Message( level = MessageLevel.INFO, text = "Configured stacks directory is {0}" )
+  void usingStacksDirectory(String path);
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
index 4b2a0ac..a2dfdbf 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/config/impl/GatewayConfigImpl.java
@@ -75,6 +75,8 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig {
 
   private static final String GATEWAY_CONFIG_FILE_PREFIX = "gateway";
 
+  private static final String STACKS_SERVICES_DIRECTORY = "services";
+
   public static final String[] GATEWAY_CONFIG_FILENAMES = {
       GATEWAY_CONFIG_DIR_PREFIX + "/" + GATEWAY_CONFIG_FILE_PREFIX + "-default.xml",
       GATEWAY_CONFIG_DIR_PREFIX + "/" + GATEWAY_CONFIG_FILE_PREFIX + "-site.xml"
@@ -164,6 +166,20 @@ public class GatewayConfigImpl extends Configuration implements GatewayConfig {
   }
 
   @Override
+  public String getGatewayStacksDir() {
+    return getGatewayDataDir() + File.separator + STACKS_SERVICES_DIRECTORY;
+  }
+  @Override
+  public String getGatewayStacksDir() {
+    return getVar( GATEWAY_DATA_HOME_VAR, getGatewayHomeDir() + File.separator + "stacks" );
+  }
+
+  @Override
+  public String getGatewayStacksDir() {
+    return getVar( GATEWAY_DATA_HOME_VAR, getGatewayHomeDir() + File.separator + "stacks" );
+  }
+
+  @Override
   public String getHadoopConfDir() {
     return get( HADOOP_CONF_DIR );
   }

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
index 44ba37a..d2245cc 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
@@ -19,18 +19,18 @@ package org.apache.hadoop.gateway.deploy;
 
 import org.apache.hadoop.gateway.GatewayMessages;
 import org.apache.hadoop.gateway.GatewayForwardingServlet;
-import org.apache.hadoop.gateway.GatewayResources;
 import org.apache.hadoop.gateway.GatewayServlet;
 import org.apache.hadoop.gateway.config.GatewayConfig;
 import org.apache.hadoop.gateway.descriptor.GatewayDescriptor;
 import org.apache.hadoop.gateway.descriptor.GatewayDescriptorFactory;
 import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
-import org.apache.hadoop.gateway.i18n.resources.ResourcesFactory;
 import org.apache.hadoop.gateway.services.GatewayServices;
 import org.apache.hadoop.gateway.services.registry.ServiceRegistry;
 import org.apache.hadoop.gateway.topology.Provider;
 import org.apache.hadoop.gateway.topology.Service;
 import org.apache.hadoop.gateway.topology.Topology;
+import org.apache.hadoop.gateway.topology.Version;
+import org.apache.hadoop.gateway.util.ServiceDefinitionsLoader;
 import org.jboss.shrinkwrap.api.ShrinkWrap;
 import org.jboss.shrinkwrap.api.asset.Asset;
 import org.jboss.shrinkwrap.api.asset.StringAsset;
@@ -40,27 +40,18 @@ import org.jboss.shrinkwrap.descriptor.api.webapp30.WebAppDescriptor;
 import org.jboss.shrinkwrap.descriptor.api.webcommon30.ServletType;
 
 import java.beans.Statement;
+import java.io.File;
 import java.io.IOException;
 import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.LinkedHashMap;
+import java.util.*;
 
 public abstract class DeploymentFactory {
 
   private static final String DEFAULT_APP_REDIRECT_CONTEXT_PATH = "redirectTo";
-  private static GatewayResources res = ResourcesFactory.get( GatewayResources.class );
   private static GatewayMessages log = MessagesFactory.get( GatewayMessages.class );
   private static GatewayServices gatewayServices = null;
 
-  //private static Set<ServiceDeploymentContributor> SERVICE_CONTRIBUTORS;
-  private static Map<String,Map<String,ServiceDeploymentContributor>> SERVICE_CONTRIBUTOR_MAP;
+  private static Map<String,Map<String,Map<Version, ServiceDeploymentContributor>>> SERVICE_CONTRIBUTOR_MAP;
   static {
     loadServiceContributors();
   }
@@ -70,13 +61,20 @@ public abstract class DeploymentFactory {
   static {
     loadProviderContributors();
   }
-  
+
   public static void setGatewayServices(GatewayServices services) {
     DeploymentFactory.gatewayServices = services;
   }
 
   public static WebArchive createDeployment( GatewayConfig config, Topology topology ) {
     DeploymentContext context = null;
+     //TODO move the loading of service defs
+    String stacks = config.getGatewayStacksDir();
+    log.usingStacksDirectory(stacks);
+    File stacksDir = new File(stacks);
+    Set<ServiceDeploymentContributor> deploymentContributors = ServiceDefinitionsLoader.loadServiceDefinitions(stacksDir);
+    addServiceDeploymentContributors(deploymentContributors.iterator());
+
     Map<String,List<ProviderDeploymentContributor>> providers = selectContextProviders( topology );
     Map<String,List<ServiceDeploymentContributor>> services = selectContextServices( topology );
     context = createDeploymentContext( config, topology.getName(), topology, providers, services );
@@ -187,7 +185,7 @@ public abstract class DeploymentFactory {
         = new HashMap<String,List<ServiceDeploymentContributor>>();
     for( Service service : topology.getServices() ) {
       String role = service.getRole();
-      ServiceDeploymentContributor contributor = getServiceContributor( role, service.getName() );
+      ServiceDeploymentContributor contributor = getServiceContributor( role, service.getName(), service.getVersion() );
       if( contributor != null ) {
         List<ServiceDeploymentContributor> list = defaults.get( role );
         if( list == null ) {
@@ -239,12 +237,12 @@ public abstract class DeploymentFactory {
       }
     }
   }
-  
+
   private static void injectServices(Object contributor) {
     if (gatewayServices != null) {
       Statement stmt = null;
       for(String serviceName : gatewayServices.getServiceNames()) {
-        
+
         try {
           // TODO: this is just a temporary injection solution
           // TODO: test for the existence of the setter before attempting it
@@ -280,12 +278,12 @@ public abstract class DeploymentFactory {
       }
     }
     for( Service service : topology.getServices() ) {
-      ServiceDeploymentContributor contributor = getServiceContributor( service.getRole(), null );
+      ServiceDeploymentContributor contributor = getServiceContributor( service.getRole(), service.getName(), service.getVersion() );
       if( contributor != null ) {
         try {
           contributor.contributeService( context, service );
           if (gatewayServices != null) {
-            ServiceRegistry sr = (ServiceRegistry) gatewayServices.getService(GatewayServices.SERVICE_REGISTRY_SERVICE);
+            ServiceRegistry sr = gatewayServices.getService(GatewayServices.SERVICE_REGISTRY_SERVICE);
             if (sr != null) {
               String regCode = sr.getRegistrationCode(topology.getName());
               sr.registerService(regCode, topology.getName(), service.getRole(), service.getUrls() );
@@ -313,14 +311,22 @@ public abstract class DeploymentFactory {
     return contributor;
   }
 
-  public static ServiceDeploymentContributor getServiceContributor( String role, String name ) {
+  public static ServiceDeploymentContributor getServiceContributor( String role, String name, Version version ) {
     ServiceDeploymentContributor contributor = null;
-    Map<String,ServiceDeploymentContributor> nameMap = SERVICE_CONTRIBUTOR_MAP.get( role );
-    if( nameMap != null ) {
-      if( name == null ) {
-        contributor = nameMap.values().iterator().next();
-      } else if ( !nameMap.isEmpty() ) {
-        contributor = nameMap.get( name );
+    Map<String,Map<Version, ServiceDeploymentContributor>> nameMap = SERVICE_CONTRIBUTOR_MAP.get( role );
+    if( nameMap != null && !nameMap.isEmpty()) {
+      Map<Version, ServiceDeploymentContributor> versionMap = null;
+      if ( name == null ) {
+        versionMap = nameMap.values().iterator().next();
+      } else {
+        versionMap = nameMap.get( name );
+      }
+      if ( versionMap != null && !versionMap.isEmpty()) {
+        if( version == null ) {
+          contributor = ((TreeMap<Version, ServiceDeploymentContributor>) versionMap).firstEntry().getValue();
+        } else {
+          contributor = versionMap.get( version );
+        }
       }
     }
     return contributor;
@@ -391,38 +397,45 @@ public abstract class DeploymentFactory {
       }
     }
     return null;
-  }  
-  
-  private static void loadServiceContributors() {
-    Set<ServiceDeploymentContributor> set = new HashSet<ServiceDeploymentContributor>();
-    Map<String,Map<String,ServiceDeploymentContributor>> roleMap
-        = new HashMap<String,Map<String,ServiceDeploymentContributor>>();
+  }
 
+  private static void loadServiceContributors() {
+    SERVICE_CONTRIBUTOR_MAP = new HashMap<String, Map<String, Map<Version, ServiceDeploymentContributor>>>();
     ServiceLoader<ServiceDeploymentContributor> loader = ServiceLoader.load( ServiceDeploymentContributor.class );
     Iterator<ServiceDeploymentContributor> contributors = loader.iterator();
-    while( contributors.hasNext() ) {
-      ServiceDeploymentContributor contributor = contributors.next();
-      if( contributor.getName() == null ) {
-        log.ignoringServiceContributorWithMissingName( contributor.getClass().getName() );
-        continue;
-      }
-      if( contributor.getRole() == null ) {
-        log.ignoringServiceContributorWithMissingRole( contributor.getClass().getName() );
-        continue;
-      }
-      set.add( contributor );
-      Map nameMap = roleMap.get( contributor.getRole() );
-      if( nameMap == null ) {
-        nameMap = new HashMap<String,ServiceDeploymentContributor>();
-        roleMap.put( contributor.getRole(), nameMap );
-      }
-      nameMap.put( contributor.getName(), contributor );
-    }
-    //SERVICE_CONTRIBUTORS = set;
-    SERVICE_CONTRIBUTOR_MAP = roleMap;
+    addServiceDeploymentContributors(contributors);
   }
 
-  private static void loadProviderContributors() {
+   private static void addServiceDeploymentContributors(Iterator<ServiceDeploymentContributor> contributors) {
+      while( contributors.hasNext() ) {
+        ServiceDeploymentContributor contributor = contributors.next();
+        if( contributor.getName() == null ) {
+          log.ignoringServiceContributorWithMissingName( contributor.getClass().getName() );
+          continue;
+        }
+        if( contributor.getRole() == null ) {
+          log.ignoringServiceContributorWithMissingRole( contributor.getClass().getName() );
+          continue;
+        }
+        if( contributor.getVersion() == null ) {
+          log.ignoringServiceContributorWithMissingVersion(contributor.getClass().getName());
+          continue;
+        }
+        Map<String,Map<Version, ServiceDeploymentContributor>> nameMap = SERVICE_CONTRIBUTOR_MAP.get( contributor.getRole() );
+        if( nameMap == null ) {
+          nameMap = new HashMap<String,Map<Version, ServiceDeploymentContributor>>();
+          SERVICE_CONTRIBUTOR_MAP.put( contributor.getRole(), nameMap );
+        }
+        Map<Version, ServiceDeploymentContributor> versionMap = nameMap.get(contributor.getName());
+        if (versionMap == null) {
+          versionMap = new TreeMap<Version, ServiceDeploymentContributor>();
+          nameMap.put(contributor.getName(), versionMap);
+        }
+        versionMap.put( contributor.getVersion(), contributor );
+      }
+   }
+
+   private static void loadProviderContributors() {
     Set<ProviderDeploymentContributor> set = new HashSet<ProviderDeploymentContributor>();
     Map<String,Map<String,ProviderDeploymentContributor>> roleMap
         = new HashMap<String,Map<String,ProviderDeploymentContributor>>();
@@ -465,18 +478,18 @@ public abstract class DeploymentFactory {
     return contributor;
   }
 
-  static ServiceDeploymentContributor getServiceContributor(
-      Map<String,List<ServiceDeploymentContributor>> services, String role, String name ) {
-    ServiceDeploymentContributor contributor = null;
-    if( name == null ) {
-      List<ServiceDeploymentContributor> list = services.get( role );
-      if( !list.isEmpty() ) {
-        contributor = list.get( 0 );
-      }
-    } else {
-      contributor = getServiceContributor( role, name );
-    }
-    return contributor;
-  }
+//  static ServiceDeploymentContributor getServiceContributor(
+//      Map<String,List<ServiceDeploymentContributor>> services, String role, String name ) {
+//    ServiceDeploymentContributor contributor = null;
+//    if( name == null ) {
+//      List<ServiceDeploymentContributor> list = services.get( role );
+//      if( !list.isEmpty() ) {
+//        contributor = list.get( 0 );
+//      }
+//    } else {
+//      contributor = getServiceContributor( role, name );
+//    }
+//    return contributor;
+//  }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/DispatchDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/DispatchDeploymentContributor.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/DispatchDeploymentContributor.java
index ab3448b..30f2c65 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/DispatchDeploymentContributor.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/DispatchDeploymentContributor.java
@@ -22,6 +22,7 @@ import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributorBase;
 import org.apache.hadoop.gateway.descriptor.FilterDescriptor;
 import org.apache.hadoop.gateway.descriptor.FilterParamDescriptor;
 import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
+import org.apache.hadoop.gateway.dispatch.GatewayDispatchFilter;
 import org.apache.hadoop.gateway.dispatch.HttpClientDispatch;
 import org.apache.hadoop.gateway.topology.Provider;
 import org.apache.hadoop.gateway.topology.Service;
@@ -32,7 +33,9 @@ import java.util.Map;
 public class DispatchDeploymentContributor extends ProviderDeploymentContributorBase {
   
   private static final String REPLAY_BUFFER_SIZE_PARAM = "replayBufferSize";
-  
+
+  private static final String DISPATCH_IMPL_PARAM = "dispatch-impl";
+
   // Default global replay buffer size in KB
   public static final String DEFAULT_REPLAY_BUFFER_SIZE = "8";
 
@@ -48,8 +51,8 @@ public class DispatchDeploymentContributor extends ProviderDeploymentContributor
 
   @Override
   public void contributeFilter( DeploymentContext context, Provider provider, Service service, ResourceDescriptor resource, List<FilterParamDescriptor> params ) {
-    FilterDescriptor filter = resource.addFilter().name( getName() ).role( getRole() ).impl( HttpClientDispatch.class );
-
+    FilterDescriptor filter = resource.addFilter().name( getName() ).role( getRole() ).impl( GatewayDispatchFilter.class );
+    filter.param().name(DISPATCH_IMPL_PARAM).value(HttpClientDispatch.class.getName());
     FilterParamDescriptor filterParam = filter.param().name( REPLAY_BUFFER_SIZE_PARAM ).value( DEFAULT_REPLAY_BUFFER_SIZE );
     for ( Map.Entry<String,String> serviceParam : service.getParams().entrySet() ) {
       if ( REPLAY_BUFFER_SIZE_PARAM.equals( serviceParam.getKey() ) ) {

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
new file mode 100644
index 0000000..c14a156
--- /dev/null
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/impl/ServiceDefinitionDeploymentContributor.java
@@ -0,0 +1,216 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.deploy.impl;
+
+import org.apache.hadoop.gateway.deploy.DeploymentContext;
+import org.apache.hadoop.gateway.deploy.ServiceDeploymentContributorBase;
+import org.apache.hadoop.gateway.descriptor.FilterDescriptor;
+import org.apache.hadoop.gateway.descriptor.FilterParamDescriptor;
+import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
+import org.apache.hadoop.gateway.dispatch.GatewayDispatchFilter;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
+import org.apache.hadoop.gateway.service.definition.*;
+import org.apache.hadoop.gateway.topology.Provider;
+import org.apache.hadoop.gateway.topology.Service;
+import org.apache.hadoop.gateway.topology.Version;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ServiceDefinitionDeploymentContributor extends ServiceDeploymentContributorBase {
+
+  private static final String DISPATCH_ROLE = "dispatch";
+
+  private static final String DISPATCH_IMPL_PARAM = "dispatch-impl";
+
+  private static final String REPLAY_BUFFER_SIZE_PARAM = "replayBufferSize";
+
+  public static final String DEFAULT_REPLAY_BUFFER_SIZE = "8";
+
+  private ServiceDefinition serviceDefinition;
+
+  private UrlRewriteRulesDescriptor serviceRules;
+
+  public ServiceDefinitionDeploymentContributor(ServiceDefinition serviceDefinition, UrlRewriteRulesDescriptor serviceRules) {
+    this.serviceDefinition = serviceDefinition;
+    this.serviceRules = serviceRules;
+  }
+
+  @Override
+  public String getRole() {
+    return serviceDefinition.getRole();
+  }
+
+  @Override
+  public String getName() {
+    return serviceDefinition.getName();
+  }
+
+  @Override
+  public Version getVersion() {
+    return new Version(serviceDefinition.getVersion());
+  }
+
+  @Override
+  public void contributeService(DeploymentContext context, Service service) throws Exception {
+    contributeRewriteRules(context, service);
+    contributeResources(context, service);
+  }
+
+  private void contributeRewriteRules(DeploymentContext context, Service service) {
+    if ( serviceRules != null ) {
+      UrlRewriteRulesDescriptor clusterRules = context.getDescriptor("rewrite");
+      clusterRules.addRules(serviceRules);
+    }
+  }
+
+  private void contributeResources(DeploymentContext context, Service service) {
+    Map<String, String> filterParams = new HashMap<String, String>();
+    List<Route> bindings = serviceDefinition.getRoutes();
+    for ( Route binding : bindings ) {
+      List<Rewrite> filters = binding.getRewrites();
+      if ( filters != null && !filters.isEmpty() ) {
+        filterParams.clear();
+        for ( Rewrite filter : filters ) {
+          filterParams.put(filter.getTo(), filter.getApply());
+        }
+      }
+      try {
+        contributeResource(context, service, binding, filterParams);
+      } catch ( URISyntaxException e ) {
+        e.printStackTrace();
+      }
+    }
+
+  }
+
+  private void contributeResource(DeploymentContext context, Service service, Route binding, Map<String, String> filterParams) throws URISyntaxException {
+    List<FilterParamDescriptor> params = new ArrayList<FilterParamDescriptor>();
+    ResourceDescriptor resource = context.getGatewayDescriptor().addResource();
+    resource.role(service.getRole());
+    resource.pattern(binding.getPath());
+    List<Policy> policyBindings = binding.getPolicies();
+    if ( policyBindings == null ) {
+      policyBindings = serviceDefinition.getPolicies();
+    }
+    if ( policyBindings == null ) {
+      //add default set
+      addDefaultPolicies(context, service, filterParams, params, resource);
+    } else {
+      addPolicies(context, service, filterParams, params, resource, policyBindings);
+    }
+    addDispatchFilter(context, service, resource, binding);
+  }
+
+  private void addPolicies(DeploymentContext context, Service service, Map<String, String> filterParams, List<FilterParamDescriptor> params, ResourceDescriptor resource, List<Policy> policyBindings) throws URISyntaxException {
+    for ( Policy policyBinding : policyBindings ) {
+      String role = policyBinding.getRole();
+      if ( role == null ) {
+        throw new IllegalArgumentException("Policy defined has no role for service " + service.getName());
+      }
+      role = role.trim().toLowerCase();
+      if ( role.equals("rewrite") ) {
+        addRewriteFilter(context, service, filterParams, params, resource);
+      } else if ( topologyContainsProviderType(context, role) ) {
+        context.contributeFilter(service, resource, role, policyBinding.getName(), null);
+      }
+    }
+  }
+
+  private void addDefaultPolicies(DeploymentContext context, Service service, Map<String, String> filterParams, List<FilterParamDescriptor> params, ResourceDescriptor resource) throws URISyntaxException {
+    addWebAppSecFilters(context, service, resource);
+    addAuthenticationFilter(context, service, resource);
+    addRewriteFilter(context, service, filterParams, params, resource);
+    addIdentityAssertionFilter(context, service, resource);
+    addAuthorizationFilter(context, service, resource);
+  }
+
+  private void addRewriteFilter(DeploymentContext context, Service service, Map<String, String> filterParams, List<FilterParamDescriptor> params, ResourceDescriptor resource) throws URISyntaxException {
+    if ( !filterParams.isEmpty() ) {
+      for ( Map.Entry<String, String> filterParam : filterParams.entrySet() ) {
+        params.add(resource.createFilterParam().name(filterParam.getKey()).value(filterParam.getValue()));
+      }
+    }
+    addRewriteFilter(context, service, resource, params);
+  }
+
+  private void addDispatchFilter(DeploymentContext context, Service service, ResourceDescriptor resource, Route binding) {
+    CustomDispatch customDispatch = binding.getDispatch();
+    if ( customDispatch == null ) {
+      customDispatch = serviceDefinition.getDispatch();
+    }
+    if ( customDispatch != null ) {
+      boolean isHaEnabled = isHaEnabled(context);
+      String haContributorName = customDispatch.getHaContributorName();
+      String haClassName = customDispatch.getHaClassName();
+      if ( isHaEnabled && (haContributorName != null || haClassName != null)) {
+        if (haContributorName != null) {
+          addDispatchFilter(context, service, resource, DISPATCH_ROLE, haContributorName);
+        } else {
+          addDispatchFilterForClass(context, service, resource, haClassName);
+        }
+      } else {
+        String contributorName = customDispatch.getContributorName();
+        if ( contributorName != null ) {
+          addDispatchFilter(context, service, resource, DISPATCH_ROLE, contributorName);
+        } else {
+          String className = customDispatch.getClassName();
+          if ( className != null ) {
+            addDispatchFilterForClass(context, service, resource, className);
+          }
+        }
+      }
+    } else {
+      addDispatchFilter(context, service, resource, DISPATCH_ROLE, "http-client");
+    }
+  }
+
+  private void addDispatchFilterForClass(DeploymentContext context, Service service, ResourceDescriptor resource, String className) {
+    FilterDescriptor filter = resource.addFilter().name(getName()).role(DISPATCH_ROLE).impl(GatewayDispatchFilter.class);
+    filter.param().name(DISPATCH_IMPL_PARAM).value(className);
+    FilterParamDescriptor filterParam = filter.param().name(REPLAY_BUFFER_SIZE_PARAM).value(DEFAULT_REPLAY_BUFFER_SIZE);
+    for ( Map.Entry<String, String> serviceParam : service.getParams().entrySet() ) {
+      if ( REPLAY_BUFFER_SIZE_PARAM.equals(serviceParam.getKey()) ) {
+        filterParam.value(serviceParam.getValue());
+      }
+    }
+    if ( context.getGatewayConfig().isHadoopKerberosSecured() ) {
+      filter.param().name("kerberos").value("true");
+    } else {
+      //special case for hive
+      filter.param().name("basicAuthPreemptive").value("true");
+    }
+  }
+
+  private boolean isHaEnabled(DeploymentContext context) {
+    Provider provider = getProviderByRole(context, "ha");
+    if ( provider != null && provider.isEnabled() ) {
+      Map<String, String> params = provider.getParams();
+      if ( params != null ) {
+        if ( params.containsKey(getRole()) ) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
index 5b02221..c0347cf 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
@@ -26,6 +26,7 @@ import org.apache.hadoop.gateway.audit.api.AuditServiceFactory;
 import org.apache.hadoop.gateway.audit.api.Auditor;
 import org.apache.hadoop.gateway.audit.api.ResourceType;
 import org.apache.hadoop.gateway.audit.log4j.audit.AuditConstants;
+import org.apache.hadoop.gateway.filter.AbstractGatewayFilter;
 import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.i18n.resources.ResourcesFactory;
 import org.apache.hadoop.gateway.util.urltemplate.Parser;
@@ -36,6 +37,8 @@ import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
 import org.apache.hadoop.security.authentication.client.AuthenticationException;
 import org.apache.hadoop.security.authentication.client.KerberosAuthenticator;
 
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -53,7 +56,7 @@ import java.util.Enumeration;
 /**
  *
  */
-public class UrlConnectionDispatch extends AbstractGatewayDispatch {
+public class UrlConnectionDispatch extends AbstractGatewayFilter {
 
   private static final GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class );
   private static final GatewayResources RES = ResourcesFactory.get( GatewayResources.class );
@@ -61,6 +64,30 @@ public class UrlConnectionDispatch extends AbstractGatewayDispatch {
           AuditConstants.KNOX_SERVICE_NAME, AuditConstants.KNOX_COMPONENT_NAME );
 
   @Override
+  protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
+    String method = request.getMethod().toUpperCase();
+    if (method.equals("GET")) {
+      try {
+        doGet(getDispatchUrl(request), request, response);
+      } catch ( URISyntaxException e ) {
+        throw new ServletException(e);
+      }
+    } else {
+      response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+    }
+  }
+
+  protected static URI getDispatchUrl(HttpServletRequest request) {
+    StringBuffer str = request.getRequestURL();
+    String query = request.getQueryString();
+    if ( query != null ) {
+      str.append('?');
+      str.append(query);
+    }
+    URI url = URI.create(str.toString());
+    return url;
+  }
+
   public void doGet( URI url, HttpServletRequest request, HttpServletResponse response ) throws IOException, URISyntaxException {
     String sourcePathInfo = request.getPathInfo();
     String sourcePattern = getConfig().getInitParameter( "pattern" );

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java
index 985fd6b..d297178 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/builder/property/interpreter/ServicePropertyInterpreter.java
@@ -59,7 +59,8 @@ public class ServicePropertyInterpreter extends AbstractInterpreter {
         }
         nextToken = nextToken.substring(dotPosition + 1);
 
-        Service service = topology.getService(serviceRole, serviceName);
+      //TODO: sumit - version needs to be passed parsed and passed in if we want to continue to support the 'ambari' format
+        Service service = topology.getService(serviceRole, serviceName, null);
         if (service == null) {
             service = new Service();
             service.setName(serviceName);

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
index 745c661..b32f0c9 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
@@ -22,6 +22,7 @@ import org.apache.commons.digester3.binder.AbstractRulesModule;
 import org.apache.hadoop.gateway.topology.Param;
 import org.apache.hadoop.gateway.topology.Provider;
 import org.apache.hadoop.gateway.topology.Service;
+import org.apache.hadoop.gateway.topology.Version;
 import org.apache.hadoop.gateway.topology.builder.BeanPropertyTopologyBuilder;
 import org.xml.sax.Attributes;
 
@@ -39,6 +40,7 @@ public class KnoxFormatXmlTopologyRules extends AbstractRulesModule {
   private static final String VALUE_TAG = "value";
 
   private static final Rule paramRule = new ParamRule();
+
   @Override
   protected void configure() {
     forPattern( ROOT_TAG ).createObject().ofType( BeanPropertyTopologyBuilder.class );
@@ -48,6 +50,7 @@ public class KnoxFormatXmlTopologyRules extends AbstractRulesModule {
     forPattern( ROOT_TAG + "/" + SERVICE_TAG ).createObject().ofType( Service.class ).then().setNext( "addService" );
     forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + ROLE_TAG ).setBeanProperty();
     forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + NAME_TAG ).setBeanProperty();
+    forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + VERSION_TAG ).createObject().ofType(Version.class).then().setBeanProperty().then().setNext("setVersion");
     forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + URL_TAG ).callMethod( "addUrl" ).usingElementBodyAsArgument();
     forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + PARAM_TAG ).createObject().ofType( Param.class ).then().addRule( paramRule ).then().setNext( "addParam" );
     forPattern( ROOT_TAG + "/" + SERVICE_TAG + "/" + PARAM_TAG + "/" + NAME_TAG ).setBeanProperty();

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/java/org/apache/hadoop/gateway/util/ServiceDefinitionsLoader.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/util/ServiceDefinitionsLoader.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/util/ServiceDefinitionsLoader.java
new file mode 100644
index 0000000..3d41605
--- /dev/null
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/util/ServiceDefinitionsLoader.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.util;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.IOFileFilter;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor;
+import org.apache.hadoop.gateway.deploy.impl.ServiceDefinitionDeploymentContributor;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptorFactory;
+import org.apache.hadoop.gateway.service.definition.ServiceDefinition;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import java.io.*;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+public class ServiceDefinitionsLoader {
+
+    public static Set<ServiceDeploymentContributor> loadServiceDefinitions(File servicesDir) {
+        Set<ServiceDeploymentContributor> contributors = new HashSet<ServiceDeploymentContributor>();
+        if (servicesDir.exists() && servicesDir.isDirectory()) {
+            JAXBContext context = null;
+            try {
+                context = JAXBContext.newInstance(ServiceDefinition.class);
+                Unmarshaller unmarshaller = context.createUnmarshaller();
+                Collection<File> files = FileUtils.listFiles(servicesDir, new IOFileFilter() {
+                    @Override
+                    public boolean accept(File file) {
+                        return file.getName().contains("service");
+                    }
+
+                    @Override
+                    public boolean accept(File dir, String name) {
+                        return name.contains("service");
+                    }
+                }, TrueFileFilter.INSTANCE);
+                for (File file : files) {
+                    try {
+                        FileInputStream inputStream = new FileInputStream(file);
+                        ServiceDefinition definition = (ServiceDefinition) unmarshaller.unmarshal(inputStream);
+                        //look for rewrite rules as a sibling (for now)
+                        UrlRewriteRulesDescriptor rewriteRulesDescriptor = loadRewriteRules(file.getParentFile());
+                        contributors.add(new ServiceDefinitionDeploymentContributor(definition, rewriteRulesDescriptor));
+                    } catch (FileNotFoundException e) {
+                        e.printStackTrace();
+                    }
+                }
+            } catch (JAXBException e) {
+                e.printStackTrace();
+            }
+        }
+        return contributors;
+    }
+
+    private static UrlRewriteRulesDescriptor loadRewriteRules(File servicesDir) {
+        File rewriteFile = new File(servicesDir, "rewrite.xml");
+        if (rewriteFile.exists()) {
+            InputStream stream = null;
+            try {
+                stream = new FileInputStream(rewriteFile);
+                Reader reader = new InputStreamReader(stream);
+                UrlRewriteRulesDescriptor rules = UrlRewriteRulesDescriptorFactory.load(
+                        "xml", reader);
+                reader.close();
+                stream.close();
+                return rules;
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/main/resources/build.properties
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/resources/build.properties b/gateway-server/src/main/resources/build.properties
index a380579..fbd4d83 100644
--- a/gateway-server/src/main/resources/build.properties
+++ b/gateway-server/src/main/resources/build.properties
@@ -14,5 +14,5 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-build.version=${gateway-version}
+build.version=0.5.0.2.2.1.0-2340
 build.hash=${buildNumber}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/test/java/org/apache/hadoop/gateway/AuditLoggingTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/AuditLoggingTest.java b/gateway-server/src/test/java/org/apache/hadoop/gateway/AuditLoggingTest.java
index b15c56b..8d88ec0 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/AuditLoggingTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/AuditLoggingTest.java
@@ -49,6 +49,7 @@ import org.apache.hadoop.gateway.audit.log4j.correlation.Log4jCorrelationService
 import org.apache.hadoop.gateway.dispatch.HttpClientDispatch;
 import org.apache.hadoop.gateway.i18n.resources.ResourcesFactory;
 import org.apache.hadoop.test.log.CollectAppender;
+import org.apache.http.impl.client.DefaultHttpClient;
 import org.apache.log4j.spi.LoggingEvent;
 import org.easymock.EasyMock;
 import org.junit.After;
@@ -171,6 +172,7 @@ public class AuditLoggingTest {
     EasyMock.replay( outboundResponse );
 
     HttpClientDispatch dispatch = new HttpClientDispatch();
+    dispatch.setHttpClient(new DefaultHttpClient());
     try {
       dispatch.doGet( new URI( uri ), inboundRequest, outboundResponse );
       fail( "Expected exception while accessing to unreachable host" );

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java b/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java
index 06b5b2a..85836fc 100644
--- a/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java
+++ b/gateway-server/src/test/java/org/apache/hadoop/gateway/topology/xml/TopologyRulesModuleTest.java
@@ -17,11 +17,15 @@
  */
 package org.apache.hadoop.gateway.topology.xml;
 
+import org.apache.commons.collections.keyvalue.MultiKey;
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.commons.collections.map.MultiKeyMap;
 import org.apache.commons.digester3.Digester;
 import org.apache.commons.digester3.binder.DigesterLoader;
 import org.apache.hadoop.gateway.topology.Provider;
 import org.apache.hadoop.gateway.topology.Service;
 import org.apache.hadoop.gateway.topology.Topology;
+import org.apache.hadoop.gateway.topology.Version;
 import org.apache.hadoop.gateway.topology.builder.TopologyBuilder;
 import org.junit.After;
 import org.junit.Before;
@@ -72,7 +76,8 @@ public class TopologyRulesModuleTest {
 
     Service comp = topology.getServices().iterator().next();
     assertThat( comp, notNullValue() );
-    assertThat( comp.getRole(), is( "WEBHDFS" ) );
+    assertThat( comp.getRole(), is("WEBHDFS") );
+    assertThat( comp.getVersion().toString(), is( "2.4.0" ));
     assertThat( comp.getUrls().size(), is( 2 ) );
     assertThat( comp.getUrls(), hasItem( "http://host1:80/webhdfs" ) );
     assertThat( comp.getUrls(), hasItem( "http://host2:80/webhdfs" ) );
@@ -116,6 +121,7 @@ public class TopologyRulesModuleTest {
     assertThat( service.getName(), is( "test-service-name" ) );
     assertThat( service.getParams(), hasEntry( is( "test-service-param-name-1" ), is( "test-service-param-value-1" ) ) );
     assertThat( service.getParams(), hasEntry( is( "test-service-param-name-2" ), is( "test-service-param-value-2" ) ) );
+    assertThat( service.getVersion(), is( new Version(1,0,0)));
   }
 
 
@@ -136,7 +142,7 @@ public class TopologyRulesModuleTest {
     assertThat( topology.getServices().size(), is( 4 ) );
     assertThat( topology.getProviders().size(), is( 2 ) );
 
-    Service webhdfsService = topology.getService( "WEBHDFS", null );
+    Service webhdfsService = topology.getService( "WEBHDFS", null, null);
     assertThat( webhdfsService, notNullValue() );
     assertThat( webhdfsService.getRole(), is( "WEBHDFS" ) );
     assertThat( webhdfsService.getName(), nullValue() );
@@ -144,21 +150,21 @@ public class TopologyRulesModuleTest {
     assertThat( webhdfsService.getUrls(), hasItem( "http://host1:50070/webhdfs" ) );
     assertThat( webhdfsService.getUrls(), hasItem( "http://host2:50070/webhdfs" ) );
 
-    Service webhcatService = topology.getService( "WEBHCAT", null );
+    Service webhcatService = topology.getService( "WEBHCAT", null, null);
     assertThat( webhcatService, notNullValue() );
     assertThat( webhcatService.getRole(), is( "WEBHCAT" ) );
     assertThat( webhcatService.getName(), nullValue() );
     assertThat( webhcatService.getUrls().size(), is( 1 ) );
     assertThat( webhcatService.getUrls(), hasItem( "http://host:50111/templeton" ) );
 
-    Service oozieService = topology.getService( "OOZIE", null );
+    Service oozieService = topology.getService( "OOZIE", null, null);
     assertThat( oozieService, notNullValue() );
     assertThat( oozieService.getRole(), is( "OOZIE" ) );
     assertThat( oozieService.getName(), nullValue() );
     assertThat( webhcatService.getUrls().size(), is( 1 ) );
     assertThat( oozieService.getUrls(), hasItem( "http://host:11000/oozie" ) );
 
-    Service hiveService = topology.getService( "HIVE", null );
+    Service hiveService = topology.getService( "HIVE", null, null);
     assertThat( hiveService, notNullValue() );
     assertThat( hiveService.getRole(), is( "HIVE" ) );
     assertThat( hiveService.getName(), nullValue() );
@@ -217,5 +223,4 @@ public class TopologyRulesModuleTest {
     assertThat( service.getParams(), hasEntry( is( "test-service-param-name-1" ), is( "test-service-param-value-1" ) ) );
     assertThat( service.getParams(), hasEntry( is( "test-service-param-name-2" ), is( "test-service-param-value-2" ) ) );
   }
-
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml b/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml
index a7c476e..870015a 100644
--- a/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml
+++ b/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/service-param-topology-knox-format.xml
@@ -31,6 +31,7 @@
     <service>
         <role>test-service-role</role>
         <name>test-service-name</name>
+        <version>1.0.0</version>
         <url>test-service-scheme://test-service-host1:42/test-service-path</url>
         <url>test-service-scheme://test-service-host2:42/test-service-path</url>
         <param>

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/simple-topology-knox-format.xml
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/simple-topology-knox-format.xml b/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/simple-topology-knox-format.xml
index 46175d1..1a181f1 100644
--- a/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/simple-topology-knox-format.xml
+++ b/gateway-server/src/test/resources/org/apache/hadoop/gateway/topology/xml/simple-topology-knox-format.xml
@@ -63,6 +63,7 @@
 
     <service>
         <role>WEBHDFS</role>
+        <version>2.4.0</version>
         <url>http://host1:80/webhdfs</url>
         <url>http://host2:80/webhdfs</url>
     </service>

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/pom.xml b/gateway-service-definitions/pom.xml
new file mode 100644
index 0000000..004aed8
--- /dev/null
+++ b/gateway-service-definitions/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0"?>
+<project
+        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+        xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.knox</groupId>
+        <artifactId>gateway</artifactId>
+        <version>0.6.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>gateway-service-definitions</artifactId>
+    <name>gateway-service-definitions</name>
+    <description>The service definitions aka stacks.</description>
+    <licenses>
+        <license>
+            <name>The Apache Software License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>eclipselink</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.knox</groupId>
+            <artifactId>gateway-test-utils</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/CustomDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/CustomDispatch.java b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/CustomDispatch.java
new file mode 100644
index 0000000..7270a2b
--- /dev/null
+++ b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/CustomDispatch.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.service.definition;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType(name = "dispatch")
+public class CustomDispatch {
+
+  private String contributorName;
+
+  private String haContributorName;
+
+  private String className;
+
+  private String haClassName;
+
+  @XmlAttribute(name = "contributor-name")
+  public String getContributorName() {
+    return contributorName;
+  }
+
+  public void setContributorName(String contributorName) {
+    this.contributorName = contributorName;
+  }
+
+  @XmlAttribute(name = "ha-contributor-name")
+  public String getHaContributorName() {
+    return haContributorName;
+  }
+
+  public void setHaContributorName(String haContributorName) {
+    this.haContributorName = haContributorName;
+  }
+
+  @XmlAttribute(name = "classname")
+  public String getClassName() {
+    return className;
+  }
+
+  public void setClassName(String className) {
+    this.className = className;
+  }
+
+  @XmlAttribute(name = "ha-classname")
+  public String getHaClassName() {
+    return haClassName;
+  }
+
+  public void setHaClassName(String haContributorClassName) {
+    this.haClassName = haContributorClassName;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Policy.java
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Policy.java b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Policy.java
new file mode 100644
index 0000000..471aae5
--- /dev/null
+++ b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Policy.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.service.definition;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+public class Policy {
+
+  private String name;
+
+  private String role;
+
+  @XmlAttribute
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  @XmlAttribute
+  public String getRole() {
+    return role;
+  }
+
+  public void setRole(String role) {
+    this.role = role;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Rewrite.java
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Rewrite.java b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Rewrite.java
new file mode 100644
index 0000000..a7a3e3c
--- /dev/null
+++ b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Rewrite.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.service.definition;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType(name = "rewrite")
+public class Rewrite {
+
+  private String apply;
+
+  private String to;
+
+  @XmlAttribute
+  public String getApply() {
+    return apply;
+  }
+
+  public void setApply(String apply) {
+    this.apply = apply;
+  }
+
+  @XmlAttribute
+  public String getTo() {
+    return to;
+  }
+
+  public void setTo(String to) {
+    this.to = to;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Route.java
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Route.java b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Route.java
new file mode 100644
index 0000000..7112c2e
--- /dev/null
+++ b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/Route.java
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.service.definition;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlType;
+import java.util.List;
+
+@XmlType(name = "route")
+public class Route {
+
+  private String path;
+
+  private List<Rewrite> rewrites;
+
+  private List<Policy> policies;
+
+  private CustomDispatch dispatch;
+
+  @XmlAttribute
+  public String getPath() {
+    return path;
+  }
+
+  public void setPath(String path) {
+    this.path = path;
+  }
+
+  @XmlElement(name = "rewrite")
+  public List<Rewrite> getRewrites() {
+    return rewrites;
+  }
+
+  public void setRewrites(List<Rewrite> rewrites) {
+    this.rewrites = rewrites;
+  }
+
+  @XmlElement(name = "policy")
+  @XmlElementWrapper(name = "policies")
+  public List<Policy> getPolicies() {
+    return policies;
+  }
+
+  public void setPolicies(List<Policy> policies) {
+    this.policies = policies;
+  }
+
+  @XmlElement(name = "dispatch")
+  public CustomDispatch getDispatch() {
+    return dispatch;
+  }
+
+  public void setDispatch(CustomDispatch dispatch) {
+    this.dispatch = dispatch;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/ServiceDefinition.java
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/ServiceDefinition.java b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/ServiceDefinition.java
new file mode 100644
index 0000000..0e61b4a
--- /dev/null
+++ b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/ServiceDefinition.java
@@ -0,0 +1,142 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.gateway.service.definition;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement(name = "service")
+public class ServiceDefinition {
+
+  private String name;
+
+  private String role;
+
+  private String version;
+
+  private List<Route> routes;
+
+  private List<Policy> policies;
+
+  private CustomDispatch dispatch;
+
+  private List<PolicyBinding> policyBindings;
+
+  private CustomDispatch dispatch;
+
+  private List<PolicyBinding> policyBindings;
+
+  private CustomDispatch dispatch;
+
+  @XmlAttribute
+  public String getName() {
+    return name;
+  }
+
+  public void setName(String name) {
+    this.name = name;
+  }
+
+  @XmlAttribute
+  public String getRole() {
+    return role;
+  }
+
+  public void setRole(String role) {
+    this.role = role;
+  }
+
+  @XmlAttribute
+  public String getVersion() {
+    return version;
+  }
+
+  public void setVersion(String version) {
+    this.version = version;
+  }
+
+  @XmlElement(name = "route")
+  @XmlElementWrapper(name = "routes")
+  public List<Route> getRoutes() {
+    return routes;
+  }
+
+  public void setRoutes(List<Route> routes) {
+    this.routes = routes;
+  }
+
+  @XmlElement(name = "policy")
+  @XmlElementWrapper(name = "policies")
+  public List<Policy> getPolicies() {
+    return policies;
+  }
+
+  public void setPolicies(List<Policy> policies) {
+    this.policies = policies;
+  }
+
+  @XmlElement(name = "dispatch")
+  public CustomDispatch getDispatch() {
+    return dispatch;
+  }
+
+  public void setDispatch(CustomDispatch dispatch) {
+    this.dispatch = dispatch;
+  }
+
+  @XmlElement(name = "policy")
+  @XmlElementWrapper(name = "policies")
+  public List<PolicyBinding> getPolicyBindings() {
+    return policyBindings;
+  }
+
+  public void setPolicyBindings(List<PolicyBinding> policyBindings) {
+    this.policyBindings = policyBindings;
+  }
+
+  @XmlElement(name = "dispatch")
+  public CustomDispatch getDispatch() {
+    return dispatch;
+  }
+
+  public void setDispatch(CustomDispatch dispatch) {
+    this.dispatch = dispatch;
+  }
+
+  @XmlElement(name = "policy")
+  @XmlElementWrapper(name = "policies")
+  public List<PolicyBinding> getPolicyBindings() {
+    return policyBindings;
+  }
+
+  public void setPolicyBindings(List<PolicyBinding> policyBindings) {
+    this.policyBindings = policyBindings;
+  }
+
+  @XmlElement(name = "dispatch")
+  public CustomDispatch getDispatch() {
+    return dispatch;
+  }
+
+  public void setDispatch(CustomDispatch dispatch) {
+    this.dispatch = dispatch;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/src/main/resources/services/hbase/0.98.0/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/hbase/0.98.0/rewrite.xml b/gateway-service-definitions/src/main/resources/services/hbase/0.98.0/rewrite.xml
new file mode 100644
index 0000000..64ca750
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/hbase/0.98.0/rewrite.xml
@@ -0,0 +1,62 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<rules>
+
+    <rule dir="IN" name="WEBHBASE/webhbase/root/inbound" pattern="*://*:*/**/hbase/?{**}">
+        <rewrite template="{$serviceUrl[WEBHBASE]}/?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="WEBHBASE/webhbase/path/inbound" pattern="*://*:*/**/hbase/{path=**}?{**}">
+        <rewrite template="{$serviceUrl[WEBHBASE]}/{path=**}?{**}"/>
+    </rule>
+
+    <rule name="WEBHBASE/webhbase/location/outbound">
+        <match pattern="*://*:*/{path=**}?{**}"/>
+        <rewrite template="{$frontend[url]}/hbase/{path=**}?{**}"/>
+    </rule>
+
+    <rule name="WEBHBASE/webhbase/address/outbound">
+        <match pattern="{host}:{port}"/>
+        <rewrite template="{$frontend[url]}/hbase-region?host={host}?port={port}"/>
+        <encrypt-query/>
+    </rule>
+
+    <filter name="WEBHBASE/webhbase/headers/outbound">
+        <content type="application/x-http-headers">
+            <apply path="Location" rule="WEBHBASE/webhbase/location/outbound"/>
+        </content>
+    </filter>
+
+    <filter name="WEBHBASE/webhbase/status/outbound">
+        <content type="*/json">
+            <apply path="$[LiveNodes][*][name]" rule="WEBHBASE/webhbase/address/outbound"/>
+        </content>
+        <content type="*/xml">
+            <apply path="/ClusterStatus/LiveNodes/Node/@name" rule="WEBHBASE/webhbase/address/outbound"/>
+        </content>
+    </filter>
+
+    <filter name="WEBHBASE/webhbase/regions/outbound">
+        <content type="*/json">
+            <apply path="$[Region][*][location]" rule="WEBHBASE/webhbase/address/outbound"/>
+        </content>
+        <content type="*/xml">
+            <apply path="/TableInfo/Region/@location" rule="WEBHBASE/webhbase/address/outbound"/>
+        </content>
+    </filter>
+
+</rules>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/src/main/resources/services/hbase/0.98.0/service.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/hbase/0.98.0/service.xml b/gateway-service-definitions/src/main/resources/services/hbase/0.98.0/service.xml
new file mode 100644
index 0000000..e03bca7
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/hbase/0.98.0/service.xml
@@ -0,0 +1,33 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<service role="WEBHBASE" name="webhbase" version="0.98.0">
+    <routes>
+        <route path="/hbase/?**">
+            <rewrite apply="WEBHBASE/webhbase/headers/outbound" to="response.headers"/>
+        </route>
+        <route path="/hbase/**?**">
+            <rewrite apply="WEBHBASE/webhbase/headers/outbound" to="response.headers"/>
+        </route>
+        <route path="/hbase/status/cluster?**">
+            <rewrite apply="WEBHBASE/webhbase/status/outbound" to="response.body"/>
+        </route>
+        <route path="/hbase/*/regions?**">
+            <rewrite apply="WEBHBASE/webhbase/regions/outbound" to="response.body"/>
+        </route>
+    </routes>
+    <dispatch classname="org.apache.hadoop.gateway.hbase.HBaseHttpClientDispatch"/>
+</service>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/src/main/resources/services/hive/0.13.0/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/hive/0.13.0/rewrite.xml b/gateway-service-definitions/src/main/resources/services/hive/0.13.0/rewrite.xml
new file mode 100644
index 0000000..765e017
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/hive/0.13.0/rewrite.xml
@@ -0,0 +1,21 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<rules>
+    <rule dir="IN" name="HIVE/hive/inbound" pattern="*://*:*/**/hive">
+        <rewrite template="{$serviceUrl[HIVE]}"/>
+    </rule>
+</rules>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/ea28bf22/gateway-service-definitions/src/main/resources/services/hive/0.13.0/service.xml
----------------------------------------------------------------------
diff --git a/gateway-service-definitions/src/main/resources/services/hive/0.13.0/service.xml b/gateway-service-definitions/src/main/resources/services/hive/0.13.0/service.xml
new file mode 100644
index 0000000..32d1560
--- /dev/null
+++ b/gateway-service-definitions/src/main/resources/services/hive/0.13.0/service.xml
@@ -0,0 +1,22 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<service role="HIVE" name="hive" version="0.13.0">
+    <routes>
+        <route path="/hive"/>
+    </routes>
+    <dispatch classname="org.apache.hadoop.gateway.hive.HiveHttpClientDispatch"/>
+</service>


Mime
View raw message