centralize the bundle identifier construction

The ready marker logic is created to hide the real usage. The ready
marker uses an "identifier" that is not specific or limited to bundles.

Currently the bundle symbolic name is used as bundle identifier.
That "convention" needs to be known at several different places.

There should be one method that created an identifier for a bundle and
"no one" needs to care about the implementation details.

Another point is that the bundle symbolic name that has been used is
optional. It may be null e.g. for bundles that has been installed by the
synthetic bundle installer mechanism etc.

The runtime assigns a bundle ID to an installed bundle that remains the
same for the bundle (see JavaDoc). The bundle ID is present all the
time.

The implementation of the "get identifier for bundle" has been choosen
to use the BSN -- if available -- (as before) but fallback to a custom
one using also the bundle ID (to be unique).
So we can provide always a non null identifier for a bundle.
It should be easily to change the identifier creation now if there is
every any need for.

Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
This commit is contained in:
Markus Rathgeb
2019-02-06 15:56:00 +01:00
parent 92b71f1712
commit fd95b86b36
5 changed files with 103 additions and 57 deletions
@@ -51,6 +51,7 @@ import org.eclipse.smarthome.core.library.items.StringItem;
import org.eclipse.smarthome.core.library.types.OnOffType;
import org.eclipse.smarthome.core.library.types.StringType;
import org.eclipse.smarthome.core.service.ReadyMarker;
import org.eclipse.smarthome.core.service.ReadyMarkerUtils;
import org.eclipse.smarthome.core.service.ReadyService;
import org.eclipse.smarthome.core.thing.Bridge;
import org.eclipse.smarthome.core.thing.ChannelUID;
@@ -1523,10 +1524,10 @@ public class ThingManagerOSGiTest extends JavaOSGiTest {
registerService(thingHandlerFactory);
final ReadyMarker marker = new ReadyMarker(ThingManagerImpl.XML_THING_TYPE,
ReadyMarkerUtils.getIdentifier(FrameworkUtil.getBundle(this.getClass())));
waitForAssert(() -> {
// wait for the XML processing to be finished, then remove the ready marker again
ReadyMarker marker = new ReadyMarker(ThingManagerImpl.XML_THING_TYPE,
FrameworkUtil.getBundle(this.getClass()).getSymbolicName());
assertThat(readyService.isReady(marker), is(true));
readyService.unmarkReady(marker);
});
@@ -1542,8 +1543,7 @@ public class ThingManagerOSGiTest extends JavaOSGiTest {
verify(thingHandler, never()).initialize();
assertThat(thing.getStatusInfo(), is(uninitializedNone));
readyService.markReady(new ReadyMarker(ThingManagerImpl.XML_THING_TYPE,
FrameworkUtil.getBundle(this.getClass()).getSymbolicName()));
readyService.markReady(marker);
// ThingHandler.initialize() called, thing status is INITIALIZING.NONE
ThingStatusInfo initializingNone = ThingStatusInfoBuilder