Commit Graph

235 Commits

Author SHA1 Message Date
Stephane Nicoll
dcade06fa0 Support for candidate components index
This commit adds a "spring-context-indexer" module that can be added to
any project in order to generate an index of candidate components defined
in the project.

`CandidateComponentsIndexer` is a standard annotation processor that
looks for source files with target annotations (typically `@Component`)
and references them in a `META-INF/spring.components` generated file.

Each entry in the index is the fully qualified name of a candidate
component and the comma-separated list of stereotypes that apply to that
candidate. A typical example of a stereotype is `@Component`. If a
project has a `com.example.FooService` annotated with `@Component` the
following `META-INF/spring.components` file is generated at compile time:

```
com.example.FooService=org.springframework.stereotype.Component
```

A new `@Indexed` annotation can be added on any annotation to instructs
the scanner to include a source file that contains that annotation. For
instance, `@Component` is meta-annotated with `@Indexed` now and adding
`@Indexed` to more annotation types will transparently improve the index
with additional information. This also works for interaces or parent
classes: adding `@Indexed` on a `Repository` base interface means that
the indexed can be queried for its implementation by using the fully
qualified name of the `Repository` interface.

The indexer also adds any class or interface that has a type-level
annotation from the `javax` package. This includes obviously JPA
(`@Entity` and related) but also CDI (`@Named`, `@ManagedBean`) and
servlet annotations (i.e. `@WebFilter`). These are meant to handle
cases where a component needs to identify candidates and use classpath
scanning currently.

If a `package-info.java` file exists, the package is registered using
a "package-info" stereotype.

Such files can later be reused by the `ApplicationContext` to avoid
using component scan. A global `CandidateComponentsIndex` can be easily
loaded from the current classpath using `CandidateComponentsIndexLoader`.

The core framework uses such infrastructure in two areas: to retrieve
the candidate `@Component`s and to build a default `PersistenceUnitInfo`.
Rather than scanning the classpath and using ASM to identify candidates,
the index is used if present.

As long as the include filters refer to an annotation that is directly
annotated with `@Indexed` or an assignable type that is directly
annotated with `@Indexed`, the index can be used since a dedicated entry
wil be present for that type. If any other unsupported include filter is
specified, we fallback on classpath scanning.

In case the index is incomplete or cannot be used, The
`spring.index.ignore` system property can be set to `true` or,
alternatively, in a "spring.properties" at the root of the classpath.

Issue: SPR-11890
2016-09-01 15:30:47 +02:00
Juergen Hoeller
5ee65cd4b1 Updated to JPA 2.1 requirement 2016-08-18 10:17:01 +02:00
Juergen Hoeller
f1ab37cd01 Renamed setDefaultPersistenceUnitRootLocation to setPersistenceUnitRootLocation 2016-08-17 22:12:47 +02:00
Stephane Nicoll
1cad98dd31 Add setter for defaultPersistenceUnitRootLocation
This commit adds a setter for the default persistence unit's
defaultPersistenceUnitRootLocation attribute.
2016-08-17 17:40:58 +02:00
Juergen Hoeller
8b5d3559f5 Avoid stack overflow in case of chained factory-bean references to FactoryBean class
Issue: SPR-14551
2016-08-11 22:56:14 +02:00
Juergen Hoeller
6157fad91f PersistenceAnnotationBeanPostProcessor obtains default EntityManagerFactory via getBean(Class) algorithm
Issue: SPR-7549
2016-08-11 22:42:06 +02:00
Juergen Hoeller
36143692ac Consistent use of AvailableSettings instead of Environment
Issue: SPR-14548
2016-08-08 14:48:05 +02:00
Juergen Hoeller
fad931d764 Consistent default connection release mode with Hibernate 5.1
Issue: SPR-14548
2016-08-04 03:07:14 +02:00
Sam Brannen
7ff9f0a8e9 Clean up warnings in spring-orm 2016-07-26 14:02:33 +02:00
Juergen Hoeller
195467083c Drop JpaSystemException(PersistenceException) constructor to avoid ambiguity in HibernateJpaVendorAdapter
Hibernate 5.2's HibernateException extends PersistenceException, leading to a different constructor compiled into the bytecode, breaking compatibility with Hibernate 5.0 at runtime.

