Commit Graph

72 Commits

Author SHA1 Message Date
Stephane Nicoll 073c176400 Fix test
The rework of 314b069 in a7fec6a has created a lazy proxy to make sure
that the need for an exception cache resolver come as late as possible.

Unfortunately, the test that was only failing on CI because of an early
lookup has not been updated accordingly. This is now the case.

Issue: SPR-12850
2015-03-28 12:23:30 +01:00
Stephane Nicoll a7fec6a459 Lazily resolve the default exception CacheResolver
This is a rework of 314b069 that may still lead to issue if a Cacheable
annotated bean is inspected on startup. Instead of resolving the default
exception CacheResolver if a cache operation is parsed, we resolve it as
late as possible (i.e. when an exception is thrown and the relevant
exception cache needs to be resolved)

Issue: SPR-12850
2015-03-27 09:42:06 +01:00
Stephane Nicoll 314b069fd8 Only require an exception CacheResolver if necessary
Previously, a cache infrastructure with only a CacheResolver would have
worked fine until the JSR-107 API is added to the classpath. When this is
the case, the JCache support kicks in and an exception cache resolver is
all of the sudden required.

The CacheResolver _is_ different as the default implementation does look
different attributes so if a custom CacheResolver is set, it is not
possible to "reuse" it as a fallback exception CacheResolver.

Now, an exception CacheResolver is only required if a JSR-107 annotation
with an "exceptionCacheName" attribute is processed (i.e. the exception
CacheResolver is lazily instantiated if necessary).

The use case of having a CachingConfigurerSupport with only a
CacheResolver was still broken though since the JCache support only looks
for a JCacheConfigurer bean (per the generic type set on
AbstractCachingConfiguration). This has been fixed as well.

Issue: SPR-12850
2015-03-25 15:12:08 +01:00
Juergen Hoeller 26d4f91835 Compatibility with EhCache 3.0 M1 (as a JCache provider)
Issue: SPR-12847
2015-03-24 19:20:26 +01:00
Stephane Nicoll 9172a6d05e Restore proper use of CacheLoader
Since Guava 11, CacheLoader is only invoked with a LoadingCache but the
GuavaCache wrapper is always invoking getIfPresent(), available on the
main Guava Cache interface.

Update GuavaCache#get to check for the presence of a LoadingCache and
call the appropriate method.

Issue: SPR-12842
2015-03-22 10:02:36 +01:00
Stephane Nicoll a64532ede2 Add testConnection on JavaMailSender
Add a way to test that a particular JavaMailSender instance can connect
to the server that it is configured for.

Issue: SPR-12799
2015-03-10 16:58:29 +01:00
Stas Volsky ef95fc2f7e Synchronize clear on TransactionAwareCacheDecorator
Previously, a cache decorated with TransactionAwareCacheDecorator would
clear the cache immediately, even when a transaction is running. This
commit updates the decorator to synchronize to the afterCommit phase for
the clear operation as well.

Issue: SPR-12653
2015-02-10 14:53:16 +01:00
Juergen Hoeller 49e31c302b Allow schedulerWithHsqlDataSource to pass through reducing it to the trigger table check
Issue: SPR-12618
2015-01-21 11:11:07 +01:00
Sam Brannen d5fb829ade Polish failed assertion messages in QuartzSupportTests 2015-01-10 22:28:00 +01:00
Juergen Hoeller e2518e0b7c Reduced DefaultJCacheOperationSource's dependency from ApplicationContext to BeanFactory
Issue: SPR-12336
2014-11-01 09:06:55 +01:00
Juergen Hoeller 0e36402bd2 Revised retrieval of cache strategy beans
Issue: SPR-12336
2014-11-01 08:26:48 +01:00
Stephane Nicoll 5aefcc802e Prevent early bean initialization with @EnableCaching
Prior to this commmit, any configuration class holding a CacheManager
bean would be eagerly instantiated. This is because the
CacheConfiguration infrastructure requests all beans of type
CacheManager.

This commit defers the resolution of the CacheManager as late
as possible.

Issue: SPR-12336
2014-10-31 14:37:30 +01:00
Juergen Hoeller 8325b10080 Consistent formatting of license headers, package javadocs, and import declarations 2014-10-21 01:44:07 +02:00
Juergen Hoeller b7faef0103 JavaMailSenderImpl catches Exception instead of MessagingException and checks for reconnect in case of message batches
Issue: SPR-12298
2014-10-06 15:37:08 +02:00
Stephane Nicoll d47c5433cb Improve configuration changes in GuavaCacheManager
Prior to this commit, setting the parameters used to build the caches
was fragile in static mode as the caches were created right when the
setCacheNames setter was called.

This commit provides a better handling of such arguments and also
provide a way to restore the dynamic mode if necessary.

Issue: SPR-12120
2014-08-27 16:36:01 +02:00
Juergen Hoeller a2e6b56dd0 SchedulerAccessorBean falls back to finding a default Scheduler bean by type
Issue: SPR-12094
2014-08-18 21:23:29 +02:00
Phillip Webb ac8326d2df Polish mockito usage
Consistent use of BDDMockito rather than standard Mockito.
2014-08-11 16:23:11 -07:00
Stephane Nicoll 8d8d47fb4e Fix compiler warning 2014-07-23 19:24:52 +02:00
Stephane Nicoll d9e0b292ab polishing 2014-07-23 17:08:19 +02:00
Juergen Hoeller a53987ace1 Renamed JCacheEhCacheTest to JCacheEhCacheTests 2014-07-16 20:27:49 +02:00
Stephane Nicoll fac0599aef Add cache abstraction tests using JSR-107
This commit adds an extra test implementation that runs the cache
abstraction tests using a JSR-107 cache manager. This further covers
JCacheCacheManager.

The actual JSR-107 implementation is ehcache-jcache that requires at
least ehcache 2.8.3. Since the ehcache-core artifact is no longer a
public artifact, this commit switches to the full ehcache library,
that is net.sf.ehcache:ehcache
2014-07-16 17:35:34 +02:00
Sam Brannen c60c1cec45 Suppress serial warning in JCacheCustomInterceptorTests 2014-07-01 17:40:18 +02:00
Stephane Nicoll aaae10ce3b Cache operation invocation hook point
This commit adds a invokeOperation protected method in case one
needs a hook point in the way the underlying cache method is invoked,
and how exceptions that might be thrown by that invocation are handled.

Issue: SPR-11540
2014-06-02 15:00:51 +02:00
Stephane Nicoll bb6e07bd3a polishing 2014-05-26 13:39:38 +02:00
Stephane Nicoll 9952973e01 Add missing cache-resolver attribute
Prior to this commit, CacheResolver could not be configured through
the XML namespace (i.e. cache:annotation-driven). This is now the
case.

Issue: SPR-11490
2014-05-21 09:03:18 +02:00
Stephane Nicoll 05e96ee448 Cache provider related exceptions handling
This commit adds the necessary infrastructure to handle exceptions
thrown by a cache provider in both Spring's and JCache's caching
abstractions.

Both interceptors can be configured with a CacheErrorHandler that
defines several callbacks on typical cache operations. In particular,
handleCacheGetError can be implemented in such a way that an
exception thrown by the provider is handled as a cache miss by the
caching abstraction.

The handler can be configured with both CachingConfigurer and the
XML namespace (error-handler property)

Issue: SPR-9275
2014-05-20 16:39:34 +02:00
Juergen Hoeller e04fb15a5e Compilation compatibility with JasperReports 5.5.2 2014-05-12 20:34:38 +02:00
Philippe Marschall 1e8c799a60 Clean up spring-context-support tests warnings
Clean up compiler warnings in the tests of spring-context-support.

This commit:
* adds type parameters to all the types except `Cache` (mostly `List`
  and `Map`)
* removes unused imports
2014-04-22 07:32:11 +02:00
Stephane Nicoll 3cda355e7f polishing
This commit fixes the handling of cached exceptions in the JSR-107
advisor. Such exceptions are now properly propagated instead of being
wrapped in a RuntimeException.

Issue: SPR-9616
2014-04-08 17:04:25 +02:00
Stephane Nicoll a198026469 fix CI build
Prior to this commit, AnnotatedJCacheableService contained an annotated
method demonstrating a failure scenario. This could break depending on
the order of the methods array as AopUtils creates the proxy if the
pointcut matches by checking each method.

On the CI server, the first method was this invalid use case so
checking if the proxy has to be created lead to an unexpected
exception. This scenario has been moved to its own private class now.
2014-04-08 11:37:41 +02:00
Stephane Nicoll f3b8a4103e Use CacheResolver in Spring abstraction
Prior to this commit, the CacheResolver was not used by Spring's
caching abstraction. This commit provides the necessary configuration
options to tune how a cache is resolved for a given operation.

CacheResolver can be customized globally, at the operation level or at
the class level. This breaks the CachingConfigurer class and a support
implementation is provided that implements all methods so that the
default is taken if it's not overridden. The JSR-107 support has been
updated as well, with a similar support class.

In particular, the static and runtime information of a cache
operation were mixed which prevents any forms of caching. As the
CacheResolver and the KeyGenerator can be customized, every operation
call lead to a lookup in the context for the bean.

This commit adds CacheOperationMetadata, a static holder of all
the non-runtime metadata about a cache operation. This is used
as an input source for the existing CacheOperationContext.

Caching the operation metadata in an AspectJ aspect can have side
effects as the aspect is static instance for the current ClassLoader.
The metadata cache needs to be cleared when the context shutdowns.
This is essentially a test issue only as in practice each application
runs in its class loader. Tests are now closing the context properly
to honor the DisposableBean callback.

Issue: SPR-11490
2014-04-07 15:41:09 +02:00
Stephane Nicoll 47a4327193 Add JSR-107 cache annotations support
This commit adds support for the JSR-107 cache annotations alongside
the Spring's cache annotations, that is @CacheResult, @CachePut,
@CacheRemove and @CacheRemoveAll as well as related annotations
@CacheDefaults, @CacheKey and @CacheValue.

Spring's caching configuration infrastructure detects the presence of
the JSR-107 API and Spring's JCache implementation. Both
@EnableCaching and the cache namespace are able to configure the
required JCache infrastructure when necessary. Both proxy mode
and AspectJ mode are supported.

As JSR-107 permits the customization of the CacheResolver to use for
both regular and exception caches, JCacheConfigurer has been
introduced as an extension of CachingConfigurer and permits to define
those.

If an exception is cached and should be rethrown, it is cloned and
the call stack is rewritten so that it matches the calling thread each
time. If the exception cannot be cloned, the original exception is
returned.

Internally, the interceptors uses Spring's caching abstraction by default
with an adapter layer when a JSR-107 component needs to be called.
This is the case for CacheResolver and CacheKeyGenerator.

The implementation uses Spring's CacheManager abstraction behind the
scene. The standard annotations can therefore be used against any
CacheManager implementation.

Issue: SPR-9616
2014-04-07 12:07:20 +02:00
Stephane Nicoll 3e74d3b2fb Add putIfAbsent on Cache abstraction
This commit adds a putIfAbsent method to the Cache interface. This
method offers an atomic put if the key is not already associated in
the cache.

Issue: SPR-11400
2014-04-03 11:37:22 +02:00
Stephane Nicoll 119dfd9cf9 Fix cache decoration
Prior to this commit, a cache that is added on-the-fly is not properly
decorated by the provided CacheManager implementation that supports
it (EhCache and JCache).

This commits adds an extra getMissingCache method to
the AbstractCacheManager that can be extended to provide a cache that
may exist in the native cache manager but is not yet known by the
spring abstraction.

Issue: SPR-11518
2014-04-01 14:48:35 +02:00
Sam Brannen 906321dcdd Fix broken tests in QuartzSupportTests
This commit ensures that QuartzSupportTests and its related
configuration are compatible with Quartz 2.1.7.

 - Test jobs are now durable where required.

 - Deleted legacy tests that attempted to use a Runnable instead of a
   Job as a jobClass for a JobDetail.

 - Replaced quartz-hsql.sql with current version for Quartz 2.1.7.

