1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.launcher.application;
12
13 import org.mule.MuleCoreExtension;
14 import org.mule.module.launcher.AppBloodhound;
15 import org.mule.module.launcher.DefaultAppBloodhound;
16 import org.mule.module.launcher.DeploymentService;
17 import org.mule.module.launcher.descriptor.ApplicationDescriptor;
18
19 import java.io.IOException;
20 import java.util.Map;
21
22
23
24
25
26 public class ApplicationFactory
27 {
28 protected DeploymentService deploymentService;
29 protected Map<Class<? extends MuleCoreExtension>, MuleCoreExtension> coreExtensions;
30
31 public ApplicationFactory(DeploymentService deploymentService, Map<Class<? extends MuleCoreExtension>, MuleCoreExtension> coreExtensions)
32 {
33 this.deploymentService = deploymentService;
34 this.coreExtensions = coreExtensions;
35 }
36
37 public Application createApp(String appName) throws IOException
38 {
39 AppBloodhound bh = new DefaultAppBloodhound();
40 final ApplicationDescriptor descriptor = bh.fetch(appName);
41 if (descriptor.isPrivileged())
42 {
43 final PriviledgedMuleApplication delegate = new PriviledgedMuleApplication(descriptor);
44 delegate.setDeploymentService(deploymentService);
45 delegate.setCoreExtensions(coreExtensions);
46 return new ApplicationWrapper(delegate);
47 }
48 else
49 {
50 final DefaultMuleApplication delegate = new DefaultMuleApplication(descriptor);
51 delegate.setDeploymentService(deploymentService);
52 return new ApplicationWrapper(delegate);
53 }
54 }
55 }