http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/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..cbb9309
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/java/org/apache/hadoop/gateway/service/definition/ServiceDefinition.java
@@ -0,0 +1,96 @@
+/**
+ * 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;
+
+  @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;
+  }
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/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/0d9fa0da/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/0d9fa0da/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/0d9fa0da/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>

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/main/resources/services/oozie/4.0.0/rewrite.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/main/resources/services/oozie/4.0.0/rewrite.xml
 
b/gateway-service-definitions/src/main/resources/services/oozie/4.0.0/rewrite.xml
new file mode 100644
index 0000000..d3c52bb
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/oozie/4.0.0/rewrite.xml
@@ -0,0 +1,122 @@
+<!--
+   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="OOZIE/oozie/root" 
pattern="*://*:*/**/oozie/{**}?{**}">
+        <rewrite template="{$serviceUrl[OOZIE]}/{**}?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="OOZIE/oozie/v1" 
pattern="*://*:*/**/oozie/v1/{**}?{**}">
+        <rewrite template="{$serviceUrl[OOZIE]}/v1/{**}?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="OOZIE/oozie/v2" 
pattern="*://*:*/**/oozie/v2/{**}?{**}">
+        <rewrite template="{$serviceUrl[OOZIE]}/v2/{**}?{**}"/>
+    </rule>
+
+    <rule name="OOZIE/oozie/user-name">
+        <rewrite template="{$username}"/>
+    </rule>
+
+    <rule name="OOZIE/oozie/name-node-url">
+        <rewrite template="hdfs://{$serviceMappedAddr[NAMENODE]}"/>
+    </rule>
+
+    <rule name="OOZIE/oozie/job-tracker-address">
+        <rewrite template="{$serviceMappedAddr[JOBTRACKER]}"/>
+    </rule>
+
+    <rule name="OOZIE/oozie/hdfs-path" flow="OR">
+        <match pattern="/~">
+            <rewrite 
template="hdfs://{$serviceMappedHost[NAMENODE]}:{$servicePort[NAMENODE]}/user/{$username}"/>
+        </match>
+        <match pattern="/~/{path=**}">
+            <rewrite 
template="hdfs://{$serviceMappedHost[NAMENODE]}:{$servicePort[NAMENODE]}/user/{$username}/{path=**}"/>
+        </match>
+        <match pattern="{path=**}">
+            <rewrite 
template="hdfs://{$serviceMappedHost[NAMENODE]}:{$servicePort[NAMENODE]}/{path=**}"/>
+        </match>
+    </rule>
+
+    <filter name="OOZIE/oozie/configuration">
+        <content type="*/xml">
+            <buffer path="/configuration/property">
+                <detect path="name" value="user.name">
+                    <apply path="value" rule="OOZIE/oozie/user-name"/>
+                </detect>
+                <detect path="name" value="nameNode">
+                    <apply path="value" rule="OOZIE/oozie/name-node-url"/>
+                </detect>
+                <detect path="name" value="jobTracker">
+                    <apply path="value" 
rule="OOZIE/oozie/job-tracker-address"/>
+                </detect>
+                <detect path="name" value="fs.default.name">
+                    <apply path="value" rule="OOZIE/oozie/name-node-url"/>
+                </detect>
+                <detect path="name" value="fs.defaultFS">
+                    <apply path="value" rule="OOZIE/oozie/name-node-url"/>
+                </detect>
+                <detect path="name" value="oozie.wf.application.path">
+                    <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
+                </detect>
+                <detect path="name" value="oozie.coord.application.path">
+                    <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
+                </detect>
+                <detect path="name" value="oozie.bundle.application.path">
+                    <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
+                </detect>
+                <detect path="name" value="oozie.libpath">
+                    <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
+                </detect>
+                <detect path="name" value="mapreduce.job.user.name">
+                    <apply path="value" rule="OOZIE/oozie/user-name"/>
+                </detect>
+                <detect path="name" value="mapred.job.tracker">
+                    <apply path="value" 
rule="OOZIE/oozie/job-tracker-address"/>
+                </detect>
+                <detect path="name" value="mapred.input.dir">
+                    <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
+                </detect>
+                <detect path="name" value="inputDir">
+                    <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
+                </detect>
+                <detect path="name" value="mapred.output.dir">
+                    <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
+                </detect>
+                <detect path="name" value="outputDir">
+                    <apply path="value" rule="OOZIE/oozie/hdfs-path"/>
+                </detect>
+            </buffer>
+        </content>
+        <content type="*/json">
+            <apply path="$[user.name]" rule="OOZIE/oozie/user-name"/>
+            <apply path="$[nameNode]" rule="OOZIE/oozie/name-node-url"/>
+            <apply path="$[jobTracker]" rule="OOZIE/oozie/job-tracker-addr"/>
+            <apply path="$[fs.default.name]" rule="OOZIE/oozie/name-node-url"/>
+            <apply path="$[fs.defaultFS]" rule="OOZIE/oozie/name-node-url"/>
+            <apply path="$[oozie.wf.application.path]" 
rule="OOZIE/oozie/hdfs-path"/>
+            <apply path="$[oozie.coord.application.path]" 
rule="OOZIE/oozie/hdfs-path"/>
+            <apply path="$[oozie.bundle.application.path]" 
rule="OOZIE/oozie/hdfs-path"/>
+            <apply path="$[oozie.libpath]" rule="OOZIE/oozie/hdfs-path"/>
+            <apply path="$[mapreduce.job.user.name]" 
rule="OOZIE/oozie/user-name"/>
+            <apply path="$[mapred.job.tracker]" 
rule="OOZIE/oozie/job-tracker-address"/>
+            <apply path="$[mapred.input.dir]" rule="OOZIE/oozie/hdfs-path"/>
+            <apply path="$[mapred.output.dir]" rule="OOZIE/oozie/hdfs-path"/>
+        </content>
+    </filter>
+
+</rules>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/main/resources/services/oozie/4.0.0/service.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/main/resources/services/oozie/4.0.0/service.xml
 
b/gateway-service-definitions/src/main/resources/services/oozie/4.0.0/service.xml
new file mode 100644
index 0000000..7bc7eb3
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/oozie/4.0.0/service.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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="OOZIE" name="oozie" version="4.0.0">
+    <routes>
+        <route path="/oozie/**?**">
+            <rewrite apply="OOZIE/oozie/configuration" to="request.body"/>
+        </route>
+        <route path="/oozie/v1/**?**">
+            <rewrite apply="OOZIE/oozie/configuration" to="request.body"/>
+        </route>
+        <route path="/oozie/v2/**?**">
+            <rewrite apply="OOZIE/oozie/configuration" to="request.body"/>
+        </route>
+    </routes>
+</service>

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/main/resources/services/webhcat/0.13.0/rewrite.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/main/resources/services/webhcat/0.13.0/rewrite.xml
 
