1
2
3
4
5
6
7 package org.mule.module.launcher.application;
8
9 import org.mule.api.registry.RegistrationException;
10 import org.mule.config.i18n.MessageFactory;
11 import org.mule.module.launcher.DeploymentInitException;
12 import org.mule.module.launcher.DeploymentService;
13
14
15
16
17 public class PriviledgedMuleApplication extends DefaultMuleApplication
18 {
19
20 public static final String REGISTRY_KEY_DEPLOYMENT_SERVICE = "_deploymentService";
21
22 protected DeploymentService deploymentService;
23
24 protected PriviledgedMuleApplication(String appName)
25 {
26 super(appName);
27 }
28
29 @Override
30 public void init()
31 {
32 if (this.deploymentService == null)
33 {
34 final String msg = String.format("Deployment service ref wasn't provided for privileged app '%s'", getAppName());
35 throw new DeploymentInitException(MessageFactory.createStaticMessage(msg));
36 }
37
38 super.init();
39 try
40 {
41 if (getDescriptor().isPriviledged())
42 {
43 getMuleContext().getRegistry().registerObject(REGISTRY_KEY_DEPLOYMENT_SERVICE, deploymentService);
44 }
45 }
46 catch (RegistrationException e)
47 {
48 final String msg = String.format("Failed to init a privileged app: [%s]", getDescriptor().getAppName());
49 throw new DeploymentInitException(MessageFactory.createStaticMessage(msg), e);
50 }
51 }
52
53 public void setDeploymentService(DeploymentService deploymentService)
54 {
55 this.deploymentService = deploymentService;
56 }
57 }