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.api.registry.RegistrationException;
15 import org.mule.config.i18n.MessageFactory;
16 import org.mule.module.launcher.DeploymentInitException;
17 import org.mule.module.launcher.descriptor.ApplicationDescriptor;
18
19 import java.util.Map;
20
21
22
23
24 public class PriviledgedMuleApplication extends DefaultMuleApplication
25 {
26
27 public static final String REGISTRY_KEY_DEPLOYMENT_SERVICE = "_deploymentService";
28 public static final String REGISTRY_KEY_CORE_EXTENSIONS = "_coreExtensions";
29
30 protected Map<Class<? extends MuleCoreExtension>, MuleCoreExtension> coreExtensions;
31
32 protected PriviledgedMuleApplication(ApplicationDescriptor appDescriptor)
33 {
34 super(appDescriptor);
35 }
36
37 @Override
38 public void init()
39 {
40 if (this.deploymentService == null)
41 {
42 final String msg = String.format("Deployment service ref wasn't provided for privileged app '%s'", getAppName());
43 throw new DeploymentInitException(MessageFactory.createStaticMessage(msg));
44 }
45
46 super.init();
47 try
48 {
49 if (getDescriptor().isPrivileged())
50 {
51 getMuleContext().getRegistry().registerObject(REGISTRY_KEY_DEPLOYMENT_SERVICE, deploymentService);
52 getMuleContext().getRegistry().registerObject(REGISTRY_KEY_CORE_EXTENSIONS, coreExtensions);
53 }
54 }
55 catch (RegistrationException e)
56 {
57 final String msg = String.format("Failed to init a privileged app: [%s]", getDescriptor().getAppName());
58 throw new DeploymentInitException(MessageFactory.createStaticMessage(msg), e);
59 }
60 }
61
62 public void setCoreExtensions(Map<Class<? extends MuleCoreExtension>, MuleCoreExtension> coreExtensions)
63 {
64 this.coreExtensions = coreExtensions;
65 }
66 }