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; ...@@ -24,7 +24,18 @@ import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; 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.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ScheduledThreadPoolExecutor;
...@@ -192,10 +203,9 @@ public class PluginManager { ...@@ -192,10 +203,9 @@ public class PluginManager {
String classesDirKey = pluginName + ".classes"; String classesDirKey = pluginName + ".classes";
String webRoot = System.getProperty(webRootKey); String webRoot = System.getProperty(webRootKey);
String classesDir = System.getProperty(classesDirKey); String classesDir = System.getProperty(classesDirKey);
boolean inDevelopmentMode = webRoot != null && classesDir != null; if (webRoot != null) {
if(inDevelopmentMode){
final File compilationClassesDir = new File(pluginDir, "classes"); final File compilationClassesDir = new File(pluginDir, "classes");
if(!compilationClassesDir.exists()){ if (!compilationClassesDir.exists()) {
compilationClassesDir.mkdir(); compilationClassesDir.mkdir();
} }
} }
...@@ -206,7 +216,7 @@ public class PluginManager { ...@@ -206,7 +216,7 @@ public class PluginManager {
// See if the parent is already loaded. // See if the parent is already loaded.
if (plugins.containsKey(parentPlugin)) { if (plugins.containsKey(parentPlugin)) {
pluginLoader = classloaders.get(getPlugin(parentPlugin)); pluginLoader = classloaders.get(getPlugin(parentPlugin));
pluginLoader.addDirectory(pluginDir, inDevelopmentMode); pluginLoader.addDirectory(pluginDir, classesDir != null);
} }
else { else {
...@@ -249,16 +259,18 @@ public class PluginManager { ...@@ -249,16 +259,18 @@ public class PluginManager {
// This is not a child plugin, so create a new class loader. // This is not a child plugin, so create a new class loader.
else { else {
pluginLoader = new PluginClassLoader(); 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, // Check to see if development mode is turned on for the plugin. If it is,
// configure dev mode. // configure dev mode.
PluginDevEnvironment dev = null; PluginDevEnvironment dev = null;
if (inDevelopmentMode) { if (webRoot != null || classesDir != null) {
dev = new PluginDevEnvironment(); dev = new PluginDevEnvironment();
System.out.println(pluginName + " is running in development mode.");
if (webRoot != null) {
File webRootDir = new File(webRoot); File webRootDir = new File(webRoot);
if (!webRootDir.exists()) { if (!webRootDir.exists()) {
// ok, let's try it relative from this plugin dir? // ok, let's try it relative from this plugin dir?
...@@ -268,7 +280,9 @@ public class PluginManager { ...@@ -268,7 +280,9 @@ public class PluginManager {
if (webRootDir.exists()) { if (webRootDir.exists()) {
dev.setWebRoot(webRootDir); dev.setWebRoot(webRootDir);
} }
}
if (classesDir != null) {
File classes = new File(classesDir); File classes = new File(classesDir);
if (!classes.exists()) { if (!classes.exists()) {
// ok, let's try it relative from this plugin dir? // ok, let's try it relative from this plugin dir?
...@@ -280,12 +294,13 @@ public class PluginManager { ...@@ -280,12 +294,13 @@ public class PluginManager {
pluginLoader.addURL(classes.getAbsoluteFile().toURL()); pluginLoader.addURL(classes.getAbsoluteFile().toURL());
} }
} }
}
pluginLoader.initialize(); pluginLoader.initialize();
String className = pluginXML.selectSingleNode("/plugin/class").getText(); String className = pluginXML.selectSingleNode("/plugin/class").getText();
plugin = (Plugin)pluginLoader.loadClass(className).newInstance(); plugin = (Plugin)pluginLoader.loadClass(className).newInstance();
if(parentPluginNode != null){ if (parentPluginNode != null) {
String parentPlugin = parentPluginNode.getTextTrim(); String parentPlugin = parentPluginNode.getTextTrim();
// See if the parent is already loaded. // See if the parent is already loaded.
if (plugins.containsKey(parentPlugin)) { if (plugins.containsKey(parentPlugin)) {
...@@ -336,11 +351,10 @@ public class PluginManager { ...@@ -336,11 +351,10 @@ public class PluginManager {
// If there a <adminconsole> section defined, register it. // If there a <adminconsole> section defined, register it.
Element adminElement = (Element)pluginXML.selectSingleNode("/plugin/adminconsole"); Element adminElement = (Element)pluginXML.selectSingleNode("/plugin/adminconsole");
if (adminElement != null) { if (adminElement != null) {
if(parentPluginNode != null){ if (parentPluginNode != null) {
pluginName = parentPluginNode.getTextTrim(); pluginName = parentPluginNode.getTextTrim();
} }
// If global images are specified, override their URL. // If global images are specified, override their URL.
Element imageEl = (Element)adminElement.selectSingleNode( Element imageEl = (Element)adminElement.selectSingleNode(
"/plugin/adminconsole/global/logo-image"); "/plugin/adminconsole/global/logo-image");
...@@ -355,7 +369,7 @@ public class PluginManager { ...@@ -355,7 +369,7 @@ public class PluginManager {
// the plugin servlet correctly. // the plugin servlet correctly.
List urls = adminElement.selectNodes("//@url"); List urls = adminElement.selectNodes("//@url");
for (Object url : urls) { for (Object url : urls) {
Attribute attr = (Attribute) url; Attribute attr = (Attribute)url;
attr.setValue("plugins/" + pluginName + "/" + attr.getValue()); attr.setValue("plugins/" + pluginName + "/" + attr.getValue());
} }
AdminConsole.addModel(pluginName, adminElement); AdminConsole.addModel(pluginName, adminElement);
...@@ -440,8 +454,7 @@ public class PluginManager { ...@@ -440,8 +454,7 @@ public class PluginManager {
* @throws InstantiationException if the class could not be created. * @throws InstantiationException if the class could not be created.
*/ */
public Class loadClass(Plugin plugin, String className) throws ClassNotFoundException, public Class loadClass(Plugin plugin, String className) throws ClassNotFoundException,
IllegalAccessException, InstantiationException IllegalAccessException, InstantiationException {
{
PluginClassLoader loader = classloaders.get(plugin); PluginClassLoader loader = classloaders.get(plugin);
return loader.loadClass(className); return loader.loadClass(className);
} }
...@@ -511,10 +524,11 @@ public class PluginManager { ...@@ -511,10 +524,11 @@ public class PluginManager {
/** /**
* Returns the classloader of a plugin. * Returns the classloader of a plugin.
*
* @param plugin the plugin. * @param plugin the plugin.
* @return the classloader of the plugin. * @return the classloader of the plugin.
*/ */
public PluginClassLoader getPluginClassloader(Plugin plugin){ public PluginClassLoader getPluginClassloader(Plugin plugin) {
return classloaders.get(plugin); return classloaders.get(plugin);
} }
......
...@@ -20,14 +20,6 @@ import org.jivesoftware.util.Log; ...@@ -20,14 +20,6 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.util.StringUtils; import org.jivesoftware.util.StringUtils;
import org.xml.sax.SAXException; 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.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -40,6 +32,14 @@ import java.util.List; ...@@ -40,6 +32,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; 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) * 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 * to plugins. Since plugins can be dynamically loaded and live in a different place
...@@ -75,8 +75,7 @@ public class PluginServlet extends HttpServlet { ...@@ -75,8 +75,7 @@ public class PluginServlet extends HttpServlet {
} }
public void service(HttpServletRequest request, HttpServletResponse response) public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException throws ServletException, IOException {
{
String pathInfo = request.getPathInfo(); String pathInfo = request.getPathInfo();
if (pathInfo == null) { if (pathInfo == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND); response.setStatus(HttpServletResponse.SC_NOT_FOUND);
...@@ -490,8 +489,10 @@ public class PluginServlet extends HttpServlet { ...@@ -490,8 +489,10 @@ public class PluginServlet extends HttpServlet {
classpath.append(wildfireLib.getAbsolutePath()).append("//wildfire.jar;"); classpath.append(wildfireLib.getAbsolutePath()).append("//wildfire.jar;");
classpath.append(wildfireLib.getAbsolutePath()).append("//jasper-compiler.jar;"); classpath.append(wildfireLib.getAbsolutePath()).append("//jasper-compiler.jar;");
classpath.append(wildfireLib.getAbsolutePath()).append("//jasper-runtime.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(); 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