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.context.MuleContextAware;
15 import org.mule.api.store.ObjectStore;
16
17 import java.io.Serializable;
18
19 import org.springframework.beans.factory.config.AbstractFactoryBean;
20
21
22
23
24 public class ObjectStoreFromRegistryFactoryBean extends AbstractFactoryBean<ObjectStore<Serializable>> implements MuleContextAware
25 {
26 private String objectStoreName;
27 private MuleContext muleContext;
28
29 public ObjectStoreFromRegistryFactoryBean(String name)
30 {
31 super();
32 objectStoreName = name;
33 }
34
35 @Override
36 public Class<?> getObjectType()
37 {
38 return ObjectStore.class;
39 }
40
41 @Override
42 protected ObjectStore<Serializable> createInstance() throws Exception
43 {
44 return muleContext.getRegistry().lookupObject(objectStoreName);
45 }
46
47 @Override
48 public void setMuleContext(MuleContext context)
49 {
50 muleContext = context;
51 }
52 }