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 | 0 | super(appName); |
27 | 0 | } |
28 | |
|
29 | |
@Override |
30 | |
public void init() |
31 | |
{ |
32 | 0 | if (this.deploymentService == null) |
33 | |
{ |
34 | 0 | final String msg = String.format("Deployment service ref wasn't provided for privileged app '%s'", getAppName()); |
35 | 0 | throw new DeploymentInitException(MessageFactory.createStaticMessage(msg)); |
36 | |
} |
37 | |
|
38 | 0 | super.init(); |
39 | |
try |
40 | |
{ |
41 | 0 | if (getDescriptor().isPriviledged()) |
42 | |
{ |
43 | 0 | getMuleContext().getRegistry().registerObject(REGISTRY_KEY_DEPLOYMENT_SERVICE, deploymentService); |
44 | |
} |
45 | |
} |
46 | 0 | catch (RegistrationException e) |
47 | |
{ |
48 | 0 | final String msg = String.format("Failed to init a privileged app: [%s]", getDescriptor().getAppName()); |
49 | 0 | throw new DeploymentInitException(MessageFactory.createStaticMessage(msg), e); |
50 | 0 | } |
51 | 0 | } |
52 | |
|
53 | |
public void setDeploymentService(DeploymentService deploymentService) |
54 | |
{ |
55 | 0 | this.deploymentService = deploymentService; |
56 | 0 | } |
57 | |
} |