b/gateway-service-definitions/src/main/resources/services/webhcat/0.13.0/rewrite.xml
new file mode 100644
index 0000000..558abb4
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/webhcat/0.13.0/rewrite.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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="WEBHCAT/webhcat/root/inbound" 
pattern="*://*:*/**/templeton/v1/?{**}">
+      <rewrite template="{$serviceUrl[WEBHCAT]}/v1/?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="WEBHCAT/webhcat/path/inbound" 
pattern="*://*:*/**/templeton/v1/{path=**}?{**}">
+      <rewrite template="{$serviceUrl[WEBHCAT]}/v1/{path=**}?{**}"/>
+    </rule>
+
+</rules>

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/main/resources/services/webhcat/0.13.0/service.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/main/resources/services/webhcat/0.13.0/service.xml
 
b/gateway-service-definitions/src/main/resources/services/webhcat/0.13.0/service.xml
new file mode 100644
index 0000000..c550dc1
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/webhcat/0.13.0/service.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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="WEBHCAT" name="webhcat" version="0.13.0">
+    <routes>
+        <route path="/templeton/v1/?**"/>
+        <route path="/templeton/v1/**?**"/>
+    </routes>
+</service>

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/main/resources/services/webhdfs/2.4.0/rewrite.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/main/resources/services/webhdfs/2.4.0/rewrite.xml
 
b/gateway-service-definitions/src/main/resources/services/webhdfs/2.4.0/rewrite.xml
new file mode 100644
index 0000000..efbd93d
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/webhdfs/2.4.0/rewrite.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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="OUT" name="WEBHDFS/webhdfs/outbound" 
pattern="hdfs://*:*/{path=**}?{**}">
+        <rewrite template="{$frontend[url]}/webhdfs/v1/{path=**}?{**}"/>
+    </rule>
+
+    <rule dir="OUT" name="WEBHDFS/webhdfs/outbound" 
pattern="webhdfs://*:*/{path=**}?{**}">
+        <rewrite template="{$frontend[url]}/webhdfs/v1/{path=**}?{**}"/>
+    </rule>
+
+    <rule dir="OUT" name="WEBHDFS/webhdfs/outbound/namenode/headers/location">
+        <match pattern="{scheme}://{host}:{port}/{path=**}?{**}"/>
+        <rewrite 
template="{$frontend[url]}/webhdfs/data/v1/{path=**}?{scheme}?host={$hostmap(host)}?{port}?{**}"/>
+        <encrypt-query/>
+    </rule>
+
+    <rule dir="IN" name="WEBHDFS/webhdfs/inbound/hdfs" 
pattern="hdfs:/{path=**}?{**}">
+        <rewrite template="{$serviceMappedUrl[NAMENODE]}/{path=**}?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="WEBHDFS/webhdfs/inbound/webhdfs" 
pattern="webhdfs:/{path=**}?{**}">
+        <rewrite template="{$serviceUrl[WEBHDFS]}/{path=**}?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="WEBHDFS/webhdfs/inbound/namenode/root" 
pattern="*://*:*/**/webhdfs/{version}/?{**}">
+        <rewrite template="{$serviceUrl[WEBHDFS]}/{version}/?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="WEBHDFS/webhdfs/inbound/namenode/file" 
pattern="*://*:*/**/webhdfs/{version}/{path=**}?{**}">
+        <rewrite template="{$serviceUrl[WEBHDFS]}/{version}/{path=**}?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="WEBHDFS/webhdfs/inbound/namenode/home" 
pattern="*://*:*/**/webhdfs/{version}/~?{**}">
+        <rewrite 
template="{$serviceUrl[WEBHDFS]}/{version}/user/{$username}?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="WEBHDFS/webhdfs/inbound/namenode/home/file" 
pattern="*://*:*/**/webhdfs/{version}/~/{path=**}?{**}">
+        <rewrite 
template="{$serviceUrl[WEBHDFS]}/{version}/user/{$username}/{path=**}?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="WEBHDFS/webhdfs/inbound/datanode">
+        <decrypt-query/>
+        <match 
pattern="*://*:*/**/webhdfs/data/*/{path=**}?{scheme}?{host}?{port}?{**}"/>
+        <rewrite template="{scheme}://{host}:{port}/{path=**}?{**}"/>
+    </rule>
+
+    <filter name="WEBHDFS/webhdfs/outbound/namenode/headers">
+        <content type="application/x-http-headers">
+            <apply path="Location" 
rule="WEBHDFS/webhdfs/outbound/namenode/headers/location"/>
+        </content>
+    </filter>
+
+</rules>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/main/resources/services/webhdfs/2.4.0/service.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/main/resources/services/webhdfs/2.4.0/service.xml
 
b/gateway-service-definitions/src/main/resources/services/webhdfs/2.4.0/service.xml
new file mode 100644
index 0000000..2470175
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/webhdfs/2.4.0/service.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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="WEBHDFS" name="webhdfs" version="2.4.0">
+    <routes>
+        <route path="/webhdfs/v1/?**">
+            <rewrite apply="WEBHDFS/webhdfs/inbound/namenode/root" 
to="request.url"/>
+        </route>
+        <route path="/webhdfs/v1/**?**">
+            <rewrite apply="WEBHDFS/webhdfs/inbound/namenode/file" 
to="request.url"/>
+            <rewrite apply="WEBHDFS/webhdfs/outbound/namenode/headers" 
to="response.headers"/>
+        </route>
+        <route path="/webhdfs/v1/~?**">
+            <rewrite apply="WEBHDFS/webhdfs/inbound/namenode/home" 
to="request.url"/>
+        </route>
+        <route path="/webhdfs/v1/~/**?**">
+            <rewrite apply="WEBHDFS/webhdfs/inbound/namenode/home/file" 
to="request.url"/>
+            <rewrite apply="WEBHDFS/webhdfs/outbound/namenode/headers" 
to="response.headers"/>
+        </route>
+        <route path="/webhdfs/data/v1/**?**">
+            <rewrite apply="WEBHDFS/webhdfs/inbound/datanode" 
to="request.url"/>
+            <dispatch contributor-name="http-client" />
+        </route>
+    </routes>
+    <dispatch classname="org.apache.hadoop.gateway.hdfs.dispatch.HdfsDispatch" 
ha-classname="org.apache.hadoop.gateway.hdfs.dispatch.WebHdfsHaHttpClientDispatch"/>
+</service>

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/main/resources/services/yarn-rm/2.5.0/rewrite.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/main/resources/services/yarn-rm/2.5.0/rewrite.xml
 
