if (name == null) {
// let's get a name if possible, that will only work with Spring OSGi services
// we may need to find a better way to get a potential name.
name = (String) reference.getProperty("org.springframework.osgi.bean.name");
}
habitat.addIndex(new ExistingSingletonInhabitant(object), contractName, name);
if (logger.isLoggable(Level.FINE)) {
String objectDetails = object.getClass().getName()+"@"+
Integer.toHexString(
System.identityHashCode(object));
logger.logp(Level.FINE, "HK2Main$HK2ServiceTrackerCustomizer",
"addingService", "registering service = {0}, contract = {1}, name = {2}", new Object[]{
objectDetails, contractName, name});
}
}
} else {
// this service does not implement a specific contract, let's register it by its type.
habitat.add(new ExistingSingletonInhabitant(object));
if (logger.isLoggable(Level.FINE)) {
String objectDetails = object.getClass().getName()+"@"+
Integer.toHexString(System.identityHashCode(object));
logger.logp(Level.FINE, "HK2Main$HK2ServiceTrackerCustomizer",
"addingService", "registering service = {0}", objectDetails);