Issue: SPR-13827
2016-07-26 01:23:39 +02:00
Sam Brannen
beb45aac69 Suppress deprecation warning in PersistenceInjectionTests 2016-07-23 17:20:09 +02:00
Juergen Hoeller
aae4874b85 Revised spring-orm test suite (no AbstractJpaTests anymore)
Issue: SPR-13515
2016-07-19 17:50:57 +02:00
Juergen Hoeller
1670b4e154 Reliably pass CurrentTenantIdentifierResolver to SessionFactory
Issue: SPR-14476
2016-07-19 17:25:07 +02:00
Juergen Hoeller
adbc592f50 Unwrap JPA PersistenceException on flush failure (for Hibernate 5.2)
Issue: SPR-14457
2016-07-13 22:30:52 +02:00
Juergen Hoeller
ddb4117233 HibernateExceptionTranslator converts JPA exceptions as well (for Hibernate 5.2)
Issue: SPR-14455
2016-07-13 22:24:38 +02:00
Juergen Hoeller
c43e7497c1 Fixed typo: "occured"->"occurred" 2016-07-08 15:12:16 +02:00
Juergen Hoeller
a1f5fb53db Java 8 getParameterCount() instead of getParameterTypes().length
Issue: SPR-13188
2016-07-07 01:04:24 +02:00
Juergen Hoeller
19e5a34f9f Restored binary compatibility with Hibernate 5.0/5.1's Query type
Issue: SPR-14425
2016-07-06 15:20:09 +02:00
Stephane Nicoll
e4b0486c5a Add @FunctionalInterface on candidate interfaces
Issue: SPR-14432
2016-07-06 14:32:13 +02:00
Juergen Hoeller
bc2c22d51e Streamline XML namespace support towards unversioned schemas
This commit also removes support code for outdated options which were only available in older schema versions.

Issue: SPR-13499
2016-07-05 20:50:03 +02:00
Sam Brannen
1391248ea6 Introduce log4j 2 for Spring's test suite
This commit adds a test runtime dependency on log4j 2 for every project
and migrates all log4j.properties files to log4j2-test.xml files.

Issue: SPR-14431
2016-07-05 19:19:09 +02:00
Stephane Nicoll
00d2606b00 Explicit type can be replaced by <>
Issue: SPR-13188
2016-07-05 17:00:34 +02:00
Juergen Hoeller
0fc0ce78ae Drop deprecated dependencies on Log4j, JRuby, JExcel, Burlap, Commons Pool/DBCP
This commit also removes outdated support classes for Oracle, GlassFish, JBoss.

Issue: SPR-14429
2016-07-05 15:46:53 +02:00
Juergen Hoeller
51252ebbca Avoid defensive checks against Java 8 API (java.util.Optional etc)
This commit also fixes broken javadoc links and code references.

