【发布时间】:2012-03-06 16:59:45
【问题描述】:
我目前正在尝试使用 iPOJO 为 Felix 实现自定义 shell 命令。我的示例实现如下所示:
import java.io.PrintStream;
import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Provides;
import org.apache.felix.shell.Command;
@Component(immediate = true)
@Provides
public class SampleCommand implements Command {
@Override
public String getName() {
return "testcmd";
}
@Override
public String getUsage() {
return "testcmd";
}
@Override
public String getShortDescription() {
return "test command";
}
@Override
public void execute(String line, PrintStream out, PrintStream err) {
out.println("execute testcmd!");
}
}
当我在 Felix 上部署 Bundle 时,我的 SampleCommand 被实例化并且 getName() 被调用。但是当我尝试在 shell 上执行“testcmd”时,我得到:
gogo: CommandNotFoundException: Command not found: testcmd
我还有什么需要考虑的吗?
【问题讨论】:
标签: annotations osgi apache-felix