1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 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"; // NON-NLS 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 = 47 "org.apache.myfaces.orchestra.spring.conversationName"; // NON-NLS 48 49 public BeanDefinitionHolder decorate( 50 Node node, 51 BeanDefinitionHolder definition, 52 ParserContext parserContext) 53 { 54 String conversationName = node.getTextContent(); 55 if (conversationName != null && conversationName.length() > 0) 56 { 57 definition.getBeanDefinition().setAttribute(CONVERSATION_NAME_ATTRIBUTE, conversationName); 58 } 59 60 return definition; 61 } 62 }