Issue: SPR-11630
2014-03-30 18:05:38 +02:00
Juergen Hoeller ea1e27efa2 Require Jackson 2.0+, EhCache 2.5+, Quartz 2.1.4+
Issue: SPR-11262
2014-03-27 21:59:23 +01:00
Stephane Nicoll 4cd818b9e4 Harmonize log configuration
Prior to this commit, the codebase was using a mix of log4j.xml
and log4j.properties for test-related logging configuration. This
can be an issue as log4j takes the xml variant first when looking
for a default bootstrap configuration.

In practice, some modules declaring the properties variant were
taking the xml variant configuration from another module.

The general structure of the configuration has also been
harmonized to provide a standard console output as well as an
easy way to enable trace logs for the current module.
2014-03-20 09:43:29 -07:00
Juergen Hoeller 38e7c4776b Cache.get(key, type) should also work in case of null value found in cache
Issue: SPR-11567
2014-03-18 00:50:59 +01:00
Sam Brannen c8f2e07182 Clean up test warnings that show up in Gradle console 2014-03-06 14:50:46 +01:00
Stephane Nicoll 45406aa19b Add tests for TransactionAwareCacheDecorator
This commit adds tests for TransactionAwareCacheDecorator. In
particular, the put/evict behaviour when the operation is invoked in
the course of Spring-managed transaction.
2014-03-05 16:48:20 +01:00
Juergen Hoeller a9605a11e9 "acceptExisting" flag allows for sharing per cacheManagerName on EhCache 2.5+
As a benefit over the "shared" flag, this allows for sharing a specific CacheManager in a system with potentially multiple CacheManagers involved, and it supports controlled shutdown by the EhCacheManagerFactoryBean that actually created the CacheManager.

Issue: SPR-11178
2013-12-11 17:25:02 +01:00
Juergen Hoeller 6d7ce439b1 Introduced GuavaCacheManager as an alternative to ConcurrentMapCacheManager 2013-12-10 11:59:35 +01:00
Phillip Webb d4245610a2 Fix performance test HSQLDB error
Fix QuartzSupportTests that has been failing since the HSQLDB upgrade.
2013-12-02 23:59:32 -08:00
Juergen Hoeller 50d3f71923 Added get(key, type) method to Cache interface
This new get variant not only allows for generically specifying the required value type; it also skips the ValueWrapper that the standard get method returns. Note that it is not possible to differentiate between non-existing cache entries and cached null values that way; for that purpose, the standard get variant needs to be used.

Issue: SPR-11061
2013-11-04 14:31:41 +01:00
Phillip Webb e1c25ff1a3 Workaround jasper report test fail on OSX
Add temporary Assume.canLoadNativeDirFonts() method allowing failing
jasper report tests to be bypassed on OSX.

This should be revisited when JDK 8 is released.

Issue: SPR-10537
2013-05-07 08:23:46 -07:00
Juergen Hoeller 8fab14dfeb Upgraded to JasperReports 5.0 (preserving compatibility with all previous releases) and POI 3.9 (preserving compatibility with POI 3.5+) 2013-03-29 14:52:30 +01:00
Juergen Hoeller b78fa2715a Assigned cache manager name in order to avoid EhCache assertion failure in case of multiple tests executed on the same VM 2013-03-21 11:12:30 +01:00
Juergen Hoeller bea990196d Fixed job scheduling data test for Quartz 1.8 2013-03-20 10:07:20 +01:00
Juergen Hoeller af3c3ef15c Only call EhCacheManagerFactoryBean's destroy() method when actually initialized 2013-03-20 10:05:56 +01:00
Juergen Hoeller f2b79c80b0 Spring's EhCache setup builds on EhCache 2.1+ now
Specifically, EhCacheFactoryBean extends CacheConfiguration now and therefore inherits all configuration properties of the underlying EhCache version. This reduces the need for catching up with new EhCache properties on our side.

Issue: SPR-8258
2013-03-19 23:08:05 +01:00