Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MuleContainerContext |
|
| 3.3333333333333335;3.333 |
1 | /* | |
2 | * $Id: MuleContainerContext.java 7976 2007-08-21 14:26:13Z 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 | ||
11 | package org.mule.impl.container; | |
12 | ||
13 | import org.mule.umo.manager.ObjectNotFoundException; | |
14 | import org.mule.util.ClassUtils; | |
15 | ||
16 | import java.io.Reader; | |
17 | ||
18 | /** | |
19 | * <code>MuleContainerContext</code> is a default resolver that doesn't support | |
20 | * external reference resolution. It's function is to provide a complete | |
21 | * implementation when a componenet resolver is not defined. The default behaviour is | |
22 | * to build a component key as a fully qualified class name | |
23 | */ | |
24 | public class MuleContainerContext extends AbstractContainerContext | |
25 | { | |
26 | public static final String MULE_CONTAINER_NAME = "mule"; | |
27 | ||
28 | public MuleContainerContext() | |
29 | { | |
30 | 0 | super(MULE_CONTAINER_NAME); |
31 | 0 | } |
32 | ||
33 | /* | |
34 | * (non-Javadoc) | |
35 | * | |
36 | * @see org.mule.model.UMOContainerContext#getComponent(java.lang.Object) | |
37 | */ | |
38 | public Object getComponent(Object key) throws ObjectNotFoundException | |
39 | { | |
40 | 0 | if (key == null) |
41 | { | |
42 | 0 | throw new ObjectNotFoundException("Component not found for null key"); |
43 | } | |
44 | try | |
45 | { | |
46 | Class clazz; | |
47 | 0 | if (key instanceof Class) |
48 | { | |
49 | 0 | clazz = (Class) key; |
50 | } | |
51 | else | |
52 | { | |
53 | 0 | clazz = ClassUtils.loadClass(key.toString(), getClass()); |
54 | } | |
55 | 0 | return clazz.newInstance(); |
56 | } | |
57 | 0 | catch (Exception e) |
58 | { | |
59 | 0 | throw new ObjectNotFoundException(key.toString() + " (" + e.getMessage() + ")", e); |
60 | } | |
61 | } | |
62 | ||
63 | public void configure(Reader configuration) | |
64 | { | |
65 | 0 | throw new UnsupportedOperationException("configure(Reader)"); |
66 | } | |
67 | ||
68 | } |