diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6ca634be..ee650547 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -49,10 +49,13 @@ updates: - "> 2.9.9" - dependency-name: org.apache.derby:derby versions: - - "> 10.15.0.0" + - "> 10.15.2.0" + - dependency-name: org.apache.derby:derbyoptionaltools + versions: + - "> 10.15.2.0" + - dependency-name: org.apache.derby:derbyshared + versions: + - "> 10.15.2.0" - dependency-name: org.apache.tomcat:tomcat-catalina versions: - "> 9.1.0" - - dependency-name: org.hsqldb:hsqldb - versions: - - ">= 2.6.0" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7d72aefc..09259c30 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,7 +24,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macOS-latest, windows-latest] - java: [8, 11, 17, 18-ea, 19-ea] + java: [11, 17, 18, 19-ea] distribution: ['zulu'] fail-fast: false max-parallel: 4 diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml index 4db04acf..a44afe94 100644 --- a/.github/workflows/coveralls.yaml +++ b/.github/workflows/coveralls.yaml @@ -27,7 +27,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 8 + java-version: 11 distribution: zulu - name: Report Coverage to Coveralls for Pull Requests if: github.event_name == 'pull_request' diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml index 912a5a0d..96e2a691 100644 --- a/.github/workflows/sonar.yaml +++ b/.github/workflows/sonar.yaml @@ -33,7 +33,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: zulu - name: Analyze with SonarCloud run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_guice -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml index e10a38a8..a4aaa859 100644 --- a/.github/workflows/sonatype.yaml +++ b/.github/workflows/sonatype.yaml @@ -30,7 +30,7 @@ jobs: - name: Set up JDK uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 17 distribution: zulu - name: Deploy to Sonatype run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 00000000..956533e6 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1 @@ +-Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5 diff --git a/.mvn/settings.xml b/.mvn/settings.xml index 14555c50..b975a817 100644 --- a/.mvn/settings.xml +++ b/.mvn/settings.xml @@ -16,8 +16,8 @@ limitations under the License. --> - + ossrh diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index 17add53e..732313c4 100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -17,14 +17,24 @@ * under the License. */ -import java.net.*; -import java.io.*; -import java.nio.channels.*; +import java.io.IOException; +import java.io.InputStream; +import java.net.Authenticator; +import java.net.PasswordAuthentication; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.nio.file.StandardOpenOption; import java.util.Properties; -public class MavenWrapperDownloader +public final class MavenWrapperDownloader { - private static final String WRAPPER_VERSION = "3.1.0"; + private static final String WRAPPER_VERSION = "3.1.1"; + + private static final boolean VERBOSE = Boolean.parseBoolean( System.getenv( "MVNW_VERBOSE" ) ); /** * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. @@ -49,78 +59,53 @@ public class MavenWrapperDownloader */ private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; - public static void main( String args[] ) + public static void main( String[] args ) { - System.out.println( "- Downloader started" ); - File baseDirectory = new File( args[0] ); - System.out.println( "- Using base directory: " + baseDirectory.getAbsolutePath() ); - - // If the maven-wrapper.properties exists, read it and check if it contains a custom - // wrapperUrl parameter. - File mavenWrapperPropertyFile = new File( baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH ); - String url = DEFAULT_DOWNLOAD_URL; - if ( mavenWrapperPropertyFile.exists() ) + if ( args.length == 0 ) { - FileInputStream mavenWrapperPropertyFileInputStream = null; - try - { - mavenWrapperPropertyFileInputStream = new FileInputStream( mavenWrapperPropertyFile ); - Properties mavenWrapperProperties = new Properties(); - mavenWrapperProperties.load( mavenWrapperPropertyFileInputStream ); - url = mavenWrapperProperties.getProperty( PROPERTY_NAME_WRAPPER_URL, url ); - } - catch ( IOException e ) - { - System.out.println( "- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" ); - } - finally - { - try - { - if ( mavenWrapperPropertyFileInputStream != null ) - { - mavenWrapperPropertyFileInputStream.close(); - } - } - catch ( IOException e ) - { - // Ignore ... - } - } + System.err.println( " - ERROR projectBasedir parameter missing" ); + System.exit( 1 ); } - System.out.println( "- Downloading from: " + url ); - File outputFile = new File( baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH ); - if ( !outputFile.getParentFile().exists() ) + log( " - Downloader started" ); + final String dir = args[0].replace( "..", "" ); // Sanitize path + final Path projectBasedir = Paths.get( dir ).toAbsolutePath().normalize(); + if ( !Files.isDirectory( projectBasedir, LinkOption.NOFOLLOW_LINKS ) ) { - if ( !outputFile.getParentFile().mkdirs() ) - { - System.out.println( "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() - + "'" ); - } + System.err.println( " - ERROR projectBasedir not exists: " + projectBasedir ); + System.exit( 1 ); } - System.out.println( "- Downloading to: " + outputFile.getAbsolutePath() ); + + log( " - Using base directory: " + projectBasedir ); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + Path mavenWrapperPropertyFile = projectBasedir.resolve( MAVEN_WRAPPER_PROPERTIES_PATH ); + String url = readWrapperUrl( mavenWrapperPropertyFile ); + try { + Path outputFile = projectBasedir.resolve( MAVEN_WRAPPER_JAR_PATH ); + createDirectories( outputFile.getParent() ); downloadFileFromURL( url, outputFile ); - System.out.println( "Done" ); + log( "Done" ); System.exit( 0 ); } - catch ( Throwable e ) + catch ( IOException e ) { - System.out.println( "- Error downloading" ); + System.err.println( "- Error downloading" ); e.printStackTrace(); System.exit( 1 ); } } - private static void downloadFileFromURL( String urlString, File destination ) - throws Exception + private static void downloadFileFromURL( String urlString, Path destination ) throws IOException { + log( " - Downloading to: " + destination ); if ( System.getenv( "MVNW_USERNAME" ) != null && System.getenv( "MVNW_PASSWORD" ) != null ) { - String username = System.getenv( "MVNW_USERNAME" ); - char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray(); + final String username = System.getenv( "MVNW_USERNAME" ); + final char[] password = System.getenv( "MVNW_PASSWORD" ).toCharArray(); Authenticator.setDefault( new Authenticator() { @Override @@ -131,12 +116,47 @@ protected PasswordAuthentication getPasswordAuthentication() } ); } URL website = new URL( urlString ); - ReadableByteChannel rbc; - rbc = Channels.newChannel( website.openStream() ); - FileOutputStream fos = new FileOutputStream( destination ); - fos.getChannel().transferFrom( rbc, 0, Long.MAX_VALUE ); - fos.close(); - rbc.close(); + try ( InputStream inStream = website.openStream() ) { + Files.copy( inStream, destination, StandardCopyOption.REPLACE_EXISTING ); + } + log( " - Downloader complete" ); + } + + private static void createDirectories(Path outputPath) throws IOException + { + if ( !Files.isDirectory( outputPath, LinkOption.NOFOLLOW_LINKS ) ) { + Path createDirectories = Files.createDirectories( outputPath ); + log( " - Directories created: " + createDirectories ); + } + } + + private static String readWrapperUrl( Path mavenWrapperPropertyFile ) + { + String url = DEFAULT_DOWNLOAD_URL; + if ( Files.exists( mavenWrapperPropertyFile, LinkOption.NOFOLLOW_LINKS ) ) + { + log( " - Reading property file: " + mavenWrapperPropertyFile ); + try ( InputStream in = Files.newInputStream( mavenWrapperPropertyFile, StandardOpenOption.READ ) ) + { + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load( in ); + url = mavenWrapperProperties.getProperty( PROPERTY_NAME_WRAPPER_URL, DEFAULT_DOWNLOAD_URL ); + } + catch ( IOException e ) + { + System.err.println( " - ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'" ); + } + } + log( " - Downloading from: " + url ); + return url; + } + + private static void log( String msg ) + { + if ( VERBOSE ) + { + System.out.println( msg ); + } } } diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 8c79a83a..dc3affce 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -5,14 +5,14 @@ # to you 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 -# +# +# https://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. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar diff --git a/license.txt b/LICENSE_HEADER similarity index 100% rename from license.txt rename to LICENSE_HEADER diff --git a/README.md b/README.md index 89f56d95..eb2998bf 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ MyBatis Guice Module [![Coverage Status](https://coveralls.io/repos/mybatis/guice/badge.svg?branch=master&service=github)](https://coveralls.io/github/mybatis/guice?branch=master) [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-guice/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-guice) [![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis-guice.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-guice/) -[![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) +[![License](https://img.shields.io/:license-apache-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) ![mybatis-guice](http://mybatis.github.io/images/mybatis-logo.png) diff --git a/pom.xml b/pom.xml index 4dc05ba8..7401434c 100644 --- a/pom.xml +++ b/pom.xml @@ -17,12 +17,13 @@ --> + 4.0.0 org.mybatis mybatis-parent - 34 + 35 @@ -192,6 +193,7 @@ jakarta.annotation jakarta.annotation-api ${annotation-api.version} + true @@ -247,7 +249,7 @@ org.hsqldb hsqldb - 2.5.2 + 2.7.0 test @@ -301,7 +303,19 @@ org.apache.derby derby - 10.14.2.0 + 10.15.2.0 + test + + + org.apache.derby + derbyshared + 10.15.2.0 + test + + + org.apache.derby + derbyoptionaltools + 10.15.2.0 test @@ -377,6 +391,17 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + + + + test + + + + org.apache.maven.plugins maven-surefire-plugin diff --git a/src/main/java/org/mybatis/guice/AbstractMyBatisModule.java b/src/main/java/org/mybatis/guice/AbstractMyBatisModule.java index d7a990d3..57747957 100644 --- a/src/main/java/org/mybatis/guice/AbstractMyBatisModule.java +++ b/src/main/java/org/mybatis/guice/AbstractMyBatisModule.java @@ -106,6 +106,7 @@ final void bindMapper(Class mapperType) { * * @param resourceClassLoader * the resource class loader + * * @since 3.3 */ public void useResourceClassLoader(ClassLoader resourceClassLoader) { @@ -116,6 +117,7 @@ public void useResourceClassLoader(ClassLoader resourceClassLoader) { * Gets the resource class loader. * * @return the resource class loader + * * @since 3.3 */ protected final ClassLoader getResourceClassLoader() { @@ -127,6 +129,7 @@ protected final ClassLoader getResourceClassLoader() { * * @param driverClassLoader * the driver class loader + * * @since 3.3 */ public void useJdbcDriverClassLoader(ClassLoader driverClassLoader) { @@ -137,6 +140,7 @@ public void useJdbcDriverClassLoader(ClassLoader driverClassLoader) { * Gets the default class loader. * * @return the default class loader + * * @since 3.3 */ private ClassLoader getDefaultClassLoader() { diff --git a/src/main/java/org/mybatis/guice/MyBatisModule.java b/src/main/java/org/mybatis/guice/MyBatisModule.java index 2c281a20..59d15b61 100644 --- a/src/main/java/org/mybatis/guice/MyBatisModule.java +++ b/src/main/java/org/mybatis/guice/MyBatisModule.java @@ -280,6 +280,7 @@ protected final void executorType(ExecutorType executorType) { * * @param localeCacheScope * The cache scope to use. + * * @since 3.4 */ protected final void localCacheScope(LocalCacheScope localeCacheScope) { @@ -428,6 +429,7 @@ protected final void bindDefaultScriptingLanguageType(Class TypeHandlerBinder handleType(final Class type) { @@ -691,6 +694,7 @@ protected final void addMapperClasses(final String packageName, final ResolverUt * * @param packageName * the package has to be analyzed. + * * @return a set of all classes contained in the given package. */ private static Set> getClasses(String packageName) { @@ -704,6 +708,7 @@ private static Set> getClasses(String packageName) { * the class filter on the given package. * @param packageName * the package has to be analyzed. + * * @return a set of all classes contained in the given package. */ private static Set> getClasses(ResolverUtil.Test test, String packageName) { diff --git a/src/main/java/org/mybatis/guice/Preconditions.java b/src/main/java/org/mybatis/guice/Preconditions.java index 10426b5a..1e21f921 100644 --- a/src/main/java/org/mybatis/guice/Preconditions.java +++ b/src/main/java/org/mybatis/guice/Preconditions.java @@ -27,7 +27,6 @@ * throw new IllegalArgumentException("must be positive: " + count); * } * - * *

* to be replaced with the more compact *

@@ -35,13 +34,11 @@ *
  * checkArgument(count > 0, "must be positive: %s", count);
  * 
- * *

* Note that the sense of the expression is inverted; with {@code Preconditions} you declare what you expect to be * true, just as you do with an * {@code assert} or a JUnit {@code assertTrue()} call. *

- * *

* Take care not to confuse precondition checking with other similar types of checks! Precondition exceptions -- * including those provided here, but also {@link IndexOutOfBoundsException}, {@link NoSuchElementException}, @@ -49,7 +46,6 @@ * error. This tells the caller that it should not have invoked the method when it did, with the arguments it did, or * perhaps ever. Postcondition or other invariant failures should not throw these types of exceptions. *

- * *

* Note: The methods of the {@code Preconditions} class are highly unusual in one way: they are supposed * to throw exceptions, and promise in their specifications to do so even when given perfectly valid input. That is, @@ -57,7 +53,6 @@ * be even marked as {@link com.google.inject.internal.util.Nullable} -- yet the method will still throw an exception * anyway, because that's what its contract says to do. *

- * *

* This class may be used with the Google Web Toolkit (GWT). *

@@ -73,6 +68,7 @@ private Preconditions() { * * @param expression * a boolean expression + * * @throws IllegalArgumentException * if {@code expression} is false */ @@ -90,6 +86,7 @@ public static void checkArgument(boolean expression) { * @param errorMessage * the exception message to use if the check fails; will be converted to a string using * {@link String#valueOf(Object)} + * * @throws IllegalArgumentException * if {@code expression} is false */ @@ -112,6 +109,7 @@ public static void checkArgument(boolean expression, Object errorMessage) { * @param errorMessageArgs * the arguments to be substituted into the message template. Arguments are converted to strings using * {@link String#valueOf(Object)}. + * * @throws IllegalArgumentException * if {@code expression} is false * @throws NullPointerException @@ -130,6 +128,7 @@ public static void checkArgument(boolean expression, String errorMessageTemplate * * @param expression * a boolean expression + * * @throws IllegalStateException * if {@code expression} is false */ @@ -148,6 +147,7 @@ public static void checkState(boolean expression) { * @param errorMessage * the exception message to use if the check fails; will be converted to a string using * {@link String#valueOf(Object)} + * * @throws IllegalStateException * if {@code expression} is false */ @@ -171,6 +171,7 @@ public static void checkState(boolean expression, Object errorMessage) { * @param errorMessageArgs * the arguments to be substituted into the message template. Arguments are converted to strings using * {@link String#valueOf(Object)}. + * * @throws IllegalStateException * if {@code expression} is false * @throws NullPointerException @@ -188,7 +189,9 @@ public static void checkState(boolean expression, String errorMessageTemplate, O * * @param reference * an object reference + * * @return the non-null reference that was validated + * * @throws NullPointerException * if {@code reference} is null */ @@ -207,7 +210,9 @@ public static T checkNotNull(T reference) { * @param errorMessage * the exception message to use if the check fails; will be converted to a string using * {@link String#valueOf(Object)} + * * @return the non-null reference that was validated + * * @throws NullPointerException * if {@code reference} is null */ @@ -231,7 +236,9 @@ public static T checkNotNull(T reference, Object errorMessage) { * @param errorMessageArgs * the arguments to be substituted into the message template. Arguments are converted to strings using * {@link String#valueOf(Object)}. + * * @return the non-null reference that was validated + * * @throws NullPointerException * if {@code reference} is null */ @@ -249,7 +256,9 @@ public static T checkNotNull(T reference, String errorMessageTemplate, Objec * * @param iterable * the iterable to check the contents of + * * @return the non-null {@code iterable} reference just validated + * * @throws NullPointerException * if {@code iterable} is null or contains at least one null element */ @@ -269,7 +278,9 @@ public static > T checkContentsNotNull(T iterable) { * @param errorMessage * the exception message to use if the check fails; will be converted to a string using * {@link String#valueOf(Object)} + * * @return the non-null {@code iterable} reference just validated + * * @throws NullPointerException * if {@code iterable} is null or contains at least one null element */ @@ -294,7 +305,9 @@ public static > T checkContentsNotNull(T iterable, Object * @param errorMessageArgs * the arguments to be substituted into the message template. Arguments are converted to strings using * {@link String#valueOf(Object)}. + * * @return the non-null {@code iterable} reference just validated + * * @throws NullPointerException * if {@code iterable} is null or contains at least one null element */ @@ -337,6 +350,7 @@ private static boolean containsOrIsNull(Iterable iterable) { * a user-supplied index identifying an element of an array, list or string * @param size * the size of that array, list or string + * * @throws IndexOutOfBoundsException * if {@code index} is negative or is not less than {@code size} * @throws IllegalArgumentException @@ -356,6 +370,7 @@ public static void checkElementIndex(int index, int size) { * the size of that array, list or string * @param desc * the text to use to describe this index in an error message + * * @throws IndexOutOfBoundsException * if {@code index} is negative or is not less than {@code size} * @throws IllegalArgumentException @@ -379,6 +394,7 @@ public static void checkElementIndex(int index, int size, String desc) { * a user-supplied index identifying a position in an array, list or string * @param size * the size of that array, list or string + * * @throws IndexOutOfBoundsException * if {@code index} is negative or is greater than {@code size} * @throws IllegalArgumentException @@ -398,6 +414,7 @@ public static void checkPositionIndex(int index, int size) { * the size of that array, list or string * @param desc * the text to use to describe this index in an error message + * * @throws IndexOutOfBoundsException * if {@code index} is negative or is greater than {@code size} * @throws IllegalArgumentException @@ -423,6 +440,7 @@ public static void checkPositionIndex(int index, int size, String desc) { * a user-supplied index identifying a ending position in an array, list or string * @param size * the size of that array, list or string + * * @throws IndexOutOfBoundsException * if either index is negative or is greater than {@code size}, or if {@code end} is less than {@code start} * @throws IllegalArgumentException diff --git a/src/main/java/org/mybatis/guice/configuration/ConfigurationProvider.java b/src/main/java/org/mybatis/guice/configuration/ConfigurationProvider.java index bd329882..95bacc3c 100644 --- a/src/main/java/org/mybatis/guice/configuration/ConfigurationProvider.java +++ b/src/main/java/org/mybatis/guice/configuration/ConfigurationProvider.java @@ -110,6 +110,7 @@ public class ConfigurationProvider implements Provider, Configura * * @param environment * the environment + * * @since 1.0.1 */ @com.google.inject.Inject @@ -127,6 +128,7 @@ public void setEnvironment(Environment environment) { * * @param failFast * flag to check all statements are completed + * * @since 1.0.1 */ public void setFailFast(boolean failFast) { @@ -148,6 +150,7 @@ public void addMapperConfigurationSetting(MapperConfigurationSetting mapperConfi * * @param environment * the environment + * * @return new configuration */ protected Configuration newConfiguration(Environment environment) { diff --git a/src/main/java/org/mybatis/guice/datasource/builtin/PooledDataSourceProvider.java b/src/main/java/org/mybatis/guice/datasource/builtin/PooledDataSourceProvider.java index 9a463c44..86c74611 100644 --- a/src/main/java/org/mybatis/guice/datasource/builtin/PooledDataSourceProvider.java +++ b/src/main/java/org/mybatis/guice/datasource/builtin/PooledDataSourceProvider.java @@ -55,6 +55,7 @@ public PooledDataSourceProvider(@Named("JDBC.driver") final String driver, @Name * * @param username * the new user + * * @since 3.3 */ @com.google.inject.Inject(optional = true) @@ -67,6 +68,7 @@ public void setUser(@Named("JDBC.username") final String username) { * * @param password * the new password + * * @since 3.3 */ @com.google.inject.Inject(optional = true) diff --git a/src/main/java/org/mybatis/guice/datasource/builtin/UnpooledDataSourceProvider.java b/src/main/java/org/mybatis/guice/datasource/builtin/UnpooledDataSourceProvider.java index f0fa2216..f9e4c253 100644 --- a/src/main/java/org/mybatis/guice/datasource/builtin/UnpooledDataSourceProvider.java +++ b/src/main/java/org/mybatis/guice/datasource/builtin/UnpooledDataSourceProvider.java @@ -55,6 +55,7 @@ public UnpooledDataSourceProvider(@Named("JDBC.driver") final String driver, @Na * * @param username * the new user + * * @since 3.3 */ @com.google.inject.Inject(optional = true) @@ -67,6 +68,7 @@ public void setUser(@Named("JDBC.username") final String username) { * * @param password * the new password + * * @since 3.3 */ @com.google.inject.Inject(optional = true) diff --git a/src/main/java/org/mybatis/guice/datasource/c3p0/C3p0DataSourceProvider.java b/src/main/java/org/mybatis/guice/datasource/c3p0/C3p0DataSourceProvider.java index fcb56224..d513e8c5 100644 --- a/src/main/java/org/mybatis/guice/datasource/c3p0/C3p0DataSourceProvider.java +++ b/src/main/java/org/mybatis/guice/datasource/c3p0/C3p0DataSourceProvider.java @@ -61,6 +61,7 @@ public C3p0DataSourceProvider(@Named("JDBC.driver") final String driver, @Named( * * @param username * the new user + * * @since 3.3 */ @com.google.inject.Inject(optional = true) @@ -73,6 +74,7 @@ public void setUser(@Named("JDBC.username") final String username) { * * @param password * the new password + * * @since 3.3 */ @com.google.inject.Inject(optional = true) diff --git a/src/main/java/org/mybatis/guice/datasource/dbcp/BasicDataSourceProvider.java b/src/main/java/org/mybatis/guice/datasource/dbcp/BasicDataSourceProvider.java index 8993ec2a..da6d77e6 100644 --- a/src/main/java/org/mybatis/guice/datasource/dbcp/BasicDataSourceProvider.java +++ b/src/main/java/org/mybatis/guice/datasource/dbcp/BasicDataSourceProvider.java @@ -58,6 +58,7 @@ public BasicDataSourceProvider(@Named("JDBC.driver") final String driver, @Named * * @param username * the new user + * * @since 3.3 */ @com.google.inject.Inject(optional = true) @@ -70,6 +71,7 @@ public void setUser(@Named("JDBC.username") final String username) { * * @param password * the new password + * * @since 3.3 */ @com.google.inject.Inject(optional = true) diff --git a/src/main/java/org/mybatis/guice/datasource/dbcp/DriverAdapterCPDSProvider.java b/src/main/java/org/mybatis/guice/datasource/dbcp/DriverAdapterCPDSProvider.java index c9d11a05..ff6802b7 100644 --- a/src/main/java/org/mybatis/guice/datasource/dbcp/DriverAdapterCPDSProvider.java +++ b/src/main/java/org/mybatis/guice/datasource/dbcp/DriverAdapterCPDSProvider.java @@ -52,6 +52,7 @@ public DriverAdapterCPDSProvider(@Named("JDBC.driver") final String driver, @Nam * * @param username * the new user + * * @since 3.3 */ @com.google.inject.Inject(optional = true) @@ -64,6 +65,7 @@ public void setUser(@Named("JDBC.username") final String username) { * * @param password * the new password + * * @since 3.3 */ @com.google.inject.Inject(optional = true) diff --git a/src/main/java/org/mybatis/guice/datasource/dbcp/PerUserPoolDataSourceModule.java b/src/main/java/org/mybatis/guice/datasource/dbcp/PerUserPoolDataSourceModule.java index 91d5940f..0e532648 100644 --- a/src/main/java/org/mybatis/guice/datasource/dbcp/PerUserPoolDataSourceModule.java +++ b/src/main/java/org/mybatis/guice/datasource/dbcp/PerUserPoolDataSourceModule.java @@ -99,6 +99,7 @@ public static final class Builder { * * @param perUserDefaultAutoCommitProviderClass * the perUserDefaultAutoCommitProviderClass to set + * * @return the builder */ public Builder setPerUserDefaultAutoCommitProviderClass( @@ -112,6 +113,7 @@ public Builder setPerUserDefaultAutoCommitProviderClass( * * @param perUserDefaultReadOnlyProviderClass * the perUserDefaultReadOnlyProviderClass to set + * * @return the builder */ public Builder setPerUserDefaultReadOnlyProviderClass( @@ -125,6 +127,7 @@ public Builder setPerUserDefaultReadOnlyProviderClass( * * @param perUserDefaultTransactionIsolationProviderClass * the perUserDefaultTransactionIsolationProviderClass to set + * * @return the builder */ public Builder setPerUserDefaultTransactionIsolationProviderClass( @@ -138,6 +141,7 @@ public Builder setPerUserDefaultTransactionIsolationProviderClass( * * @param perUserMaxActiveProviderClass * the perUserMaxActiveProviderClass to set + * * @return the builder */ public Builder setPerUserMaxTotalProviderClass( @@ -151,6 +155,7 @@ public Builder setPerUserMaxTotalProviderClass( * * @param perUserMaxIdleProviderClass * the perUserMaxIdleProviderClass to set + * * @return the builder */ public Builder setPerUserMaxIdleProviderClass( @@ -164,6 +169,7 @@ public Builder setPerUserMaxIdleProviderClass( * * @param perUserMaxWaitProviderClass * the perUserMaxWaitProviderClass to set + * * @return the builder */ public Builder setPerUserMaxWaitMillisProviderClass( diff --git a/src/main/java/org/mybatis/guice/session/SqlSessionFactoryProvider.java b/src/main/java/org/mybatis/guice/session/SqlSessionFactoryProvider.java index 7457781e..5f4a51d0 100644 --- a/src/main/java/org/mybatis/guice/session/SqlSessionFactoryProvider.java +++ b/src/main/java/org/mybatis/guice/session/SqlSessionFactoryProvider.java @@ -57,6 +57,7 @@ public SqlSessionFactoryProvider(final Configuration configuration) { * * @param configuration * the specified configuration. + * * @since 1.0.1 */ @Inject diff --git a/src/main/java/org/mybatis/guice/session/SqlSessionManagerProvider.java b/src/main/java/org/mybatis/guice/session/SqlSessionManagerProvider.java index 22e5e53b..87daa9ce 100644 --- a/src/main/java/org/mybatis/guice/session/SqlSessionManagerProvider.java +++ b/src/main/java/org/mybatis/guice/session/SqlSessionManagerProvider.java @@ -46,6 +46,7 @@ public SqlSessionManagerProvider(SqlSessionFactory sqlSessionFactory) { * * @param sqlSessionFactory * the sql session factory + * * @since 1.0.1 */ @Inject diff --git a/src/main/java/org/mybatis/guice/transactional/Isolation.java b/src/main/java/org/mybatis/guice/transactional/Isolation.java index a9b1b02f..f0f252ae 100644 --- a/src/main/java/org/mybatis/guice/transactional/Isolation.java +++ b/src/main/java/org/mybatis/guice/transactional/Isolation.java @@ -22,15 +22,21 @@ * to add the DEFAULT level which means - do not specify an isolation level. * * @author Jeff Butler + * * @since 3.1 */ public enum Isolation { DEFAULT(null), + NONE(TransactionIsolationLevel.NONE), + READ_COMMITTED(TransactionIsolationLevel.READ_COMMITTED), + READ_UNCOMMITTED(TransactionIsolationLevel.READ_UNCOMMITTED), + REPEATABLE_READ(TransactionIsolationLevel.REPEATABLE_READ), + SERIALIZABLE(TransactionIsolationLevel.SERIALIZABLE); private final TransactionIsolationLevel transactionIsolationLevel; diff --git a/src/main/java/org/mybatis/guice/transactional/Transactional.java b/src/main/java/org/mybatis/guice/transactional/Transactional.java index ac4f1796..f1cfe289 100644 --- a/src/main/java/org/mybatis/guice/transactional/Transactional.java +++ b/src/main/java/org/mybatis/guice/transactional/Transactional.java @@ -48,6 +48,7 @@ * Returns the constant indicating the transaction isolation level. * * @return the constant indicating the transaction isolation level. + * * @deprecated use {@link #isolation()} instead, setting this property has no effect. */ @Deprecated @@ -79,18 +80,19 @@ /** * A custom error message when throwing the custom exception. - * + *

* It supports java.util.Formatter place holders, intercepted method arguments will be used as message format * arguments. * * @return a custom error message when throwing the custom exception. + * * @see java.util.Formatter#format(String, Object...) */ String exceptionMessage() default ""; /** * If true, the transaction will never committed but rather rolled back, useful for testing purposes. - * + *

* This parameter is false by default. * * @return if true, the transaction will never committed but rather rolled back, useful for testing purposes. diff --git a/src/main/java/org/mybatis/guice/transactional/TxTransactionalMethodInterceptor.java b/src/main/java/org/mybatis/guice/transactional/TxTransactionalMethodInterceptor.java index e74342eb..4f20d813 100644 --- a/src/main/java/org/mybatis/guice/transactional/TxTransactionalMethodInterceptor.java +++ b/src/main/java/org/mybatis/guice/transactional/TxTransactionalMethodInterceptor.java @@ -34,7 +34,6 @@ /** * Method interceptor for {@link Transactional} annotation. - * */ public class TxTransactionalMethodInterceptor implements MethodInterceptor { /** diff --git a/src/test/java/org/mybatis/guice/customconfiguration/MyConfigurationProvider.java b/src/test/java/org/mybatis/guice/customconfiguration/MyConfigurationProvider.java index e821537b..ea98f5ce 100644 --- a/src/test/java/org/mybatis/guice/customconfiguration/MyConfigurationProvider.java +++ b/src/test/java/org/mybatis/guice/customconfiguration/MyConfigurationProvider.java @@ -25,6 +25,7 @@ public class MyConfigurationProvider extends ConfigurationProvider { /** * @param environment + * * @since 1.0.1 */ @Inject diff --git a/src/test/java/org/mybatis/guice/jta/JtaCustomXaResourceTest.java b/src/test/java/org/mybatis/guice/jta/JtaCustomXaResourceTest.java index 467c3976..637e2266 100644 --- a/src/test/java/org/mybatis/guice/jta/JtaCustomXaResourceTest.java +++ b/src/test/java/org/mybatis/guice/jta/JtaCustomXaResourceTest.java @@ -111,7 +111,7 @@ void tearDown(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) commit REQUIRED - * + *

* have 1 rows */ @Test diff --git a/src/test/java/org/mybatis/guice/jta/JtaLocalTest.java b/src/test/java/org/mybatis/guice/jta/JtaLocalTest.java index ac40ed9a..45c94934 100644 --- a/src/test/java/org/mybatis/guice/jta/JtaLocalTest.java +++ b/src/test/java/org/mybatis/guice/jta/JtaLocalTest.java @@ -137,7 +137,7 @@ void tearDown(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) commit REQUIRED - * + *

* have 1 rows */ @Test @@ -148,7 +148,7 @@ void testRequired(TestInfo testInfo) throws Exception { /** * begin REQUIRES_NEW insert(id=1) commit REQUIRES_NEW - * + *

* have 1 rows */ @Test @@ -159,7 +159,7 @@ void testRequiresNew(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) roll back REQUIRED - * + *

* have 0 rows */ @Test @@ -173,7 +173,7 @@ void testRequiredAndRollback(TestInfo testInfo) throws Exception { /** * begin REQUIRES_NEW insert(id=1) roll back REQUIRES_NEW - * + *

* have 0 rows */ @Test @@ -187,7 +187,7 @@ void testRequiresNewAndRollback(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) begin REQUIRES_NEW insert(id=2) commit REQUIRES_NEW commit REQUIRED - * + *

* have 2 rows */ @Test @@ -198,7 +198,7 @@ void testRequiredAndRequiresNew(TestInfo testInfo) throws Exception { /** * begin REQUIRED begin REQUIRES_NEW insert(id=2) commit REQUIRES_NEW insert(id=1) commit REQUIRED - * + *

* have 2 rows */ @Test @@ -209,7 +209,7 @@ void testRequiresNewAndRequired(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) begin REQUIRES_NEW insert(id=2) roll back REQUIRES_NEW commit REQUIRED - * + *

* have 1 rows and id=1 (from commited REQUIRED) */ @Test @@ -223,7 +223,7 @@ void testRollbackInternalRequiresNew(TestInfo testInfo) throws Exception { /** * begin REQUIRED begin REQUIRES_NEW insert(id=1) roll back REQUIRES_NEW insert(id=2) commit REQUIRED - * + *

* have 1 rows and id=2 (from commited REQUIRED) */ @Test @@ -237,7 +237,7 @@ void testRollbackInternalRequiresNew2(TestInfo testInfo) throws Exception { /** * begin REQUIRED begin REQUIRES_NEW insert(id=1) commit REQUIRES_NEW insert(id=2) roll back REQUIRED - * + *

* have 1 rows and id=1 (from commited REQUIRES_NEW) */ @Test @@ -251,7 +251,7 @@ void testRollbackExternalRequired(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) begin REQUIRES_NEW insert(id=2) commit REQUIRES_NEW roll back REQUIRED - * + *

* have 1 rows and id=2 (from commited REQUIRES_NEW) */ @Test diff --git a/src/test/java/org/mybatis/guice/jta/JtaProcess.java b/src/test/java/org/mybatis/guice/jta/JtaProcess.java index 50211e42..69367a47 100644 --- a/src/test/java/org/mybatis/guice/jta/JtaProcess.java +++ b/src/test/java/org/mybatis/guice/jta/JtaProcess.java @@ -49,7 +49,7 @@ private void inserts(int offset) { /** * begin REQUIRED insert(id=1) commit REQUIRED - * + *

* have 1 rows */ @Transactional @@ -60,7 +60,7 @@ public void required(int offset) { /** * begin REQUIRES_NEW insert(id=1) commit REQUIRES_NEW - * + *

* have 1 rows */ @Transactional(Transactional.TxType.REQUIRES_NEW) @@ -71,7 +71,7 @@ public void requiresNew(int offset) { /** * begin REQUIRED insert(id=1) roll back REQUIRED - * + *

* have 0 rows */ @Transactional @@ -84,7 +84,7 @@ public void requiredAndRollback(int offset) throws JtaRollbackException { /** * begin REQUIRES_NEW insert(id=1) roll back REQUIRES_NEW - * + *

* have 0 rows */ @Transactional(Transactional.TxType.REQUIRES_NEW) @@ -97,7 +97,7 @@ public void requiresNewAndRollback(int offset) throws JtaRollbackException { /** * begin REQUIRED insert(id=1) begin REQUIRES_NEW insert(id=2) commit REQUIRES_NEW commit REQUIRED - * + *

* have 2 rows */ @Transactional @@ -111,7 +111,7 @@ public void requiredAndRequiresNew() { /** * begin REQUIRED begin REQUIRES_NEW insert(id=1) commit REQUIRES_NEW insert(id=2) commit REQUIRED - * + *

* have 2 rows */ @Transactional @@ -125,7 +125,7 @@ public void requiresNewAndRequired() { /** * begin REQUIRED insert(id=1) begin REQUIRES_NEW insert(id=2) roll back REQUIRES_NEW commit REQUIRED - * + *

* have 1 rows and id=1 (from commited REQUIRED) */ @Transactional @@ -147,7 +147,7 @@ public void rollbackInternalRequiresNew() throws JtaRollbackException { /** * begin REQUIRED begin REQUIRES_NEW insert(id=1) roll back REQUIRES_NEW insert(id=2) commit REQUIRED - * + *

* have 1 rows and id=2 (from commited REQUIRED) */ @Transactional @@ -169,7 +169,7 @@ public void rollbackInternalRequiresNew2() throws JtaRollbackException { /** * begin REQUIRED begin REQUIRES_NEW insert(id=1) commit REQUIRES_NEW insert(id=2) roll back REQUIRED - * + *

* have 1 rows and id=1 (from commited REQUIRES_NEW) */ @Transactional @@ -189,7 +189,7 @@ public void rollbackExternalRequired() throws JtaRollbackException { /** * begin REQUIRED insert(id=1) begin REQUIRES_NEW insert(id=2) commit REQUIRES_NEW roll back REQUIRED - * + *

* have 1 rows and id=2 (from commited REQUIRES_NEW) */ @Transactional diff --git a/src/test/java/org/mybatis/guice/jta/JtaXaTest.java b/src/test/java/org/mybatis/guice/jta/JtaXaTest.java index 4998a755..ad72cb7a 100644 --- a/src/test/java/org/mybatis/guice/jta/JtaXaTest.java +++ b/src/test/java/org/mybatis/guice/jta/JtaXaTest.java @@ -136,7 +136,7 @@ void tearDown(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) commit REQUIRED - * + *

* have 1 rows */ @Test @@ -147,7 +147,7 @@ void testRequired(TestInfo testInfo) throws Exception { /** * begin REQUIRES_NEW insert(id=1) commit REQUIRES_NEW - * + *

* have 1 rows */ @Test @@ -158,7 +158,7 @@ void testRequiresNew(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) roll back REQUIRED - * + *

* have 0 rows */ @Test @@ -172,7 +172,7 @@ void testRequiredAndRollback(TestInfo testInfo) throws Exception { /** * begin REQUIRES_NEW insert(id=1) roll back REQUIRES_NEW - * + *

* have 0 rows */ @Test @@ -186,7 +186,7 @@ void testRequiresNewAndRollback(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) begin REQUIRES_NEW insert(id=2) commit REQUIRES_NEW commit REQUIRED - * + *

* have 2 rows */ @Test @@ -197,7 +197,7 @@ void testRequiredAndRequiresNew(TestInfo testInfo) throws Exception { /** * begin REQUIRED begin REQUIRES_NEW insert(id=2) commit REQUIRES_NEW insert(id=1) commit REQUIRED - * + *

* have 2 rows */ @Test @@ -208,7 +208,7 @@ void testRequiresNewAndRequired(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) begin REQUIRES_NEW insert(id=2) roll back REQUIRES_NEW commit REQUIRED - * + *

* have 1 rows and id=1 (from commited REQUIRED) */ @Test @@ -222,7 +222,7 @@ void testRollbackInternalRequiresNew(TestInfo testInfo) throws Exception { /** * begin REQUIRED begin REQUIRES_NEW insert(id=1) roll back REQUIRES_NEW insert(id=2) commit REQUIRED - * + *

* have 1 rows and id=2 (from commited REQUIRED) */ @Test @@ -236,7 +236,7 @@ void testRollbackInternalRequiresNew2(TestInfo testInfo) throws Exception { /** * begin REQUIRED begin REQUIRES_NEW insert(id=1) commit REQUIRES_NEW insert(id=2) roll back REQUIRED - * + *

* have 1 rows and id=1 (from commited REQUIRES_NEW) */ @Test @@ -250,7 +250,7 @@ void testRollbackExternalRequired(TestInfo testInfo) throws Exception { /** * begin REQUIRED insert(id=1) begin REQUIRES_NEW insert(id=2) commit REQUIRES_NEW roll back REQUIRED - * + *

* have 1 rows and id=2 (from commited REQUIRES_NEW) */ @Test diff --git a/src/test/java/org/mybatis/guice/sample/SampleBasicTest.java b/src/test/java/org/mybatis/guice/sample/SampleBasicTest.java index 47c6aece..3947d7f1 100644 --- a/src/test/java/org/mybatis/guice/sample/SampleBasicTest.java +++ b/src/test/java/org/mybatis/guice/sample/SampleBasicTest.java @@ -45,7 +45,7 @@ /** * Example of MyBatis-Guice basic integration usage. - * + *

* This is the recommended scenario. */ class SampleBasicTest { diff --git a/src/test/java/org/mybatis/guice/sample/SampleSqlSessionTest.java b/src/test/java/org/mybatis/guice/sample/SampleSqlSessionTest.java index 9c1d22fa..4e218c1f 100644 --- a/src/test/java/org/mybatis/guice/sample/SampleSqlSessionTest.java +++ b/src/test/java/org/mybatis/guice/sample/SampleSqlSessionTest.java @@ -52,7 +52,7 @@ /** * Example of MyBatis-Guice basic integration usage. - * + *

* This is the recommended scenario. */ class SampleSqlSessionTest { diff --git a/src/test/java/org/mybatis/guice/sample/service/FooService.java b/src/test/java/org/mybatis/guice/sample/service/FooService.java index 590b2995..52000bc9 100644 --- a/src/test/java/org/mybatis/guice/sample/service/FooService.java +++ b/src/test/java/org/mybatis/guice/sample/service/FooService.java @@ -19,7 +19,7 @@ /** * FooService acts as a business service. - * + *

* All calls to any method of FooService are transactional. */ public interface FooService { diff --git a/src/test/java/org/mybatis/guice/sample/service/FooServiceDaoImpl.java b/src/test/java/org/mybatis/guice/sample/service/FooServiceDaoImpl.java index cb5d173b..6442af60 100644 --- a/src/test/java/org/mybatis/guice/sample/service/FooServiceDaoImpl.java +++ b/src/test/java/org/mybatis/guice/sample/service/FooServiceDaoImpl.java @@ -25,7 +25,7 @@ /** * Impl of the FooService. - * + *

* FooService simply receives a userId and uses a mapper/dao to get a record from the database. */ @Transactional(rethrowExceptionsAs = CustomException.class) diff --git a/src/test/java/org/mybatis/guice/sample/service/FooServiceMapperImpl.java b/src/test/java/org/mybatis/guice/sample/service/FooServiceMapperImpl.java index e2d95309..91a3f517 100644 --- a/src/test/java/org/mybatis/guice/sample/service/FooServiceMapperImpl.java +++ b/src/test/java/org/mybatis/guice/sample/service/FooServiceMapperImpl.java @@ -25,7 +25,7 @@ /** * Impl of the FooService. - * + *

* FooService simply receives a userId and uses a mapper/dao to get a record from the database. */ @Transactional(isolation = Isolation.SERIALIZABLE, rethrowExceptionsAs = CustomException.class)