Я пытаюсь использовать bndtools для создания моей OSGI-программы. Вот мой предыдущий код, и он может хорошо работать с консолью felix.Как использовать файл свойств java в OSGI Declarative Services Аннотации
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();
}
}
И это мои свойства файла: config.properties
Это содержание, как это:
osgi.command.scope\:String:example
osgi.command.function\:String:publish
Когда я запускаю программу, введите команду «публиковать что-то» и то возникает проблема:
'gogo: CommandNotFoundException: Command not found: publish'
Итак, что мне делать, чтобы исправить эту проблему?