KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > container > MuleContainerContext


1 /*
2  * $Id: MuleContainerContext.java 3192 2006-09-24 22:45:24Z holger $
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 MuleSource MPL
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 java.io.Reader JavaDoc;
14
15 import org.mule.umo.manager.ObjectNotFoundException;
16 import org.mule.util.ClassUtils;
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 JavaDoc MULE_CONTAINER_NAME = "mule";
27
28     public MuleContainerContext()
29     {
30         super(MULE_CONTAINER_NAME);
31     }
32
33     /*
34      * (non-Javadoc)
35      *
36      * @see org.mule.model.UMOContainerContext#getComponent(java.lang.Object)
37      */

38     public Object JavaDoc getComponent(Object JavaDoc key) throws ObjectNotFoundException
39     {
40         if (key == null)
41         {
42             throw new ObjectNotFoundException("Component not found for null key");
43         }
44         try
45         {
46             Class JavaDoc clazz;
47             if (key instanceof Class JavaDoc)
48             {
49                 clazz = (Class JavaDoc)key;
50             }
51             else
52             {
53                 clazz = ClassUtils.loadClass(key.toString(), getClass());
54             }
55             return clazz.newInstance();
56         }
57         catch (Exception JavaDoc e)
58         {
59             throw new ObjectNotFoundException(key.toString() + " (" + e.getMessage() + ")");
60         }
61     }
62
63     public void configure(Reader JavaDoc configuration)
64     {
65         throw new UnsupportedOperationException JavaDoc("configure(Reader)");
66     }
67
68 }
69
Popular Tags