KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > parser > lib > JarManager


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2005 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================
26 $Id: JarManager.java,v 1.2 2005/07/06 15:36:00 moroy Exp $
27 ====================================================================*/

28
29 package org.objectweb.util.explorer.parser.lib;
30
31 import java.net.URL JavaDoc;
32 import java.util.Iterator JavaDoc;
33 import java.util.List JavaDoc;
34 import java.util.Vector JavaDoc;
35
36 import org.objectweb.util.explorer.core.common.lib.BasicLoggable;
37 import org.objectweb.util.explorer.core.common.lib.ClassResolver;
38 import org.objectweb.util.explorer.explorerConfig.Jar;
39 import org.objectweb.util.explorer.explorerConfig.Node;
40 import org.objectweb.util.explorer.explorerConfig.beans.ExplorerBean;
41 import org.objectweb.util.explorer.parser.api.ExplorerParser;
42 import org.objectweb.util.explorer.parser.api.NodeParser;
43
44 /**
45  * This component manages the "jar" XML element.
46  *
47  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
48  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
49  *
50  * @version 0.1
51  */

52 public class JarManager
53      extends BasicLoggable
54   implements ExplorerParser, NodeParser
55 {
56
57     //==================================================================
58
//
59
// No Internal State.
60
//
61
// ==================================================================
62

63     // ==================================================================
64
//
65
// No Constructor.
66
//
67
// ==================================================================
68

69     // ==================================================================
70
//
71
// No internal methods.
72
//
73
// ==================================================================
74

75     /**
76      * Loads the list of jar URL into the Explorer CLassLoader
77      * @param jarList A list of jar to load
78      */

79     protected void loadJars(List JavaDoc jarList){
80         Vector JavaDoc urlList = new Vector JavaDoc();
81         Iterator JavaDoc it = jarList.iterator();
82         while(it.hasNext()){
83             String JavaDoc jarUrl = ((Jar)it.next()).getUrl();
84             try {
85                 urlList.add(new URL JavaDoc(jarUrl));
86             } catch (java.net.MalformedURLException JavaDoc e) {
87                 getTrace().info(jarUrl + " : Malformed URL!");
88             }
89         }
90         if (!urlList.isEmpty()) {
91             ClassResolver.addContext((URL JavaDoc[]) urlList.toArray(new URL JavaDoc[0]));
92         }
93     }
94     
95     // ==================================================================
96
//
97
// Public methods for ExplorerParser interface.
98
//
99
// ==================================================================
100

101     /* (non-Javadoc)
102      * @see org.objectweb.util.explorer.parser.api.ExplorerParser#parseExplorer(org.objectweb.util.explorer.explorerConfig.beans.ExplorerBean)
103      */

104     public void parseExplorer(ExplorerBean explorer) {
105         loadJars(explorer.getJarList());
106     }
107
108     // ==================================================================
109
//
110
// Public methods for NodeParser interface.
111
//
112
// ==================================================================
113

114     /* (non-Javadoc)
115      * @see org.objectweb.util.explorer.parser.api.NodeParser#parseNode(java.lang.Object, org.objectweb.util.explorer.explorerConfig.Node)
116      */

117     public void parseNode(Object JavaDoc key, Node node) {
118         loadJars(node.getJarList());
119     }
120 }
121
Popular Tags