KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > adl > AbstractLoader


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;
25
26 import java.util.Map JavaDoc;
27
28 import org.objectweb.fractal.api.control.BindingController;
29
30 /**
31  * An abstract {@link Loader} that delegates to another {@link Loader}.
32  */

33
34 public abstract class AbstractLoader implements BindingController, Loader {
35
36   /**
37    * Name of the mandatory interface bound to the {@link Loader} used by this
38    * loader.
39    */

40   
41   public final static String JavaDoc LOADER_BINDING = "client-loader";
42
43   /**
44    * The {@link Loader} used by this loader.
45    */

46   
47   public Loader clientLoader;
48
49   // ------------------------------------------------------------------------
50
// Implementation of the BindingController interface
51
// ------------------------------------------------------------------------
52

53   public String JavaDoc[] listFc () {
54     return new String JavaDoc[] { LOADER_BINDING };
55   }
56
57   public Object JavaDoc lookupFc (String JavaDoc s) {
58     if (LOADER_BINDING.equals(s)) {
59       return clientLoader;
60     }
61     return null;
62   }
63
64   public void bindFc (String JavaDoc s, Object JavaDoc o) {
65     if (LOADER_BINDING.equals(s)) {
66       clientLoader = (Loader)o;
67     }
68   }
69
70   public void unbindFc (String JavaDoc s) {
71     if (LOADER_BINDING.equals(s)) {
72       clientLoader = null;
73     }
74   }
75   
76   // ------------------------------------------------------------------------
77
// Implementation of the BindingController interface
78
// ------------------------------------------------------------------------
79

80   protected ClassLoader JavaDoc getClassLoader (final Map JavaDoc context) {
81     ClassLoader JavaDoc loader = null;
82     if (context != null) {
83       loader = (ClassLoader JavaDoc)context.get("classloader");
84     }
85     if (loader == null) {
86       loader = getClass().getClassLoader();
87     }
88     return loader;
89   }
90 }
91
92
Popular Tags