我正在尝试创建一个应用程序,女巫将通过所有总线宣布信号。您不需要连接到总线中的特定对象的想法。我看到接口可以是自省的,但是当我发现这个接口在总线上注册时会自动添加到总线对象中。所以问题是如何让信号在总线上可见。
界面:
@BusInterface(name = Door.DOOR_INTF_NAME, announced = "true")
public interface Door {
String DOOR_INTF_NAME = "com.example.Door";
String PERSON_PASSED_THROUGH = "PersonPassedThrough";
@BusSignal(name = PERSON_PASSED_THROUGH, sessionless = true)
void personPassedThrough(String person) throws BusException;
}
出版:
private void doRegisterBusObject(Object obj) {
LocatableBusObject object = (LocatableBusObject) obj;
String location = object.getBusObjectLocation();
if (!location.startsWith("/")) {
location = "/" + location;
}
// Register the object on the local bus
Status status = bus.registerBusObject(object, location);
if (Status.OK != status) {
return;
}
// Have About send a signal a new door is available.
aboutObj.announce(CONTACT_PORT, aboutData);
}
物体可见,但信号不可见。