You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by mo...@apache.org on 2017/09/01 13:17:35 UTC
[37/64] [partial] knox git commit: KNOX-998 - Refactoring save 1
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/hadoop/gateway/inboundurl/api/InboundUrlFunctionDescriptorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/hadoop/gateway/inboundurl/api/InboundUrlFunctionDescriptorTest.java b/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/hadoop/gateway/inboundurl/api/InboundUrlFunctionDescriptorTest.java
deleted file mode 100644
index 59d1f8a..0000000
--- a/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/hadoop/gateway/inboundurl/api/InboundUrlFunctionDescriptorTest.java
+++ /dev/null
@@ -1,48 +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.inboundurl.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-import org.junit.Test;
-
-import java.util.Iterator;
-import java.util.ServiceLoader;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
-
-public class InboundUrlFunctionDescriptorTest {
-
- @Test
- public void testServiceLoader() throws Exception {
- ServiceLoader loader = ServiceLoader.load( UrlRewriteFunctionDescriptor.class );
- Iterator iterator = loader.iterator();
- assertThat( "Service iterator empty.", iterator.hasNext() );
- while( iterator.hasNext() ) {
- Object object = iterator.next();
- if( object instanceof InboundUrlFunctionDescriptor ) {
- String name = ((InboundUrlFunctionDescriptor)object).name();
- assertThat( name, is("inboundurl"));
- return;
- }
- }
- fail( "Failed to find " + InboundUrlFunctionDescriptor.class.getName() + " via service loader." );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/hadoop/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/hadoop/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java b/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/hadoop/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
deleted file mode 100644
index f78bf50..0000000
--- a/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/hadoop/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
+++ /dev/null
@@ -1,140 +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.inboundurl.impl;
-
-import com.google.common.collect.Lists;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-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.api.UrlRewriteRulesDescriptorFactory;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.ext.UrlRewriteActionRewriteDescriptorExt;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteResponse;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteProcessor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletContextListener;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletFilter;
-import org.apache.hadoop.gateway.services.GatewayServices;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Resolver;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteContextImpl;
-import org.junit.Test;
-
-import java.util.*;
-
-import org.easymock.EasyMock;
-
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
-
-public class InboundUrlFunctionProcessorTest {
-
- @Test
- public void testServiceLoader() throws Exception {
- ServiceLoader loader = ServiceLoader.load( UrlRewriteFunctionProcessor.class );
- Iterator iterator = loader.iterator();
- assertThat( "Service iterator empty.", iterator.hasNext() );
- while( iterator.hasNext() ) {
- Object object = iterator.next();
- if( object instanceof InboundUrlFunctionProcessor ) {
- return;
- }
- }
- fail( "Failed to find " + InboundUrlFunctionProcessor.class.getName() + " via service loader." );
- }
-
- @Test
- public void testServiceResolve() throws Exception {
- ServiceLoader loader = ServiceLoader.load( UrlRewriteFunctionProcessor.class );
- Iterator iterator = loader.iterator();
- assertThat( "Service iterator empty.", iterator.hasNext() );
- InboundUrlFunctionProcessor proc = null;
- while( iterator.hasNext() ) {
- Object object = iterator.next();
- if( object instanceof InboundUrlFunctionProcessor ) {
- proc = (InboundUrlFunctionProcessor) object ;
- }
- }
- if( proc == null )
- fail( "Failed to find " + InboundUrlFunctionProcessor.class.getName() + " via service loader." );
-
- Map<String,UrlRewriteFunctionProcessor> functions = new HashMap<>();
- UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
- UrlRewriter.Direction direction = UrlRewriter.Direction.OUT;
-
- List<String> parameters = Collections.singletonList("host");
-
- Template template = Parser.parseLiteral( "https://localhost:8443/gateway/default/datanode/?host=http://foo:50075" );
- UrlRewriteContextImpl ctx = new UrlRewriteContextImpl( environment, this.getRewriteResponse(), functions, direction, template );
-
- List<String> result = proc.resolve(ctx, parameters);
- assertThat( result.get(0), is( "http://foo:50075" ) );
- }
-
- private UrlRewriteResponse getRewriteResponse() throws Exception {
- UrlRewriteProcessor rewriter = EasyMock.createNiceMock( UrlRewriteProcessor.class );
- EasyMock.expect( rewriter.getConfig() ).andReturn( null ).anyTimes();
-
- ServletContext context = EasyMock.createNiceMock( ServletContext.class );
- EasyMock.expect( context.getAttribute( UrlRewriteServletContextListener.PROCESSOR_ATTRIBUTE_NAME ) ).andReturn( rewriter ).anyTimes();
-
- FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
- EasyMock.expect( config.getInitParameter( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM ) ).andReturn( "test-filter" ).anyTimes();
- EasyMock.expect( config.getServletContext() ).andReturn( context ).anyTimes();
-
- HttpServletRequest request = EasyMock.createNiceMock( HttpServletRequest.class );
- EasyMock.expect( request.getParameterValues("host" ) ).andReturn( new String[]{"http://foo:50075"} ).anyTimes();
-
- HttpServletResponse response = EasyMock.createNiceMock( HttpServletResponse.class );
-
- EasyMock.replay( rewriter, context, config, request, response );
-
- return new UrlRewriteResponse( config, request, response );
- }
-
-
- @Test
- public void testQueryParam() throws Exception {
- GatewayServices gatewayServices = EasyMock.createNiceMock( GatewayServices.class );
- UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
- EasyMock.expect( environment.getAttribute( GatewayServices.GATEWAY_SERVICES_ATTRIBUTE ) ).andReturn( gatewayServices ).anyTimes();
- EasyMock.expect( environment.resolve( "cluster.name" ) ).andReturn(Collections.singletonList("test-cluster-name")).anyTimes();
-
- Resolver resolver = EasyMock.createNiceMock( Resolver.class );
- EasyMock.expect( resolver.resolve( "query.param.host" ) ).andReturn( Lists.newArrayList( "http://foo:50075" ) ).anyTimes();
- EasyMock.replay( gatewayServices, environment, resolver );
-
- UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
- UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-location" );
- rule.pattern( "{*}://{*}:{*}/{**}/?{**}" );
- UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
- rewrite.template( "{$inboundurl[host]}" );
- UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
- rewriter.initialize( environment, descriptor );
- Template input = Parser.parseLiteral( "https://localhost:8443/gateway/default/datanode/?host=http://foo:50075" );
- Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.OUT, "test-location" );
- assertThat( output.toString(), is( "http://foo:50075" ) );
- }
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/api/InboundUrlFunctionDescriptorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/api/InboundUrlFunctionDescriptorTest.java b/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/api/InboundUrlFunctionDescriptorTest.java
new file mode 100644
index 0000000..e8afe82
--- /dev/null
+++ b/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/api/InboundUrlFunctionDescriptorTest.java
@@ -0,0 +1,48 @@
+/**
+ * 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.knox.gateway.inboundurl.api;
+
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
+import org.junit.Test;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
+
+public class InboundUrlFunctionDescriptorTest {
+
+ @Test
+ public void testServiceLoader() throws Exception {
+ ServiceLoader loader = ServiceLoader.load( UrlRewriteFunctionDescriptor.class );
+ Iterator iterator = loader.iterator();
+ assertThat( "Service iterator empty.", iterator.hasNext() );
+ while( iterator.hasNext() ) {
+ Object object = iterator.next();
+ if( object instanceof InboundUrlFunctionDescriptor ) {
+ String name = ((InboundUrlFunctionDescriptor)object).name();
+ assertThat( name, is("inboundurl"));
+ return;
+ }
+ }
+ fail( "Failed to find " + InboundUrlFunctionDescriptor.class.getName() + " via service loader." );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java b/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
new file mode 100644
index 0000000..e3bf9f7
--- /dev/null
+++ b/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
@@ -0,0 +1,140 @@
+/**
+ * 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.knox.gateway.inboundurl.impl;
+
+import com.google.common.collect.Lists;
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteEnvironment;
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteRuleDescriptor;
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteRulesDescriptorFactory;
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriter;
+import org.apache.knox.gateway.filter.rewrite.ext.UrlRewriteActionRewriteDescriptorExt;
+import org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
+import org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteResponse;
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteProcessor;
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteServletContextListener;
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteServletFilter;
+import org.apache.knox.gateway.services.GatewayServices;
+import org.apache.knox.gateway.util.urltemplate.Parser;
+import org.apache.knox.gateway.util.urltemplate.Resolver;
+import org.apache.knox.gateway.util.urltemplate.Template;
+import org.apache.knox.gateway.filter.rewrite.impl.UrlRewriteContextImpl;
+import org.junit.Test;
+
+import java.util.*;
+
+import org.easymock.EasyMock;
+
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
+
+public class InboundUrlFunctionProcessorTest {
+
+ @Test
+ public void testServiceLoader() throws Exception {
+ ServiceLoader loader = ServiceLoader.load( UrlRewriteFunctionProcessor.class );
+ Iterator iterator = loader.iterator();
+ assertThat( "Service iterator empty.", iterator.hasNext() );
+ while( iterator.hasNext() ) {
+ Object object = iterator.next();
+ if( object instanceof InboundUrlFunctionProcessor ) {
+ return;
+ }
+ }
+ fail( "Failed to find " + InboundUrlFunctionProcessor.class.getName() + " via service loader." );
+ }
+
+ @Test
+ public void testServiceResolve() throws Exception {
+ ServiceLoader loader = ServiceLoader.load( UrlRewriteFunctionProcessor.class );
+ Iterator iterator = loader.iterator();
+ assertThat( "Service iterator empty.", iterator.hasNext() );
+ InboundUrlFunctionProcessor proc = null;
+ while( iterator.hasNext() ) {
+ Object object = iterator.next();
+ if( object instanceof InboundUrlFunctionProcessor ) {
+ proc = (InboundUrlFunctionProcessor) object ;
+ }
+ }
+ if( proc == null )
+ fail( "Failed to find " + InboundUrlFunctionProcessor.class.getName() + " via service loader." );
+
+ Map<String,UrlRewriteFunctionProcessor> functions = new HashMap<>();
+ UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
+ UrlRewriter.Direction direction = UrlRewriter.Direction.OUT;
+
+ List<String> parameters = Collections.singletonList("host");
+
+ Template template = Parser.parseLiteral( "https://localhost:8443/gateway/default/datanode/?host=http://foo:50075" );
+ UrlRewriteContextImpl ctx = new UrlRewriteContextImpl( environment, this.getRewriteResponse(), functions, direction, template );
+
+ List<String> result = proc.resolve(ctx, parameters);
+ assertThat( result.get(0), is( "http://foo:50075" ) );
+ }
+
+ private UrlRewriteResponse getRewriteResponse() throws Exception {
+ UrlRewriteProcessor rewriter = EasyMock.createNiceMock( UrlRewriteProcessor.class );
+ EasyMock.expect( rewriter.getConfig() ).andReturn( null ).anyTimes();
+
+ ServletContext context = EasyMock.createNiceMock( ServletContext.class );
+ EasyMock.expect( context.getAttribute( UrlRewriteServletContextListener.PROCESSOR_ATTRIBUTE_NAME ) ).andReturn( rewriter ).anyTimes();
+
+ FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
+ EasyMock.expect( config.getInitParameter( UrlRewriteServletFilter.RESPONSE_BODY_FILTER_PARAM ) ).andReturn( "test-filter" ).anyTimes();
+ EasyMock.expect( config.getServletContext() ).andReturn( context ).anyTimes();
+
+ HttpServletRequest request = EasyMock.createNiceMock( HttpServletRequest.class );
+ EasyMock.expect( request.getParameterValues("host" ) ).andReturn( new String[]{"http://foo:50075"} ).anyTimes();
+
+ HttpServletResponse response = EasyMock.createNiceMock( HttpServletResponse.class );
+
+ EasyMock.replay( rewriter, context, config, request, response );
+
+ return new UrlRewriteResponse( config, request, response );
+ }
+
+
+ @Test
+ public void testQueryParam() throws Exception {
+ GatewayServices gatewayServices = EasyMock.createNiceMock( GatewayServices.class );
+ UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
+ EasyMock.expect( environment.getAttribute( GatewayServices.GATEWAY_SERVICES_ATTRIBUTE ) ).andReturn( gatewayServices ).anyTimes();
+ EasyMock.expect( environment.resolve( "cluster.name" ) ).andReturn(Collections.singletonList("test-cluster-name")).anyTimes();
+
+ Resolver resolver = EasyMock.createNiceMock( Resolver.class );
+ EasyMock.expect( resolver.resolve( "query.param.host" ) ).andReturn( Lists.newArrayList( "http://foo:50075" ) ).anyTimes();
+ EasyMock.replay( gatewayServices, environment, resolver );
+
+ UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
+ UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-location" );
+ rule.pattern( "{*}://{*}:{*}/{**}/?{**}" );
+ UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
+ rewrite.template( "{$inboundurl[host]}" );
+ UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
+ rewriter.initialize( environment, descriptor );
+ Template input = Parser.parseLiteral( "https://localhost:8443/gateway/default/datanode/?host=http://foo:50075" );
+ Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.OUT, "test-location" );
+ assertThat( output.toString(), is( "http://foo:50075" ) );
+ }
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceAddressFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceAddressFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceAddressFunctionDescriptor.java
deleted file mode 100644
index bfe8933..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceAddressFunctionDescriptor.java
+++ /dev/null
@@ -1,31 +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.svcregfunc.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class ServiceAddressFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
-
- public static final String FUNCTION_NAME = "serviceAddr";
-
- @Override
- public String name() {
- return FUNCTION_NAME;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceHostFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceHostFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceHostFunctionDescriptor.java
deleted file mode 100644
index cff251b..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceHostFunctionDescriptor.java
+++ /dev/null
@@ -1,31 +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.svcregfunc.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class ServiceHostFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
-
- public static final String FUNCTION_NAME = "serviceHost";
-
- @Override
- public String name() {
- return FUNCTION_NAME;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedAddressFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedAddressFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedAddressFunctionDescriptor.java
deleted file mode 100644
index ae12de0..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedAddressFunctionDescriptor.java
+++ /dev/null
@@ -1,31 +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.svcregfunc.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class ServiceMappedAddressFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
-
- public static final String FUNCTION_NAME = "serviceMappedAddr";
-
- @Override
- public String name() {
- return FUNCTION_NAME;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedHostFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedHostFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedHostFunctionDescriptor.java
deleted file mode 100644
index dd8beb2..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedHostFunctionDescriptor.java
+++ /dev/null
@@ -1,31 +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.svcregfunc.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class ServiceMappedHostFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
-
- public static final String FUNCTION_NAME = "serviceMappedHost";
-
- @Override
- public String name() {
- return FUNCTION_NAME;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedUrlFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedUrlFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedUrlFunctionDescriptor.java
deleted file mode 100644
index 8ea8271..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceMappedUrlFunctionDescriptor.java
+++ /dev/null
@@ -1,31 +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.svcregfunc.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class ServiceMappedUrlFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceMappedUrlFunctionDescriptor> {
-
- public static final String FUNCTION_NAME = "serviceMappedUrl";
-
- @Override
- public String name() {
- return FUNCTION_NAME;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServicePathFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServicePathFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServicePathFunctionDescriptor.java
deleted file mode 100644
index ab69264..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServicePathFunctionDescriptor.java
+++ /dev/null
@@ -1,31 +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.svcregfunc.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class ServicePathFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
-
- public static final String FUNCTION_NAME = "servicePath";
-
- @Override
- public String name() {
- return FUNCTION_NAME;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServicePortFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServicePortFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServicePortFunctionDescriptor.java
deleted file mode 100644
index cc05975..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServicePortFunctionDescriptor.java
+++ /dev/null
@@ -1,31 +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.svcregfunc.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class ServicePortFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
-
- public static final String FUNCTION_NAME = "servicePort";
-
- @Override
- public String name() {
- return FUNCTION_NAME;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceSchemeFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceSchemeFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceSchemeFunctionDescriptor.java
deleted file mode 100644
index dc73dee..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceSchemeFunctionDescriptor.java
+++ /dev/null
@@ -1,31 +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.svcregfunc.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class ServiceSchemeFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
-
- public static final String FUNCTION_NAME = "serviceScheme";
-
- @Override
- public String name() {
- return FUNCTION_NAME;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceUrlFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceUrlFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceUrlFunctionDescriptor.java
deleted file mode 100644
index 788c164..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/api/ServiceUrlFunctionDescriptor.java
+++ /dev/null
@@ -1,31 +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.svcregfunc.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class ServiceUrlFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
-
- public static final String FUNCTION_NAME = "serviceUrl";
-
- @Override
- public String name() {
- return FUNCTION_NAME;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceAddressFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceAddressFunctionProcessor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceAddressFunctionProcessor.java
deleted file mode 100644
index e7bafae..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceAddressFunctionProcessor.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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.svcregfunc.api.ServiceAddressFunctionDescriptor;
-import org.apache.hadoop.gateway.util.urltemplate.Host;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Port;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ServiceAddressFunctionProcessor
- extends ServiceRegistryFunctionProcessorBase<ServiceAddressFunctionDescriptor>
- implements UrlRewriteFunctionProcessor<ServiceAddressFunctionDescriptor> {
-
- @Override
- public String name() {
- return ServiceAddressFunctionDescriptor.FUNCTION_NAME;
- }
-
- @Override
- public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
- List<String> results = null;
- if( parameters != null ) {
- UrlRewriter.Direction direction = context.getDirection();
- results = new ArrayList<String>( parameters.size() );
- for( String parameter : parameters ) {
- parameter = resolve( parameter );
- results.add( parameter );
- }
- }
- return results;
- }
-
- public String resolve( String parameter ) throws Exception {
- String addr = parameter;
- String url = lookupServiceUrl( parameter );
- if( url != null ) {
- Template template = Parser.parseLiteral( url );
- Host host = template.getHost();
- String hostStr = null;
- if( host != null ) {
- hostStr = host.getFirstValue().getPattern();
- }
-
- Port port = template.getPort();
- String portStr = null;
- if( port != null ) {
- portStr = port.getFirstValue().getPattern();
- }
-
- if( hostStr != null && portStr != null ) {
- addr = hostStr + ":" + portStr;
- } else if( host != null && port == null ) {
- addr = hostStr;
- } else if( host == null && port != null ) {
- addr = ":" + portStr;
- }
- }
- return addr;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceHostFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceHostFunctionProcessor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceHostFunctionProcessor.java
deleted file mode 100644
index 7448d12..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceHostFunctionProcessor.java
+++ /dev/null
@@ -1,60 +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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.svcregfunc.api.ServiceHostFunctionDescriptor;
-import org.apache.hadoop.gateway.util.urltemplate.Host;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ServiceHostFunctionProcessor
- extends ServiceRegistryFunctionProcessorBase<ServiceHostFunctionDescriptor>
- implements UrlRewriteFunctionProcessor<ServiceHostFunctionDescriptor> {
-
- @Override
- public String name() {
- return ServiceHostFunctionDescriptor.FUNCTION_NAME;
- }
-
- @Override
- public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
- List<String> results = null;
- if( parameters != null ) {
- results = new ArrayList<String>( parameters.size() );
- for( String parameter : parameters ) {
- String url = lookupServiceUrl( parameter );
- if( url != null ) {
- Template template = Parser.parseLiteral( url );
- Host host = template.getHost();
- if( host != null ) {
- parameter = host.getFirstValue().getPattern();
- }
- }
- results.add( parameter );
- }
- }
- return results;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessor.java
deleted file mode 100644
index c5c8116..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedAddressFunctionProcessor.java
+++ /dev/null
@@ -1,110 +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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.services.GatewayServices;
-import org.apache.hadoop.gateway.services.hostmap.HostMapper;
-import org.apache.hadoop.gateway.services.hostmap.HostMapperService;
-import org.apache.hadoop.gateway.svcregfunc.api.ServiceMappedAddressFunctionDescriptor;
-import org.apache.hadoop.gateway.util.urltemplate.Host;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Port;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter.Direction;
-
-public class ServiceMappedAddressFunctionProcessor
- extends ServiceRegistryFunctionProcessorBase<ServiceMappedAddressFunctionDescriptor>
- implements UrlRewriteFunctionProcessor<ServiceMappedAddressFunctionDescriptor> {
-
- private HostMapper hostmap = null;
-
- @Override
- public String name() {
- return ServiceMappedAddressFunctionDescriptor.FUNCTION_NAME;
- }
-
- @Override
- public void initialize( UrlRewriteEnvironment environment, ServiceMappedAddressFunctionDescriptor descriptor ) throws Exception {
- super.initialize( environment, descriptor );
- HostMapperService hostmapService = services().getService( GatewayServices.HOST_MAPPING_SERVICE );
- if( hostmapService != null ) {
- hostmap = hostmapService.getHostMapper( cluster() );
- }
- }
-
- @Override
- public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
- List<String> results = null;
- if( parameters != null ) {
- Direction direction = context.getDirection();
- results = new ArrayList<String>( parameters.size() );
- for( String parameter : parameters ) {
- parameter = resolve( direction, parameter );
- results.add( parameter );
- }
- }
- return results;
- }
-
- public String resolve( Direction direction, String parameter ) throws Exception {
- String addr = parameter;
- String url = lookupServiceUrl( parameter );
- if( url != null ) {
- Template template = Parser.parseLiteral( url );
- Host host = template.getHost();
- String hostStr = null;
- if( host != null ) {
- hostStr = host.getFirstValue().getPattern();
- if( hostmap != null ) {
- switch( direction ) {
- case IN:
- hostStr = hostmap.resolveInboundHostName( hostStr );
- break;
- case OUT:
- hostStr = hostmap.resolveOutboundHostName( hostStr );
- break;
- }
- }
- }
-
- Port port = template.getPort();
- String portStr = null;
- if( port != null ) {
- portStr = port.getFirstValue().getPattern();
- }
-
- if( hostStr != null && portStr != null ) {
- addr = hostStr + ":" + portStr;
- } else if( host != null && port == null ) {
- addr = hostStr;
- } else if( host == null && port != null ) {
- addr = ":" + portStr;
- }
- }
- return addr;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedHostFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedHostFunctionProcessor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedHostFunctionProcessor.java
deleted file mode 100644
index 770aecd..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedHostFunctionProcessor.java
+++ /dev/null
@@ -1,87 +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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.services.GatewayServices;
-import org.apache.hadoop.gateway.services.hostmap.HostMapper;
-import org.apache.hadoop.gateway.services.hostmap.HostMapperService;
-import org.apache.hadoop.gateway.svcregfunc.api.ServiceMappedHostFunctionDescriptor;
-import org.apache.hadoop.gateway.util.urltemplate.Host;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ServiceMappedHostFunctionProcessor
- extends ServiceRegistryFunctionProcessorBase<ServiceMappedHostFunctionDescriptor>
- implements UrlRewriteFunctionProcessor<ServiceMappedHostFunctionDescriptor> {
-
- private HostMapper hostmap;
-
- @Override
- public String name() {
- return ServiceMappedHostFunctionDescriptor.FUNCTION_NAME;
- }
-
- @Override
- public void initialize( UrlRewriteEnvironment environment, ServiceMappedHostFunctionDescriptor descriptor ) throws Exception {
- super.initialize( environment, descriptor );
- HostMapperService hostmapService = services().getService( GatewayServices.HOST_MAPPING_SERVICE );
- if( hostmapService != null ) {
- hostmap = hostmapService.getHostMapper( cluster() );
- }
- }
-
- @Override
- public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
- List<String> results = null;
- if( parameters != null ) {
- results = new ArrayList<String>( parameters.size() );
- for( String parameter : parameters ) {
- String url = lookupServiceUrl( parameter );
- if( url != null ) {
- Template template = Parser.parseLiteral( url );
- Host host = template.getHost();
- if( host != null ) {
- String hostStr = host.getFirstValue().getPattern();
- if( hostmap != null ) {
- switch( context.getDirection() ) {
- case IN:
- parameter = hostmap.resolveInboundHostName( hostStr );
- break;
- case OUT:
- parameter = hostmap.resolveOutboundHostName( hostStr );
- break;
- }
- } else {
- parameter = hostStr;
- }
- }
- }
- results.add( parameter );
- }
- }
- return results;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedUrlFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedUrlFunctionProcessor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedUrlFunctionProcessor.java
deleted file mode 100644
index 2747681..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceMappedUrlFunctionProcessor.java
+++ /dev/null
@@ -1,90 +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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.services.GatewayServices;
-import org.apache.hadoop.gateway.services.hostmap.HostMapper;
-import org.apache.hadoop.gateway.services.hostmap.HostMapperService;
-import org.apache.hadoop.gateway.svcregfunc.api.ServiceMappedUrlFunctionDescriptor;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ServiceMappedUrlFunctionProcessor
- extends ServiceRegistryFunctionProcessorBase<ServiceMappedUrlFunctionDescriptor>
- implements UrlRewriteFunctionProcessor<ServiceMappedUrlFunctionDescriptor> {
-
- private HostMapper hostmap;
-
- @Override
- public String name() {
- return ServiceMappedUrlFunctionDescriptor.FUNCTION_NAME;
- }
-
- @Override
- public void initialize( UrlRewriteEnvironment environment, ServiceMappedUrlFunctionDescriptor descriptor ) throws Exception {
- super.initialize( environment, descriptor );
- HostMapperService hostmapService = services().getService( GatewayServices.HOST_MAPPING_SERVICE );
- if( hostmapService != null ) {
- hostmap = hostmapService.getHostMapper( cluster() );
- }
- }
-
- @Override
- public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
- List<String> results = null;
- if( parameters != null ) {
- UrlRewriter.Direction direction = context.getDirection();
- results = new ArrayList<String>( parameters.size() );
- for( String parameter : parameters ) {
- parameter = resolve( direction, parameter );
- results.add( parameter );
- }
- }
- return results;
- }
-
- public String resolve( UrlRewriter.Direction direction, String parameter ) throws Exception {
- String url = lookupServiceUrl( parameter );
- if( url != null ) {
- URI outputUri;
- URI inputUri = new URI( url );
- String host = inputUri.getHost();
- if( host != null && hostmap != null ) {
- switch( direction ) {
- case IN:
- host = hostmap.resolveInboundHostName( host );
- break;
- case OUT:
- host = hostmap.resolveOutboundHostName( host );
- break;
- }
- }
- outputUri = new URI( inputUri.getScheme(), inputUri.getUserInfo(), host, inputUri.getPort(), inputUri.getPath(), inputUri.getQuery(), inputUri.getFragment() );
- parameter = outputUri.toString();
- }
- return parameter;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServicePathFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServicePathFunctionProcessor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServicePathFunctionProcessor.java
deleted file mode 100644
index 1269ca9..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServicePathFunctionProcessor.java
+++ /dev/null
@@ -1,72 +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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.svcregfunc.api.ServicePathFunctionDescriptor;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Path;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ServicePathFunctionProcessor
- extends ServiceRegistryFunctionProcessorBase<ServicePathFunctionDescriptor>
- implements UrlRewriteFunctionProcessor<ServicePathFunctionDescriptor> {
-
- @Override
- public String name() {
- return ServicePathFunctionDescriptor.FUNCTION_NAME;
- }
-
- @Override
- public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
- List<String> results = null;
- if( parameters != null ) {
- results = new ArrayList<String>( parameters.size() );
- for( String parameter : parameters ) {
- String url = lookupServiceUrl( parameter );
- if( url != null ) {
- Template template = Parser.parseLiteral( url );
- List<Path> path = template.getPath();
- if( path != null ) {
- parameter = toString( path );
- }
- }
- results.add( parameter );
- }
- }
- return results;
- }
-
- private String toString( List<Path> paths ) {
- StringBuilder s = new StringBuilder();
- for( Path path: paths ) {
- s.append( '/' );
- s.append( path.getFirstValue().getPattern() );
- }
- if( s.length() == 0 ) {
- s.append( '/' );
- }
- return s.toString();
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServicePortFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServicePortFunctionProcessor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServicePortFunctionProcessor.java
deleted file mode 100644
index d05620c..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServicePortFunctionProcessor.java
+++ /dev/null
@@ -1,60 +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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.svcregfunc.api.ServicePortFunctionDescriptor;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Port;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ServicePortFunctionProcessor
- extends ServiceRegistryFunctionProcessorBase<ServicePortFunctionDescriptor>
- implements UrlRewriteFunctionProcessor<ServicePortFunctionDescriptor> {
-
- @Override
- public String name() {
- return ServicePortFunctionDescriptor.FUNCTION_NAME;
- }
-
- @Override
- public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
- List<String> results = null;
- if( parameters != null ) {
- results = new ArrayList<String>( parameters.size() );
- for( String parameter : parameters ) {
- String url = lookupServiceUrl( parameter );
- if( url != null ) {
- Template template = Parser.parseLiteral( url );
- Port port = template.getPort();
- if( port != null ) {
- parameter = port.getFirstValue().getPattern();
- }
- }
- results.add( parameter );
- }
- }
- return results;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceRegistryFunctionProcessorBase.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceRegistryFunctionProcessorBase.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceRegistryFunctionProcessorBase.java
deleted file mode 100644
index f14ff7b..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceRegistryFunctionProcessorBase.java
+++ /dev/null
@@ -1,81 +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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.ha.provider.HaProvider;
-import org.apache.hadoop.gateway.ha.provider.HaServletContextListener;
-import org.apache.hadoop.gateway.services.GatewayServices;
-import org.apache.hadoop.gateway.services.registry.ServiceRegistry;
-
-abstract class ServiceRegistryFunctionProcessorBase<T extends UrlRewriteFunctionDescriptor> implements UrlRewriteFunctionProcessor<T> {
-
- private String cluster;
- private GatewayServices services;
- private ServiceRegistry registry;
- private HaProvider haProvider;
-
- @Override
- public void initialize( UrlRewriteEnvironment environment, T descriptor ) throws Exception {
- if( environment == null ) {
- throw new IllegalArgumentException( "environment==null" );
- }
- cluster = environment.getAttribute( GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE );
- if( cluster == null ) {
- throw new IllegalArgumentException( "cluster==null" );
- }
- services = environment.getAttribute( GatewayServices.GATEWAY_SERVICES_ATTRIBUTE );
- if( services == null ) {
- throw new IllegalArgumentException( "services==null" );
- }
- registry = services.getService( GatewayServices.SERVICE_REGISTRY_SERVICE );
- if( registry == null ) {
- throw new IllegalArgumentException( "registry==null" );
- }
- haProvider = environment.getAttribute(HaServletContextListener.PROVIDER_ATTRIBUTE_NAME);
- }
-
- @Override
- public void destroy() throws Exception {
- registry = null;
- cluster = null;
- }
-
- public String lookupServiceUrl( String role ) throws Exception {
- if (haProvider != null && haProvider.isHaEnabled(role)) {
- return haProvider.getActiveURL(role);
- }
- return registry.lookupServiceURL( cluster, role );
- }
-
- String cluster() {
- return cluster;
- }
-
- GatewayServices services() {
- return services;
- }
-
- ServiceRegistry registry() {
- return registry;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceSchemeFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceSchemeFunctionProcessor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceSchemeFunctionProcessor.java
deleted file mode 100644
index 4c5f03b..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceSchemeFunctionProcessor.java
+++ /dev/null
@@ -1,60 +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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.svcregfunc.api.ServiceSchemeFunctionDescriptor;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Scheme;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ServiceSchemeFunctionProcessor
- extends ServiceRegistryFunctionProcessorBase<ServiceSchemeFunctionDescriptor>
- implements UrlRewriteFunctionProcessor<ServiceSchemeFunctionDescriptor> {
-
- @Override
- public String name() {
- return ServiceSchemeFunctionDescriptor.FUNCTION_NAME;
- }
-
- @Override
- public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
- List<String> results = null;
- if( parameters != null ) {
- results = new ArrayList<String>( parameters.size() );
- for( String parameter : parameters ) {
- String url = lookupServiceUrl( parameter );
- if( url != null && !url.equals( parameter ) ) {
- Template template = Parser.parseLiteral( url );
- Scheme scheme = template.getScheme();
- if( scheme != null ) {
- parameter = scheme.getFirstValue().getPattern();
- }
- }
- results.add( parameter );
- }
- }
- return results;
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceUrlFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceUrlFunctionProcessor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceUrlFunctionProcessor.java
deleted file mode 100644
index 912fd3f..0000000
--- a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/hadoop/gateway/svcregfunc/impl/ServiceUrlFunctionProcessor.java
+++ /dev/null
@@ -1,64 +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.svcregfunc.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.svcregfunc.api.ServiceUrlFunctionDescriptor;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ServiceUrlFunctionProcessor
- extends ServiceRegistryFunctionProcessorBase<ServiceUrlFunctionDescriptor>
- implements UrlRewriteFunctionProcessor<ServiceUrlFunctionDescriptor> {
-
- @Override
- public String name() {
- return ServiceUrlFunctionDescriptor.FUNCTION_NAME;
- }
-
- @Override
- public List<String> resolve( UrlRewriteContext context, List<String> parameters ) throws Exception {
- List<String> results = null;
- if( parameters != null ) {
- UrlRewriter.Direction direction = context.getDirection();
- results = new ArrayList<String>( parameters.size() );
- for( String parameter : parameters ) {
- parameter = resolve( parameter );
- results.add( parameter );
- }
- }
- return results;
- }
-
- private String resolve( String parameter ) throws Exception {
- String url = lookupServiceUrl( parameter );
- if( url != null ) {
- URI outputUri;
- URI inputUri = new URI( url );
- String host = inputUri.getHost();
- outputUri = new URI( inputUri.getScheme(), inputUri.getUserInfo(), host, inputUri.getPort(), inputUri.getPath(), inputUri.getQuery(), inputUri.getFragment() );
- parameter = outputUri.toString();
- }
- return parameter;
- }
-}
-
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceAddressFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceAddressFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceAddressFunctionDescriptor.java
new file mode 100644
index 0000000..5ba0014
--- /dev/null
+++ b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceAddressFunctionDescriptor.java
@@ -0,0 +1,32 @@
+/**
+ * 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.knox.gateway.svcregfunc.api;
+
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
+
+public class ServiceAddressFunctionDescriptor implements
+ UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
+
+ public static final String FUNCTION_NAME = "serviceAddr";
+
+ @Override
+ public String name() {
+ return FUNCTION_NAME;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceHostFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceHostFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceHostFunctionDescriptor.java
new file mode 100644
index 0000000..37382d8
--- /dev/null
+++ b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceHostFunctionDescriptor.java
@@ -0,0 +1,32 @@
+/**
+ * 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.knox.gateway.svcregfunc.api;
+
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
+
+public class ServiceHostFunctionDescriptor implements
+ UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
+
+ public static final String FUNCTION_NAME = "serviceHost";
+
+ @Override
+ public String name() {
+ return FUNCTION_NAME;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedAddressFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedAddressFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedAddressFunctionDescriptor.java
new file mode 100644
index 0000000..8c7ad62
--- /dev/null
+++ b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedAddressFunctionDescriptor.java
@@ -0,0 +1,31 @@
+/**
+ * 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.knox.gateway.svcregfunc.api;
+
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
+
+public class ServiceMappedAddressFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
+
+ public static final String FUNCTION_NAME = "serviceMappedAddr";
+
+ @Override
+ public String name() {
+ return FUNCTION_NAME;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedHostFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedHostFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedHostFunctionDescriptor.java
new file mode 100644
index 0000000..a852be9
--- /dev/null
+++ b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedHostFunctionDescriptor.java
@@ -0,0 +1,32 @@
+/**
+ * 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.knox.gateway.svcregfunc.api;
+
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
+
+public class ServiceMappedHostFunctionDescriptor implements
+ UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
+
+ public static final String FUNCTION_NAME = "serviceMappedHost";
+
+ @Override
+ public String name() {
+ return FUNCTION_NAME;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedUrlFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedUrlFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedUrlFunctionDescriptor.java
new file mode 100644
index 0000000..9b5d65a
--- /dev/null
+++ b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServiceMappedUrlFunctionDescriptor.java
@@ -0,0 +1,32 @@
+/**
+ * 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.knox.gateway.svcregfunc.api;
+
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
+
+public class ServiceMappedUrlFunctionDescriptor implements
+ UrlRewriteFunctionDescriptor<ServiceMappedUrlFunctionDescriptor> {
+
+ public static final String FUNCTION_NAME = "serviceMappedUrl";
+
+ @Override
+ public String name() {
+ return FUNCTION_NAME;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/af9b0c3d/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServicePathFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServicePathFunctionDescriptor.java b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServicePathFunctionDescriptor.java
new file mode 100644
index 0000000..ca61b95
--- /dev/null
+++ b/gateway-provider-rewrite-func-service-registry/src/main/java/org/apache/knox/gateway/svcregfunc/api/ServicePathFunctionDescriptor.java
@@ -0,0 +1,31 @@
+/**
+ * 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.knox.gateway.svcregfunc.api;
+
+import org.apache.knox.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
+
+public class ServicePathFunctionDescriptor implements UrlRewriteFunctionDescriptor<ServiceUrlFunctionDescriptor> {
+
+ public static final String FUNCTION_NAME = "servicePath";
+
+ @Override
+ public String name() {
+ return FUNCTION_NAME;
+ }
+
+}