b/gateway-service-definitions/src/main/resources/services/yarn-rm/2.5.0/rewrite.xml
new file mode 100644
index 0000000..95ce2a3
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/yarn-rm/2.5.0/rewrite.xml
@@ -0,0 +1,193 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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="RESOURCEMANAGER/resourcemanager/inbound/root" 
pattern="*://*:*/**/resourcemanager/v1/?{**}">
+        <rewrite template="{$serviceUrl[RESOURCEMANAGER]}/v1/?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="RESOURCEMANAGER/resourcemanager/inbound/path" 
pattern="*://*:*/**/resourcemanager/v1/{path=**}?{**}">
+        <rewrite template="{$serviceUrl[RESOURCEMANAGER]}/v1/{path=**}/?{**}"/>
+    </rule>
+
+    <rule dir="IN" name="RESOURCEMANAGER/resourcemanager/inbound/proxy" 
pattern="*://*:*/**/resourcemanager/proxy/{appid=*}/ws/v1/{path=**}?{**}">
+        <decrypt-query/>
+        <match 
pattern="*://*:*/**/resourcemanager/proxy/{appid=*}/ws/v1/{path=**}?{scheme}?{host}?{port}?{**}"/>
+        <rewrite 
template="{scheme}://{host}:{port}/proxy/{appid=*}/ws/v1/{path=**}?{**}"/>
+    </rule>
+
+    <rule dir="OUT" name="RESOURCEMANAGER/resourcemanager/url/outbound">
+        <match pattern="*://*:*/**?**"/>
+               <rewrite template=""/>
+    </rule>
+    <rule dir="OUT" 
name="RESOURCEMANAGER/resourcemanager/trackingUrlHistory/outbound">
+        <match 
pattern="{scheme}://{host}:{port}/proxy/{appid=*}/jobhistory/job/**"/>
+               <rewrite template=""/>
+    </rule>
+    <rule dir="OUT" 
name="RESOURCEMANAGER/resourcemanager/trackingUrlAM/outbound">
+        <match pattern="{scheme}://{host}:{port}/proxy/{appid=*}"/>
+               <rewrite 
template="{$frontend[url]}/resourcemanager/proxy/{appid=*}?{scheme}?host={$hostmap(host)}?{port}?{**}"/>
+               <encrypt-query/>
+    </rule>
+    <rule dir="OUT" name="RESOURCEMANAGER/resourcemanager/hostport/outbound">
+        <match pattern="*:*"/>
+               <rewrite template=""/>
+    </rule>
+    <rule dir="OUT" name="RESOURCEMANAGER/resourcemanager/logsLink/outbound">
+        <match pattern="//*:*/**?**"/>
+               <rewrite template=""/>
+    </rule>
+    <rule dir="OUT" name="RESOURCEMANAGER/resourcemanager/host/outbound">
+               <rewrite template=""/>
+    </rule>
+    <rule dir="OUT" name="RESOURCEMANAGER/resourcemanager/nodeId/outbound">
+        <match pattern="{host=*}:{port=*}"/>
+        <encrypt template="{host}:{port}" param="encaddr"/>
+        <rewrite template="{encaddr}"/>
+    </rule>
+    <rule dir="IN" name="RESOURCEMANAGER/resourcemanager/nodeId/inbound">
+        <match 
pattern="*://*:*/**/resourcemanager/v1/cluster/nodes/{addr=*}?{**}"/>
+        <decrypt param="addr"/>
+        <rewrite 
template="{$serviceUrl[RESOURCEMANAGER]}/v1/cluster/nodes/{addr}?{**}"/>
+    </rule>
+
+    <filter name="RESOURCEMANAGER/resourcemanager/apps/outbound">
+        <content type="*/json">
+               <buffer path="$.apps.app[*]">
+                       <detect path="$.trackingUI" value="History">
+                                       <apply path="$.trackingUrl" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+                               </detect>
+                               <detect path="$.trackingUI" 
value="ApplicationMaster">
+                                       <apply path="$.trackingUrl" 
rule="RESOURCEMANAGER/resourcemanager/trackingUrlAM/outbound"/>
+                               </detect>
+                               <apply path="$.amContainerLogs" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+               <apply path="$.amHostHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+               </buffer>
+        </content>
+        <content type="*/xml">
+               <buffer path="/apps/app">
+                       <detect path="trackingUI" value="History">
+                                       <apply path="trackingUrl" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+                               </detect>
+                               <detect path="trackingUI" 
value="ApplicationMaster">
+                                       <apply path="trackingUrl" 
rule="RESOURCEMANAGER/resourcemanager/trackingUrlAM/outbound"/>
+                               </detect>
+                               <apply path="amContainerLogs" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+               <apply path="amHostHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+               </buffer>
+        </content>
+    </filter>
+
+    <filter name="RESOURCEMANAGER/resourcemanager/app/outbound">
+        <content type="*/json">
+               <buffer path="$.app">
+                       <detect path="$.trackingUI" value="History">
+                               <apply path="$.trackingUrl" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+                       </detect>
+                       <detect path="$.trackingUI" value="ApplicationMaster">
+                               <apply path="$.trackingUrl" 
rule="RESOURCEMANAGER/resourcemanager/trackingUrlAM/outbound"/>
+                       </detect>
+                   <apply path="$.amContainerLogs" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+                   <apply path="$.amHostHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            </buffer>
+        </content>
+        <content type="*/xml">
+               <buffer path="/app">
+                       <detect path="trackingUI" value="History">
+                               <apply path="trackingUrl" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+                       </detect>
+                       <detect path="trackingUI" value="ApplicationMaster">
+                               <apply path="trackingUrl" 
rule="RESOURCEMANAGER/resourcemanager/trackingUrlAM/outbound"/>
+                       </detect>
+                   <apply path="amContainerLogs" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+                   <apply path="amHostHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            </buffer>
+        </content>
+    </filter>
+
+    <filter name="RESOURCEMANAGER/resourcemanager/appattempts/outbound">
+        <content type="*/json">
+            <apply path="$.appAttempts.appAttempt[*].nodeHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            <apply path="$.appAttempts.appAttempt[*].logsLink" 
rule="RESOURCEMANAGER/resourcemanager/logsLink/outbound"/>
+            <apply path="$.appAttempts.appAttempt[*].nodeId" 
rule="RESOURCEMANAGER/resourcemanager/nodeId/outbound"/>
+        </content>
+        <content type="*/xml">
+            <apply path="/appAttempts/appAttempt/nodeHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            <apply path="/appAttempts/appAttempt/logsLink" 
rule="RESOURCEMANAGER/resourcemanager/logsLink/outbound"/>
+            <apply path="/appAttempts/appAttempt/nodeId" 
rule="RESOURCEMANAGER/resourcemanager/nodeId/outbound"/>
+        </content>
+    </filter>
+
+    <filter name="RESOURCEMANAGER/resourcemanager/nodes/outbound">
+        <content type="*/json">
+            <apply path="$.nodes.node[*].nodeHTTPAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            <apply path="$.nodes.node[*].nodeHostName" 
rule="RESOURCEMANAGER/resourcemanager/host/outbound"/>
+            <apply path="$.nodes.node[*].id" 
rule="RESOURCEMANAGER/resourcemanager/nodeId/outbound"/>
+        </content>
+        <content type="*/xml">
+            <apply path="/nodes/node/nodeHTTPAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            <apply path="/nodes/node/nodeHostName" 
rule="RESOURCEMANAGER/resourcemanager/host/outbound"/>
+            <apply path="/nodes/node/id" 
rule="RESOURCEMANAGER/resourcemanager/nodeId/outbound"/>
+        </content>
+    </filter>
+
+    <filter name="RESOURCEMANAGER/resourcemanager/node/outbound">
+        <content type="*/json">
+            <apply path="$.node.nodeHTTPAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            <apply path="$.node.nodeHostName" 
rule="RESOURCEMANAGER/resourcemanager/host/outbound"/>
+            <apply path="$.node.id" 
rule="RESOURCEMANAGER/resourcemanager/nodeId/outbound"/>
+        </content>
+        <content type="*/xml">
+            <apply path="/node/nodeHTTPAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            <apply path="/node/nodeHostName" 
rule="RESOURCEMANAGER/resourcemanager/host/outbound"/>
+            <apply path="/node/id" 
rule="RESOURCEMANAGER/resourcemanager/nodeId/outbound"/>
+        </content>
+    </filter>
+
+    <filter name="RESOURCEMANAGER/resourcemanager/proxy/jobattempts/outbound">
+        <content type="*/json">
+            <apply path="$.jobAttempts.jobAttempt[*].nodeHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            <apply path="$.jobAttempts.jobAttempt[*].nodeId" 
rule="RESOURCEMANAGER/resourcemanager/nodeId/outbound"/>
+            <apply path="$.jobAttempts.jobAttempt[*].logsLink" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+        </content>
+        <content type="*/xml">
+            <apply path="/jobAttempts/jobAttempt/nodeHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+            <apply path="/jobAttempts/jobAttempt/nodeId" 
rule="RESOURCEMANAGER/resourcemanager/nodeId/outbound"/>
+            <apply path="/jobAttempts/jobAttempt/logsLink" 
rule="RESOURCEMANAGER/resourcemanager/url/outbound"/>
+        </content>
+    </filter>
+
+    <filter name="RESOURCEMANAGER/resourcemanager/proxy/taskattempts/outbound">
+        <content type="*/json">
+            <apply path="$.taskAttempts.taskAttempt[*].nodeHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+        </content>
+        <content type="*/xml">
+            <apply path="/taskAttempts/taskAttempt/nodeHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+        </content>
+    </filter>
+
+    <filter name="RESOURCEMANAGER/resourcemanager/proxy/taskattempt/outbound">
+        <content type="*/json">
+            <apply path="$.taskAttempt.nodeHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+        </content>
+        <content type="*/xml">
+            <apply path="/taskAttempt/nodeHttpAddress" 
rule="RESOURCEMANAGER/resourcemanager/hostport/outbound"/>
+        </content>
+    </filter>
+
+</rules>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/main/resources/services/yarn-rm/2.5.0/service.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/main/resources/services/yarn-rm/2.5.0/service.xml
 
