01: /*
02: * Copyright 2005-2006 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package edu.iu.uis.eden.plugin;
18:
19: import java.io.File;
20: import java.net.URL;
21:
22: import org.apache.log4j.Logger;
23: import org.kuali.rice.config.Config;
24:
25: /**
26: * A {@link PluginLoader} which creates and Loads a {@link Plugin} from the given
27: * location on the classpath.
28: *
29: * @see Plugin
30: *
31: * @author Eric Westfall
32: */
33: public class ClasspathPluginLoader extends BasePluginLoader {
34: private static final Logger LOG = Logger
35: .getLogger(ClasspathPluginLoader.class);
36:
37: private final String classpathLocation;
38:
39: public ClasspathPluginLoader(String pluginName,
40: String classpathLocation, File sharedPluginDirectory,
41: ClassLoader parentClassLoader, Config parentConfig,
42: boolean institutionalPlugin) {
43: super (pluginName, sharedPluginDirectory, parentClassLoader,
44: parentConfig, institutionalPlugin);
45: this .classpathLocation = classpathLocation;
46: }
47:
48: /**
49: * A Plugin which is loaded from the classpath will never change.
50: */
51: public boolean isModified() {
52: return false;
53: }
54:
55: protected PluginClassLoader createPluginClassLoader() {
56: LOG
57: .info(getLogPrefix()
58: + " Initiating loading of plugin from classpath location: "
59: + classpathLocation);
60: return new EmbeddedPluginClassLoader(parentClassLoader,
61: classpathLocation);
62: }
63:
64: protected URL getPluginManifestURL() {
65: String fullManifestPath = classpathLocation + "/"
66: + pluginManifestPath;
67: // NOTE: consider using the plugin's classloader (or context classloader which should
68: // probably be set to plugin's classloader at this point
69: // works because fullManifestPath is always prefixed with the plugin's classpath location
70: // prefix
71: return parentClassLoader.getResource(fullManifestPath);
72: }
73: }
|