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