b/gateway-service-definitions/src/main/resources/services/yarn-rm/2.5.0/service.xml
new file mode 100644
index 0000000..73fb771
--- /dev/null
+++ 
b/gateway-service-definitions/src/main/resources/services/yarn-rm/2.5.0/service.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+   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="RESOURCEMANAGER" name="resourcemanager" version="2.5.0">
+    <routes>
+        <route path="/resourcemanager/v1/cluster/"/>
+        <route path="/resourcemanager/v1/cluster/**?**"/>
+        <route path="/resourcemanager/v1/cluster/apps?**">
+            <rewrite apply="RESOURCEMANAGER/resourcemanager/apps/outbound" 
to="response.body"/>
+        </route>
+        <route path="/resourcemanager/v1/cluster/apps?**">
+            <rewrite apply="RESOURCEMANAGER/resourcemanager/apps/outbound" 
to="response.body"/>
+        </route>
+        <route path="/resourcemanager/v1/cluster/apps/*?**">
+            <rewrite apply="RESOURCEMANAGER/resourcemanager/app/outbound" 
to="response.body"/>
+        </route>
+        <route path="/resourcemanager/v1/cluster/apps/*/appattempts?**">
+            <rewrite 
apply="RESOURCEMANAGER/resourcemanager/appattempts/outbound" 
to="response.body"/>
+        </route>
+        <route path="/resourcemanager/v1/cluster/nodes?**">
+            <rewrite apply="RESOURCEMANAGER/resourcemanager/nodes/outbound" 
to="response.body"/>
+        </route>
+        <route path="/resourcemanager/v1/cluster/nodes/*?**">
+            <rewrite apply="RESOURCEMANAGER/resourcemanager/nodeId/inbound" 
to="request.url"/>
+            <rewrite apply="RESOURCEMANAGER/resourcemanager/node/outbound" 
to="response.body"/>
+        </route>
+        <route path="/resourcemanager/proxy/*/ws/v1/**?**">
+            <rewrite apply="RESOURCEMANAGER/resourcemanager/inbound/proxy" 
to="request.url"/>
+        </route>
+        <route 
path="/resourcemanager/proxy/*/ws/v1/mapreduce/jobs/*/jobattempts">
+            <rewrite 
apply="RESOURCEMANAGER/resourcemanager/proxy/jobattempts/outbound" 
to="response.body"/>
+        </route>
+        <route 
path="/resourcemanager/proxy/*/ws/v1/mapreduce/jobs/*/tasks/*/attempts">
+            <rewrite 
apply="RESOURCEMANAGER/resourcemanager/proxy/taskattempts/outbound" 
to="response.body"/>
+        </route>
+        <route 
path="/resourcemanager/proxy/*/ws/v1/mapreduce/jobs/*/tasks/*/attempts/*">
+            <rewrite 
apply="RESOURCEMANAGER/resourcemanager/proxy/taskattempt/outbound" 
to="response.body"/>
+        </route>
+    </routes>
+</service>

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/test/java/org/apache/hadoop/gateway/service/definition/ServiceDefinitionTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/test/java/org/apache/hadoop/gateway/service/definition/ServiceDefinitionTest.java
 
