01: /*
02: * *********************************************************************************
03: * $URL: https://source.sakaiproject.org/svn/content/trunk/content-api/api/src/java/org/sakaiproject/content/api/ContentCollection.java $
04: * $Id: ContentCollection.java 8537 2006-05-01 02:13:28Z jimeng@umich.edu $
05: * **********************************************************************************
06: *
07: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
08: *
09: * Licensed under the Educational Community License, Version 1.0 (the "License");
10: * you may not use this file except in compliance with the License.
11: * You may obtain a copy of the License at
12: *
13: * http://www.opensource.org/licenses/ecl1.php
14: *
15: * Unless required by applicable law or agreed to in writing, software
16: * distributed under the License is distributed on an "AS IS" BASIS,
17: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: * See the License for the specific language governing permissions and
19: * limitations under the License.
20: *
21: * *********************************************************************************
22: *
23: */
24:
25: package org.sakaiproject.springframework.transaction.interceptor;
26:
27: import org.springframework.beans.BeanUtils;
28: import org.springframework.transaction.PlatformTransactionManager;
29: import org.springframework.transaction.interceptor.TransactionProxyFactoryBean;
30:
31: import java.util.Properties;
32:
33: /**
34: * Created by IntelliJ IDEA.
35: * User: John Ellis
36: * Date: May 23, 2006
37: * Time: 11:35:01 AM
38: * To change this template use File | Settings | File Templates.
39: */
40: public class ConstructedTransactionProxyFactoryBean extends
41: TransactionProxyFactoryBean {
42:
43: private DynamicTargetSource dynamicTargetSource;
44: private Object target;
45:
46: public ConstructedTransactionProxyFactoryBean(
47: PlatformTransactionManager transactionManager,
48: Object targetPrototype, Properties transactionAttributes) {
49: setTransactionManager(transactionManager);
50: try {
51: dynamicTargetSource = new DynamicTargetSource(
52: loadTarget(targetPrototype.getClass()));
53: super .setTarget(dynamicTargetSource);
54: } catch (ClassNotFoundException e) {
55: e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
56: }
57: setTransactionAttributes(transactionAttributes);
58: init();
59: }
60:
61: protected Object loadTarget(Class targetClass)
62: throws ClassNotFoundException {
63: return BeanUtils.instantiateClass(targetClass);
64: }
65:
66: public void init() {
67: super .afterPropertiesSet();
68: }
69:
70: public void setTarget(Object target) {
71: this .target = target;
72: }
73:
74: public Object getTarget() {
75: return target;
76: }
77:
78: public void afterPropertiesSet() {
79: dynamicTargetSource.setTarget(getTarget());
80: }
81:
82: }
|