|
From: <cr...@us...> - 2008-06-10 11:45:48
|
Revision: 4230
http://jnode.svn.sourceforge.net/jnode/?rev=4230&view=rev
Author: crawley
Date: 2008-06-10 04:45:45 -0700 (Tue, 10 Jun 2008)
Log Message:
-----------
Converted CreateJIFSCommand
Modified Paths:
--------------
trunk/fs/descriptors/org.jnode.fs.jifs.command.xml
trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java
Modified: trunk/fs/descriptors/org.jnode.fs.jifs.command.xml
===================================================================
--- trunk/fs/descriptors/org.jnode.fs.jifs.command.xml 2008-06-10 11:44:50 UTC (rev 4229)
+++ trunk/fs/descriptors/org.jnode.fs.jifs.command.xml 2008-06-10 11:45:45 UTC (rev 4230)
@@ -10,6 +10,7 @@
<requires>
<import plugin="org.jnode.fs.jifs"/>
<import plugin="org.jnode.shell"/>
+ <import plugin="org.jnode.shell.syntax"/>
</requires>
<runtime>
@@ -22,6 +23,12 @@
<alias name="jifs" class="org.jnode.fs.jifs.command.CreateJIFSCommand"/>
</extension>
+ <extension point="org.jnode.shell.syntaxes">
+ <syntax alias="jifs">
+ <argument argLabel="action" description="Manage the JIFS filesystem plugin"/>
+ </syntax>
+ </extension>
+
<extension point="org.jnode.security.permissions">
<permission class="org.jnode.security.JNodePermission" name="stopPlugin"/>
<permission class="org.jnode.security.JNodePermission" name="startPlugin"/>
Modified: trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java
===================================================================
--- trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java 2008-06-10 11:44:50 UTC (rev 4229)
+++ trunk/fs/src/fs/org/jnode/fs/jifs/command/CreateJIFSCommand.java 2008-06-10 11:45:45 UTC (rev 4230)
@@ -28,14 +28,12 @@
import org.jnode.naming.InitialNaming;
import org.jnode.plugin.Plugin;
+import org.jnode.plugin.PluginException;
import org.jnode.plugin.PluginManager;
import org.jnode.shell.AbstractCommand;
import org.jnode.shell.CommandLine;
-import org.jnode.shell.help.Help;
-import org.jnode.shell.help.Parameter;
-import org.jnode.shell.help.ParsedArguments;
-import org.jnode.shell.help.Syntax;
-import org.jnode.shell.help.argument.OptionArgument;
+import org.jnode.shell.syntax.Argument;
+import org.jnode.shell.syntax.EnumArgument;
// TODO fix class name
// TODO this class is actually just PluginCommand specialized for JIFS ...
@@ -46,41 +44,44 @@
*/
public class CreateJIFSCommand extends AbstractCommand {
- static final OptionArgument ACTION =
- new OptionArgument("action", "Action to perform", new OptionArgument.Option[] {
- new OptionArgument.Option("start", "start the jifs"),
- new OptionArgument.Option("stop", "stop the jifs"),
- new OptionArgument.Option("restart", "restart the jifs")});
+ private static enum Action {
+ start, stop, restart;
+ }
- static final Parameter PARAM_ACTION = new Parameter(ACTION, Parameter.MANDATORY);
+ private static class ActionArgument extends EnumArgument<Action> {
+ public ActionArgument() {
+ super("action", Argument.MANDATORY, Action.class, "action to be performed");
+ }
- public static Help.Info HELP_INFO =
- new Help.Info("jifs", new Syntax[] {new Syntax("JIFS - Jnode Information FileSystem",
- new Parameter[] {PARAM_ACTION})});
+ @Override
+ protected String argumentKind() {
+ return "{start,stop,restart}";
+ }
+ }
+
+ private final ActionArgument ARG_ACTION = new ActionArgument();
+
+ public CreateJIFSCommand() {
+ super("Manage the JIFS filesystem plugin");
+ registerArguments(ARG_ACTION);
+ }
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
- throws Exception {
- ParsedArguments cmdLine = HELP_INFO.parse(commandLine);
- String Act = ACTION.getValue(cmdLine);
-
- try {
- final PluginManager mgr = InitialNaming.lookup(PluginManager.NAME);
- final Plugin p =
- mgr.getRegistry().getPluginDescriptor("org.jnode.fs.jifs.def").getPlugin();
- if (new String("start").equals(Act)) {
+ public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err)
+ throws NameNotFoundException, PluginException {
+ final PluginManager mgr = InitialNaming.lookup(PluginManager.NAME);
+ final Plugin p =
+ mgr.getRegistry().getPluginDescriptor("org.jnode.fs.jifs.def").getPlugin();
+ switch (ARG_ACTION.getValue()) {
+ case start:
p.start();
- }
- if (new String("stop").equals(Act)) {
+ break;
+ case stop:
p.stop();
- }
- if (new String("restart").equals(Act)) {
+ break;
+ case restart:
p.stop();
p.start();
- }
- } catch (NameNotFoundException N) {
- System.err.println(N);
+ break;
}
-
}
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|