Injecting Google guava cache builder into bean via Spring

guava, java, spring

Solution

While it's possible to call arbitrary methods in Spring XML using the `factory-method` attribute, you'll find that it's close to impossible for Builder-Pattern style chained calls.

Instead, use a `FactoryBean` or Java-based container configuration for such complex scenarios. XML will not get you that far, I'm afraid.

Problem

Could some one provide a good snippet to construct and inject Google guava's `CacheBuilder` into a dependent bean via `Spring` xml? To generalize, I need some examples in `Spring` that illustrates construction of objects using builder pattern.

Original source

Related problems