From: <cr...@us...> - 2008-11-26 13:40:33
|
Revision: 4748 http://jnode.svn.sourceforge.net/jnode/?rev=4748&view=rev Author: crawley Date: 2008-11-26 13:40:30 +0000 (Wed, 26 Nov 2008) Log Message: ----------- Moved BasicNameSpace to core and fixed it so that it can be used by all classic JVM apps/tests/emulators that need it. Created DummyPluginDescriptor in core for same. Tweaked Emu's jnode.interpreter/invoker/debug properties to get it working again. Modified Paths: -------------- trunk/core/src/core/org/jnode/naming/AbstractNameSpace.java trunk/distr/src/emu/org/jnode/emu/Emu.java trunk/distr/src/emu/org/jnode/emu/ShellEmu.java trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/DeviceUtils.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/core/org/jnode/naming/BasicNameSpace.java trunk/core/src/core/org/jnode/plugin/model/DummyPluginDescriptor.java Removed Paths: ------------- trunk/distr/src/test/org/jnode/apps/jpartition/utils/BasicNameSpace.java Modified: trunk/core/src/core/org/jnode/naming/AbstractNameSpace.java =================================================================== --- trunk/core/src/core/org/jnode/naming/AbstractNameSpace.java 2008-11-25 10:44:10 UTC (rev 4747) +++ trunk/core/src/core/org/jnode/naming/AbstractNameSpace.java 2008-11-26 13:40:30 UTC (rev 4748) @@ -61,7 +61,6 @@ l.serviceBound(lookup(name)); } catch (NameNotFoundException e) { // no service bound for that name => ignore - Unsafe.debugStackTrace(e); } } Added: trunk/core/src/core/org/jnode/naming/BasicNameSpace.java =================================================================== --- trunk/core/src/core/org/jnode/naming/BasicNameSpace.java (rev 0) +++ trunk/core/src/core/org/jnode/naming/BasicNameSpace.java 2008-11-26 13:40:30 UTC (rev 4748) @@ -0,0 +1,72 @@ +/* + * $Id: Label.java 4159 2008-05-30 16:15:41Z lsantha $ + * + * 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.naming; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import javax.naming.NameAlreadyBoundException; +import javax.naming.NameNotFoundException; +import javax.naming.NamingException; + +/** + * This implementation of NameSpace does not make use of Class.getVmClass() and + * therefore can be used in JNode applications / test cases / frameworks designed + * to run on a classic Java VM. + * + * @author cr...@jn... + */ +public final class BasicNameSpace extends AbstractNameSpace { + protected final Map<Class<?>, Object> namespace = new HashMap<Class<?>, Object>(); + + public <T> void bind(Class<T> name, T service) + throws NamingException, NameAlreadyBoundException { + if (name == null) { + throw new IllegalArgumentException("name == null"); + } + synchronized (namespace) { + if (namespace.containsKey(name)) { + throw new NameAlreadyBoundException(name.getName()); + } + namespace.put(name, service); + } + } + + @SuppressWarnings("unchecked") + public <T> T lookup(Class<T> name) throws NameNotFoundException { + synchronized (namespace) { + T res = (T) namespace.get(name); + if (res == null) { + throw new NameNotFoundException(name.getName()); + } + return res; + } + } + + public Set<Class<?>> nameSet() { + return namespace.keySet(); + } + + public void unbind(Class<?> name) { + namespace.remove(name); + } +} Added: trunk/core/src/core/org/jnode/plugin/model/DummyPluginDescriptor.java =================================================================== --- trunk/core/src/core/org/jnode/plugin/model/DummyPluginDescriptor.java (rev 0) +++ trunk/core/src/core/org/jnode/plugin/model/DummyPluginDescriptor.java 2008-11-26 13:40:30 UTC (rev 4748) @@ -0,0 +1,133 @@ +package org.jnode.plugin.model; + +import org.jnode.plugin.Extension; +import org.jnode.plugin.ExtensionPoint; +import org.jnode.plugin.Plugin; +import org.jnode.plugin.PluginDescriptor; +import org.jnode.plugin.PluginDescriptorListener; +import org.jnode.plugin.PluginException; +import org.jnode.plugin.PluginPrerequisite; +import org.jnode.plugin.Runtime; + +public class DummyPluginDescriptor implements PluginDescriptor { + + private boolean systemPlugin; + + 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 + return null; + } + + public ExtensionPoint[] getExtensionPoints() { + // TODO Auto-generated method stub + return null; + } + + 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; + } + + public boolean isSystemPlugin() { + return systemPlugin; + } + + public void removeListener(PluginDescriptorListener listener) { + // TODO Auto-generated method stub + + } +} Modified: trunk/distr/src/emu/org/jnode/emu/Emu.java =================================================================== --- trunk/distr/src/emu/org/jnode/emu/Emu.java 2008-11-25 10:44:10 UTC (rev 4747) +++ trunk/distr/src/emu/org/jnode/emu/Emu.java 2008-11-26 13:40:30 UTC (rev 4748) @@ -1,3 +1,23 @@ +/* + * $Id: NameSpace.java 4564 2008-09-18 22:01:10Z fduminy $ + * + * 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; import java.io.BufferedReader; @@ -13,6 +33,7 @@ import javax.naming.NamingException; import org.jnode.naming.AbstractNameSpace; +import org.jnode.naming.BasicNameSpace; import org.jnode.naming.InitialNaming; import org.jnode.nanoxml.XMLElement; import org.jnode.shell.ShellManager; @@ -29,6 +50,9 @@ import org.jnode.shell.syntax.XMLSyntaxSpecAdapter; /** + * This class is the core of a light-weight JNode emulator that allows (some) JNode + * applications to be run using a classic JVM in the context of a JNode development sandbox. + * * @author Levente S\u00e1ntha * @author Stephen Crawley */ @@ -57,29 +81,8 @@ root = new File("").getAbsoluteFile(); System.err.println("Assuming that the JNode root is '" + root + "'"); } - InitialNaming.setNameSpace(new AbstractNameSpace() { - private Map<Class<?>, Object> space = new HashMap<Class<?>, Object>(); + InitialNaming.setNameSpace(new BasicNameSpace()); - public <T> void bind(Class<T> name, T service) throws NamingException, NameAlreadyBoundException { - if (space.get(name) != null) throw new NameAlreadyBoundException(); - space.put(name, service); - } - - public void unbind(Class<?> name) { - space.remove(name); - } - - public <T> T lookup(Class<T> name) throws NameNotFoundException { - T obj = (T) space.get(name); - if (obj == null) throw new NameNotFoundException(name.getName()); - return obj; - } - - public Set<Class<?>> nameSet() { - return space.keySet(); - } - }); - try { InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE); AliasManager aliasMgr = @@ -89,7 +92,9 @@ for (String pluginName : PLUGIN_NAMES) { configurePluginCommands(root, pluginName, aliasMgr, syntaxMgr); } - System.setProperty("jnode.invoker", "default"); + System.setProperty("jnode.invoker", "thread"); + System.setProperty("jnode.interpreter", "redirecting"); + System.setProperty("jnode.debug", "true"); InitialNaming.bind(AliasManager.NAME, aliasMgr); InitialNaming.bind(ShellManager.NAME, new DefaultShellManager()); InitialNaming.bind(SyntaxManager.NAME, syntaxMgr); Modified: trunk/distr/src/emu/org/jnode/emu/ShellEmu.java =================================================================== --- trunk/distr/src/emu/org/jnode/emu/ShellEmu.java 2008-11-25 10:44:10 UTC (rev 4747) +++ trunk/distr/src/emu/org/jnode/emu/ShellEmu.java 2008-11-26 13:40:30 UTC (rev 4748) @@ -4,6 +4,7 @@ import org.jnode.driver.console.ConsoleManager; import org.jnode.driver.console.swing.SwingTextScreenConsoleManager; +import org.jnode.driver.console.textscreen.TextScreenConsoleManager; import org.jnode.shell.CommandShell; /** @@ -17,7 +18,7 @@ return; } initEnv(argv.length > 0 ? new File(argv[0]) : null); - SwingTextScreenConsoleManager cm = new SwingTextScreenConsoleManager(); + TextScreenConsoleManager cm = new SwingTextScreenConsoleManager(); new Thread(new CommandShell(cm.createConsole( "Console 1", (ConsoleManager.CreateOptions.TEXT | Deleted: trunk/distr/src/test/org/jnode/apps/jpartition/utils/BasicNameSpace.java =================================================================== --- trunk/distr/src/test/org/jnode/apps/jpartition/utils/BasicNameSpace.java 2008-11-25 10:44:10 UTC (rev 4747) +++ trunk/distr/src/test/org/jnode/apps/jpartition/utils/BasicNameSpace.java 2008-11-26 13:40:30 UTC (rev 4748) @@ -1,36 +0,0 @@ -/** - * - */ -package org.jnode.apps.jpartition.utils; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.naming.NameAlreadyBoundException; -import javax.naming.NameNotFoundException; -import javax.naming.NamingException; - -import org.jnode.naming.AbstractNameSpace; - -public final class BasicNameSpace extends AbstractNameSpace { - protected final Map<Class<?>, Object> namespace = new HashMap<Class<?>, Object>(); - - public <T> void bind(Class<T> name, T service) - throws NamingException, NameAlreadyBoundException { - namespace.put(name, service); - } - - @SuppressWarnings("unchecked") - public <T> T lookup(Class<T> name) throws NameNotFoundException { - return (T) namespace.get(name); - } - - public Set<Class<?>> nameSet() { - return namespace.keySet(); - } - - public void unbind(Class<?> name) { - namespace.remove(name); - } -} Modified: trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/DeviceUtils.java =================================================================== --- trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/DeviceUtils.java 2008-11-25 10:44:10 UTC (rev 4747) +++ trunk/distr/src/test/org/jnode/apps/jpartition/utils/device/DeviceUtils.java 2008-11-26 13:40:30 UTC (rev 4748) @@ -9,7 +9,6 @@ import org.apache.log4j.Logger; import org.jnode.apps.jpartition.ErrorReporter; import org.jnode.apps.jpartition.swingview.FileDeviceView; -import org.jnode.apps.jpartition.utils.BasicNameSpace; import org.jnode.apps.vmware.disk.VMWareDisk; import org.jnode.apps.vmware.disk.tools.DiskFactory; import org.jnode.driver.Device; @@ -20,6 +19,7 @@ import org.jnode.driver.bus.ide.IDEDevice; import org.jnode.fs.service.FileSystemService; import org.jnode.fs.service.def.FileSystemPlugin; +import org.jnode.naming.BasicNameSpace; import org.jnode.naming.InitialNaming; import org.jnode.naming.NameSpace; import org.jnode.plugin.Extension; @@ -30,6 +30,7 @@ import org.jnode.plugin.PluginException; import org.jnode.plugin.PluginPrerequisite; import org.jnode.plugin.Runtime; +import org.jnode.plugin.model.DummyPluginDescriptor; import org.jnode.test.fs.driver.stubs.StubDeviceManager; import org.jnode.util.OsUtils; @@ -49,124 +50,7 @@ InitialNaming.bind(DeviceManager.NAME, StubDeviceManager.INSTANCE); - PluginDescriptor desc = new PluginDescriptor() { - - 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 - return null; - } - - public ExtensionPoint[] getExtensionPoints() { - // TODO Auto-generated method stub - return null; - } - - 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; - } - - public boolean isSystemPlugin() { - // TODO Auto-generated method stub - return true; - } - - public void removeListener(PluginDescriptorListener listener) { - // TODO Auto-generated method stub - - } - - }; + PluginDescriptor desc = new DummyPluginDescriptor(true); FileSystemService fss = new FileSystemPlugin(desc); namespace.bind(FileSystemService.class, fss); } catch (NameAlreadyBoundException e) { Modified: trunk/gui/src/test/org/jnode/test/gui/Emu.java =================================================================== --- trunk/gui/src/test/org/jnode/test/gui/Emu.java 2008-11-25 10:44:10 UTC (rev 4747) +++ trunk/gui/src/test/org/jnode/test/gui/Emu.java 2008-11-26 13:40:30 UTC (rev 4748) @@ -18,6 +18,7 @@ import org.jnode.driver.DeviceToDriverMapper; import org.jnode.driver.DriverException; import org.jnode.naming.AbstractNameSpace; +import org.jnode.naming.BasicNameSpace; import org.jnode.naming.InitialNaming; import org.jnode.plugin.Extension; import org.jnode.plugin.ExtensionPoint; @@ -34,28 +35,7 @@ public class Emu { protected static void initEnv() throws NamingException { if (true) { - InitialNaming.setNameSpace(new AbstractNameSpace() { - private Map<Class<?>, Object> space = new HashMap<Class<?>, Object>(); - - public <T> void bind(Class<T> name, T service) throws NamingException, NameAlreadyBoundException { - if (space.get(name) != null) throw new NameAlreadyBoundException(); - space.put(name, service); - } - - public void unbind(Class<?> name) { - space.remove(name); - } - - public <T> T lookup(Class<T> name) throws NameNotFoundException { - T obj = (T) space.get(name); - if (obj == null) throw new NameNotFoundException(name.getName()); - return obj; - } - - public Set<Class<?>> nameSet() { - return space.keySet(); - } - }); + InitialNaming.setNameSpace(new BasicNameSpace()); InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE); final AliasManager aliasMgr = new DefaultAliasManager(new DummyExtensionPoint()); final ShellManager shellMgr = new DefaultShellManager(); Modified: trunk/shell/src/test/org/jnode/test/shell/Cassowary.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/Cassowary.java 2008-11-25 10:44:10 UTC (rev 4747) +++ trunk/shell/src/test/org/jnode/test/shell/Cassowary.java 2008-11-26 13:40:30 UTC (rev 4748) @@ -30,6 +30,7 @@ import org.apache.log4j.BasicConfigurator; import org.jnode.naming.AbstractNameSpace; +import org.jnode.naming.BasicNameSpace; import org.jnode.naming.InitialNaming; import org.jnode.shell.ShellManager; import org.jnode.shell.alias.AliasManager; @@ -51,33 +52,7 @@ if (initialized) { return; } - InitialNaming.setNameSpace(new AbstractNameSpace() { - private Map<Class<?>, Object> space = new HashMap<Class<?>, Object>(); - - public <T> void bind(Class<T> name, T service) - throws NamingException, NameAlreadyBoundException { - if (space.get(name) != null) { - throw new NameAlreadyBoundException(); - } - space.put(name, service); - } - - public void unbind(Class<?> name) { - space.remove(name); - } - - public <T> T lookup(Class<T> name) throws NameNotFoundException { - T obj = (T) space.get(name); - if (obj == null) { - throw new NameNotFoundException(name.getName()); - } - return obj; - } - - public Set<Class<?>> nameSet() { - return space.keySet(); - } - }); + InitialNaming.setNameSpace(new BasicNameSpace()); InitialNaming.bind(DeviceManager.NAME, DeviceManager.INSTANCE); AliasManager alias_mgr = new DefaultAliasManager(new DummyExtensionPoint()).createAliasManager(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |