001 /* 002 * Copyright 2008-2009 the original author or authors. 003 * The contents of this file are subject to the Mozilla Public License 004 * Version 1.1 (the "License"); you may not use this file except in 005 * compliance with the License. You may obtain a copy of the License at 006 * http://www.mozilla.org/MPL/ 007 * 008 * Software distributed under the License is distributed on an "AS IS" 009 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 010 * License for the specific language governing rights and limitations 011 * under the License. 012 */ 013 014 package com.mtgi.analytics.aop.config.v11; 015 016 import org.springframework.beans.factory.config.BeanDefinitionHolder; 017 import org.springframework.beans.factory.support.BeanDefinitionBuilder; 018 import org.springframework.beans.factory.xml.BeanDefinitionDecorator; 019 import org.springframework.beans.factory.xml.ParserContext; 020 import org.w3c.dom.Node; 021 022 import com.mtgi.analytics.sql.BehaviorTrackingDataSource; 023 024 /** decorates the annotated datasource bean definition with behavior tracking */ 025 public class BtDataSourceBeanDefinitionDecorator implements BeanDefinitionDecorator { 026 027 public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { 028 BeanDefinitionBuilder wrapper = BeanDefinitionBuilder.rootBeanDefinition(BehaviorTrackingDataSource.class); 029 wrapper.addPropertyReference("trackingManager", node.getNodeValue()); 030 wrapper.addPropertyValue("targetDataSource", definition.getBeanDefinition()); 031 return new BeanDefinitionHolder(wrapper.getRawBeanDefinition(), definition.getBeanName()); 032 } 033 034 }