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