|
From: <cr...@us...> - 2008-05-09 13:45:35
|
Revision: 4075
http://jnode.svn.sourceforge.net/jnode/?rev=4075&view=rev
Author: crawley
Date: 2008-05-09 06:45:11 -0700 (Fri, 09 May 2008)
Log Message:
-----------
Converted BootpCommand
Modified Paths:
--------------
trunk/net/descriptors/org.jnode.net.command.xml
trunk/net/src/net/org/jnode/net/command/BootpCommand.java
Modified: trunk/net/descriptors/org.jnode.net.command.xml
===================================================================
--- trunk/net/descriptors/org.jnode.net.command.xml 2008-05-09 13:14:24 UTC (rev 4074)
+++ trunk/net/descriptors/org.jnode.net.command.xml 2008-05-09 13:45:11 UTC (rev 4075)
@@ -44,6 +44,9 @@
<empty description="List the ARP cache"/>
<option argLabel="clear" shortName="c" longName="clear" description="Clear the ARP cache"/>
</syntax>
+ <syntax alias="bootp">
+ <argument argLabel="device" description="Configure a network interface using BOOTP"/>
+ </syntax>
</extension>
<extension point="org.jnode.security.permissions">
Modified: trunk/net/src/net/org/jnode/net/command/BootpCommand.java
===================================================================
--- trunk/net/src/net/org/jnode/net/command/BootpCommand.java 2008-05-09 13:14:24 UTC (rev 4074)
+++ trunk/net/src/net/org/jnode/net/command/BootpCommand.java 2008-05-09 13:45:11 UTC (rev 4075)
@@ -24,45 +24,42 @@
import java.io.InputStream;
import java.io.PrintStream;
+import javax.naming.NameNotFoundException;
+
import org.jnode.driver.Device;
import org.jnode.driver.net.NetDeviceAPI;
+import org.jnode.driver.net.NetworkException;
import org.jnode.naming.InitialNaming;
import org.jnode.net.ipv4.config.IPv4ConfigurationService;
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.argument.DeviceArgument;
+import org.jnode.shell.syntax.*;
/**
* @author epr
*/
public class BootpCommand extends AbstractCommand {
- static final DeviceArgument ARG_DEVICE = new DeviceArgument("device", "the device to boot from", NetDeviceAPI.class);
+ private final DeviceArgument ARG_DEVICE =
+ new DeviceArgument("device", Argument.MANDATORY,
+ "", NetDeviceAPI.class);
- public static Help.Info HELP_INFO = new Help.Info(
- "bootp",
- "Try to configure the given device using BOOTP",
- new Parameter[]{
- new Parameter(ARG_DEVICE, Parameter.MANDATORY)
- }
- );
+ public BootpCommand() {
+ super("Configure a network interface using BOOTP");
+ registerArguments(ARG_DEVICE);
+ }
- public static void main(String[] args)
- throws Exception {
+ public static void main(String[] args) throws Exception {
new BootpCommand().execute(args);
}
- public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws Exception {
- ParsedArguments cmdLine = HELP_INFO.parse(commandLine);
-
- final Device dev = ARG_DEVICE.getDevice(cmdLine);
- System.out.println("Trying to configure " + dev.getId() + "...");
- final IPv4ConfigurationService cfg = (IPv4ConfigurationService)InitialNaming.lookup(IPv4ConfigurationService.NAME);
+ public void execute(CommandLine commandLine, InputStream in,
+ PrintStream out, PrintStream err) throws NameNotFoundException, NetworkException {
+ final Device dev = ARG_DEVICE.getValue();
+ out.println("Trying to configure " + dev.getId() + "...");
+ final IPv4ConfigurationService cfg =
+ (IPv4ConfigurationService) InitialNaming.lookup(IPv4ConfigurationService.NAME);
cfg.configureDeviceBootp(dev, true);
-
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|