Issue: SPR-13188
2016-07-05 02:09:00 +02:00
Juergen Hoeller
54004e0d78 Upgrade to JPA 2.1+ and Bean Validation 1.1+; remove native support for Hibernate 3.6 and 4.x
Issue: SPR-13481
Issue: SPR-13827
2016-07-04 23:37:23 +02:00
Juergen Hoeller
69ec437fbc Drop native OpenJPA support
Issue: SPR-14426
2016-07-04 23:35:19 +02:00
Juergen Hoeller
d341624e91 Drop JDO support
Issue: SPR-14130
2016-07-04 23:34:48 +02:00
Juergen Hoeller
711eb99812 HibernateJpaVendorAdapter and LocalSessionFactoryBuilder enforce Hibernate 5.2's connection handling mode DELAYED_ACQUISITION_AND_HOLD
Issue: SPR-14393
2016-06-24 12:37:31 +02:00
Juergen Hoeller
5e08598a2a HibernateJpaDialect accepts equivalent connection for proper reset as well
Issue: SPR-14393
2016-06-23 18:24:09 +02:00
Juergen Hoeller
9394616f8f Support for Hibernate ORM 5.2
Issue: SPR-14327
2016-06-02 23:35:31 +02:00
Sam Brannen
49bc2a9a02 Clean up warnings in PersistenceXmlParsingTests 2016-05-27 16:30:50 +02:00
Juergen Hoeller
abfe3f209d DefaultPersistenceUnitManager can determine persistence unit root from orm.xml location
Issue: SPR-14246
2016-05-26 23:57:49 +02:00
Johnny Lim
44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Juergen Hoeller
836a321ab2 JPA ClassFileTransformerAdapter defensively backs out when called from within a transform call
Issue: SPR-13886
2016-04-12 21:44:17 +02:00
Juergen Hoeller
74608e6b49 Polishing 2016-04-12 16:03:57 +02:00
Juergen Hoeller
517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Juergen Hoeller
7fcb277de9 Consistent behavior for unwrap(null) on JPA and Bean Validation wrappers
Includes a fix for Query unwrapping before passing it to addNamedQuery.

Issue: SPR-13960
Issue: SPR-13957
2016-02-18 16:19:09 +01:00
Juergen Hoeller
50829c9fdc Shared EntityManager does not insist on actualTransactionActive flag anymore
Issue: SPR-13838
2016-01-13 14:11:13 +01:00
Juergen Hoeller
09cea6e6bb Refined Future exception handling
Issue: SPR-13732
2015-12-21 15:09:09 +01:00
Juergen Hoeller
db1171d5c4 Background bootstrapping via "bootstrapExecutor" for LocalContainerEntityManagerFactoryBean and LocalSessionFactoryBean/Builder
Issue: SPR-13732
2015-12-19 15:13:46 +01:00
Juergen Hoeller
fca5365cf1 Avoid scoped destruction callbacks in case of no post-processor actually applying
Issue: SPR-13744
2015-12-18 16:54:05 +01:00
Sam Brannen
5b3edcd9f9 Spring Cleaning in December
- Delete unused imports
- Delete unused code
- Clean up warnings
2015-12-17 20:27:33 +01:00
Juergen Hoeller
e90942223f Deprecate Hibernate 3 support
Issue: SPR-13230
2015-12-17 17:17:05 +01:00
Juergen Hoeller
9e03e0e73d Polishing 2015-12-15 11:53:40 +01:00
Juergen Hoeller
98be36a306 Extended default collection size for common per-bean caches
Issue: SPR-13621
2015-11-13 08:31:00 +01:00
Johnny Lim
2defb6555e Fix broken Javadoc related to < and > 2015-11-12 11:22:08 +01:00
Juergen Hoeller
15b88782f7 Polishing 2015-10-07 20:06:18 +02:00
Sam Brannen
3dcf8c1712 Simplify legacy JUnit 3.8 based tests in spring-orm
This is in preparation for a migration from JUnit 3 to JUnit 4.

Issue: SPR-13514, SPR-13515
2015-09-28 01:19:27 +02:00
Sam Brannen
d5ee787e1e Migrate JUnit 3 tests to JUnit 4
This commit migrates all remaining tests from JUnit 3 to JUnit 4, with
the exception of Spring's legacy JUnit 3.8 based testing framework that
is still in use in the spring-orm module.

Issue: SPR-13514
2015-09-27 21:17:51 +02:00
Juergen Hoeller
a1107af06f HibernateJpaDialect logs warning in case of Connection mismatch (e.g. configured release mode other than ON_CLOSE)
Related to that, HibernateTransactionManager specifically checks for active physical connections on reset as of Hibernate 5.

Issue: SPR-13269
Issue: SPR-13002
2015-08-27 16:41:41 +02:00