From 50eea105028b0b62548e67618fe2de12612d7d63 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Fri, 3 Sep 2010 14:27:25 +0000 Subject: [PATCH] INT-1419 - changing structure --- .../gateway-with-futures/.classpath | 10 --- .../gateway-with-futures/.project | 29 ------- .../.settings/org.maven.ide.eclipse.prefs | 9 -- .../gateway-with-futures/pom.xml | 19 ----- .../gateway/futures/DemoClient.java | 85 ------------------- .../gateway/futures/ExceptionMapper.java | 34 -------- .../gateway/futures/MathService.java | 33 ------- .../gateway/futures/MathServiceGateway.java | 27 ------ .../integration/math-service-config.xml | 35 -------- 9 files changed, 281 deletions(-) delete mode 100644 spring-integration-samples/gateway-with-futures/.classpath delete mode 100644 spring-integration-samples/gateway-with-futures/.project delete mode 100644 spring-integration-samples/gateway-with-futures/.settings/org.maven.ide.eclipse.prefs delete mode 100644 spring-integration-samples/gateway-with-futures/pom.xml delete mode 100644 spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/DemoClient.java delete mode 100644 spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/ExceptionMapper.java delete mode 100644 spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/MathService.java delete mode 100644 spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/MathServiceGateway.java delete mode 100644 spring-integration-samples/gateway-with-futures/src/main/resources/META-INF/spring/integration/math-service-config.xml diff --git a/spring-integration-samples/gateway-with-futures/.classpath b/spring-integration-samples/gateway-with-futures/.classpath deleted file mode 100644 index 96489ff1c9..0000000000 --- a/spring-integration-samples/gateway-with-futures/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/spring-integration-samples/gateway-with-futures/.project b/spring-integration-samples/gateway-with-futures/.project deleted file mode 100644 index 3897200b11..0000000000 --- a/spring-integration-samples/gateway-with-futures/.project +++ /dev/null @@ -1,29 +0,0 @@ - - - async-gateway - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - org.springframework.ide.eclipse.core.springbuilder - - - - - - org.springframework.ide.eclipse.core.springnature - org.eclipse.jdt.core.javanature - org.maven.ide.eclipse.maven2Nature - - diff --git a/spring-integration-samples/gateway-with-futures/.settings/org.maven.ide.eclipse.prefs b/spring-integration-samples/gateway-with-futures/.settings/org.maven.ide.eclipse.prefs deleted file mode 100644 index 8bbec67ffa..0000000000 --- a/spring-integration-samples/gateway-with-futures/.settings/org.maven.ide.eclipse.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Fri Sep 03 00:46:56 EDT 2010 -activeProfiles= -eclipse.preferences.version=1 -fullBuildGoals=process-test-resources -includeModules=false -resolveWorkspaceProjects=false -resourceFilterGoals=process-resources resources\:testResources -skipCompilerPlugin=true -version=1 diff --git a/spring-integration-samples/gateway-with-futures/pom.xml b/spring-integration-samples/gateway-with-futures/pom.xml deleted file mode 100644 index d329bb46a6..0000000000 --- a/spring-integration-samples/gateway-with-futures/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - 4.0.0 - - org.springframework.integration.samples - spring-integration-samples - 2.0.0.BUILD-SNAPSHOT - - async-gateway - Gateway Demo - jar - - - org.springframework.integration - spring-integration-core - 2.0.0.BUILD-SNAPSHOT - - - \ No newline at end of file diff --git a/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/DemoClient.java b/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/DemoClient.java deleted file mode 100644 index 343f8bf513..0000000000 --- a/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/DemoClient.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed 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.springframework.integration.gateway.futures; - -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.FileSystemXmlApplicationContext; - -/** - * @author Oleg Zhurakousky - * - */ -public class DemoClient { - - private static ExecutorService executor = Executors.newFixedThreadPool(100); - private static int timeout = 20; - /** - * @param args - */ - public static void main(String[] args) { - ApplicationContext ac = new FileSystemXmlApplicationContext("src/main/resources/META-INF/spring/integration/*.xml"); - MathServiceGateway mathService = ac.getBean("mathService", MathServiceGateway.class); - Map> results = new HashMap>(); - Random random = new Random(); - for (int i = 0; i < 100; i++) { - int number = random.nextInt(200); - Future result = mathService.multiplyByTwo(number); - results.put(number, result); - } - for (final Map.Entry> resultEntry : results.entrySet()) { - executor.execute(new Runnable() { - public void run() { - int[] result = processFuture(resultEntry); - - if (result[1] == -1){ - System.out.println("Multiplying " + result[0] + " should be easy. You should be able to multiply any number < 100 by 2 in your head"); - } else if (result[1] == -2){ - System.out.println("Multiplication of " + result[0] + " by 2 is can not be accomplished in " + timeout + " seconds"); - } else { - System.out.println("Result of multiplication of " + result[0] + " by 2 is " + result[1]); - } - } - }); - } - } - - public static int[] processFuture(Map.Entry> resultEntry){ - int originalNumber = resultEntry.getKey(); - Future result = resultEntry.getValue(); - try { - int finalResult = result.get(timeout, TimeUnit.SECONDS); - return new int[]{originalNumber, finalResult}; - } catch (ExecutionException e) { - return new int[]{originalNumber, -1}; - } catch (TimeoutException tex){ - return new int[]{originalNumber, -2}; - } catch (Exception ex){ - System.out.println(); - // ignore - } - return null; - } -} diff --git a/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/ExceptionMapper.java b/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/ExceptionMapper.java deleted file mode 100644 index 8a8ad03685..0000000000 --- a/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/ExceptionMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed 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.springframework.integration.gateway.futures; - -import org.springframework.integration.Message; -import org.springframework.integration.MessageHandlingException; -import org.springframework.integration.mapping.InboundMessageMapper; - -/** - * @author Oleg Zhurakousky - * - */ -public class ExceptionMapper implements InboundMessageMapper{ - - @Override - public Message toMessage(MessageHandlingException messageHandlingException) - throws Exception { - return messageHandlingException.getFailedMessage(); - } - -} diff --git a/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/MathService.java b/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/MathService.java deleted file mode 100644 index 639e5c77e2..0000000000 --- a/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/MathService.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed 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.springframework.integration.gateway.futures; - -import java.util.Random; - -/** - * @author Oleg Zhurakousky - * - */ -public class MathService { - private final Random random = new Random(); - - public int multiplyByTwo(int i) throws Exception{ - long sleep = random.nextInt(10) * 1000; - Thread.sleep(sleep); - //System.out.println("Multiplied " + i); - return i*2; - } -} diff --git a/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/MathServiceGateway.java b/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/MathServiceGateway.java deleted file mode 100644 index 12c1d8918e..0000000000 --- a/spring-integration-samples/gateway-with-futures/src/main/java/org/springframework/integration/gateway/futures/MathServiceGateway.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed 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.springframework.integration.gateway.futures; - -import java.util.concurrent.Future; - -/** - * @author Oleg Zhurakousky - * - */ -public interface MathServiceGateway { - - Future multiplyByTwo(int i); -} diff --git a/spring-integration-samples/gateway-with-futures/src/main/resources/META-INF/spring/integration/math-service-config.xml b/spring-integration-samples/gateway-with-futures/src/main/resources/META-INF/spring/integration/math-service-config.xml deleted file mode 100644 index 9fb416fc80..0000000000 --- a/spring-integration-samples/gateway-with-futures/src/main/resources/META-INF/spring/integration/math-service-config.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - -