Revision: 1186
Author: dhanji
Date: Mon Jul 5 03:22:06 2010
Log: Guice-persist limpbizkit's review cleanups.
http://code.google.com/p/google-guice/source/detail?r=1186
Added:
/trunk/extensions/persist/src/com/google/inject/persist/finder/DynamicFinder.java
/trunk/extensions/persist/src/com/google/inject/persist/finder/NumResults.java
Deleted:
/trunk/extensions/persist/src/com/google/inject/persist/finder/MaxResults.java
Modified:
/trunk/extensions/persist/src/com/google/inject/persist/PersistenceFilter.java
/trunk/extensions/persist/src/com/google/inject/persist/PersistenceService.java
/trunk/extensions/persist/src/com/google/inject/persist/Transactional.java
/trunk/extensions/persist/src/com/google/inject/persist/WorkManager.java
/trunk/extensions/persist/src/com/google/inject/persist/finder/FirstResult.java
/trunk/extensions/persist/src/com/google/inject/persist/jpa/JpaFinderInterceptor.java
/trunk/extensions/persist/src/com/google/inject/persist/jpa/JpaLocalTxnInterceptor.java
/trunk/extensions/persist/test/com/google/inject/persist/jpa/ClassLevelManagedLocalTransactionsTest.java
=======================================
--- /dev/null
+++
/trunk/extensions/persist/src/com/google/inject/persist/finder/DynamicFinder.java
Mon Jul 5 03:22:06 2010
@@ -0,0 +1,9 @@
+// Copyright 2010 Google Inc. All Rights Reserved.
+
+package com.google.inject.persist.finder;
+
+/**
+ * @author [email protected] (Dhanji R. Prasanna)
+ */
+public final class DynamicFinder {
+}
=======================================
--- /dev/null
+++
/trunk/extensions/persist/src/com/google/inject/persist/finder/NumResults.java
Mon Jul 5 03:22:06 2010
@@ -0,0 +1,34 @@
+/**
+ * Copyright (C) 2010 Google, Inc.
+ *
+ * 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 com.google.inject.persist.finder;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 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}
+ *
+ * @author Dhanji R. Prasanna ([email protected])
+ */
+...@target(ElementType.PARAMETER)
+...@retention(RetentionPolicy.RUNTIME)
+public @interface NumResults {
+}
=======================================
---
/trunk/extensions/persist/src/com/google/inject/persist/finder/MaxResults.java
Tue May 25 15:48:47 2010
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright (C) 2010 Google, Inc.
- *
- * 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 com.google.inject.persist.finder;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-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}
- *
- * @author Dhanji R. Prasanna ([email protected])
- */
-...@target(ElementType.PARAMETER)
-...@retention(RetentionPolicy.RUNTIME)
-public @interface MaxResults {
-}
=======================================
---
/trunk/extensions/persist/src/com/google/inject/persist/PersistenceFilter.java
Tue May 25 15:48:47 2010
+++
/trunk/extensions/persist/src/com/google/inject/persist/PersistenceFilter.java
Mon Jul 5 03:22:06 2010
@@ -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);
}
}
=======================================
---
/trunk/extensions/persist/src/com/google/inject/persist/PersistenceService.java
Tue May 25 15:48:47 2010
+++
/trunk/extensions/persist/src/com/google/inject/persist/PersistenceService.java
Mon Jul 5 03:22:06 2010
@@ -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);
=======================================
---
/trunk/extensions/persist/src/com/google/inject/persist/Transactional.java
Tue May 25 15:48:47 2010
+++
/trunk/extensions/persist/src/com/google/inject/persist/Transactional.java
Mon Jul 5 03:22:06 2010
@@ -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 ([email protected])
*/
@@ -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 { };
+}
=======================================
---
/trunk/extensions/persist/src/com/google/inject/persist/WorkManager.java
Tue May 25 15:48:47 2010
+++
/trunk/extensions/persist/src/com/google/inject/persist/WorkManager.java
Mon Jul 5 03:22:06 2010
@@ -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();
=======================================
---
/trunk/extensions/persist/src/com/google/inject/persist/finder/FirstResult.java
Tue May 25 15:48:47 2010
+++
/trunk/extensions/persist/src/com/google/inject/persist/finder/FirstResult.java
Mon Jul 5 03:22:06 2010
@@ -29,7 +29,7 @@
*
* @author Dhanji R. Prasanna ([email protected])
* @since 1.0
- * @see com.google.inject.persist.finder.MaxResults
+ * @see NumResults
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
=======================================
---
/trunk/extensions/persist/src/com/google/inject/persist/jpa/JpaFinderInterceptor.java
Tue May 25 15:48:47 2010
+++
/trunk/extensions/persist/src/com/google/inject/persist/jpa/JpaFinderInterceptor.java
Mon Jul 5 03:22:06 2010
@@ -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;
=======================================
---
/trunk/extensions/persist/src/com/google/inject/persist/jpa/JpaLocalTxnInterceptor.java
Tue May 25 15:48:47 2010
+++
/trunk/extensions/persist/src/com/google/inject/persist/jpa/JpaLocalTxnInterceptor.java
Mon Jul 5 03:22:06 2010
@@ -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();
}
=======================================
---
/trunk/extensions/persist/test/com/google/inject/persist/jpa/ClassLevelManagedLocalTransactionsTest.java
Tue May 25 15:48:47 2010
+++
/trunk/extensions/persist/test/com/google/inject/persist/jpa/ClassLevelManagedLocalTransactionsTest.java
Mon Jul 5 03:22:06 2010
@@ -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;
--
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice-dev?hl=en.