| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.krad.util.spring; |
| 17 | |
|
| 18 | |
import org.springframework.beans.factory.BeanFactory; |
| 19 | |
import org.springframework.beans.factory.BeanFactoryAware; |
| 20 | |
import org.springframework.beans.factory.config.AbstractFactoryBean; |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | 0 | public class IfExistsFactoryBean extends AbstractFactoryBean implements BeanFactoryAware { |
| 31 | |
private BeanFactory beanFactory; |
| 32 | |
private String beanName; |
| 33 | |
private Object customReturnValue; |
| 34 | |
|
| 35 | |
@Override |
| 36 | |
protected Object createInstance() throws Exception { |
| 37 | 0 | if (beanFactory.containsBean(beanName)) { |
| 38 | 0 | if (customReturnValue != null) { |
| 39 | 0 | return customReturnValue; |
| 40 | |
} else { |
| 41 | 0 | return beanFactory.getBean(beanName); |
| 42 | |
} |
| 43 | |
} |
| 44 | 0 | return null; |
| 45 | |
} |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
@Override |
| 53 | |
public Class getObjectType() { |
| 54 | 0 | return null; |
| 55 | |
} |
| 56 | |
|
| 57 | |
public BeanFactory getBeanFactory() { |
| 58 | 0 | return this.beanFactory; |
| 59 | |
} |
| 60 | |
|
| 61 | |
public String getBeanName() { |
| 62 | 0 | return this.beanName; |
| 63 | |
} |
| 64 | |
|
| 65 | |
public Object getCustomReturnValue() { |
| 66 | 0 | return this.customReturnValue; |
| 67 | |
} |
| 68 | |
|
| 69 | |
public void setBeanFactory(BeanFactory beanFactory) { |
| 70 | 0 | this.beanFactory = beanFactory; |
| 71 | 0 | } |
| 72 | |
|
| 73 | |
public void setBeanName(String beanName) { |
| 74 | 0 | this.beanName = beanName; |
| 75 | 0 | } |
| 76 | |
|
| 77 | |
public void setCustomReturnValue(Object customReturnValue) { |
| 78 | 0 | this.customReturnValue = customReturnValue; |
| 79 | 0 | } |
| 80 | |
|
| 81 | |
} |