Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 16 | package org.onlab.onos.foo; |
| 17 | |
| 18 | import static org.onlab.onos.foo.SimpleNettyServer.startStandalone; |
| 19 | |
| 20 | import org.apache.karaf.shell.commands.Argument; |
| 21 | import org.apache.karaf.shell.commands.Command; |
| 22 | import org.onlab.onos.cli.AbstractShellCommand; |
| 23 | |
| 24 | /** |
| 25 | * Starts the Simple Netty server. |
| 26 | */ |
pankaj | ea0acef | 2014-10-07 15:01:47 -0700 | [diff] [blame] | 27 | @Command(scope = "onos", name = "simple-netty-server", |
pankaj | 5364ca9 | 2014-10-09 14:11:58 -0700 | [diff] [blame] | 28 | description = "Starts simple Netty server") |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 29 | public class SimpleNettyServerCommand extends AbstractShellCommand { |
| 30 | |
pankaj | ea0acef | 2014-10-07 15:01:47 -0700 | [diff] [blame] | 31 | //FIXME: Replace these with parameters for |
pankaj | 5364ca9 | 2014-10-09 14:11:58 -0700 | [diff] [blame] | 32 | @Argument(index = 0, name = "port", description = "listen port", |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 33 | required = false, multiValued = false) |
pankaj | 9d7e4be | 2014-10-09 14:10:03 -0700 | [diff] [blame] | 34 | String port = "8081"; |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 35 | |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 36 | @Override |
| 37 | protected void execute() { |
| 38 | try { |
pankaj | 9d7e4be | 2014-10-09 14:10:03 -0700 | [diff] [blame] | 39 | startStandalone(new String[]{port}); |
pankaj | f49b45e | 2014-10-07 14:24:22 -0700 | [diff] [blame] | 40 | } catch (Exception e) { |
| 41 | error("Unable to start server %s", e); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | } |