-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added argument support and annotations
- Loading branch information
Showing
2 changed files
with
11 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
....osgi.greeter.cmd/src/main/scala/com/example/scala/osgi/greeter/impl/GreeterCommand.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,23 @@ | ||
package com.example.scala.osgi.greeter.impl | ||
|
||
import org.apache.felix.gogo.commands.Argument | ||
import org.apache.felix.gogo.commands.Command | ||
import org.apache.karaf.shell.console.OsgiCommandSupport | ||
import com.example.scala.osgi.greeter.Greeter | ||
|
||
@Command(scope = "greeter", name = "greet", description="Says hello") | ||
class GreeterCommand extends OsgiCommandSupport { | ||
var greeter: Greeter = null | ||
|
||
@Argument(index = 0, name = "name", description = "the name to greet", required = true, multiValued = false) | ||
var name: String = null | ||
|
||
override | ||
def doExecute(): Object = { | ||
greeter greet "Fred" | ||
greeter greet name | ||
} | ||
|
||
def setGreeter(g:Greeter) = { | ||
def setGreeter(g: Greeter) = { | ||
greeter = g | ||
} | ||
} |