KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > loader > PathLoader


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * Resin Open Source is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17  * of NON-INFRINGEMENT. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with Resin Open Source; if not, write to the
22  *
23  * Free Software Foundation, Inc.
24  * 59 Temple Place, Suite 330
25  * Boston, MA 02111-1307 USA
26  *
27  * @author Scott Ferguson
28  */

29
30 package com.caucho.loader;
31
32 import com.caucho.log.Log;
33 import com.caucho.vfs.Dependency;
34 import com.caucho.vfs.Path;
35
36 import java.net.URL JavaDoc;
37 import java.util.HashMap JavaDoc;
38 import java.util.Vector JavaDoc;
39 import java.util.logging.Logger JavaDoc;
40
41 /**
42  * Class loader which loads specific paths.
43  */

44 public class PathLoader extends Loader implements Dependency {
45   private static final Logger JavaDoc log = Log.open(PathLoader.class);
46
47   private HashMap JavaDoc<String JavaDoc,Path> _pathMap = new HashMap JavaDoc<String JavaDoc,Path>();
48
49   /**
50    * Creates a new directory loader.
51    */

52   public PathLoader()
53   {
54   }
55
56   /**
57    * Initialize
58    */

59   public void init()
60   {
61   }
62
63   /**
64    * Returns the modified
65    */

66   public boolean isModified()
67   {
68     return false;
69   }
70
71   /**
72    * Adds a new path.
73    */

74   public void put(String JavaDoc name, Path path)
75   {
76     _pathMap.put(name, path);
77   }
78
79   /**
80    * Returns the class entry.
81    *
82    * @param name name of the class
83    */

84   protected ClassEntry getClassEntry(String JavaDoc name)
85     throws ClassNotFoundException JavaDoc
86   {
87     Path path = _pathMap.get(name);
88
89     if (path != null && path.canRead() && path.getLength() > 0) {
90       ClassEntry entry = new ClassEntry(getLoader(), name, path,
91                     path, getCodeSource(path));
92
93       /*
94       int p = name.lastIndexOf('.');
95       String pkg;
96       if (p > 0)
97     pkg = name.substring(0, p);
98       else
99     pkg = "";
100
101       ClassPackage classPackage = jarEntry.getPackage(pkg);
102
103       entry.setClassPackage(classPackage);
104       */

105
106       return entry;
107     }
108
109     return null;
110   }
111   
112   /**
113    * Adds resources to the enumeration.
114    */

115   public void getResources(Vector JavaDoc<URL JavaDoc> vector, String JavaDoc name)
116   {
117   }
118
119   /**
120    * Find a given path somewhere in the classpath
121    *
122    * @param pathName the relative resourceName
123    *
124    * @return the matching path or null
125    */

126   public Path getPath(String JavaDoc pathName)
127   {
128     return null;
129   }
130
131   public Path getCodePath()
132   {
133     return null;
134   }
135
136   public String JavaDoc toString()
137   {
138     return "PathLoader[]";
139   }
140 }
141
Popular Tags