b/gateway-service-definitions/src/test/java/org/apache/hadoop/gateway/service/definition/ServiceDefinitionTest.java
new file mode 100644
index 0000000..5d1a544
--- /dev/null
+++ 
b/gateway-service-definitions/src/test/java/org/apache/hadoop/gateway/service/definition/ServiceDefinitionTest.java
@@ -0,0 +1,86 @@
+/**
+ * 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 org.junit.Test;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import java.net.URL;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class ServiceDefinitionTest {
+
+  @Test
+  public void testUnmarshalling() throws Exception {
+    JAXBContext context = JAXBContext.newInstance(ServiceDefinition.class);
+    Unmarshaller unmarshaller = context.createUnmarshaller();
+    URL url = ClassLoader.getSystemResource("services/foo/1.0.0/service.xml");
+    ServiceDefinition definition = (ServiceDefinition) 
unmarshaller.unmarshal(url.openStream());
+    assertEquals("foo", definition.getName());
+    assertEquals("FOO", definition.getRole());
+    assertEquals("1.0.0", definition.getVersion());
+    assertEquals("custom-client", 
definition.getDispatch().getContributorName());
+    assertEquals("ha-client", definition.getDispatch().getHaContributorName());
+    List<Policy> policies = definition.getPolicies();
+    assertEquals(5, policies.size());
+    String[] policyOrder = new String[]{"webappsec", "authentication", 
"rewrite", "identity-assertion", "authorization"};
+    for (int i=0; i< policyOrder.length; i++ ) {
+      assertEquals(policyOrder[i], policies.get(i).getRole());
+    }
+    List<Route> routes = definition.getRoutes();
+    assertNotNull(routes);
+    assertEquals(1, routes.size());
+    Route route = routes.get(0);
+    assertEquals("/foo/?**", route.getPath());
+    assertEquals("http-client", route.getDispatch().getContributorName());
+    policies = route.getPolicies();
+    assertEquals(5, policies.size());
+    policyOrder = new String[]{"webappsec", "federation", 
"identity-assertion", "authorization", "rewrite"};
+    for (int i=0; i< policyOrder.length; i++ ) {
+      assertEquals(policyOrder[i], policies.get(i).getRole());
+    }
+  }
+
+  @Test
+  public void testUnmarshallingCommonServices() throws Exception {
+    JAXBContext context = JAXBContext.newInstance(ServiceDefinition.class);
+    Unmarshaller unmarshaller = context.createUnmarshaller();
+    URL url = 
ClassLoader.getSystemResource("services/yarn-rm/2.5.0/service.xml");
+    ServiceDefinition definition = (ServiceDefinition) 
unmarshaller.unmarshal(url.openStream());
+    assertEquals("resourcemanager", definition.getName());
+    assertEquals("RESOURCEMANAGER", definition.getRole());
+    assertEquals("2.5.0", definition.getVersion());
+    List<Route> routes = definition.getRoutes();
+    assertNotNull(routes);
+    assertEquals(12, routes.size());
+    assertNotNull(routes.get(0).getPath());
+    url = ClassLoader.getSystemResource("services/hbase/0.98.0/service.xml");
+    definition = (ServiceDefinition) unmarshaller.unmarshal(url.openStream());
+    assertNotNull(definition.getDispatch());
+    assertEquals("org.apache.hadoop.gateway.hbase.HBaseHttpClientDispatch", 
definition.getDispatch().getClassName());
+    url = ClassLoader.getSystemResource("services/webhdfs/2.4.0/service.xml");
+    definition = (ServiceDefinition) unmarshaller.unmarshal(url.openStream());
+    assertNotNull(definition.getDispatch());
+    assertEquals("org.apache.hadoop.gateway.hdfs.dispatch.HdfsDispatch", 
definition.getDispatch().getClassName());
+    
assertEquals("org.apache.hadoop.gateway.hdfs.dispatch.WebHdfsHaHttpClientDispatch",
 definition.getDispatch().getHaClassName());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/test/resources/services/foo/1.0.0/rewrite.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/test/resources/services/foo/1.0.0/rewrite.xml 
b/gateway-service-definitions/src/test/resources/services/foo/1.0.0/rewrite.xml
new file mode 100644
index 0000000..761bd4b
--- /dev/null
+++ 
b/gateway-service-definitions/src/test/resources/services/foo/1.0.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="FOO/foo/inbound" pattern="*://*:*/**/foo">
+        <rewrite template="{$serviceUrl[FOO]}"/>
+    </rule>
+</rules>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-definitions/src/test/resources/services/foo/1.0.0/service.xml
----------------------------------------------------------------------
diff --git 
a/gateway-service-definitions/src/test/resources/services/foo/1.0.0/service.xml 
b/gateway-service-definitions/src/test/resources/services/foo/1.0.0/service.xml
new file mode 100644
index 0000000..21a10f1
--- /dev/null
+++ 
b/gateway-service-definitions/src/test/resources/services/foo/1.0.0/service.xml
@@ -0,0 +1,39 @@
+<!--
+   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="FOO" name="foo" version="1.0.0">
+    <policies>
+        <policy role="webappsec"/>
+        <policy role="authentication"/>
+        <policy role="rewrite"/>
+        <policy role="identity-assertion"/>
+        <policy role="authorization"/>
+    </policies>
+    <routes>
+        <route path="/foo/?**">
+            <rewrite apply="FOO/foo/inbound" to="request.url"/>
+            <policies>
+                <policy role="webappsec"/>
+                <policy role="federation"/>
+                <policy role="identity-assertion"/>
+                <policy role="authorization"/>
+                <policy role="rewrite"/>
+            </policies>
+            <dispatch contributor-name="http-client" />
+        </route>
+    </routes>
+    <dispatch contributor-name="custom-client" 
ha-contributor-name="ha-client"/>
+</service>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributor.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributor.java
 
