1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.orchestra.conversation.spring;
20
21 import org.springframework.beans.factory.xml.BeanDefinitionDecorator;
22 import org.springframework.beans.factory.xml.ParserContext;
23 import org.springframework.beans.factory.config.BeanDefinitionHolder;
24 import org.w3c.dom.Node;
25
26 /***
27 * Invoked by Spring when a bean definition is found in its config file which has an
28 * xml attribute called "conversationName" in the orchestra namespace.
29 * <p>
30 * The value of the xml attribute is simply copied onto the BeanDefinition object.
31 * <p>
32 * See also class OrchestraNamespaceHandler.
33 */
34 public class BeanDefinitionConversationNameAttrDecorator implements BeanDefinitionDecorator
35 {
36 /***
37 * The name of the xml attribute in the spring bean definition that is used by
38 * orchestra as the conversation name.
39 */
40 public final static String XSD_CONVERSATION_NAME_ATTRIBUTE = "conversationName";
41
42 /***
43 * A unique key used to store the orchestra conversationName within the attributes map
44 * of a spring bean definition.
45 */
46 public final static String CONVERSATION_NAME_ATTRIBUTE = "org.apache.myfaces.orchestra.spring.conversationName";
47
48 public BeanDefinitionHolder decorate(
49 Node node,
50 BeanDefinitionHolder definition,
51 ParserContext parserContext)
52 {
53 String conversationName = node.getTextContent();
54 if (conversationName != null && conversationName.length() > 0)
55 {
56 definition.getBeanDefinition().setAttribute(CONVERSATION_NAME_ATTRIBUTE, conversationName);
57 }
58
59 return definition;
60 }
61 }