KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > adl > implementations > JavaImplementationBuilder


1 /***
2  * Fractal ADL Parser
3  * Copyright (C) 2002-2004 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package org.objectweb.fractal.adl.implementations;
25
26 import java.util.HashMap JavaDoc;
27 import java.util.Map JavaDoc;
28
29 /**
30  * A Java based implementation of the {@link ImplementationBuilder} interface.
31  */

32
33 public class JavaImplementationBuilder implements ImplementationBuilder {
34   
35   // --------------------------------------------------------------------------
36
// Implementation of the ImplementationBuilder interface
37
// --------------------------------------------------------------------------
38

39   public Object JavaDoc createComponent (
40     final Object JavaDoc type,
41     final String JavaDoc name,
42     final String JavaDoc definition,
43     final Object JavaDoc controllerDesc,
44     final Object JavaDoc contentDesc,
45     final Object JavaDoc context) throws Exception JavaDoc
46   {
47     ClassLoader JavaDoc loader = null;
48     if (context instanceof Map JavaDoc) {
49       loader = (ClassLoader JavaDoc)((Map JavaDoc)context).get("classloader");
50     }
51     if (loader == null) {
52       loader = getClass().getClassLoader();
53     }
54     
55     if (contentDesc == null) {
56       return new HashMap JavaDoc();
57     } else {
58       String JavaDoc c = (String JavaDoc)contentDesc;
59       return loader.loadClass(c).newInstance();
60     }
61   }
62 }
63
Popular Tags