b/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributor.java
deleted file mode 100644
index 15372ec..0000000
--- 
a/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributor.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * 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.hbase;
-
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-import org.apache.hadoop.gateway.deploy.ServiceDeploymentContributorBase;
-import org.apache.hadoop.gateway.descriptor.FilterParamDescriptor;
-import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
-import 
org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptorFactory;
-import org.apache.hadoop.gateway.topology.Service;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class HBaseDeploymentContributor extends 
ServiceDeploymentContributorBase {
-
-  private static final String RULES_RESOURCE = 
HBaseDeploymentContributor.class.getName().replace( '.', '/' ) + "/rewrite.xml";
-  private static final String EXTERNAL_PATH = "/hbase";
-
-  @Override 
-  public String getRole() {
-    return "WEBHBASE";
-  }
-
-  @Override
-  public String getName() {
-    return "webhbase";
-  }
-
-  @Override
-  public void contributeService( DeploymentContext context, Service service ) 
throws Exception {
-    contributeRewriteRules( context, service );
-    contributeResources( context, service );
-  }
-
-  private void contributeRewriteRules( DeploymentContext context, Service 
service ) throws URISyntaxException, IOException {
-    UrlRewriteRulesDescriptor hbaseRules = loadRulesFromTemplate();
-    UrlRewriteRulesDescriptor clusterRules = context.getDescriptor( "rewrite" 
);
-    clusterRules.addRules( hbaseRules );
-  }
-
-  private void contributeResources( DeploymentContext context, Service service 
) throws URISyntaxException {
-    List<FilterParamDescriptor> params;
-
-    ResourceDescriptor rootResource = 
context.getGatewayDescriptor().addResource();
-    rootResource.role( service.getRole() );
-    rootResource.pattern( EXTERNAL_PATH + "/?**" );
-    addWebAppSecFilters(context, service, rootResource);
-    addAuthenticationFilter( context, service, rootResource );
-    params = new ArrayList<FilterParamDescriptor>();
-    params.add( rootResource.createFilterParam().name( "response.headers" 
).value( getQualifiedName() + "/headers/outbound" ) );
-    addRewriteFilter( context, service, rootResource, params );
-    addIdentityAssertionFilter( context, service, rootResource );
-    addAuthorizationFilter(context, service, rootResource);
-    addDispatchFilter( context, service, rootResource );
-    
-    ResourceDescriptor pathResource = 
context.getGatewayDescriptor().addResource();
-    pathResource.role( service.getRole() );
-    pathResource.pattern( EXTERNAL_PATH + "/**?**" );
-    addWebAppSecFilters(context, service, pathResource);
-    addAuthenticationFilter( context, service, pathResource );
-    params = new ArrayList<FilterParamDescriptor>();
-    params.add( rootResource.createFilterParam().name( "response.headers" 
).value( getQualifiedName() + "/headers/outbound" ) );
-    addRewriteFilter( context, service, pathResource, params );
-    addIdentityAssertionFilter( context, service, pathResource );
-    addAuthorizationFilter(context, service, pathResource);
-    addDispatchFilter( context, service, pathResource );
-
-    ResourceDescriptor statusResource = 
context.getGatewayDescriptor().addResource();
-    statusResource.role( service.getRole() );
-    statusResource.pattern( EXTERNAL_PATH + "/status/cluster?**" );
-    addWebAppSecFilters(context, service, statusResource);
-    addAuthenticationFilter( context, service, statusResource );
-    params = new ArrayList<FilterParamDescriptor>();
-    params.add( statusResource.createFilterParam().name( "response.body" 
).value( getQualifiedName() + "/status/outbound" ) );
-    addRewriteFilter( context, service, statusResource, params );
-    addIdentityAssertionFilter( context, service, statusResource );
-    addAuthorizationFilter(context, service, statusResource);
-    addDispatchFilter( context, service, statusResource );
-
-    ResourceDescriptor regionResource = 
context.getGatewayDescriptor().addResource();
-    regionResource.role( service.getRole() );
-    regionResource.pattern( EXTERNAL_PATH + "/*/regions?**" );
-    addWebAppSecFilters(context, service, regionResource);
-    addAuthenticationFilter( context, service, regionResource );
-    params = new ArrayList<FilterParamDescriptor>();
-    params.add( regionResource.createFilterParam().name( "response.body" 
).value( getQualifiedName() + "/regions/outbound" ) );
-    addRewriteFilter( context, service, regionResource, params );
-    addIdentityAssertionFilter( context, service, regionResource );
-    addAuthorizationFilter(context, service, regionResource);
-    addDispatchFilter( context, service, regionResource );
-  }
-
-  private void addDispatchFilter(
-    DeploymentContext context, Service service, ResourceDescriptor resource ) {
-    context.contributeFilter( service, resource, "dispatch", "hbase", null );
-  }
-
-  private String getQualifiedName() {
-    return getRole() + "/" + getName();
-  }
-
-  UrlRewriteRulesDescriptor loadRulesFromTemplate() throws IOException {
-    InputStream stream = this.getClass().getClassLoader().getResourceAsStream( 
RULES_RESOURCE );
-    Reader reader = new InputStreamReader( stream );
-    UrlRewriteRulesDescriptor rules = UrlRewriteRulesDescriptorFactory.load( 
"xml", reader );
-    reader.close();
-    stream.close();
-    return rules;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDispatchDeploymentContributor.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDispatchDeploymentContributor.java
 
b/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDispatchDeploymentContributor.java
deleted file mode 100644
index d2b4ce0..0000000
--- 
a/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseDispatchDeploymentContributor.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * 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.hbase;
-
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-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.topology.Provider;
-import org.apache.hadoop.gateway.topology.Service;
-
-import java.util.List;
-import java.util.Map;
-
-public class HBaseDispatchDeploymentContributor extends 
ProviderDeploymentContributorBase {
-  
-  private static final String REPLAY_BUFFER_SIZE_PARAM = "replayBufferSize";
-  
-  // Default global replay buffer size in KB
-  public static final String DEFAULT_REPLAY_BUFFER_SIZE = "8";
-
-  @Override
-  public String getRole() {
-    return "dispatch";
-  }
-
-  @Override
-  public String getName() {
-    return "hbase";
-  }
-
-  @Override
-  public void contributeFilter( DeploymentContext context, Provider provider, 
Service service, ResourceDescriptor resource, List<FilterParamDescriptor> 
params ) {
-    FilterDescriptor filter = resource.addFilter().name( getName() ).role( 
getRole() ).impl( HBaseHttpClientDispatch.class );
-
-    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 ( params != null ) {
-      for ( FilterParamDescriptor customParam : params ) {
-        if ( REPLAY_BUFFER_SIZE_PARAM.equals( customParam.name() ) ) {
-          filterParam.value( customParam.value() );
-        }
-      }
-    }
-
-    if( context.getGatewayConfig().isHadoopKerberosSecured() ) {
-      filter.param().name("kerberos").value("true");
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseHttpClientDispatch.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseHttpClientDispatch.java
 
b/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseHttpClientDispatch.java
index a569692..0d39950 100644
--- 
a/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseHttpClientDispatch.java
+++ 
b/gateway-service-hbase/src/main/java/org/apache/hadoop/gateway/hbase/HBaseHttpClientDispatch.java
@@ -29,8 +29,9 @@ import javax.servlet.ServletException;
 public class HBaseHttpClientDispatch extends HttpClientDispatch {
 
   @Override
-  public void init( FilterConfig filterConfig ) throws ServletException {
-    super.init( filterConfig, new HBaseCookieManager() );
+  public void init() {
+    super.init();
+    setAppCookieManager(new HBaseCookieManager());
   }
 
 }

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hbase/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
----------------------------------------------------------------------
diff --git 
a/gateway-service-hbase/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
 
b/gateway-service-hbase/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
deleted file mode 100644
index 610bfbb..0000000
--- 
a/gateway-service-hbase/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
+++ /dev/null
@@ -1,19 +0,0 @@
-##########################################################################
-# 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.
-##########################################################################
-
-org.apache.hadoop.gateway.hbase.HBaseDispatchDeploymentContributor

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hbase/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
----------------------------------------------------------------------
diff --git 
a/gateway-service-hbase/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
 
b/gateway-service-hbase/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
deleted file mode 100644
index 5fc751f..0000000
--- 
a/gateway-service-hbase/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
+++ /dev/null
@@ -1,19 +0,0 @@
-##########################################################################
-# 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.
-##########################################################################
-
-org.apache.hadoop.gateway.hbase.HBaseDeploymentContributor

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hbase/src/test/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributorTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-hbase/src/test/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributorTest.java
 
b/gateway-service-hbase/src/test/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributorTest.java
deleted file mode 100644
index 3c8c1b1..0000000
--- 
a/gateway-service-hbase/src/test/java/org/apache/hadoop/gateway/hbase/HBaseDeploymentContributorTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.hbase;
-
-import org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor;
-import org.junit.Test;
-
-import java.util.Iterator;
-import java.util.ServiceLoader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
-
-public class HBaseDeploymentContributorTest {
-
-  @Test
-  public void testServiceLoader() throws Exception {
-    ServiceLoader loader = ServiceLoader.load( 
ServiceDeploymentContributor.class );
-    Iterator iterator = loader.iterator();
-    assertThat( "Service iterator empty.", iterator.hasNext() );
-    while( iterator.hasNext() ) {
-      Object object = iterator.next();
-      if( object instanceof HBaseDeploymentContributor ) {
-        return;
-      }
-    }
-    fail( "Failed to find " + HBaseDeploymentContributor.class.getName() + " 
via service loader." );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hbase/src/test/java/org/apache/hadoop/gateway/hbase/HBaseDispatchDeploymentContributorTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-hbase/src/test/java/org/apache/hadoop/gateway/hbase/HBaseDispatchDeploymentContributorTest.java
 
b/gateway-service-hbase/src/test/java/org/apache/hadoop/gateway/hbase/HBaseDispatchDeploymentContributorTest.java
deleted file mode 100644
index e2b4d10..0000000
--- 
a/gateway-service-hbase/src/test/java/org/apache/hadoop/gateway/hbase/HBaseDispatchDeploymentContributorTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.hbase;
-
-import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor;
-import org.junit.Test;
-
-import java.util.Iterator;
-import java.util.ServiceLoader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
-
-public class HBaseDispatchDeploymentContributorTest {
-
-  @Test
-  public void testServiceLoader() throws Exception {
-    ServiceLoader loader = ServiceLoader.load( 
ProviderDeploymentContributor.class );
-    Iterator iterator = loader.iterator();
-    assertThat( "Service iterator empty.", iterator.hasNext() );
-    while( iterator.hasNext() ) {
-      Object object = iterator.next();
-      if( object instanceof HBaseDispatchDeploymentContributor ) {
-        return;
-      }
-    }
-    fail( "Failed to find " + 
HBaseDispatchDeploymentContributor.class.getName() + " via service loader." );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDeploymentContributor.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDeploymentContributor.java
 
b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDeploymentContributor.java
deleted file mode 100644
index eb3779f..0000000
--- 
a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDeploymentContributor.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.hive;
-
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-import org.apache.hadoop.gateway.deploy.ServiceDeploymentContributorBase;
-import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRuleDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
-import 
org.apache.hadoop.gateway.filter.rewrite.ext.UrlRewriteActionRewriteDescriptorExt;
-import org.apache.hadoop.gateway.topology.Service;
-
-import java.net.URISyntaxException;
-
-public class HiveDeploymentContributor extends 
ServiceDeploymentContributorBase {
-
-  private static final String ROLE = "HIVE";
-  private static final String NAME = "hive";
-  private static final String EXTERNAL_PATH = "/hive";
-
-  @Override
-  public String getRole() {
-    return ROLE;
-  }
-
-  @Override
-  public String getName() {
-    return NAME;
-  }
-
-  @Override
-  public void contributeService( DeploymentContext context, Service service ) 
throws Exception {
-    contributeRewriteRules( context, service );
-    contributeResources( context, service );
-  }
-
-  private void contributeRewriteRules( DeploymentContext context, Service 
service ) throws URISyntaxException {
-    UrlRewriteRulesDescriptor rules = context.getDescriptor( "rewrite" );
-    UrlRewriteRuleDescriptor rule;
-    UrlRewriteActionRewriteDescriptorExt rewrite;
-
-    rule = rules.addRule( getRole() + "/" + getName() + "/inbound" )
-        .directions( "inbound" )
-        .pattern( "*://*:*/**" + EXTERNAL_PATH );
-    rewrite = rule.addStep( "rewrite" );
-    rewrite.template( service.getUrl() );
-  }
-
-  public void contributeResources( DeploymentContext context, Service service 
) throws URISyntaxException {
-    ResourceDescriptor rootResource = 
context.getGatewayDescriptor().addResource();
-    rootResource.role( service.getRole() );
-    rootResource.pattern( EXTERNAL_PATH );
-    addWebAppSecFilters(context, service, rootResource);
-    addAuthenticationFilter( context, service, rootResource );
-    addRewriteFilter( context, service, rootResource );
-    addIdentityAssertionFilter( context, service, rootResource );
-    addAuthorizationFilter(context, service, rootResource);
-    addDispatchFilter( context, service, rootResource );
-  }
-
-  private void addRewriteFilter(
-      DeploymentContext context, Service service, ResourceDescriptor resource 
) throws URISyntaxException {
-    context.contributeFilter( service, resource, "rewrite", null, null );
-  }
-
-  private void addDispatchFilter( DeploymentContext context, Service service, 
ResourceDescriptor resource ) {
-    context.contributeFilter( service, resource, "dispatch", "hive", null );
-  }
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatchDeploymentContributor.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatchDeploymentContributor.java
 
b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatchDeploymentContributor.java
deleted file mode 100644
index 00b13d9..0000000
--- 
a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveDispatchDeploymentContributor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.hive;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-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.topology.Provider;
-import org.apache.hadoop.gateway.topology.Service;
-
-/**
- *
- */
-public class HiveDispatchDeploymentContributor extends 
ProviderDeploymentContributorBase {
-  
-  private static final String REPLAY_BUFFER_SIZE_PARAM = "replayBufferSize";
-  
-  // Default global replay buffer size in KB
-  public static final String DEFAULT_REPLAY_BUFFER_SIZE = "8";
-
-  @Override
-  public String getRole() {
-    return "dispatch";
-  }
-
-  @Override
-  public String getName() {
-    return "hive";
-  }
-
-  @Override
-  public void contributeFilter( DeploymentContext context, Provider provider, 
Service service, ResourceDescriptor resource, List<FilterParamDescriptor> 
params ) {
-    FilterDescriptor filter = resource.addFilter().name( getName() ).role( 
getRole() ).impl( HiveHttpClientDispatch.class );
-
-    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 ( params != null ) {
-      for ( FilterParamDescriptor customParam : params ) {
-        if ( REPLAY_BUFFER_SIZE_PARAM.equals( customParam.name() ) ) {
-          filterParam.value( customParam.value() );
-        }
-      }
-    }
-
-    if( context.getGatewayConfig().isHadoopKerberosSecured() ) {
-      filter.param().name("kerberos").value("true");
-    } else {
-      filter.param().name("basicAuthPreemptive").value("true");
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHttpClientDispatch.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHttpClientDispatch.java
 
b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHttpClientDispatch.java
index 21d39ba..b19b03d 100644
--- 
a/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHttpClientDispatch.java
+++ 
b/gateway-service-hive/src/main/java/org/apache/hadoop/gateway/hive/HiveHttpClientDispatch.java
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.gateway.hive;
 
+import org.apache.hadoop.gateway.config.Configure;
 import org.apache.hadoop.gateway.dispatch.HttpClientDispatch;
 import org.apache.hadoop.gateway.security.PrimaryPrincipal;
 import org.apache.http.Header;
@@ -46,18 +47,14 @@ import java.security.Principal;
  * default HttpClientDispatch.
  */
 public class HiveHttpClientDispatch extends HttpClientDispatch {
-  private static final String BASIC_AUTH_PREEMPTIVE_PARAM = 
"basicAuthPreemptive";
   private static final String PASSWORD_PLACEHOLDER = "*";
   private boolean basicAuthPreemptive = false;
+  private boolean kerberos = false;
   private static final EmptyJaasCredentials EMPTY_JAAS_CREDENTIALS = new 
EmptyJaasCredentials();
 
   @Override
-  public void init( FilterConfig filterConfig ) throws ServletException {
-    super.init( filterConfig );
-    String basicAuthPreemptiveString = filterConfig.getInitParameter( 
BASIC_AUTH_PREEMPTIVE_PARAM );
-    if( basicAuthPreemptiveString != null ) {
-      setBasicAuthPreemptive( Boolean.parseBoolean( basicAuthPreemptiveString 
) );
-    }
+  public void init() {
+    super.init();
   }
 
   protected Principal getPrimaryPrincipal() {
@@ -82,6 +79,7 @@ public class HiveHttpClientDispatch extends 
HttpClientDispatch {
     }
   }
 
+  @Configure
   public void setBasicAuthPreemptive( boolean basicAuthPreemptive ) {
     this.basicAuthPreemptive = basicAuthPreemptive;
   }
@@ -89,7 +87,16 @@ public class HiveHttpClientDispatch extends 
HttpClientDispatch {
   public boolean isBasicAuthPreemptive() {
     return basicAuthPreemptive;
   }
-  
+
+  public boolean isKerberos() {
+    return kerberos;
+  }
+
+  @Configure
+  public void setKerberos(boolean kerberos) {
+    this.kerberos = kerberos;
+  }
+
   protected HttpResponse executeKerberosDispatch(HttpUriRequest 
outboundRequest,
       DefaultHttpClient client) throws IOException, ClientProtocolException {
     //DefaultHttpClient client = new DefaultHttpClient();

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
----------------------------------------------------------------------
diff --git 
a/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
 
b/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
deleted file mode 100644
index 3762427..0000000
--- 
a/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
+++ /dev/null
@@ -1,19 +0,0 @@
-##########################################################################
-# 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.
-##########################################################################
-
-org.apache.hadoop.gateway.hive.HiveDispatchDeploymentContributor

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
----------------------------------------------------------------------
diff --git 
a/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
 
b/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
deleted file mode 100644
index 3898804..0000000
--- 
a/gateway-service-hive/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ServiceDeploymentContributor
+++ /dev/null
@@ -1,19 +0,0 @@
-##########################################################################
-# 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.
-##########################################################################
-
-org.apache.hadoop.gateway.hive.HiveDeploymentContributor

http://git-wip-us.apache.org/repos/asf/knox/blob/0d9fa0da/gateway-service-hive/src/test/java/org/apache/hadoop/gateway/hive/HiveDispatchDeploymentContributorTest.java
----------------------------------------------------------------------
diff --git 
a/gateway-service-hive/src/test/java/org/apache/hadoop/gateway/hive/HiveDispatchDeploymentContributorTest.java
 
b/gateway-service-hive/src/test/java/org/apache/hadoop/gateway/hive/HiveDispatchDeploymentContributorTest.java
deleted file mode 100644
index d748ea4..0000000
--- 
a/gateway-service-hive/src/test/java/org/apache/hadoop/gateway/hive/HiveDispatchDeploymentContributorTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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.hive;
-
-import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor;
-import org.junit.Test;
-
-import java.util.Iterator;
-import java.util.ServiceLoader;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
-
-public class HiveDispatchDeploymentContributorTest {
-
-  @Test
-  public void testServiceLoader() throws Exception {
-    ServiceLoader loader = ServiceLoader.load( 
ProviderDeploymentContributor.class );
-    Iterator iterator = loader.iterator();
-    assertThat( "Service iterator empty.", iterator.hasNext() );
-    while( iterator.hasNext() ) {
-      Object object = iterator.next();
-      if( object instanceof HiveDispatchDeploymentContributor ) {
-        return;
-      }
-    }
-    fail( "Failed to find " + 
HiveDispatchDeploymentContributor.class.getName() + " via service loader." );
-  }
-}

Reply via email to