From: <cr...@us...> - 2008-11-29 08:31:54
|
Revision: 4754 http://jnode.svn.sourceforge.net/jnode/?rev=4754&view=rev Author: crawley Date: 2008-11-29 08:31:48 +0000 (Sat, 29 Nov 2008) Log Message: ----------- More refactoring of Emu related stuff Modified Paths: -------------- trunk/core/src/emu/org/jnode/emu/plugin/model/DummyPluginDescriptor.java trunk/distr/src/emu/org/jnode/emu/Emu.java trunk/gui/src/test/org/jnode/test/gui/Emu.java trunk/shell/src/test/org/jnode/test/shell/Cassowary.java Added Paths: ----------- trunk/core/src/emu/org/jnode/emu/plugin/model/DummyConfigurationElement.java trunk/core/src/emu/org/jnode/emu/plugin/model/DummyExtension.java trunk/core/src/emu/org/jnode/emu/plugin/model/DummyExtensionPoint.java Removed Paths: ------------- trunk/distr/src/emu/org/jnode/emu/DummyExtensionPoint.java trunk/shell/src/test/org/jnode/test/shell/DummyExtensionPoint.java Added: trunk/core/src/emu/org/jnode/emu/plugin/model/DummyConfigurationElement.java =================================================================== --- trunk/core/src/emu/org/jnode/emu/plugin/model/DummyConfigurationElement.java (rev 0) +++ trunk/core/src/emu/org/jnode/emu/plugin/model/DummyConfigurationElement.java 2008-11-29 08:31:48 UTC (rev 4754) @@ -0,0 +1,71 @@ +/* + * $Id: CommandInfo.java 4193 2008-06-04 14:39:34Z crawley $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.emu.plugin.model; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.jnode.plugin.ConfigurationElement; +import org.jnode.plugin.PluginDescriptor; + +/** + * Dummy configuration element for configuring plugins outside of the normal JNode framework. + * Most methods have dummy implementations. If you come across a use-case that requires + * a non-dummy implementation, please implement the method in this class rather than + * subclassing. + * + * @author cr...@jn... + */ +public class DummyConfigurationElement implements ConfigurationElement { + + private Map<String, String> map = new HashMap<String, String>(); + + @Override + public Set<String> attributeNames() { + return map.keySet(); + } + + @Override + public String getAttribute(String name) { + return map.get(name); + } + + @Override + public PluginDescriptor getDeclaringPluginDescriptor() { + return null; + } + + @Override + public ConfigurationElement[] getElements() { + return null; + } + + @Override + public String getName() { + return null; + } + + public void addAttribute(String name, String value) { + map.put(name, value); + } + +} Added: trunk/core/src/emu/org/jnode/emu/plugin/model/DummyExtension.java =================================================================== --- trunk/core/src/emu/org/jnode/emu/plugin/model/DummyExtension.java (rev 0) +++ trunk/core/src/emu/org/jnode/emu/plugin/model/DummyExtension.java 2008-11-29 08:31:48 UTC (rev 4754) @@ -0,0 +1,83 @@ +/* + * $Id: CommandInfo.java 4193 2008-06-04 14:39:34Z crawley $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.emu.plugin.model; + +import java.util.ArrayList; +import java.util.List; + +import org.jnode.plugin.ConfigurationElement; +import org.jnode.plugin.Extension; +import org.jnode.plugin.PluginDescriptor; + + +/** + * Dummy plugin extension for configuring plugins outside of the normal JNode framework. + * Most methods have dummy implementations. If you come across a use-case that requires + * a non-dummy implementation, please implement the method in this class rather than + * subclassing. + * + * @author cr...@jn... + */ +public class DummyExtension implements Extension { + + private List<ConfigurationElement> elements; + + @Override + public ConfigurationElement[] getConfigurationElements() { + if (elements != null) { + return elements.toArray(new ConfigurationElement[elements.size()]); + } + return new ConfigurationElement[0]; + } + + public void addElement(ConfigurationElement element) { + if (elements == null) { + elements = new ArrayList<ConfigurationElement>(1); + } + elements.add(element); + } + + @Override + public PluginDescriptor getDeclaringPluginDescriptor() { + return null; + } + + @Override + public String getExtensionPointPluginId() { + return null; + } + + @Override + public String getExtensionPointUniqueIdentifier() { + return null; + } + + @Override + public String getSimpleIdentifier() { + return null; + } + + @Override + public String getUniqueIdentifier() { + return null; + } + +} Added: trunk/core/src/emu/org/jnode/emu/plugin/model/DummyExtensionPoint.java =================================================================== --- trunk/core/src/emu/org/jnode/emu/plugin/model/DummyExtensionPoint.java (rev 0) +++ trunk/core/src/emu/org/jnode/emu/plugin/model/DummyExtensionPoint.java 2008-11-29 08:31:48 UTC (rev 4754) @@ -0,0 +1,95 @@ +/* + * $Id: CommandInfo.java 4193 2008-06-04 14:39:34Z crawley $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.jnode.emu.plugin.model; + +import java.util.ArrayList; +import java.util.List; + +import org.jnode.plugin.Extension; +import org.jnode.plugin.ExtensionPoint; +import org.jnode.plugin.ExtensionPointListener; +import org.jnode.plugin.PluginDescriptor; + +/** + * Dummy plugin extension point for configuring plugins outside of the normal JNode framework. + * Most methods have dummy implementations. If you come across a use-case that requires + * a non-dummy implementation, please implement the method in this class rather than + * subclassing. + * + * @author Levente S\u00e1ntha + * @author cr...@jn... + */ +public class DummyExtensionPoint implements ExtensionPoint { + + private final String id; + private final String uid; + private final String name; + private List<Extension> extensions; + + public DummyExtensionPoint() { + this("A", "aaa", "B"); + } + + public DummyExtensionPoint(String id, String uid, String name) { + this.id = id; + this.uid = uid; + this.name = name; + } + + public String getSimpleIdentifier() { + return id; + } + + public String getUniqueIdentifier() { + return uid; + } + + public String getName() { + return name; + } + + public Extension[] getExtensions() { + if (extensions != null) { + return extensions.toArray(new Extension[extensions.size()]); + } + return new Extension[0]; + } + + public void addExtension(Extension extension) { + if (extensions == null) { + extensions = new ArrayList<Extension>(1); + } + extensions.add(extension); + } + + public void addListener(ExtensionPointListener listener) { + } + + public void addPriorityListener(ExtensionPointListener listener) { + } + + public void removeListener(ExtensionPointListener listener) { + } + + public PluginDescriptor getDeclaringPluginDescriptor() { + return null; + } +} Modified: trunk/core/src/emu/org/jnode/emu/plugin/model/DummyPluginDescriptor.java =================================================================== --- trunk/core/src/emu/org/jnode/emu/plugin/model/DummyPluginDescriptor.java 2008-11-29 01:01:48 UTC (rev 4753) +++ trunk/core/src/emu/org/jnode/emu/plugin/model/DummyPluginDescriptor.java 2008-11-29 08:31:48 UTC (rev 4754) @@ -1,5 +1,28 @@ +/* + * $Id: CommandInfo.java 4193 2008-06-04 14:39:34Z crawley $ + * + * JNode.org + * Copyright (C) 2003-2006 JNode.org + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; If not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ package org.jnode.emu.plugin.model; +import java.util.ArrayList; +import java.util.List; + import org.jnode.plugin.Extension; import org.jnode.plugin.ExtensionPoint; import org.jnode.plugin.Plugin; @@ -9,116 +32,121 @@ import org.jnode.plugin.PluginPrerequisite; import org.jnode.plugin.Runtime; +/** + * Dummy plugin descriptor for configuring plugins outside of the normal JNode framework. + * Most methods have dummy implementations. If you come across a use-case that requires + * a non-dummy implementation, please implement the method in this class rather than + * subclassing. + * + * @author scr...@jn... + */ public class DummyPluginDescriptor implements PluginDescriptor { private boolean systemPlugin; + private List<ExtensionPoint> extensionPoints = null; public DummyPluginDescriptor(boolean systemPlugin) { this.systemPlugin = systemPlugin; } public void addListener(PluginDescriptorListener listener) { - // TODO Auto-generated method stub - } public boolean depends(String id) { - // TODO Auto-generated method stub return false; } public String getCustomPluginClassName() { - // TODO Auto-generated method stub return null; } public ExtensionPoint getExtensionPoint(String extensionPointId) { - // TODO Auto-generated method stub + if (extensionPoints != null) { + for (ExtensionPoint ep : extensionPoints) { + if (ep.getSimpleIdentifier().equals(extensionPointId)) { + return ep; + } + } + } return null; } public ExtensionPoint[] getExtensionPoints() { - // TODO Auto-generated method stub - return null; + if (extensionPoints == null) { + return null; + } else { + return extensionPoints.toArray(new ExtensionPoint[extensionPoints.size()]); + } } + + public void addExtensionPoint(ExtensionPoint ep) { + if (extensionPoints == null) { + extensionPoints = new ArrayList<ExtensionPoint>(1); + } + extensionPoints.add(ep); + } public Extension[] getExtensions() { - // TODO Auto-generated method stub return null; } public String getId() { - // TODO Auto-generated method stub return null; } public String getLicenseName() { - // TODO Auto-generated method stub return null; } public String getLicenseUrl() { - // TODO Auto-generated method stub return null; } public String getName() { - // TODO Auto-generated method stub return null; } public Plugin getPlugin() throws PluginException { - // TODO Auto-generated method stub return null; } public ClassLoader getPluginClassLoader() { - // TODO Auto-generated method stub return null; } public PluginPrerequisite[] getPrerequisites() { - // TODO Auto-generated method stub return null; } public int getPriority() { - // TODO Auto-generated method stub return 0; } public String getProviderName() { - // TODO Auto-generated method stub return null; } public String getProviderUrl() { - // TODO Auto-generated method stub return null; } public Runtime getRuntime() { - // TODO Auto-generated method stub return null; } public String getVersion() { - // TODO Auto-generated method stub return null; } public boolean hasCustomPluginClass() { - // TODO Auto-generated method stub return false; } public boolean isAutoStart() { - // TODO Auto-generated method stub return false; } public boolean isFragment() { - // TODO Auto-generated method stub return false; } Deleted: trunk/distr/src/emu/org/jnode/emu/DummyExtensionPoint.java =================================================================== --- trunk/distr/src/emu/org/jnode/emu/DummyExtensionPoint.java 2008-11-29 01:01:48 UTC (rev 4753) +++ trunk/distr/src/emu/org/jnode/emu/DummyExtensionPoint.java 2008-11-29 08:31:48 UTC (rev 4754) @@ -1,43 +0,0 @@ -/* - * $Id$ - */ -package org.jnode.emu; - -import org.jnode.plugin.Extension; -import org.jnode.plugin.ExtensionPoint; -import org.jnode.plugin.ExtensionPointListener; -import org.jnode.plugin.PluginDescriptor; - -/** - * @author Levente S\u00e1ntha - */ -class DummyExtensionPoint implements ExtensionPoint { - public String getSimpleIdentifier() { - return "A"; - } - - public String getUniqueIdentifier() { - return "aaa"; - } - - public String getName() { - return "B"; - } - - public Extension[] getExtensions() { - return new Extension[0]; - } - - public void addListener(ExtensionPointListener listener) { - } - - public void addPriorityListener(ExtensionPointListener listener) { - } - - public void removeListener(ExtensionPointListener listener) { - } - - public PluginDescriptor getDeclaringPluginDescriptor() { - return null; - } -} Modified: trunk/distr/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/distr/src/emu/org/jnode/emu/Emu.java 2008-11-29 01:01:48 UTC (rev 4753) +++ trunk/distr/src/emu/org/jnode/emu/Emu.java 2008-11-29 08:31:48 UTC (rev 4754) @@ -28,6 +28,7 @@ import javax.naming.NamingException; import org.jnode.emu.naming.BasicNameSpace; +import org.jnode.emu.plugin.model.DummyExtensionPoint; import org.jnode.naming.InitialNaming; import org.jnode.nanoxml.XMLElement; import org.jnode.shell.ShellManager; Modified: trunk/gui/src/test/org/jnode/test/gui/Emu.java =================================================================== --- trunk/gui/src/test/org/jnode/test/gui/Emu.java 2008-11-29 01:01:48 UTC (rev 4753) +++ trunk/gui/src/test/org/jnode/test/gui/Emu.java 2008-11-29 08:31:48 UTC (rev 4754) @@ -13,6 +13,7 @@ import org.jnode.driver.DeviceToDriverMapper; import org.jnode.driver.DriverException; import org.jnode.emu.naming.BasicNameSpace; +import org.jnode.emu.plugin.model.DummyExtensionPoint; import org.jnode.naming.InitialNaming; import org.jnode.plugin.Extension; import org.jnode.plugin.ExtensionPoint; @@ -38,37 +39,6 @@ } } - private static class DummyExtensionPoint implements ExtensionPoint { - public String getSimpleIdentifier() { - return "A"; - } - - public String getUniqueIdentifier() { - return "aaa"; - } - - public String getName() { - return "B"; - } - - public Extension[] getExtensions() { - return new Extension[0]; - } - - public void addListener(ExtensionPointListener listener) { - } - - public void addPriorityListener(ExtensionPointListener listener) { - } - - public void removeListener(ExtensionPointListener listener) { - } - - public PluginDescriptor getDeclaringPluginDescriptor() { - return null; - } - } - public static class DeviceManager extends AbstractDeviceManager { public static final Logger log = Logger.getLogger(DeviceManager.class); Modified: trunk/shell/src/test/org/jnode/test/shell/Cassowary.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/Cassowary.java 2008-11-29 01:01:48 UTC (rev 4753) +++ trunk/shell/src/test/org/jnode/test/shell/Cassowary.java 2008-11-29 08:31:48 UTC (rev 4754) @@ -24,6 +24,7 @@ import org.apache.log4j.BasicConfigurator; import org.jnode.emu.naming.BasicNameSpace; +import org.jnode.emu.plugin.model.DummyExtensionPoint; import org.jnode.naming.InitialNaming; import org.jnode.shell.ShellManager; import org.jnode.shell.alias.AliasManager; Deleted: trunk/shell/src/test/org/jnode/test/shell/DummyExtensionPoint.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/DummyExtensionPoint.java 2008-11-29 01:01:48 UTC (rev 4753) +++ trunk/shell/src/test/org/jnode/test/shell/DummyExtensionPoint.java 2008-11-29 08:31:48 UTC (rev 4754) @@ -1,43 +0,0 @@ -/* - * $Id$ - */ -package org.jnode.test.shell; - -import org.jnode.plugin.Extension; -import org.jnode.plugin.ExtensionPoint; -import org.jnode.plugin.ExtensionPointListener; -import org.jnode.plugin.PluginDescriptor; - -/** - * @author Levente S\u00e1ntha - */ -class DummyExtensionPoint implements ExtensionPoint { - public String getSimpleIdentifier() { - return "A"; - } - - public String getUniqueIdentifier() { - return "aaa"; - } - - public String getName() { - return "B"; - } - - public Extension[] getExtensions() { - return new Extension[0]; - } - - public void addListener(ExtensionPointListener listener) { - } - - public void addPriorityListener(ExtensionPointListener listener) { - } - - public void removeListener(ExtensionPointListener listener) { - } - - public PluginDescriptor getDeclaringPluginDescriptor() { - return null; - } -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |