1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.impl.container; |
12 | |
|
13 | |
import org.mule.config.i18n.CoreMessages; |
14 | |
import org.mule.impl.model.ModelHelper; |
15 | |
import org.mule.umo.UMODescriptor; |
16 | |
import org.mule.umo.manager.ContainerException; |
17 | |
import org.mule.umo.manager.ObjectNotFoundException; |
18 | |
|
19 | |
import java.io.Reader; |
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
public class DescriptorContainerContext extends AbstractContainerContext |
25 | |
{ |
26 | |
public static final String DESCRIPTOR_CONTAINER_NAME = "descriptor"; |
27 | |
|
28 | |
public DescriptorContainerContext() |
29 | |
{ |
30 | 392 | super(DESCRIPTOR_CONTAINER_NAME); |
31 | 392 | } |
32 | |
|
33 | |
public void configure(Reader configuration) throws ContainerException |
34 | |
{ |
35 | 0 | throw new UnsupportedOperationException("configure"); |
36 | |
} |
37 | |
|
38 | |
public void setName(String name) |
39 | |
{ |
40 | |
|
41 | 0 | } |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
public Object getComponent(Object key) throws ObjectNotFoundException |
54 | |
{ |
55 | |
|
56 | 70 | if (key instanceof DescriptorContainerKeyPair) |
57 | |
{ |
58 | 0 | DescriptorContainerKeyPair dckp = (DescriptorContainerKeyPair) key; |
59 | |
|
60 | 0 | UMODescriptor d = ModelHelper.getDescriptor(dckp.getDescriptorName()); |
61 | 0 | if (d == null) |
62 | |
{ |
63 | 0 | throw new ObjectNotFoundException( |
64 | |
key.toString(), |
65 | |
new ContainerException( |
66 | |
CoreMessages.failedToLoad("descriptor: " + dckp.getDescriptorName()))); |
67 | |
} |
68 | 0 | Object component = d.getProperties().get(dckp.getKey()); |
69 | 0 | if (component == null) |
70 | |
{ |
71 | 0 | throw new ObjectNotFoundException(dckp.getKey().toString()); |
72 | |
} |
73 | 0 | return component; |
74 | |
} |
75 | |
else |
76 | |
{ |
77 | 70 | throw new ObjectNotFoundException(key.toString()); |
78 | |
} |
79 | |
} |
80 | |
|
81 | |
} |