1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.impl.container; |
12 | |
|
13 | |
import org.mule.umo.lifecycle.InitialisationException; |
14 | |
import org.mule.umo.manager.ObjectNotFoundException; |
15 | |
import org.mule.util.ClassUtils; |
16 | |
|
17 | |
import javax.naming.NamingException; |
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
public class RmiContainerContext extends JndiContainerContext |
24 | |
{ |
25 | 0 | protected String securityPolicy = null; |
26 | 0 | protected String securityManager = null; |
27 | |
|
28 | |
protected RmiContainerContext(String name) |
29 | |
{ |
30 | 0 | super(name); |
31 | 0 | } |
32 | |
|
33 | |
public RmiContainerContext() |
34 | |
{ |
35 | 0 | super("rmi"); |
36 | 0 | } |
37 | |
|
38 | |
public void initialise() throws InitialisationException |
39 | |
{ |
40 | 0 | super.initialise(); |
41 | 0 | if (securityPolicy != null) |
42 | |
{ |
43 | 0 | if (ClassUtils.getResource(securityPolicy, getClass()) != null) |
44 | |
{ |
45 | 0 | System.setProperty("java.security.policy", securityPolicy); |
46 | |
} |
47 | |
} |
48 | |
|
49 | |
|
50 | 0 | if (System.getSecurityManager() == null) |
51 | |
{ |
52 | |
try |
53 | |
{ |
54 | 0 | if (securityManager != null) |
55 | |
{ |
56 | 0 | Class clazz = ClassUtils.loadClass(securityManager, getClass()); |
57 | 0 | System.setSecurityManager((SecurityManager) clazz.newInstance()); |
58 | |
} |
59 | |
} |
60 | 0 | catch (Exception e) |
61 | |
{ |
62 | 0 | throw new InitialisationException(e, this); |
63 | 0 | } |
64 | |
} |
65 | 0 | } |
66 | |
|
67 | |
public Object getComponent(Object key) throws ObjectNotFoundException |
68 | |
{ |
69 | 0 | Object object = null; |
70 | 0 | if (key == null) |
71 | |
{ |
72 | 0 | throw new ObjectNotFoundException("null"); |
73 | |
} |
74 | |
try |
75 | |
{ |
76 | 0 | object = context.lookup(key.toString()); |
77 | |
} |
78 | 0 | catch (NamingException e) |
79 | |
{ |
80 | 0 | throw new ObjectNotFoundException(key.toString(), e); |
81 | 0 | } |
82 | |
|
83 | 0 | if (object == null) |
84 | |
{ |
85 | 0 | throw new ObjectNotFoundException(key.toString()); |
86 | |
} |
87 | |
else |
88 | |
{ |
89 | 0 | return object; |
90 | |
} |
91 | |
} |
92 | |
|
93 | |
public String getSecurityPolicy() |
94 | |
{ |
95 | 0 | return securityPolicy; |
96 | |
} |
97 | |
|
98 | |
public void setSecurityPolicy(String securityPolicy) |
99 | |
{ |
100 | 0 | this.securityPolicy = securityPolicy; |
101 | 0 | } |
102 | |
|
103 | |
public String getSecurityManager() |
104 | |
{ |
105 | 0 | return securityManager; |
106 | |
} |
107 | |
|
108 | |
public void setSecurityManager(String securityManager) |
109 | |
{ |
110 | 0 | this.securityManager = securityManager; |
111 | 0 | } |
112 | |
} |