Polishing

This commit is contained in:
Juergen Hoeller 2016-04-12 16:03:57 +02:00
parent 831f09cf48
commit 74608e6b49
12 changed files with 43 additions and 65 deletions

View File

@ -594,8 +594,7 @@ public class AnnotatedElementUtilsTests {
@Test @Test
public void findMergedAnnotationAttributesOnClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() { public void findMergedAnnotationAttributesOnClassWithAttributeAliasInComposedAnnotationAndNestedAnnotationsInTargetAnnotation() {
AnnotationAttributes attributes = assertComponentScanAttributes(TestComponentScanClass.class, AnnotationAttributes attributes = assertComponentScanAttributes(TestComponentScanClass.class, "com.example.app.test");
"com.example.app.test");
Filter[] excludeFilters = attributes.getAnnotationArray("excludeFilters", Filter.class); Filter[] excludeFilters = attributes.getAnnotationArray("excludeFilters", Filter.class);
assertNotNull(excludeFilters); assertNotNull(excludeFilters);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,23 +54,23 @@ public class AnnotationAttributesTests {
nestedAttributes.put("name", "algernon"); nestedAttributes.put("name", "algernon");
attributes.put("name", "dave"); attributes.put("name", "dave");
attributes.put("names", new String[] { "dave", "frank", "hal" }); attributes.put("names", new String[] {"dave", "frank", "hal"});
attributes.put("bool1", true); attributes.put("bool1", true);
attributes.put("bool2", false); attributes.put("bool2", false);
attributes.put("color", Color.RED); attributes.put("color", Color.RED);
attributes.put("class", Integer.class); attributes.put("class", Integer.class);
attributes.put("classes", new Class<?>[] { Number.class, Short.class, Integer.class }); attributes.put("classes", new Class<?>[] {Number.class, Short.class, Integer.class});
attributes.put("number", 42); attributes.put("number", 42);
attributes.put("anno", nestedAttributes); attributes.put("anno", nestedAttributes);
attributes.put("annoArray", new AnnotationAttributes[] { nestedAttributes }); attributes.put("annoArray", new AnnotationAttributes[] {nestedAttributes});
assertThat(attributes.getString("name"), equalTo("dave")); assertThat(attributes.getString("name"), equalTo("dave"));
assertThat(attributes.getStringArray("names"), equalTo(new String[] { "dave", "frank", "hal" })); assertThat(attributes.getStringArray("names"), equalTo(new String[] {"dave", "frank", "hal"}));
assertThat(attributes.getBoolean("bool1"), equalTo(true)); assertThat(attributes.getBoolean("bool1"), equalTo(true));
assertThat(attributes.getBoolean("bool2"), equalTo(false)); assertThat(attributes.getBoolean("bool2"), equalTo(false));
assertThat(attributes.<Color>getEnum("color"), equalTo(Color.RED)); assertThat(attributes.<Color>getEnum("color"), equalTo(Color.RED));
assertTrue(attributes.getClass("class").equals(Integer.class)); assertTrue(attributes.getClass("class").equals(Integer.class));
assertThat(attributes.getClassArray("classes"), equalTo(new Class[] { Number.class, Short.class, Integer.class })); assertThat(attributes.getClassArray("classes"), equalTo(new Class<?>[] {Number.class, Short.class, Integer.class}));
assertThat(attributes.<Integer>getNumber("number"), equalTo(42)); assertThat(attributes.<Integer>getNumber("number"), equalTo(42));
assertThat(attributes.getAnnotation("anno").<Integer>getNumber("value"), equalTo(10)); assertThat(attributes.getAnnotation("anno").<Integer>getNumber("value"), equalTo(10));
assertThat(attributes.getAnnotationArray("annoArray")[0].getString("name"), equalTo("algernon")); assertThat(attributes.getAnnotationArray("annoArray")[0].getString("name"), equalTo("algernon"));
@ -99,8 +99,8 @@ public class AnnotationAttributesTests {
attributes.put("filters", filter); attributes.put("filters", filter);
// Get back arrays of single elements // Get back arrays of single elements
assertThat(attributes.getStringArray("names"), equalTo(new String[] { "Dogbert" })); assertThat(attributes.getStringArray("names"), equalTo(new String[] {"Dogbert"}));
assertThat(attributes.getClassArray("classes"), equalTo(new Class[] { Number.class })); assertThat(attributes.getClassArray("classes"), equalTo(new Class<?>[] {Number.class}));
AnnotationAttributes[] array = attributes.getAnnotationArray("nestedAttributes"); AnnotationAttributes[] array = attributes.getAnnotationArray("nestedAttributes");
assertNotNull(array); assertNotNull(array);
@ -118,7 +118,7 @@ public class AnnotationAttributesTests {
Filter filter = FilteredClass.class.getAnnotation(Filter.class); Filter filter = FilteredClass.class.getAnnotation(Filter.class);
attributes.put("filter", filter); attributes.put("filter", filter);
attributes.put("filters", new Filter[] { filter, filter }); attributes.put("filters", new Filter[] {filter, filter});
Filter retrievedFilter = attributes.getAnnotation("filter", Filter.class); Filter retrievedFilter = attributes.getAnnotation("filter", Filter.class);
assertThat(retrievedFilter, equalTo(filter)); assertThat(retrievedFilter, equalTo(filter));
@ -257,7 +257,7 @@ public class AnnotationAttributesTests {
@Test @Test
public void getAliasedStringArray() { public void getAliasedStringArray() {
final String[] INPUT = new String[] { "test.xml" }; final String[] INPUT = new String[] {"test.xml"};
final String[] EMPTY = new String[0]; final String[] EMPTY = new String[0];
attributes.clear(); attributes.clear();
@ -297,7 +297,7 @@ public class AnnotationAttributesTests {
@Test @Test
public void getAliasedStringArrayWithImplicitAliases() { public void getAliasedStringArrayWithImplicitAliases() {
final String[] INPUT = new String[] { "test.xml" }; final String[] INPUT = new String[] {"test.xml"};
final String[] EMPTY = new String[0]; final String[] EMPTY = new String[0];
final List<String> aliases = Arrays.asList("value", "location1", "location2", "location3", "xmlFile", "groovyScript"); final List<String> aliases = Arrays.asList("value", "location1", "location2", "location3", "xmlFile", "groovyScript");
@ -352,8 +352,8 @@ public class AnnotationAttributesTests {
@Test @Test
public void getAliasedStringArrayWithDifferentAliasedValues() { public void getAliasedStringArrayWithDifferentAliasedValues() {
attributes.put("location", new String[] { "1.xml" }); attributes.put("location", new String[] {"1.xml"});
attributes.put("value", new String[] { "2.xml" }); attributes.put("value", new String[] {"2.xml"});
exception.expect(AnnotationConfigurationException.class); exception.expect(AnnotationConfigurationException.class);
exception.expectMessage(containsString("In annotation [" + ContextConfig.class.getName() + "]")); exception.expectMessage(containsString("In annotation [" + ContextConfig.class.getName() + "]"));
@ -382,7 +382,7 @@ public class AnnotationAttributesTests {
@Test @Test
public void getAliasedClassArray() { public void getAliasedClassArray() {
final Class<?>[] INPUT = new Class<?>[] { String.class }; final Class<?>[] INPUT = new Class<?>[] {String.class};
final Class<?>[] EMPTY = new Class<?>[0]; final Class<?>[] EMPTY = new Class<?>[0];
attributes.clear(); attributes.clear();
@ -422,7 +422,7 @@ public class AnnotationAttributesTests {
@Test @Test
public void getAliasedClassArrayWithImplicitAliases() { public void getAliasedClassArrayWithImplicitAliases() {
final Class<?>[] INPUT = new Class<?>[] { String.class }; final Class<?>[] INPUT = new Class<?>[] {String.class};
final Class<?>[] EMPTY = new Class<?>[0]; final Class<?>[] EMPTY = new Class<?>[0];
final List<String> aliases = Arrays.asList("value", "location1", "location2", "location3", "xmlFile", "groovyScript"); final List<String> aliases = Arrays.asList("value", "location1", "location2", "location3", "xmlFile", "groovyScript");
@ -465,8 +465,8 @@ public class AnnotationAttributesTests {
@Test @Test
public void getAliasedClassArrayWithDifferentAliasedValues() { public void getAliasedClassArrayWithDifferentAliasedValues() {
attributes.put("classes", new Class[] { String.class }); attributes.put("classes", new Class<?>[] {String.class});
attributes.put("value", new Class[] { Number.class }); attributes.put("value", new Class<?>[] {Number.class});
exception.expect(AnnotationConfigurationException.class); exception.expect(AnnotationConfigurationException.class);
exception.expectMessage(containsString("In annotation [" + Filter.class.getName() + "]")); exception.expectMessage(containsString("In annotation [" + Filter.class.getName() + "]"));
@ -477,6 +477,7 @@ public class AnnotationAttributesTests {
getAliasedClassArray("classes"); getAliasedClassArray("classes");
} }
private Class<?>[] getAliasedClassArray(String attributeName) { private Class<?>[] getAliasedClassArray(String attributeName) {
return attributes.getAliasedClassArray(attributeName, Filter.class, null); return attributes.getAliasedClassArray(attributeName, Filter.class, null);
} }
@ -491,9 +492,11 @@ public class AnnotationAttributesTests {
enum Color { enum Color {
RED, WHITE, BLUE RED, WHITE, BLUE
} }
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@interface Filter { @interface Filter {
@ -506,10 +509,12 @@ public class AnnotationAttributesTests {
String pattern(); String pattern();
} }
@Filter(pattern = "foo") @Filter(pattern = "foo")
static class FilteredClass { static class FilteredClass {
} }
/** /**
* Mock of {@code org.springframework.context.annotation.Scope}. * Mock of {@code org.springframework.context.annotation.Scope}.
*/ */
@ -523,6 +528,7 @@ public class AnnotationAttributesTests {
String name() default "singleton"; String name() default "singleton";
} }
@Scope(name = "custom") @Scope(name = "custom")
static class ScopedComponent { static class ScopedComponent {
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -43,19 +43,16 @@ public interface ConnectionCallback<T> {
* Gets called by {@code JdbcTemplate.execute} with an active JDBC * Gets called by {@code JdbcTemplate.execute} with an active JDBC
* Connection. Does not need to care about activating or closing the * Connection. Does not need to care about activating or closing the
* Connection, or handling transactions. * Connection, or handling transactions.
*
* <p>If called without a thread-bound JDBC transaction (initiated by * <p>If called without a thread-bound JDBC transaction (initiated by
* DataSourceTransactionManager), the code will simply get executed on the * DataSourceTransactionManager), the code will simply get executed on the
* JDBC connection with its transactional semantics. If JdbcTemplate is * JDBC connection with its transactional semantics. If JdbcTemplate is
* configured to use a JTA-aware DataSource, the JDBC Connection and thus * configured to use a JTA-aware DataSource, the JDBC Connection and thus
* the callback code will be transactional if a JTA transaction is active. * the callback code will be transactional if a JTA transaction is active.
*
* <p>Allows for returning a result object created within the callback, i.e. * <p>Allows for returning a result object created within the callback, i.e.
* a domain object or a collection of domain objects. Note that there's special * a domain object or a collection of domain objects. Note that there's special
* support for single step actions: see {@code JdbcTemplate.queryForObject} * support for single step actions: see {@code JdbcTemplate.queryForObject}
* etc. A thrown RuntimeException is treated as application exception: * etc. A thrown RuntimeException is treated as application exception:
* it gets propagated to the caller of the template. * it gets propagated to the caller of the template.
*
* @param con active JDBC Connection * @param con active JDBC Connection
* @return a result object, or {@code null} if none * @return a result object, or {@code null} if none
* @throws SQLException if thrown by a JDBC method, to be auto-converted * @throws SQLException if thrown by a JDBC method, to be auto-converted

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -47,26 +47,22 @@ public interface PreparedStatementCallback<T> {
* PreparedStatement. Does not need to care about closing the Statement * PreparedStatement. Does not need to care about closing the Statement
* or the Connection, or about handling transactions: this will all be * or the Connection, or about handling transactions: this will all be
* handled by Spring's JdbcTemplate. * handled by Spring's JdbcTemplate.
*
* <p><b>NOTE:</b> Any ResultSets opened should be closed in finally blocks * <p><b>NOTE:</b> Any ResultSets opened should be closed in finally blocks
* within the callback implementation. Spring will close the Statement * within the callback implementation. Spring will close the Statement
* object after the callback returned, but this does not necessarily imply * object after the callback returned, but this does not necessarily imply
* that the ResultSet resources will be closed: the Statement objects might * that the ResultSet resources will be closed: the Statement objects might
* get pooled by the connection pool, with {@code close} calls only * get pooled by the connection pool, with {@code close} calls only
* returning the object to the pool but not physically closing the resources. * returning the object to the pool but not physically closing the resources.
*
* <p>If called without a thread-bound JDBC transaction (initiated by * <p>If called without a thread-bound JDBC transaction (initiated by
* DataSourceTransactionManager), the code will simply get executed on the * DataSourceTransactionManager), the code will simply get executed on the
* JDBC connection with its transactional semantics. If JdbcTemplate is * JDBC connection with its transactional semantics. If JdbcTemplate is
* configured to use a JTA-aware DataSource, the JDBC connection and thus * configured to use a JTA-aware DataSource, the JDBC connection and thus
* the callback code will be transactional if a JTA transaction is active. * the callback code will be transactional if a JTA transaction is active.
*
* <p>Allows for returning a result object created within the callback, i.e. * <p>Allows for returning a result object created within the callback, i.e.
* a domain object or a collection of domain objects. Note that there's * a domain object or a collection of domain objects. Note that there's
* special support for single step actions: see JdbcTemplate.queryForObject etc. * special support for single step actions: see JdbcTemplate.queryForObject etc.
* A thrown RuntimeException is treated as application exception, it gets * A thrown RuntimeException is treated as application exception, it gets
* propagated to the caller of the template. * propagated to the caller of the template.
*
* @param ps active JDBC PreparedStatement * @param ps active JDBC PreparedStatement
* @return a result object, or {@code null} if none * @return a result object, or {@code null} if none
* @throws SQLException if thrown by a JDBC method, to be auto-converted * @throws SQLException if thrown by a JDBC method, to be auto-converted

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -40,26 +40,22 @@ public interface StatementCallback<T> {
* Statement. Does not need to care about closing the Statement or the * Statement. Does not need to care about closing the Statement or the
* Connection, or about handling transactions: this will all be handled * Connection, or about handling transactions: this will all be handled
* by Spring's JdbcTemplate. * by Spring's JdbcTemplate.
*
* <p><b>NOTE:</b> Any ResultSets opened should be closed in finally blocks * <p><b>NOTE:</b> Any ResultSets opened should be closed in finally blocks
* within the callback implementation. Spring will close the Statement * within the callback implementation. Spring will close the Statement
* object after the callback returned, but this does not necessarily imply * object after the callback returned, but this does not necessarily imply
* that the ResultSet resources will be closed: the Statement objects might * that the ResultSet resources will be closed: the Statement objects might
* get pooled by the connection pool, with {@code close} calls only * get pooled by the connection pool, with {@code close} calls only
* returning the object to the pool but not physically closing the resources. * returning the object to the pool but not physically closing the resources.
*
* <p>If called without a thread-bound JDBC transaction (initiated by * <p>If called without a thread-bound JDBC transaction (initiated by
* DataSourceTransactionManager), the code will simply get executed on the * DataSourceTransactionManager), the code will simply get executed on the
* JDBC connection with its transactional semantics. If JdbcTemplate is * JDBC connection with its transactional semantics. If JdbcTemplate is
* configured to use a JTA-aware DataSource, the JDBC connection and thus * configured to use a JTA-aware DataSource, the JDBC connection and thus
* the callback code will be transactional if a JTA transaction is active. * the callback code will be transactional if a JTA transaction is active.
*
* <p>Allows for returning a result object created within the callback, i.e. * <p>Allows for returning a result object created within the callback, i.e.
* a domain object or a collection of domain objects. Note that there's * a domain object or a collection of domain objects. Note that there's
* special support for single step actions: see JdbcTemplate.queryForObject etc. * special support for single step actions: see JdbcTemplate.queryForObject etc.
* A thrown RuntimeException is treated as application exception, it gets * A thrown RuntimeException is treated as application exception, it gets
* propagated to the caller of the template. * propagated to the caller of the template.
*
* @param stmt active JDBC Statement * @param stmt active JDBC Statement
* @return a result object, or {@code null} if none * @return a result object, or {@code null} if none
* @throws SQLException if thrown by a JDBC method, to be auto-converted * @throws SQLException if thrown by a JDBC method, to be auto-converted

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -613,7 +613,7 @@ public class OracleLobHandler extends AbstractLobHandler {
/** /**
* Internal callback interface for use with createLob. * Internal callback interface for use with createLob.
*/ */
protected static interface LobCallback { protected interface LobCallback {
/** /**
* Populate the given BLOB or CLOB instance with content. * Populate the given BLOB or CLOB instance with content.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,12 +36,10 @@ public interface HibernateCallback<T> {
* Gets called by {@code HibernateTemplate.execute} with an active * Gets called by {@code HibernateTemplate.execute} with an active
* Hibernate {@code Session}. Does not need to care about activating * Hibernate {@code Session}. Does not need to care about activating
* or closing the {@code Session}, or handling transactions. * or closing the {@code Session}, or handling transactions.
*
* <p>Allows for returning a result object created within the callback, * <p>Allows for returning a result object created within the callback,
* i.e. a domain object or a collection of domain objects. * i.e. a domain object or a collection of domain objects.
* A thrown custom RuntimeException is treated as an application exception: * A thrown custom RuntimeException is treated as an application exception:
* It gets propagated to the caller of the template. * It gets propagated to the caller of the template.
*
* @param session active Hibernate session * @param session active Hibernate session
* @return a result object, or {@code null} if none * @return a result object, or {@code null} if none
* @throws HibernateException if thrown by the Hibernate API * @throws HibernateException if thrown by the Hibernate API

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,12 +36,10 @@ public interface HibernateCallback<T> {
* Gets called by {@code HibernateTemplate.execute} with an active * Gets called by {@code HibernateTemplate.execute} with an active
* Hibernate {@code Session}. Does not need to care about activating * Hibernate {@code Session}. Does not need to care about activating
* or closing the {@code Session}, or handling transactions. * or closing the {@code Session}, or handling transactions.
*
* <p>Allows for returning a result object created within the callback, * <p>Allows for returning a result object created within the callback,
* i.e. a domain object or a collection of domain objects. * i.e. a domain object or a collection of domain objects.
* A thrown custom RuntimeException is treated as an application exception: * A thrown custom RuntimeException is treated as an application exception:
* It gets propagated to the caller of the template. * It gets propagated to the caller of the template.
*
* @param session active Hibernate session * @param session active Hibernate session
* @return a result object, or {@code null} if none * @return a result object, or {@code null} if none
* @throws HibernateException if thrown by the Hibernate API * @throws HibernateException if thrown by the Hibernate API

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,18 +49,15 @@ public interface HibernateCallback<T> {
* Gets called by {@code HibernateTemplate.execute} with an active * Gets called by {@code HibernateTemplate.execute} with an active
* Hibernate {@code Session}. Does not need to care about activating * Hibernate {@code Session}. Does not need to care about activating
* or closing the {@code Session}, or handling transactions. * or closing the {@code Session}, or handling transactions.
*
* <p>If called without a thread-bound Hibernate transaction (initiated * <p>If called without a thread-bound Hibernate transaction (initiated
* by HibernateTransactionManager), the code will simply get executed on the * by HibernateTransactionManager), the code will simply get executed on the
* underlying JDBC connection with its transactional semantics. If Hibernate * underlying JDBC connection with its transactional semantics. If Hibernate
* is configured to use a JTA-aware DataSource, the JDBC connection and thus * is configured to use a JTA-aware DataSource, the JDBC connection and thus
* the callback code will be transactional if a JTA transaction is active. * the callback code will be transactional if a JTA transaction is active.
*
* <p>Allows for returning a result object created within the callback, * <p>Allows for returning a result object created within the callback,
* i.e. a domain object or a collection of domain objects. * i.e. a domain object or a collection of domain objects.
* A thrown custom RuntimeException is treated as an application exception: * A thrown custom RuntimeException is treated as an application exception:
* It gets propagated to the caller of the template. * It gets propagated to the caller of the template.
*
* @param session active Hibernate session * @param session active Hibernate session
* @return a result object, or {@code null} if none * @return a result object, or {@code null} if none
* @throws HibernateException if thrown by the Hibernate API * @throws HibernateException if thrown by the Hibernate API

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,19 +46,16 @@ public interface ConnectionCallback<T> {
* Gets called by {@code CciTemplate.execute} with an active CCI Connection. * Gets called by {@code CciTemplate.execute} with an active CCI Connection.
* Does not need to care about activating or closing the Connection, or handling * Does not need to care about activating or closing the Connection, or handling
* transactions. * transactions.
*
* <p>If called without a thread-bound CCI transaction (initiated by * <p>If called without a thread-bound CCI transaction (initiated by
* CciLocalTransactionManager), the code will simply get executed on the CCI * CciLocalTransactionManager), the code will simply get executed on the CCI
* Connection with its transactional semantics. If CciTemplate is configured * Connection with its transactional semantics. If CciTemplate is configured
* to use a JTA-aware ConnectionFactory, the CCI Connection and thus the callback * to use a JTA-aware ConnectionFactory, the CCI Connection and thus the callback
* code will be transactional if a JTA transaction is active. * code will be transactional if a JTA transaction is active.
*
* <p>Allows for returning a result object created within the callback, i.e. * <p>Allows for returning a result object created within the callback, i.e.
* a domain object or a collection of domain objects. Note that there's special * a domain object or a collection of domain objects. Note that there's special
* support for single step actions: see the {@code CciTemplate.execute} * support for single step actions: see the {@code CciTemplate.execute}
* variants. A thrown RuntimeException is treated as application exception: * variants. A thrown RuntimeException is treated as application exception:
* it gets propagated to the caller of the template. * it gets propagated to the caller of the template.
*
* @param connection active CCI Connection * @param connection active CCI Connection
* @param connectionFactory the CCI ConnectionFactory that the Connection was * @param connectionFactory the CCI ConnectionFactory that the Connection was
* created with (gives access to RecordFactory and ResourceAdapterMetaData) * created with (gives access to RecordFactory and ResourceAdapterMetaData)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -47,19 +47,16 @@ public interface InteractionCallback<T> {
* Gets called by {@code CciTemplate.execute} with an active CCI Interaction. * Gets called by {@code CciTemplate.execute} with an active CCI Interaction.
* Does not need to care about activating or closing the Interaction, or * Does not need to care about activating or closing the Interaction, or
* handling transactions. * handling transactions.
*
* <p>If called without a thread-bound CCI transaction (initiated by * <p>If called without a thread-bound CCI transaction (initiated by
* CciLocalTransactionManager), the code will simply get executed on the CCI * CciLocalTransactionManager), the code will simply get executed on the CCI
* Interaction with its transactional semantics. If CciTemplate is configured * Interaction with its transactional semantics. If CciTemplate is configured
* to use a JTA-aware ConnectionFactory, the CCI Interaction and thus the callback * to use a JTA-aware ConnectionFactory, the CCI Interaction and thus the callback
* code will be transactional if a JTA transaction is active. * code will be transactional if a JTA transaction is active.
*
* <p>Allows for returning a result object created within the callback, i.e. * <p>Allows for returning a result object created within the callback, i.e.
* a domain object or a collection of domain objects. Note that there's special * a domain object or a collection of domain objects. Note that there's special
* support for single step actions: see the {@code CciTemplate.execute} * support for single step actions: see the {@code CciTemplate.execute}
* variants. A thrown RuntimeException is treated as application exception: * variants. A thrown RuntimeException is treated as application exception:
* it gets propagated to the caller of the template. * it gets propagated to the caller of the template.
*
* @param interaction active CCI Interaction * @param interaction active CCI Interaction
* @param connectionFactory the CCI ConnectionFactory that the Connection was * @param connectionFactory the CCI ConnectionFactory that the Connection was
* created with (gives access to RecordFactory and ResourceAdapterMetaData) * created with (gives access to RecordFactory and ResourceAdapterMetaData)

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,17 +36,14 @@ public interface TransactionCallback<T> {
/** /**
* Gets called by {@link TransactionTemplate#execute} within a transactional context. * Gets called by {@link TransactionTemplate#execute} within a transactional context.
* Does not need to care about transactions itself, although it can retrieve * Does not need to care about transactions itself, although it can retrieve and
* and influence the status of the current transaction via the given status * influence the status of the current transaction via the given status object,
* object, e.g. setting rollback-only. * e.g. setting rollback-only.
* * <p>Allows for returning a result object created within the transaction, i.e. a
* <p>Allows for returning a result object created within the transaction, i.e. * domain object or a collection of domain objects. A RuntimeException thrown by the
* a domain object or a collection of domain objects. A RuntimeException thrown * callback is treated as application exception that enforces a rollback. Any such
* by the callback is treated as application exception that enforces a rollback. * exception will be propagated to the caller of the template, unless there is a
* Any such exception will be propagated to the caller of the template, unless * problem rolling back, in which case a TransactionException will be thrown.
* there is a problem rolling back, in which case a TransactionException will be
* thrown.
*
* @param status associated transaction status * @param status associated transaction status
* @return a result object, or {@code null} * @return a result object, or {@code null}
* @see TransactionTemplate#execute * @see TransactionTemplate#execute