Commit cf00a951 authored by Derek DeMoro's avatar Derek DeMoro Committed by derek

Update development mode to not require classes dir. It's not needed in all cases.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3849 b35dd754-fafc-0310-a699-88a17e54d16e
parent 628cd368
......@@ -24,7 +24,18 @@ import java.io.File;
import java.io.FileFilter;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
......@@ -192,10 +203,9 @@ public class PluginManager {
String classesDirKey = pluginName + ".classes";
String webRoot = System.getProperty(webRootKey);
String classesDir = System.getProperty(classesDirKey);
boolean inDevelopmentMode = webRoot != null && classesDir != null;
if(inDevelopmentMode){
if (webRoot != null) {
final File compilationClassesDir = new File(pluginDir, "classes");
if(!compilationClassesDir.exists()){
if (!compilationClassesDir.exists()) {
compilationClassesDir.mkdir();
}
}
......@@ -206,7 +216,7 @@ public class PluginManager {
// See if the parent is already loaded.
if (plugins.containsKey(parentPlugin)) {
pluginLoader = classloaders.get(getPlugin(parentPlugin));
pluginLoader.addDirectory(pluginDir, inDevelopmentMode);
pluginLoader.addDirectory(pluginDir, classesDir != null);
}
else {
......@@ -249,16 +259,18 @@ public class PluginManager {
// This is not a child plugin, so create a new class loader.
else {
pluginLoader = new PluginClassLoader();
pluginLoader.addDirectory(pluginDir, inDevelopmentMode);
pluginLoader.addDirectory(pluginDir, classesDir != null);
}
// Check to see if development mode is turned on for the plugin. If it is,
// configure dev mode.
PluginDevEnvironment dev = null;
if (inDevelopmentMode) {
if (webRoot != null || classesDir != null) {
dev = new PluginDevEnvironment();
System.out.println(pluginName + " is running in development mode.");
if (webRoot != null) {
File webRootDir = new File(webRoot);
if (!webRootDir.exists()) {
// ok, let's try it relative from this plugin dir?
......@@ -268,7 +280,9 @@ public class PluginManager {
if (webRootDir.exists()) {
dev.setWebRoot(webRootDir);
}
}
if (classesDir != null) {
File classes = new File(classesDir);
if (!classes.exists()) {
// ok, let's try it relative from this plugin dir?
......@@ -280,12 +294,13 @@ public class PluginManager {
pluginLoader.addURL(classes.getAbsoluteFile().toURL());
}
}
}
pluginLoader.initialize();
String className = pluginXML.selectSingleNode("/plugin/class").getText();
plugin = (Plugin)pluginLoader.loadClass(className).newInstance();
if(parentPluginNode != null){
if (parentPluginNode != null) {
String parentPlugin = parentPluginNode.getTextTrim();
// See if the parent is already loaded.
if (plugins.containsKey(parentPlugin)) {
......@@ -336,11 +351,10 @@ public class PluginManager {
// If there a <adminconsole> section defined, register it.
Element adminElement = (Element)pluginXML.selectSingleNode("/plugin/adminconsole");
if (adminElement != null) {
if(parentPluginNode != null){
if (parentPluginNode != null) {
pluginName = parentPluginNode.getTextTrim();
}
// If global images are specified, override their URL.
Element imageEl = (Element)adminElement.selectSingleNode(
"/plugin/adminconsole/global/logo-image");
......@@ -355,7 +369,7 @@ public class PluginManager {
// the plugin servlet correctly.
List urls = adminElement.selectNodes("//@url");
for (Object url : urls) {
Attribute attr = (Attribute) url;
Attribute attr = (Attribute)url;
attr.setValue("plugins/" + pluginName + "/" + attr.getValue());
}
AdminConsole.addModel(pluginName, adminElement);
......@@ -440,8 +454,7 @@ public class PluginManager {
* @throws InstantiationException if the class could not be created.
*/
public Class loadClass(Plugin plugin, String className) throws ClassNotFoundException,
IllegalAccessException, InstantiationException
{
IllegalAccessException, InstantiationException {
PluginClassLoader loader = classloaders.get(plugin);
return loader.loadClass(className);
}
......@@ -511,10 +524,11 @@ public class PluginManager {
/**
* Returns the classloader of a plugin.
*
* @param plugin the plugin.
* @return the classloader of the plugin.
*/
public PluginClassLoader getPluginClassloader(Plugin plugin){
public PluginClassLoader getPluginClassloader(Plugin plugin) {
return classloaders.get(plugin);
}
......
......@@ -20,14 +20,6 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils;
import org.xml.sax.SAXException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.GenericServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServlet;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
......@@ -40,6 +32,14 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.servlet.GenericServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* The plugin servlet acts as a proxy for web requests (in the admin console)
* to plugins. Since plugins can be dynamically loaded and live in a different place
......@@ -75,8 +75,7 @@ public class PluginServlet extends HttpServlet {
}
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
throws ServletException, IOException {
String pathInfo = request.getPathInfo();
if (pathInfo == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
......@@ -490,8 +489,10 @@ public class PluginServlet extends HttpServlet {
classpath.append(wildfireLib.getAbsolutePath()).append("//wildfire.jar;");
classpath.append(wildfireLib.getAbsolutePath()).append("//jasper-compiler.jar;");
classpath.append(wildfireLib.getAbsolutePath()).append("//jasper-runtime.jar;");
classpath.append(pluginEnv.getClassesDir().getAbsolutePath()).append(";");
if (pluginEnv.getClassesDir() != null) {
classpath.append(pluginEnv.getClassesDir().getAbsolutePath()).append(";");
}
return classpath.toString();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment