1
2
3
4
5
6
7
8
9
10
11 package org.mule.config.spring.factories;
12
13 import org.mule.api.MuleEvent;
14 import org.mule.api.MuleException;
15 import org.mule.api.processor.MessageProcessor;
16
17 import org.springframework.beans.BeansException;
18 import org.springframework.beans.factory.FactoryBean;
19 import org.springframework.context.ApplicationContext;
20 import org.springframework.context.ApplicationContextAware;
21
22 public class FlowRefFactoryBean implements FactoryBean<MessageProcessor>, ApplicationContextAware
23 {
24
25 private String refName;;
26 private ApplicationContext applicationContext;
27
28 public void setName(String name)
29 {
30 this.refName = name;
31 }
32
33 public MessageProcessor getObject() throws Exception
34 {
35
36 return new MessageProcessor()
37 {
38 public MuleEvent process(MuleEvent event) throws MuleException
39 {
40 return ((MessageProcessor) applicationContext.getBean(refName)).process(event);
41 }
42 };
43 }
44
45 public boolean isSingleton()
46 {
47 return false;
48 }
49
50 public Class<?> getObjectType()
51 {
52 return MessageProcessor.class;
53 }
54
55 public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
56 {
57 this.applicationContext = applicationContext;
58 }
59 }