OSGIプログラムを作成するためにbndtoolsを使用しようとしています。ここに私の前のコードがあり、それはfelixコンソールでうまくいくかもしれません。OSGIでJavaプロパティファイルを使用する方法宣言的サービスAnnotations
package com.buaa.ate.service.data.command;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.apache.felix.service.command.CommandProcessor;
import com.buaa.ate.service.api.data.Publisher;
@Component(
service=PublishCommand.class,
property={
CommandProcessor.COMMAND_SCOPE + ":String=example",
CommandProcessor.COMMAND_FUNCTION + ":String=publish",
}
)
public class PublishCommand {
private Publisher publishSvc;
@Reference
public void setPublisher(Publisher publishSvc) {
this.publishSvc = publishSvc;
}
public void publish(String content) {
publishSvc.start();
long result = publishSvc.publish(content);
System.out.println(result);
publishSvc.stop();
}
}
は今、私はこのような注釈変更したい:
package com.buaa.ate.service.data.command;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.apache.felix.service.command.CommandProcessor;
import com.buaa.ate.service.api.data.Publisher;
@Component(
service=PublishCommand.class,
properties="com/buaa/ate/service/data/command/config.properties"
)
public class PublishCommand {
private Publisher publishSvc;
@Reference
public void setPublisher(Publisher publishSvc) {
this.publishSvc = publishSvc;
}
public void publish(String content) {
publishSvc.start();
long result = publishSvc.publish(content);
System.out.println(result);
publishSvc.stop();
}
}
をそして、これは私のプロパティファイルです:
osgi.command.scope\:String:example
osgi.command.function\:String:publish
それは、このようなコンテンツですプログラムを実行するときに、 '何かを公開する'というコマンドを入力し、問題が発生します。
'gogo: CommandNotFoundException: Command not found: publish'
問題を解決するにはどうすればよいですか。