Permalink
Browse files

Initial port from Spring Batch - no tests

  • Loading branch information...
0 parents commit 2215dddc699b340df760a85a3689fd7bcf304715 @dsyer dsyer committed Dec 21, 2010
Showing with 4,105 additions and 0 deletions.
  1. +6 −0 .gitignore
  2. +156 −0 pom.xml
  3. +91 −0 src/main/java/org/springframework/commons/classify/BinaryExceptionClassifier.java
  4. +38 −0 src/main/java/org/springframework/commons/classify/Classifier.java
  5. +48 −0 src/main/java/org/springframework/commons/classify/ClassifierSupport.java
  6. +148 −0 src/main/java/org/springframework/commons/classify/SubclassClassifier.java
  7. +44 −0 src/main/java/org/springframework/commons/repeat/RepeatCallback.java
  8. +91 −0 src/main/java/org/springframework/commons/repeat/RepeatContext.java
  9. +31 −0 src/main/java/org/springframework/commons/repeat/RepeatException.java
  10. +47 −0 src/main/java/org/springframework/commons/repeat/RepeatOperations.java
  11. +48 −0 src/main/java/org/springframework/commons/repeat/RepeatStatus.java
  12. +29 −0 src/main/java/org/springframework/commons/retry/ExhaustedRetryException.java
  13. +35 −0 src/main/java/org/springframework/commons/retry/RecoveryCallback.java
  14. +37 −0 src/main/java/org/springframework/commons/retry/RetryCallback.java
  15. +69 −0 src/main/java/org/springframework/commons/retry/RetryContext.java
  16. +31 −0 src/main/java/org/springframework/commons/retry/RetryException.java
  17. +62 −0 src/main/java/org/springframework/commons/retry/RetryListener.java
  18. +89 −0 src/main/java/org/springframework/commons/retry/RetryOperations.java
  19. +63 −0 src/main/java/org/springframework/commons/retry/RetryPolicy.java
  20. +60 −0 src/main/java/org/springframework/commons/retry/RetryState.java
  21. +64 −0 src/main/java/org/springframework/commons/retry/RetryStatistics.java
  22. +29 −0 src/main/java/org/springframework/commons/retry/TerminatedRetryException.java
  23. +25 −0 src/main/java/org/springframework/commons/retry/backoff/BackOffContext.java
  24. +38 −0 src/main/java/org/springframework/commons/retry/backoff/BackOffInterruptedException.java
  25. +61 −0 src/main/java/org/springframework/commons/retry/backoff/BackOffPolicy.java
  26. +192 −0 src/main/java/org/springframework/commons/retry/backoff/ExponentialBackOffPolicy.java
  27. +81 −0 src/main/java/org/springframework/commons/retry/backoff/FixedBackOffPolicy.java
  28. +31 −0 src/main/java/org/springframework/commons/retry/backoff/NoBackOffPolicy.java
  29. +37 −0 src/main/java/org/springframework/commons/retry/backoff/ObjectWaitSleeper.java
  30. +33 −0 src/main/java/org/springframework/commons/retry/backoff/Sleeper.java
  31. +51 −0 src/main/java/org/springframework/commons/retry/backoff/StatelessBackOffPolicy.java
  32. +83 −0 src/main/java/org/springframework/commons/retry/context/RetryContextSupport.java
  33. +36 −0 src/main/java/org/springframework/commons/retry/interceptor/MethodArgumentsKeyGenerator.java
  34. +40 −0 src/main/java/org/springframework/commons/retry/interceptor/MethodInvocationRecoverer.java
  35. +37 −0 src/main/java/org/springframework/commons/retry/interceptor/NewMethodArgumentsIdentifier.java
  36. +86 −0 src/main/java/org/springframework/commons/retry/interceptor/RetryOperationsInterceptor.java
  37. +214 −0 src/main/java/org/springframework/commons/retry/interceptor/StatefulRetryOperationsInterceptor.java
  38. +41 −0 src/main/java/org/springframework/commons/retry/listener/RetryListenerSupport.java
  39. +40 −0 src/main/java/org/springframework/commons/retry/policy/AlwaysRetryPolicy.java
  40. +133 −0 src/main/java/org/springframework/commons/retry/policy/CompositeRetryPolicy.java
  41. +163 −0 src/main/java/org/springframework/commons/retry/policy/ExceptionClassifierRetryPolicy.java
  42. +92 −0 src/main/java/org/springframework/commons/retry/policy/MapRetryContextCache.java
  43. +99 −0 src/main/java/org/springframework/commons/retry/policy/NeverRetryPolicy.java
  44. +52 −0 src/main/java/org/springframework/commons/retry/policy/RetryCacheCapacityExceededException.java
  45. +40 −0 src/main/java/org/springframework/commons/retry/policy/RetryContextCache.java
  46. +152 −0 src/main/java/org/springframework/commons/retry/policy/SimpleRetryPolicy.java
  47. +104 −0 src/main/java/org/springframework/commons/retry/policy/SoftReferenceMapRetryContextCache.java
  48. +94 −0 src/main/java/org/springframework/commons/retry/policy/TimeoutRetryPolicy.java
  49. +120 −0 src/main/java/org/springframework/commons/retry/support/DefaultRetryState.java
  50. +80 −0 src/main/java/org/springframework/commons/retry/support/RetrySynchronizationManager.java
  51. +484 −0 src/main/java/org/springframework/commons/retry/support/RetryTemplate.java
  52. +25 −0 src/site/site.xml
  53. +7 −0 src/test/resources/log4j.properties
  54. +18 −0 template.mf
