Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ModelHelper |
|
| 2.6666666666666665;2.667 |
1 | /* | |
2 | * $Id: ModelHelper.java 7963 2007-08-21 08:53:15Z dirk.olmes $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | package org.mule.impl.model; | |
11 | ||
12 | import org.mule.MuleManager; | |
13 | import org.mule.umo.UMOComponent; | |
14 | import org.mule.umo.UMODescriptor; | |
15 | import org.mule.umo.UMOException; | |
16 | import org.mule.umo.model.UMOModel; | |
17 | ||
18 | import java.util.Iterator; | |
19 | ||
20 | /** | |
21 | * @deprecated This functionality should be moved to the registry | |
22 | */ | |
23 | public final class ModelHelper | |
24 | { | |
25 | public static final String SYSTEM_MODEL = "_system"; | |
26 | ||
27 | /** Do not instanciate. */ | |
28 | private ModelHelper () | |
29 | 0 | { |
30 | // no-op | |
31 | 0 | } |
32 | ||
33 | public static String getSystemModelType() | |
34 | { | |
35 | 0 | return "seda"; |
36 | } | |
37 | ||
38 | public static boolean isComponentRegistered(String name) | |
39 | { | |
40 | 2 | for (Iterator iterator = MuleManager.getInstance().getModels().values().iterator(); iterator.hasNext();) |
41 | { | |
42 | 4 | UMOModel m = (UMOModel) iterator.next(); |
43 | 4 | if (m.isComponentRegistered(name)) |
44 | { | |
45 | 0 | return true; |
46 | } | |
47 | 4 | } |
48 | 2 | return false; |
49 | } | |
50 | ||
51 | public static UMOComponent getComponent(String name) | |
52 | { | |
53 | 0 | for (Iterator iterator = MuleManager.getInstance().getModels().values().iterator(); iterator.hasNext();) |
54 | { | |
55 | 0 | UMOModel m = (UMOModel) iterator.next(); |
56 | 0 | if (m.isComponentRegistered(name)) |
57 | { | |
58 | 0 | return m.getComponent(name); |
59 | } | |
60 | 0 | } |
61 | 0 | return null; |
62 | } | |
63 | ||
64 | public static UMODescriptor getDescriptor(String name) | |
65 | { | |
66 | 0 | for (Iterator iterator = MuleManager.getInstance().getModels().values().iterator(); iterator.hasNext();) |
67 | { | |
68 | 0 | UMOModel m = (UMOModel) iterator.next(); |
69 | 0 | if (m.isComponentRegistered(name)) |
70 | { | |
71 | 0 | return m.getDescriptor(name); |
72 | } | |
73 | 0 | } |
74 | 0 | return null; |
75 | } | |
76 | ||
77 | //TODO RM*: Move this method | |
78 | public static void registerSystemComponent(UMODescriptor d) throws UMOException | |
79 | { | |
80 | 2 | UMOModel model = MuleManager.getInstance().lookupModel(SYSTEM_MODEL); |
81 | 2 | if(model==null) |
82 | { | |
83 | 0 | model = ModelFactory.createModel("seda"); |
84 | 0 | model.setName(SYSTEM_MODEL); |
85 | 0 | MuleManager.getInstance().registerModel(model); |
86 | } | |
87 | 2 | model.registerComponent(d); |
88 | 2 | } |
89 | } |