1
2
3
4
5
6
7
8
9
10
11 package org.mule.config.spring.factories;
12
13 import org.mule.api.MuleContext;
14 import org.mule.api.config.MuleProperties;
15 import org.mule.api.context.MuleContextAware;
16 import org.mule.api.store.ListableObjectStore;
17 import org.mule.config.QueueProfile;
18
19 import java.io.Serializable;
20
21 import org.springframework.beans.factory.config.AbstractFactoryBean;
22
23 public class QueueProfileFactoryBean extends AbstractFactoryBean<QueueProfile> implements MuleContextAware
24 {
25 private int maxOutstandingMessages;
26 private MuleContext muleContext;
27 private ListableObjectStore<Serializable> queueStore;
28
29 @Override
30 public Class<?> getObjectType()
31 {
32 return QueueProfile.class;
33 }
34
35 @Override
36 protected QueueProfile createInstance() throws Exception
37 {
38 ListableObjectStore<Serializable> objectStore = queueStore;
39 if (objectStore == null)
40 {
41 objectStore =
42 muleContext.getRegistry().lookupObject(MuleProperties.OBJECT_STORE_DEFAULT_IN_MEMORY_NAME);
43 }
44
45 return new QueueProfile(getMaxOutstandingMessages(), objectStore);
46 }
47
48 @Override
49 public void setMuleContext(MuleContext context)
50 {
51 muleContext = context;
52 }
53
54 public int getMaxOutstandingMessages()
55 {
56 return maxOutstandingMessages;
57 }
58
59 public void setMaxOutstandingMessages(int maxOutstandingMessages)
60 {
61 this.maxOutstandingMessages = maxOutstandingMessages;
62 }
63
64 public void setQueueStore(ListableObjectStore<Serializable> queueStore)
65 {
66 this.queueStore = queueStore;
67 }
68
69 public ListableObjectStore<Serializable> getQueueStore()
70 {
71 return queueStore;
72 }
73 }
74
75