KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > classloader > Loaders


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 Fossil E-Commerce, http://www.fossilec.com/
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.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: Loaders.java 233 2006-04-18 16:10:51Z alouis $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.classloader;
23
24 import java.io.IOException JavaDoc;
25 import java.util.HashMap JavaDoc;
26 import java.util.Map JavaDoc;
27
28 /**
29  *
30  * @version $Revision: 233 $ $Date: 2006-04-18 16:10:51Z $
31  * @since Petals 1.0
32  * @author <a HREF="mailto:rmarins@fossilec.com">Rafael Marins</a>
33  */

34 class Loaders {
35
36     public static final String JavaDoc COMMON_LOADER = "common";
37
38     private static Loaders singletonInstance;
39
40     private static SharedLibrariesClassLoader slClassLoader;
41     
42     private Map JavaDoc<String JavaDoc,PetalsClassLoader> classLoadersTable =
43         new HashMap JavaDoc<String JavaDoc,PetalsClassLoader>();
44
45     /**
46      * Constructor.
47      * An unique SharedLibrariesClassLoader is created.
48      * It must be used to reference all classloader created for shared libraries.
49      *
50      */

51     private Loaders() {
52         super();
53         
54         try {
55             slClassLoader = new SharedLibrariesClassLoader();
56         } catch (IOException JavaDoc e) {
57             // TODO Auto-generated catch block
58
}
59     }
60
61     public static Loaders getInstance() {
62         if (singletonInstance == null) {
63             singletonInstance = new Loaders();
64         }
65         return singletonInstance;
66     }
67
68     public boolean contains(String JavaDoc loaderName) {
69         return classLoadersTable.containsKey(loaderName);
70     }
71
72     public PetalsClassLoader get(String JavaDoc loaderName) {
73         return classLoadersTable.get(loaderName);
74     }
75
76     public ClassLoader JavaDoc put(String JavaDoc loaderName, PetalsClassLoader cl) {
77         return classLoadersTable.put(loaderName, cl);
78     }
79
80     public void remove(String JavaDoc loaderName) {
81         classLoadersTable.remove(loaderName);
82     }
83     
84     public SharedLibrariesClassLoader getSharedLibrariesClassLoader()
85     {
86         return slClassLoader;
87     }
88
89 // /**
90
// * @return
91
// */
92
// private static ClassLoader createCommonLoader() {
93
//
94
// String basedir = SystemUtil.getPetalsInstallDirectory().getAbsolutePath();
95
//
96
// ClassPath cp = new ClassPath();
97
// cp.addPathElement(basedir + "/common", false, new String[] {".jar"});
98
// cp.addPathElement(basedir + "/conf");
99
// cp.addPathElement(basedir + "/conf/adl");
100
//
101
// ClassLoader loader = new PetalsClassLoader(cp);
102
//
103
// return loader;
104
// }
105
}
106
Popular Tags