import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener;
+import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.*;
public class SchemaServiceImpl implements //
+ SchemaContextProvider, //
SchemaService, //
ServiceTrackerCustomizer<SchemaServiceListener, SchemaServiceListener>, //
AutoCloseable {
listenerTracker.open();
}
+
+ @Override
+ public SchemaContext getSchemaContext() {
+ return getGlobalContext();
+ }
+
public SchemaContext getGlobalContext() {
return getSchemaContextSnapshot();
}
private synchronized boolean tryToUpdateState(Collection<URL> changedURLs, Multimap<Bundle, URL> proposedNewState,
boolean adding) {
- Preconditions.checkArgument(changedURLs.size() > 0, "No change can occur when no URLs are changed");
+ Preconditions.checkArgument(!changedURLs.isEmpty(), "No change can occur when no URLs are changed");
try {
// consistent state
} catch (Exception e) {
// inconsistent state
logger.debug(
- "SchemaService is falling back on last consistent state containing {}, inconsistent yang files {}, reason {}",
- consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, e.toString());
+ "SchemaService is falling back on last consistent state containing {}, inconsistent yang files {}",
+ consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, e);
return false;
}
}
// system bundle might have config-api on classpath &&
// config-api contains yang files =>
// system bundle might contain yang files from that bundle
- if (bundle.getBundleId() == 0)
+ if (bundle.getBundleId() == 0) {
return bundle;
+ }
Enumeration<URL> enumeration = bundle.findEntries("META-INF/yang", "*.yang", false);
if (enumeration != null && enumeration.hasMoreElements()) {