Note that there are some explanatory texts on larger screens.

plurals
  1. POHow are components managed in Spring MVC and how to inject a customized component in Spring 3.2.5?
    primarykey
    data
    text
    <p>I’m considering to replace the <strong>DefaultSessionAttributeStore</strong> implementation of Spring MVC 3.2.5 with some class of my own, and I’ve known from the source code that in my 3.2.5 spring source, it’s <strong>SessionAttributesHandler</strong> which possesses a <strong>SessionAttributeStore</strong> interface reference and invokes the session store function. My question is how to replace that by DI? The SessionAttributesHandler holds a final private sessionAttributeStore reference and can only be set by the constructor:</p> <pre><code>public class SessionAttributesHandler { ... private final SessionAttributeStore sessionAttributeStore; ... public SessionAttributesHandler(Class&lt;?&gt; handlerType, SessionAttributeStore sessionAttributeStore) { Assert.notNull(sessionAttributeStore, "SessionAttributeStore may not be null."); this.sessionAttributeStore = sessionAttributeStore; SessionAttributes annotation = AnnotationUtils.findAnnotation(handlerType, SessionAttributes.class); if (annotation != null) { this.attributeNames.addAll(Arrays.asList(annotation.value())); this.attributeTypes.addAll(Arrays.&lt;Class&lt;?&gt;&gt;asList(annotation.types())); } for (String attributeName : this.attributeNames) { this.knownAttributeNames.put(attributeName, Boolean.TRUE); } } ... } </code></pre> <p>Are all the components of spring mvc managed in the spring DI container? How to inject my own SessionAttributeStore implementation into SessionAttributesHandler? What does the "Class handlerType" argument mean in the constructor? From source, it seems like it's the "controller" class. Since SessionAttributesHandler is invoked and held by a ModelFactory, and in ModelFactory there is no code instantiating the SessionAttributesHandler, is there any "XML" bean configuration file for the Spring MVC inner components and how to overwrite them?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload