1 10 11 package org.mule.extras.spring.config; 12 13 import java.util.Iterator ; 14 import java.util.List ; 15 import java.util.Map ; 16 17 import org.mule.MuleManager; 18 import org.mule.config.MuleConfiguration; 19 import org.mule.umo.UMOException; 20 import org.mule.umo.UMOInterceptorStack; 21 import org.mule.umo.endpoint.UMOEndpoint; 22 import org.mule.umo.lifecycle.InitialisationException; 23 import org.mule.umo.manager.UMOManager; 24 import org.mule.umo.manager.UMOTransactionManagerFactory; 25 import org.mule.umo.model.UMOModel; 26 import org.mule.umo.provider.UMOConnector; 27 import org.mule.umo.transformer.UMOTransformer; 28 import org.springframework.beans.factory.DisposableBean; 29 import org.springframework.beans.factory.FactoryBean; 30 import org.springframework.beans.factory.InitializingBean; 31 32 40 public class UMOManagerFactoryBean implements FactoryBean, InitializingBean, DisposableBean 41 { 42 private final UMOManager manager; 43 44 public UMOManagerFactoryBean() throws Exception 45 { 46 this.manager = MuleManager.getInstance(); 47 } 48 49 public Object getObject() throws Exception 50 { 51 return manager; 52 } 53 54 public Class getObjectType() 55 { 56 return UMOManager.class; 57 } 58 59 public boolean isSingleton() 60 { 61 return true; 62 } 63 64 public void setMessageEndpoints(Map endpoints) throws InitialisationException 65 { 66 for (Iterator iterator = endpoints.entrySet().iterator(); iterator.hasNext();) 67 { 68 Map.Entry entry = (Map.Entry )iterator.next(); 69 manager.registerEndpointIdentifier(entry.getKey().toString(), entry.getValue().toString()); 70 } 71 } 72 73 public void setProperties(Map props) 74 { 75 for (Iterator iterator = props.entrySet().iterator(); iterator.hasNext();) 76 { 77 Map.Entry entry = (Map.Entry )iterator.next(); 78 manager.setProperty(entry.getKey(), entry.getValue()); 79 } 80 } 81 82 public void setConfiguration(MuleConfiguration config) 83 { 84 MuleManager.setConfiguration(config); 85 } 86 87 public void setTransactionManagerFactory(UMOTransactionManagerFactory factory) throws Exception 88 { 89 manager.setTransactionManager(factory.create()); 90 } 91 92 public void setConnectors(List connectors) throws UMOException 93 { 94 for (Iterator iterator = connectors.iterator(); iterator.hasNext();) 95 { 96 manager.registerConnector((UMOConnector)iterator.next()); 97 } 98 } 99 100 public void setTransformers(List transformers) throws InitialisationException 101 { 102 for (Iterator iterator = transformers.iterator(); iterator.hasNext();) 103 { 104 manager.registerTransformer((UMOTransformer)iterator.next()); 105 } 106 } 107 108 public void setProviders(List endpoints) throws InitialisationException 109 { 110 for (Iterator iterator = endpoints.iterator(); iterator.hasNext();) 111 { 112 manager.registerEndpoint((UMOEndpoint)iterator.next()); 113 } 114 } 115 116 public void setInterceptorStacks(Map interceptors) 117 { 118 for (Iterator iterator = interceptors.entrySet().iterator(); iterator.hasNext();) 119 { 120 Map.Entry entry = (Map.Entry )iterator.next(); 121 manager.registerInterceptorStack(entry.getKey().toString(), (UMOInterceptorStack)entry.getValue()); 122 } 123 } 124 125 public void setModel(UMOModel model) throws UMOException 126 { 127 manager.setModel(model); 128 } 129 130 public void afterPropertiesSet() throws Exception 131 { 132 manager.start(); 133 } 134 135 public void destroy() throws Exception 136 { 137 manager.dispose(); 138 } 139 140 } 141 | Popular Tags |