1 10 11 package org.mule.impl; 12 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 import org.mule.MuleException; 16 import org.mule.util.FileUtils; 17 import org.mule.config.MuleConfiguration; 18 import org.mule.config.PoolingProfile; 19 import org.mule.config.QueueProfile; 20 import org.mule.config.ThreadingProfile; 21 import org.mule.impl.container.DescriptorContainerKeyPair; 22 import org.mule.umo.UMODescriptor; 23 import org.mule.umo.UMOInterceptor; 24 import org.mule.umo.endpoint.UMOEndpoint; 25 import org.mule.umo.routing.UMOInboundMessageRouter; 26 import org.mule.umo.routing.UMOOutboundMessageRouter; 27 import org.mule.umo.routing.UMOResponseMessageRouter; 28 import org.mule.umo.transformer.UMOTransformer; 29 30 import java.beans.ExceptionListener ; 31 import java.io.FileInputStream ; 32 import java.util.List ; 33 import java.util.Map ; 34 import java.util.Properties ; 35 36 41 42 public class MuleDescriptor extends ImmutableMuleDescriptor implements UMODescriptor 43 { 44 public static final String DEFAULT_INSTANCE_REF_NAME = "_instanceRef"; 45 48 private static Log logger = LogFactory.getLog(MuleDescriptor.class); 49 50 public MuleDescriptor(String name) 51 { 52 super(); 53 this.name = name; 54 } 55 56 public MuleDescriptor(MuleDescriptor descriptor) 57 { 58 super(descriptor); 59 } 60 61 67 public MuleDescriptor() 68 { 69 super(); 70 } 71 72 public void setThreadingProfile(ThreadingProfile threadingProfile) 73 { 74 this.threadingProfile = threadingProfile; 75 } 76 77 82 public void setExceptionListener(ExceptionListener listener) 83 { 84 if (listener == null) 85 { 86 throw new IllegalArgumentException ("Exception Strategy cannot be null"); 87 } 88 this.exceptionListener = listener; 89 logger.debug("Using exception strategy: " + listener.getClass().getName()); 90 } 91 92 97 public void setName(String newName) 98 { 99 if (newName == null) 100 { 101 throw new IllegalArgumentException ("Name cannot be null"); 102 } 103 name = newName; 104 } 105 106 111 public void setOutboundTransformer(UMOTransformer transformer) 112 { 113 outboundTransformer = transformer; 114 } 115 116 121 public void setResponseTransformer(UMOTransformer transformer) 122 { 123 responseTransformer = transformer; 124 } 125 126 131 public void setProperties(Map props) 132 { 133 properties = props; 134 String delegate = (String )properties.get(MULE_PROPERTY_DOT_PROPERTIES); 135 if (delegate != null) 136 { 137 try 138 { 139 FileInputStream is = new FileInputStream (FileUtils.newFile(delegate)); 140 Properties dProps = new Properties (); 141 dProps.load(is); 142 properties.putAll(dProps); 143 } 144 catch (Exception e) 145 { 146 logger.warn(MULE_PROPERTY_DOT_PROPERTIES + " was set to " + delegate 147 + " but the file could not be read, exception is: " + e.getMessage()); 148 } 149 } 150 } 151 152 157 public void setVersion(String ver) 158 { 159 version = ver; 160 } 161 162 167 public void setInboundEndpoint(UMOEndpoint endpoint) throws MuleException 168 { 169 inboundEndpoint = endpoint; 170 if (inboundEndpoint != null) 171 { 172 inboundEndpoint.setType(UMOEndpoint.ENDPOINT_TYPE_RECEIVER); 173 if (inboundEndpoint.getTransformer() != null) 174 { 175 inboundTransformer = inboundEndpoint.getTransformer(); 176 } 177 } 178 } 179 180 186 public void setOutboundEndpoint(UMOEndpoint endpoint) throws MuleException 187 { 188 outboundEndpoint = endpoint; 189 if (outboundEndpoint != null) 190 { 191 outboundEndpoint.setType(UMOEndpoint.ENDPOINT_TYPE_SENDER); 192 if (outboundEndpoint.getTransformer() != null) 193 { 194 outboundTransformer = outboundEndpoint.getTransformer(); 195 } 196 } 197 198 } 199 200 205 public void setInboundTransformer(UMOTransformer transformer) 206 { 207 inboundTransformer = transformer; 208 } 209 210 215 public void addInterceptor(UMOInterceptor inteceptor) 216 { 217 if (inteceptor != null) 218 { 219 intecerptorList.add(inteceptor); 220 } 221 } 222 223 public void setInterceptors(List inteceptorList) 224 { 225 this.intecerptorList = inteceptorList; 226 } 227 228 233 public void setPoolingProfile(PoolingProfile poolingProfile) 234 { 235 this.poolingProfile = poolingProfile; 236 } 237 238 public void setQueueProfile(QueueProfile queueProfile) 239 { 240 this.queueProfile = queueProfile; 241 } 242 243 248 public void setImplementation(Object reference) 249 { 250 if (reference == null) 251 { 252 throw new IllegalArgumentException ("ImplementationReference cannot be null"); 253 } 254 implementationReference = reference; 255 } 256 257 public void setImplementationInstance(Object instance) 258 { 259 if (name == null) 260 { 261 throw new NullPointerException ("UMODescriptor.name"); 262 } 263 properties.put(DEFAULT_INSTANCE_REF_NAME, instance); 264 setImplementation(new DescriptorContainerKeyPair(name, DEFAULT_INSTANCE_REF_NAME)); 265 } 266 267 public void setInboundRouter(UMOInboundMessageRouter routerList) 268 { 269 this.inboundRouter = routerList; 270 } 271 272 public void setOutboundRouter(UMOOutboundMessageRouter routerList) 273 { 274 outboundRouter = routerList; 275 } 276 277 public void setContainerManaged(boolean value) 278 { 279 containerManaged = value; 280 } 281 282 public void addInitialisationCallback(InitialisationCallback callback) 283 { 284 initialisationCallbacks.add(callback); 285 } 286 287 297 public void setResponseRouter(UMOResponseMessageRouter router) 298 { 299 this.responseRouter = router; 300 } 301 302 310 public void setSingleton(boolean singleton) 311 { 312 this.singleton = singleton; 313 } 314 315 320 public void setInitialState(String state) 321 { 322 this.initialState = state; 323 } 324 325 public void setEncoding(String encoding) 326 { 327 this.encoding = encoding; 328 } 329 330 339 public void setContainer(String containerName) 340 { 341 this.container = containerName; 342 } 343 } 344 | Popular Tags |