@@ -0,0 +1,6 @@
+target
+.springBeans
+.settings
+.classpath
+.project
+
156 pom.xml
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-retry</artifactId>
+ <version>1.0.0.BUILD-SNAPSHOT</version>
+ <name>Spring Retry</name>
+ <url>http://www.springsource.org</url>
+ <packaging>jar</packaging>
+ <properties>
+ <maven.test.failure.ignore>true</maven.test.failure.ignore>
+ <spring.framework.version>3.0.5.RELEASE</spring.framework.version>
+ </properties>
+ <profiles>
+ <profile>
+ <id>strict</id>
+ <properties>
+ <maven.test.failure.ignore>false</maven.test.failure.ignore>
+ </properties>
+ </profile>
+ <profile>
+ <id>fast</id>
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ <maven.javadoc.skip>true</maven.javadoc.skip>
+ </properties>
+ </profile>
+ <profile>
+ <id>staging</id>
+ <distributionManagement>
+ <site>
+ <id>spring-site-staging</id>
+ <url>file:///${java.io.tmpdir}/spring-amqp/docs</url>
+ </site>
+ <repository>
+ <id>spring-milestone-staging</id>
+ <url>file:///${java.io.tmpdir}/spring-amqp/milestone</url>
+ </repository>
+ <snapshotRepository>
+ <id>spring-snapshot-staging</id>
+ <url>file:///${java.io.tmpdir}/spring-amqp/snapshot</url>
+ </snapshotRepository>
+ </distributionManagement>
+ </profile>
+ </profiles>
+
+ <distributionManagement>
+ <!-- see 'staging' profile for dry-run deployment settings -->
+ <downloadUrl>http://www.springsource.com/download/community
+ </downloadUrl>
+ <site>
+ <id>spring-docs</id>
+ <url>scp://static.springframework.org/var/www/domains/springframework.org/static/htdocs/spring-retry/docs/${project.version}
+ </url>
+ </site>
+ <repository>
+ <id>spring-milestone</id>
+ <name>Spring Milestone Repository</name>
+ <url>s3://maven.springframework.org/milestone</url>
+ </repository>
+ <snapshotRepository>
+ <id>spring-snapshot</id>
+ <name>Spring Snapshot Repository</name>
+ <url>s3://maven.springframework.org/snapshot</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring.framework.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.framework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <inherited>false</inherited>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>project</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestFile>target/classes/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!--forkMode>pertest</forkMode-->
+ <includes>
+ <include>**/*Tests.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/Abstract*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.springsource.bundlor</groupId>
+ <artifactId>com.springsource.bundlor.maven</artifactId>
+ <version>1.0.0.RELEASE</version>
+ <inherited>true</inherited>
+ <executions>
+ <execution>
+ <id>bundlor</id>
+ <goals>
+ <goal>bundlor</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2006-2007 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.commons.classify;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A {@link Classifier} for exceptions that has only two classes (true and
+ * false). Classifies objects according to their inheritance relation with the
+ * supplied types. If the object to be classified is one of the provided types,
+ * or is a subclass of one of the types, then the non-default value is returned
+ * (usually true).
+ *
+ * @see SubclassClassifier
+ *
+ * @author Dave Syer
+ *
+ */
+public class BinaryExceptionClassifier extends SubclassClassifier<Throwable, Boolean> {
+
+ /**
+ * Create a binary exception classifier with the provided default value.
+ *
+ * @param defaultValue defaults to false
+ */
+ public BinaryExceptionClassifier(boolean defaultValue) {
+ super(defaultValue);
+ }
+
+ /**
+ * Create a binary exception classifier with the provided classes and their
+ * subclasses. The mapped value for these exceptions will be the one
+ * provided (which will be the opposite of the default).
+ *
+ * @param value
+ */
+ public BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses, boolean value) {
+ this(!value);
+ if (exceptionClasses != null) {
+ Map<Class<? extends Throwable>, Boolean> map = new HashMap<Class<? extends Throwable>, Boolean>();
+ for (Class<? extends Throwable> type : exceptionClasses) {
+ map.put(type, !getDefault());
+ }
+ setTypeMap(map);
+ }
+ }
+
+ /**
+ * Create a binary exception classifier with the default value false and
+ * value mapping true for the provided classes and their subclasses.
+ */
+ public BinaryExceptionClassifier(Collection<Class<? extends Throwable>> exceptionClasses) {
+ this(exceptionClasses, true);
+ }
+
+ /**
+ * Create a binary exception classifier using the given classification map
+ * and a default classification of false.
+ *
+ * @param typeMap
+ */
+ public BinaryExceptionClassifier(Map<Class<? extends Throwable>, Boolean> typeMap) {
+ this(typeMap, false);
+ }
+
+ /**
+ * Create a binary exception classifier using the given classification map
+ * and a default classification of false.
+ *
+ * @param typeMap
+ */
+ public BinaryExceptionClassifier(Map<Class<? extends Throwable>, Boolean> typeMap, boolean defaultValue) {
+ super(typeMap, defaultValue);
+ }
+
+}
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2006-2007 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.commons.classify;
+
+/**
+ * Interface for a classifier. At its simplest a {@link Classifier} is just a
+ * map from objects of one type to objects of another type.
+ *
+ * @author Dave Syer
+ *
+ */
+public interface Classifier<C, T> {
+
+ /**
+ * Classify the given object and return an object of a different type,
+ * possibly an enumerated type.
+ *
+ * @param classifiable the input object. Can be null.
+ * @return an object. Can be null, but implementations should declare if
+ * this is the case.
+ */
+ T classify(C classifiable);
+
+}
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006-2007 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.commons.classify;
+
+/**
+ * Base class for {@link Classifier} implementations. Provides default behaviour
+ * and some convenience members, like constants.
+ *
+ * @author Dave Syer
+ *
+ */
+public class ClassifierSupport<C, T> implements Classifier<C, T> {
+
+ final private T defaultValue;
+
+ /**
+ * @param defaultValue
+ */
+ public ClassifierSupport(T defaultValue) {
+ super();
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * Always returns the default value. This is the main extension point for
+ * subclasses, so it must be able to classify null.
+ *
+ * @see org.springframework.commons.classify.Classifier#classify(Object)
+ */
+ public T classify(C throwable) {
+ return defaultValue;
+ }
+
+}
Oops, something went wrong.

0 comments on commit 2215ddd

Please sign in to comment.