Guice-persist limpbizkit's review cleanups.
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1186 d779f126-a31b-0410-b53b-1d3aecad763e
diff --git a/extensions/persist/src/com/google/inject/persist/PersistenceFilter.java b/extensions/persist/src/com/google/inject/persist/PersistenceFilter.java
index af13d39..d433d4c 100644
--- a/extensions/persist/src/com/google/inject/persist/PersistenceFilter.java
+++ b/extensions/persist/src/com/google/inject/persist/PersistenceFilter.java
@@ -69,11 +69,6 @@
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse,
final FilterChain filterChain) throws IOException, ServletException {
- try {
- filterChain.doFilter(servletRequest, servletResponse);
- }
- catch (IOException e) {
- throw new ServletException(e);
- }
+ filterChain.doFilter(servletRequest, servletResponse);
}
-}
\ No newline at end of file
+}
diff --git a/extensions/persist/src/com/google/inject/persist/PersistenceService.java b/extensions/persist/src/com/google/inject/persist/PersistenceService.java
index 3fa9afa..48f568e 100644
--- a/extensions/persist/src/com/google/inject/persist/PersistenceService.java
+++ b/extensions/persist/src/com/google/inject/persist/PersistenceService.java
@@ -46,10 +46,10 @@
public abstract void shutdown();
/**
- * A utility for testing if a given method is a dynamic finder.
+ * Returns true if {@code method} is a dynamic finder.
*
* @param method A method you suspect is a Dynamic Finder.
- * @return Returns true if the method is annotated {@code @Finder}
+ * @return Returns true if the method is annotated with {@code @Finder}
*/
public static boolean isDynamicFinder(Method method) {
return method.isAnnotationPresent(Finder.class);
diff --git a/extensions/persist/src/com/google/inject/persist/Transactional.java b/extensions/persist/src/com/google/inject/persist/Transactional.java
index 6b53259..089275c 100644
--- a/extensions/persist/src/com/google/inject/persist/Transactional.java
+++ b/extensions/persist/src/com/google/inject/persist/Transactional.java
@@ -24,16 +24,17 @@
/**
* <p> Any method or class marked with this annotation will be considered for transactionality.
- * Consult the documentation on http://www.wideplay.com for detailed semantics. <p> Marking a method
- * {@code @Transactional} will work with the default configuration as expected. Any classes marked
- * {@code @Transactional} will only work if you specify the
+ * Consult the documentation on http://code.google.com/p/google-guice for detailed semantics.
+ * Marking a method {@code @Transactional} will work with the default configuration as expected.
+ * Any classes marked {@code @Transactional} will only work if you specify the
* {@code forAll(Matchers.annotatedWith(Transactional.class), Matchers.any()} clause in your
- * guice-persist module configuration. <p> Class level {@code
- * * @Transactional} allows you to specify transaction semantics for all non-private methods in the
- * class once at the top. You can optionally override it on a per-method basis too. However, this
- * means that classes not marked {@code @Transactional} but with methods marked {@code
- * @Transactional} will *not* be intercepted for transaction wrapping.
-
+ * guice-persist module configuration.
+ *
+ * Class level {@code @Transactional} allows you to specify transaction semantics for all
+ * non-private methods in the class once at the top. You can optionally override it on a
+ * per-method basis too. However, this means that classes not marked {@code @Transactional}
+ * but with methods marked {@code @Transactional} will *not* be intercepted for transaction
+ * wrapping.
*
* @author Dhanji R. Prasanna (dhanji@gmail.com)
*/
@@ -45,22 +46,17 @@
/**
* A list of exceptions to rollback on, if thrown by the transactional method.
* These exceptions are propagated correctly after a rollback.
- *
- * @return Returns the configured rollback exceptions.
*/
Class<? extends Exception>[] rollbackOn() default RuntimeException.class;
/**
- * A list of exceptions to *not* rollback on. A caveat to the rollbackOn clause.
- * The disjunction of rollbackOn and exceptOn represents the list of exceptions
+ * A list of exceptions to <b>not<b> rollback on. A caveat to the rollbackOn clause.
+ * The disjunction of rollbackOn and ignore represents the list of exceptions
* that will trigger a rollback.
* The complement of rollbackOn and the universal set plus any exceptions in the
- * exceptOn set represents the list of exceptions that will trigger a commit.
- * <p/>
- * Note that exceptOn exceptions take precedence over rollbackOn, but with subtype
+ * ignore set represents the list of exceptions that will trigger a commit.
+ * Note that ignore exceptions take precedence over rollbackOn, but with subtype
* granularity.
- *
- * @return Returns the configured rollback exceptions.
*/
- Class<? extends Exception>[] exceptOn() default { };
+ Class<? extends Exception>[] ignore() default { };
}
diff --git a/extensions/persist/src/com/google/inject/persist/WorkManager.java b/extensions/persist/src/com/google/inject/persist/WorkManager.java
index b48c134..2b6952a 100755
--- a/extensions/persist/src/com/google/inject/persist/WorkManager.java
+++ b/extensions/persist/src/com/google/inject/persist/WorkManager.java
@@ -17,20 +17,21 @@
package com.google.inject.persist;
/**
- * <p> This interface is used to gain manual control over the unit of work. This is mostly to do
+ * This interface is used to gain manual control over the unit of work. This is mostly to do
* work in non-request, non-transactional threads. Or where more fine-grained control over the unit
* of work is required. Starting and ending a unit of work directly corresponds to opening and
- * closing a {@code Session}, {@code EntityManager} or {@code ObjectContainer} respectively. <p> The
+ * closing a {@code Session}, {@code EntityManager} or {@code ObjectContainer} respectively.
+ * <p> The
* Unit of Work referred to by WorkManager will always be local to the calling thread. Be careful to
* end() in a finally block. Neither JPA, nor Hibernate supports threadsafe sessions (reasoning
* behind thread-locality of Unit of Work semantics).
*
- * <ul> <li>Using WorkManager with the PersistenceFilter inside a request is not recommended.</li>
- *
- * <li>Using WorkManager with session-per-txn strategy is not terribly clever either.</li>
- *
- * <li>Using WorkManager with session-per-request strategy but *outside* a request (i.e. in a
- * background or bootstrap thread) is probably a good use case.</li> </ul>
+ * <ul>
+ * <li>Using WorkManager with the PersistenceFilter inside a request is not recommended.</li>
+ * <li>Using WorkManager with session-per-txn strategy is not terribly clever either.</li>
+ * <li>Using WorkManager with session-per-request strategy but *outside* a request (i.e. in a
+ * background or bootstrap thread) is probably a good use case.</li>
+ * </ul>
*
* @author Dhanji R. Prasanna (dhanji gmail com)
*/
@@ -49,7 +50,7 @@
* Declares an end to the current Unit of Work. Underneath, causes any open session to the data
* layer to close. If there is no Unit of work open, then the call returns silently. You can
* safely invoke end() repeatedly.
- *
+ * <p>
* Transaction semantics are not affected.
*/
void end();
diff --git a/extensions/persist/src/com/google/inject/persist/finder/DynamicFinder.java b/extensions/persist/src/com/google/inject/persist/finder/DynamicFinder.java
new file mode 100644
index 0000000..91dc86f
--- /dev/null
+++ b/extensions/persist/src/com/google/inject/persist/finder/DynamicFinder.java
@@ -0,0 +1,9 @@
+// Copyright 2010 Google Inc. All Rights Reserved.
+
+package com.google.inject.persist.finder;
+
+/**
+ * @author dhanji@google.com (Dhanji R. Prasanna)
+ */
+public final class DynamicFinder {
+}
diff --git a/extensions/persist/src/com/google/inject/persist/finder/FirstResult.java b/extensions/persist/src/com/google/inject/persist/finder/FirstResult.java
index 985e26e..b07e10b 100644
--- a/extensions/persist/src/com/google/inject/persist/finder/FirstResult.java
+++ b/extensions/persist/src/com/google/inject/persist/finder/FirstResult.java
@@ -29,7 +29,7 @@
*
* @author Dhanji R. Prasanna (dhanji@gmail.com)
* @since 1.0
- * @see com.google.inject.persist.finder.MaxResults
+ * @see NumResults
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
diff --git a/extensions/persist/src/com/google/inject/persist/finder/MaxResults.java b/extensions/persist/src/com/google/inject/persist/finder/NumResults.java
similarity index 96%
rename from extensions/persist/src/com/google/inject/persist/finder/MaxResults.java
rename to extensions/persist/src/com/google/inject/persist/finder/NumResults.java
index 38750d5..3bcf52d 100644
--- a/extensions/persist/src/com/google/inject/persist/finder/MaxResults.java
+++ b/extensions/persist/src/com/google/inject/persist/finder/NumResults.java
@@ -22,7 +22,6 @@
import java.lang.annotation.Target;
/**
- * <p>
* Annotate any dynamic finder method's integer argument with this to pass in the maximum
* size of returned results. Used for paging result lists.
* Complement of {@linkplain com.google.inject.persist.finder.FirstResult}
@@ -31,5 +30,5 @@
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
-public @interface MaxResults {
+public @interface NumResults {
}
diff --git a/extensions/persist/src/com/google/inject/persist/jpa/JpaFinderInterceptor.java b/extensions/persist/src/com/google/inject/persist/jpa/JpaFinderInterceptor.java
index 361d411..2f883ba 100644
--- a/extensions/persist/src/com/google/inject/persist/jpa/JpaFinderInterceptor.java
+++ b/extensions/persist/src/com/google/inject/persist/jpa/JpaFinderInterceptor.java
@@ -20,7 +20,7 @@
import com.google.inject.name.Named;
import com.google.inject.persist.finder.Finder;
import com.google.inject.persist.finder.FirstResult;
-import com.google.inject.persist.finder.MaxResults;
+import com.google.inject.persist.finder.NumResults;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -114,7 +114,7 @@
hibernateQuery.setParameter(named.value(), argument);
} else if (annotation instanceof FirstResult) {
hibernateQuery.setFirstResult((Integer) argument);
- } else if (annotation instanceof MaxResults) {
+ } else if (annotation instanceof NumResults) {
hibernateQuery.setMaxResults((Integer) argument);
}
}
@@ -132,7 +132,7 @@
index++;
} else if (annotation instanceof FirstResult) {
jpaQuery.setFirstResult((Integer) argument);
- } else if (annotation instanceof MaxResults) {
+ } else if (annotation instanceof NumResults) {
jpaQuery.setMaxResults((Integer) argument);
}
}
@@ -177,7 +177,7 @@
} else if (FirstResult.class.equals(annotationType)) {
discoveredAnnotations[i] = annotation;
break;
- } else if (MaxResults.class.equals(annotationType)) {
+ } else if (NumResults.class.equals(annotationType)) {
discoveredAnnotations[i] = annotation;
break;
} //leave as null for no binding
@@ -240,7 +240,7 @@
volatile Class<? extends Collection> returnCollectionType;
volatile Constructor returnCollectionTypeConstructor;
volatile Object[] parameterAnnotations;
- //contract is: null = no bind, @Named = param, @FirstResult/@MaxResults for paging
+ //contract is: null = no bind, @Named = param, @FirstResult/@NumResults for paging
private String query;
private String name;
diff --git a/extensions/persist/src/com/google/inject/persist/jpa/JpaLocalTxnInterceptor.java b/extensions/persist/src/com/google/inject/persist/jpa/JpaLocalTxnInterceptor.java
index 64d0b6c..735b731 100644
--- a/extensions/persist/src/com/google/inject/persist/jpa/JpaLocalTxnInterceptor.java
+++ b/extensions/persist/src/com/google/inject/persist/jpa/JpaLocalTxnInterceptor.java
@@ -132,8 +132,8 @@
if (rollBackOn.isInstance(e)) {
commit = false;
- //check exceptOn clauses (supercedes rollback clause)
- for (Class<? extends Exception> exceptOn : transactional.exceptOn()) {
+ //check ignore clauses (supercedes rollback clause)
+ for (Class<? extends Exception> exceptOn : transactional.ignore()) {
//An exception to the rollback clause was found, DON'T rollback
// (i.e. commit and throw anyway)
if (exceptOn.isInstance(e)) {
@@ -142,7 +142,7 @@
}
}
- //rollback only if nothing matched the exceptOn check
+ //rollback only if nothing matched the ignore check
if (!commit) {
txn.rollback();
}
diff --git a/extensions/persist/test/com/google/inject/persist/jpa/ClassLevelManagedLocalTransactionsTest.java b/extensions/persist/test/com/google/inject/persist/jpa/ClassLevelManagedLocalTransactionsTest.java
index c0bfe88..67baf8b 100644
--- a/extensions/persist/test/com/google/inject/persist/jpa/ClassLevelManagedLocalTransactionsTest.java
+++ b/extensions/persist/test/com/google/inject/persist/jpa/ClassLevelManagedLocalTransactionsTest.java
@@ -125,7 +125,7 @@
session.getTransaction().commit();
- assertNotNull("a result was not returned! rollback happened anyway (exceptOn failed)!!!",
+ assertNotNull("a result was not returned! rollback happened anyway (ignore failed)!!!",
result);
}
@@ -176,7 +176,7 @@
}
}
- @Transactional(rollbackOn = IOException.class, exceptOn = FileNotFoundException.class)
+ @Transactional(rollbackOn = IOException.class, ignore = FileNotFoundException.class)
public static class TransactionalObject3 {
@Inject EntityManager session;
@@ -201,4 +201,4 @@
throw new IOException();
}
}
-}
\ No newline at end of file
+}