.factorypath
maven-metadata-local.xml
.fbExcludeFilterFile
+META-INF
import javax.management.MBeanServer;
import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory;
import org.opendaylight.controller.config.util.ConfigRegistryJMXClient;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
LOG.debug("ConfigPersister starting");
this.context = context;
- ServiceTrackerCustomizer<SchemaContextProvider, YangStoreService> schemaServiceTrackerCustomizer = new ServiceTrackerCustomizer<SchemaContextProvider, YangStoreService>() {
+ final ServiceTrackerCustomizer<SchemaContextProvider, YangStoreService> schemaServiceTrackerCustomizer = new ServiceTrackerCustomizer<SchemaContextProvider, YangStoreService>() {
private final AtomicBoolean alreadyStarted = new AtomicBoolean(false);
@Override
- public YangStoreService addingService(ServiceReference<SchemaContextProvider> reference) {
+ public YangStoreService addingService(final ServiceReference<SchemaContextProvider> reference) {
LOG.debug("Got addingService(SchemaContextProvider) event");
- if(reference.getProperty(SchemaSourceProvider.class.getName()) == null &&
- reference.getProperty(BindingRuntimeContext.class.getName()) == null) {
+ if((reference.getProperty(SchemaSourceProvider.class.getName()) == null) &&
+ (reference.getProperty(BindingRuntimeContext.class.getName()) == null)) {
LOG.debug("SchemaContextProvider not from config-manager. Ignoring");
return null;
}
// Yang store service should not be registered multiple times
- if(!alreadyStarted.compareAndSet(false, true)) {
+ if(!this.alreadyStarted.compareAndSet(false, true)) {
LOG.warn("Starting yang store service multiple times. Received new service {}", reference);
throw new RuntimeException("Starting yang store service multiple times");
}
- SchemaContextProvider schemaContextProvider = reference.getBundle().getBundleContext().getService(reference);
+ final SchemaContextProvider schemaContextProvider = reference.getBundle().getBundleContext().getService(reference);
final Object sourceProvider = Preconditions.checkNotNull(
reference.getProperty(SchemaSourceProvider.class.getName()), "Source provider not found");
Preconditions.checkArgument(sourceProvider instanceof SchemaSourceProvider);
yangStoreService.refresh(runtimeContext);
}
- yangStoreServiceServiceRegistration = context.registerService(YangStoreService.class, yangStoreService,
+ YangStoreActivator.this.yangStoreServiceServiceRegistration = context.registerService(YangStoreService.class, yangStoreService,
new Hashtable<>());
- configRegistryLookup = new ConfigRegistryLookupThread(yangStoreService);
- configRegistryLookup.start();
+ YangStoreActivator.this.configRegistryLookup = new ConfigRegistryLookupThread(yangStoreService);
+ YangStoreActivator.this.configRegistryLookup.start();
return yangStoreService;
}
@Override
- public void modifiedService(ServiceReference<SchemaContextProvider> reference, YangStoreService service) {
+ public void modifiedService(final ServiceReference<SchemaContextProvider> reference, final YangStoreService service) {
if (service == null) {
return;
}
}
@Override
- public void removedService(ServiceReference<SchemaContextProvider> reference, YangStoreService service) {
+ public void removedService(final ServiceReference<SchemaContextProvider> reference, final YangStoreService service) {
if(service == null) {
return;
}
LOG.debug("Got removedService(SchemaContextProvider) event");
- alreadyStarted.set(false);
- configRegistryLookup.interrupt();
- yangStoreServiceServiceRegistration.unregister();
- yangStoreServiceServiceRegistration = null;
+ this.alreadyStarted.set(false);
+ YangStoreActivator.this.configRegistryLookup.interrupt();
+ YangStoreActivator.this.yangStoreServiceServiceRegistration.unregister();
+ YangStoreActivator.this.yangStoreServiceServiceRegistration = null;
}
};
- ServiceTracker<SchemaContextProvider, YangStoreService> schemaContextProviderServiceTracker =
+ final ServiceTracker<SchemaContextProvider, YangStoreService> schemaContextProviderServiceTracker =
new ServiceTracker<>(context, SchemaContextProvider.class, schemaServiceTrackerCustomizer);
schemaContextProviderServiceTracker.open();
}
@Override
- public void stop(BundleContext context) throws Exception {
- if(configRegistryLookup != null) {
- configRegistryLookup.interrupt();
+ public void stop(final BundleContext context) throws Exception {
+ if(this.configRegistryLookup != null) {
+ this.configRegistryLookup.interrupt();
}
- if(osgiRegistrayion != null) {
- osgiRegistrayion.unregister();
+ if(this.osgiRegistrayion != null) {
+ this.osgiRegistrayion.unregister();
}
- if (yangStoreServiceServiceRegistration != null) {
- yangStoreServiceServiceRegistration.unregister();
- yangStoreServiceServiceRegistration = null;
+ if (this.yangStoreServiceServiceRegistration != null) {
+ this.yangStoreServiceServiceRegistration.unregister();
+ this.yangStoreServiceServiceRegistration = null;
}
}
private final YangStoreService yangStoreService;
- private ConfigRegistryLookupThread(YangStoreService yangStoreService) {
+ private ConfigRegistryLookupThread(final YangStoreService yangStoreService) {
super("config-registry-lookup");
this.yangStoreService = yangStoreService;
}
while(true) {
try {
- configRegistryJMXClient = new ConfigRegistryJMXClient(configMBeanServer);
- configRegistryJMXClientNoNotifications = ConfigRegistryJMXClient.createWithoutNotifications(configMBeanServer);
+ configRegistryJMXClient = new ConfigRegistryJMXClient(YangStoreActivator.this.configMBeanServer);
+ configRegistryJMXClientNoNotifications = ConfigRegistryJMXClient.createWithoutNotifications(YangStoreActivator.this.configMBeanServer);
break;
- } catch (IllegalStateException e) {
+ } catch (final IllegalStateException e) {
++i;
if (i > SILENT_ATTEMPTS) {
LOG.info("JMX client not created after {} attempts, still trying", i, e);
}
try {
Thread.sleep(ATTEMPT_TIMEOUT_MS);
- } catch (InterruptedException e1) {
+ } catch (final InterruptedException e1) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Interrupted while reattempting connection", e1);
}
}
final ConfigSubsystemFacadeFactory configSubsystemFacade =
- new ConfigSubsystemFacadeFactory(jmxClient, jmxClientNoNotifications, yangStoreService);
- osgiRegistrayion = context.registerService(ConfigSubsystemFacadeFactory.class, configSubsystemFacade,
+ new ConfigSubsystemFacadeFactory(jmxClient, jmxClientNoNotifications, this.yangStoreService);
+ YangStoreActivator.this.osgiRegistrayion = YangStoreActivator.this.context.registerService(ConfigSubsystemFacadeFactory.class, configSubsystemFacade,
new Hashtable<>());
}
}
import org.opendaylight.controller.config.util.capability.ModuleListener;
import org.opendaylight.controller.config.util.capability.YangModuleCapability;
import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
}
public YangStoreContext getCurrentSnapshot() {
- return snap;
+ return this.snap;
}
@Deprecated
YangStoreSnapshot snapshot;
do {
- snapshot = snap;
+ snapshot = this.snap;
ret = snapshot.getModuleMXBeanEntryMap();
- } while (!snapshot.equals(snap));
+ } while (!snapshot.equals(this.snap));
return ret;
}
YangStoreSnapshot snapshot;
do {
- snapshot = snap;
+ snapshot = this.snap;
ret = snapshot.getQNamesToIdentitiesToModuleMXBeanEntries();
- } while (!snapshot.equals(snap));
+ } while (!snapshot.equals(this.snap));
return ret;
}
@Override
public Set<Module> getModules() {
- return snap.getModules();
+ return this.snap.getModules();
}
@Override
public String getModuleSource(final ModuleIdentifier moduleIdentifier) {
- return snap.getModuleSource(moduleIdentifier);
+ return this.snap.getModuleSource(moduleIdentifier);
}
@Override
public EnumResolver getEnumResolver() {
- return snap.getEnumResolver();
+ return this.snap.getEnumResolver();
}
public void refresh(final BindingRuntimeContext runtimeContext) {
- final YangStoreSnapshot next = new YangStoreSnapshot(runtimeContext, sourceProvider);
- final YangStoreSnapshot previous = snap;
- snap = next;
- notificationExecutor.submit(new Runnable() {
+ final YangStoreSnapshot next = new YangStoreSnapshot(runtimeContext, this.sourceProvider);
+ final YangStoreSnapshot previous = this.snap;
+ this.snap = next;
+ this.notificationExecutor.submit(new Runnable() {
@Override
public void run() {
notifyListeners(previous, next);
}
public AutoCloseable registerModuleListener(final ModuleListener listener) {
- final YangStoreContext context = snap;
+ final YangStoreContext context = this.snap;
- synchronized (listeners) {
+ synchronized (this.listeners) {
if (context != null) {
listener.onCapabilitiesChanged(toCapabilities(context.getModules(), context), Collections.<Capability>emptySet());
}
return new AutoCloseable() {
@Override
public void close() {
- synchronized (listeners) {
- listeners.remove(listener);
+ synchronized (YangStoreService.this.listeners) {
+ YangStoreService.this.listeners.remove(listener);
}
}
};
final Set<Capability> addedCaps = toCapabilities(added, current);
final Set<Capability> removedCaps = toCapabilities(removed, current);
- synchronized (listeners) {
- for (final ModuleListener listener : listeners) {
+ synchronized (this.listeners) {
+ for (final ModuleListener listener : this.listeners) {
listener.onCapabilitiesChanged(addedCaps, removedCaps);
}
}
import org.opendaylight.controller.config.yangjmxgenerator.PackageTranslator;
import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
-import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
LOG.trace("Resolved modules:{}", schemaContext.getModules());
// JMX generator
- Map<String, String> namespaceToPackageMapping = Maps.newHashMap();
- PackageTranslator packageTranslator = new PackageTranslator(namespaceToPackageMapping);
- Map<QName, ServiceInterfaceEntry> qNamesToSIEs = new HashMap<>();
- Map<IdentitySchemaNode, ServiceInterfaceEntry> knownSEITracker = new HashMap<>();
+ final Map<String, String> namespaceToPackageMapping = Maps.newHashMap();
+ final PackageTranslator packageTranslator = new PackageTranslator(namespaceToPackageMapping);
+ final Map<QName, ServiceInterfaceEntry> qNamesToSIEs = new HashMap<>();
+ final Map<IdentitySchemaNode, ServiceInterfaceEntry> knownSEITracker = new HashMap<>();
// create SIE structure qNamesToSIEs
- for (Module module : schemaContext.getModules()) {
- String packageName = packageTranslator.getPackageName(module);
- Map<QName, ServiceInterfaceEntry> namesToSIEntries = ServiceInterfaceEntry
+ for (final Module module : schemaContext.getModules()) {
+ final String packageName = packageTranslator.getPackageName(module);
+ final Map<QName, ServiceInterfaceEntry> namesToSIEntries = ServiceInterfaceEntry
.create(module, packageName, knownSEITracker);
- for (Entry<QName, ServiceInterfaceEntry> sieEntry : namesToSIEntries.entrySet()) {
+ for (final Entry<QName, ServiceInterfaceEntry> sieEntry : namesToSIEntries.entrySet()) {
// merge value into qNamesToSIEs
if (qNamesToSIEs.containsKey(sieEntry.getKey()) == false) {
qNamesToSIEs.put(sieEntry.getKey(), sieEntry.getValue());
}
}
- Map<String, Map<String, ModuleMXBeanEntry>> moduleMXBeanEntryMap = Maps.newHashMap();
+ final Map<String, Map<String, ModuleMXBeanEntry>> moduleMXBeanEntryMap = Maps.newHashMap();
- Map<QName, Map<String /* identity local name */, ModuleMXBeanEntry>> qNamesToIdentitiesToModuleMXBeanEntries = new HashMap<>();
+ final Map<QName, Map<String /* identity local name */, ModuleMXBeanEntry>> qNamesToIdentitiesToModuleMXBeanEntries = new HashMap<>();
- for (Module module : schemaContext.getModules()) {
- String packageName = packageTranslator.getPackageName(module);
- TypeProviderWrapper typeProviderWrapper = new TypeProviderWrapper(
+ for (final Module module : schemaContext.getModules()) {
+ final String packageName = packageTranslator.getPackageName(module);
+ final TypeProviderWrapper typeProviderWrapper = new TypeProviderWrapper(
new TypeProviderImpl(schemaContext));
- QName qName = QName.create(module.getNamespace(), module.getRevision(), module.getName());
+ final QName qName = QName.create(module.getNamespace(), module.getRevision(), module.getName());
- Map<String /* MB identity local name */, ModuleMXBeanEntry> namesToMBEs =
+ final Map<String /* MB identity local name */, ModuleMXBeanEntry> namesToMBEs =
Collections.unmodifiableMap(ModuleMXBeanEntry.create(module, qNamesToSIEs, schemaContext,
typeProviderWrapper, packageName));
moduleMXBeanEntryMap.put(module.getNamespace().toString(), namesToMBEs);
}
private MXBeans getMXBeans() {
- MXBeans mxBean = ref.get();
+ MXBeans mxBean = this.ref.get();
if (mxBean == null) {
synchronized (this) {
- mxBean = ref.get();
+ mxBean = this.ref.get();
if (mxBean == null) {
- mxBean = new MXBeans(bindingContextProvider.getSchemaContext());
- ref = new SoftReference<>(mxBean);
+ mxBean = new MXBeans(this.bindingContextProvider.getSchemaContext());
+ this.ref = new SoftReference<>(mxBean);
}
}
}
@Override
public Set<Module> getModules() {
- final Set<Module> modules = Sets.newHashSet(bindingContextProvider.getSchemaContext().getModules());
- for (final Module module : bindingContextProvider.getSchemaContext().getModules()) {
+ final Set<Module> modules = Sets.newHashSet(this.bindingContextProvider.getSchemaContext().getModules());
+ for (final Module module : this.bindingContextProvider.getSchemaContext().getModules()) {
modules.addAll(module.getSubmodules());
}
return modules;
@Override
public String getModuleSource(final org.opendaylight.yangtools.yang.model.api.ModuleIdentifier moduleIdentifier) {
- final CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> source = sourceProvider.getSource(
+ final CheckedFuture<? extends YangTextSchemaSource, SchemaSourceException> source = this.sourceProvider.getSource(
SourceIdentifier.create(moduleIdentifier.getName(), Optional.fromNullable(
QName.formattedRevision(moduleIdentifier.getRevision()))));
}
final YangStoreSnapshot other = (YangStoreSnapshot) obj;
- return Objects.equals(bindingContextProvider, other.bindingContextProvider);
+ return Objects.equals(this.bindingContextProvider, other.bindingContextProvider);
}
@Override
public int hashCode() {
- return Objects.hashCode(bindingContextProvider);
+ return Objects.hashCode(this.bindingContextProvider);
}
@Override
public String fromYang(final String enumClass, final String enumYangValue) {
- Preconditions.checkState(bindingContextProvider != null, "Binding context provider was not set yet");
- final BiMap<String, String> enumMapping = bindingContextProvider.getEnumMapping(enumClass);
+ Preconditions.checkState(this.bindingContextProvider != null, "Binding context provider was not set yet");
+ final BiMap<String, String> enumMapping = this.bindingContextProvider.getEnumMapping(enumClass);
final String javaName = enumMapping.get(enumYangValue);
return Preconditions.checkNotNull(javaName, "Unable to resolve enum value %s for enum class %s with assumed enum mapping: %s", enumYangValue, enumClass, enumMapping);
}
@Override
public String toYang(final String enumClass, final String enumJavaValue) {
- Preconditions.checkState(bindingContextProvider != null, "Binding context provider was not set yet");
- final BiMap<String, String> enumMapping = bindingContextProvider.getEnumMapping(enumClass);
+ Preconditions.checkState(this.bindingContextProvider != null, "Binding context provider was not set yet");
+ final BiMap<String, String> enumMapping = this.bindingContextProvider.getEnumMapping(enumClass);
final String javaName = enumMapping.inverse().get(enumJavaValue);
return Preconditions.checkNotNull(javaName,
"Unable to map enum value %s for enum class %s with assumed enum mapping: %s", enumJavaValue, enumClass,
private final MBeanServer mBeanServer;
private Integer maxDependencyDepth;
- DependencyResolverImpl(ModuleIdentifier currentModule,
- TransactionStatus transactionStatus, ModulesHolder modulesHolder,
- ServiceReferenceReadableRegistry readableRegistry, BindingContextProvider bindingContextProvider,
- String transactionName, MBeanServer mBeanServer) {
+ DependencyResolverImpl(final ModuleIdentifier currentModule,
+ final TransactionStatus transactionStatus, final ModulesHolder modulesHolder,
+ final ServiceReferenceReadableRegistry readableRegistry, final BindingContextProvider bindingContextProvider,
+ final String transactionName, final MBeanServer mBeanServer) {
this.bindingContextProvider = bindingContextProvider;
this.name = currentModule;
this.transactionStatus = transactionStatus;
//TODO: check for cycles
@Override
public void validateDependency(
- Class<? extends AbstractServiceInterface> expectedServiceInterface,
- ObjectName dependentReadOnlyON, JmxAttribute jmxAttribute) {
+ final Class<? extends AbstractServiceInterface> expectedServiceInterface,
+ final ObjectName dependentReadOnlyON, final JmxAttribute jmxAttribute) {
- transactionStatus.checkNotCommitted();
+ this.transactionStatus.checkNotCommitted();
if (expectedServiceInterface == null) {
throw new NullPointerException(
"Parameter 'expectedServiceInterface' is null");
// check that objectName belongs to this transaction - this should be
// stripped
// in DynamicWritableWrapper
- boolean hasTransaction = ObjectNameUtil
+ final boolean hasTransaction = ObjectNameUtil
.getTransactionName(dependentReadOnlyON) != null;
JmxAttributeValidationException.checkCondition(
!hasTransaction,
), jmxAttribute
);
- ObjectName newDependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
+ final ObjectName newDependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
- ModuleIdentifier moduleIdentifier = ObjectNameUtil.fromON(newDependentReadOnlyON, ObjectNameUtil
+ final ModuleIdentifier moduleIdentifier = ObjectNameUtil.fromON(newDependentReadOnlyON, ObjectNameUtil
.TYPE_MODULE);
- ModuleFactory foundFactory = modulesHolder.findModuleFactory(moduleIdentifier, jmxAttribute);
+ final ModuleFactory foundFactory = this.modulesHolder.findModuleFactory(moduleIdentifier, jmxAttribute);
- boolean implementsSI = foundFactory
+ final boolean implementsSI = foundFactory
.isModuleImplementingServiceInterface(expectedServiceInterface);
if (!implementsSI) {
- String message = String.format(
+ final String message = String.format(
"Found module factory does not expose expected service interface. "
+ "Module name is %s : %s, expected service interface %s, dependent module ON %s , "
+ "attribute %s",
throw new JmxAttributeValidationException(message, jmxAttribute);
}
synchronized (this) {
- dependencies.add(moduleIdentifier);
+ this.dependencies.add(moduleIdentifier);
}
}
// translate from serviceref to module ON
- private ObjectName translateServiceRefIfPossible(ObjectName dependentReadOnlyON) {
+ private ObjectName translateServiceRefIfPossible(final ObjectName dependentReadOnlyON) {
ObjectName translatedDependentReadOnlyON = dependentReadOnlyON;
if (ObjectNameUtil.isServiceReference(translatedDependentReadOnlyON)) {
- String serviceQName = ObjectNameUtil.getServiceQName(translatedDependentReadOnlyON);
- String refName = ObjectNameUtil.getReferenceName(translatedDependentReadOnlyON);
+ final String serviceQName = ObjectNameUtil.getServiceQName(translatedDependentReadOnlyON);
+ final String refName = ObjectNameUtil.getReferenceName(translatedDependentReadOnlyON);
translatedDependentReadOnlyON = ObjectNameUtil.withoutTransactionName( // strip again of transaction name
- readableRegistry.lookupConfigBeanByServiceInterfaceName(serviceQName, refName));
+ this.readableRegistry.lookupConfigBeanByServiceInterfaceName(serviceQName, refName));
}
return translatedDependentReadOnlyON;
}
*/
//TODO: check for cycles
@Override
- public <T> T resolveInstance(Class<T> expectedType, ObjectName dependentReadOnlyON,
- JmxAttribute jmxAttribute) {
- Module module = resolveModuleInstance(dependentReadOnlyON, jmxAttribute);
+ public <T> T resolveInstance(final Class<T> expectedType, final ObjectName dependentReadOnlyON,
+ final JmxAttribute jmxAttribute) {
+ final Module module = resolveModuleInstance(dependentReadOnlyON, jmxAttribute);
synchronized (this) {
- dependencies.add(module.getIdentifier());
+ this.dependencies.add(module.getIdentifier());
}
- AutoCloseable instance = module.getInstance();
+ final AutoCloseable instance = module.getInstance();
if (instance == null) {
- String message = String.format(
+ final String message = String.format(
"Error while %s resolving instance %s. getInstance() returned null. "
- + "Expected type %s , attribute %s", name,
+ + "Expected type %s , attribute %s", this.name,
module.getIdentifier(), expectedType, jmxAttribute
);
throw new JmxAttributeValidationException(message, jmxAttribute);
}
try {
return expectedType.cast(instance);
- } catch (ClassCastException e) {
- String message = String.format(
+ } catch (final ClassCastException e) {
+ final String message = String.format(
"Instance cannot be cast to expected type. Instance class is %s , "
+ "expected type %s , attribute %s",
instance.getClass(), expectedType, jmxAttribute
}
}
- private Module resolveModuleInstance(ObjectName dependentReadOnlyON,
- JmxAttribute jmxAttribute) {
+ private Module resolveModuleInstance(final ObjectName dependentReadOnlyON,
+ final JmxAttribute jmxAttribute) {
Preconditions.checkArgument(dependentReadOnlyON != null ,"dependentReadOnlyON");
Preconditions.checkArgument(jmxAttribute != null, "jmxAttribute");
- ObjectName translatedDependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
- transactionStatus.checkCommitStarted();
- transactionStatus.checkNotCommitted();
+ final ObjectName translatedDependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
+ this.transactionStatus.checkCommitStarted();
+ this.transactionStatus.checkNotCommitted();
- ModuleIdentifier dependentModuleIdentifier = ObjectNameUtil.fromON(
+ final ModuleIdentifier dependentModuleIdentifier = ObjectNameUtil.fromON(
translatedDependentReadOnlyON, ObjectNameUtil.TYPE_MODULE);
- return Preconditions.checkNotNull(modulesHolder.findModule(dependentModuleIdentifier, jmxAttribute));
+ return Preconditions.checkNotNull(this.modulesHolder.findModule(dependentModuleIdentifier, jmxAttribute));
}
@Override
- public boolean canReuseDependency(ObjectName objectName, JmxAttribute jmxAttribute) {
+ public boolean canReuseDependency(final ObjectName objectName, final JmxAttribute jmxAttribute) {
Preconditions.checkNotNull(objectName);
Preconditions.checkNotNull(jmxAttribute);
- Module currentModule = resolveModuleInstance(objectName, jmxAttribute);
- ModuleIdentifier identifier = currentModule.getIdentifier();
- ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = modulesHolder.findModuleInternalTransactionalInfo(identifier);
+ final Module currentModule = resolveModuleInstance(objectName, jmxAttribute);
+ final ModuleIdentifier identifier = currentModule.getIdentifier();
+ final ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = this.modulesHolder.findModuleInternalTransactionalInfo(identifier);
if(moduleInternalTransactionalInfo.hasOldModule()) {
- Module oldModule = moduleInternalTransactionalInfo.getOldInternalInfo().getReadableModule().getModule();
+ final Module oldModule = moduleInternalTransactionalInfo.getOldInternalInfo().getReadableModule().getModule();
return currentModule.canReuse(oldModule);
}
return false;
}
@Override
- public <T extends BaseIdentity> Class<? extends T> resolveIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass) {
+ public <T extends BaseIdentity> Class<? extends T> resolveIdentity(final IdentityAttributeRef identityRef, final Class<T> expectedBaseClass) {
final QName qName = QName.create(identityRef.getqNameOfIdentity());
- Class<?> deserialized = bindingContextProvider.getBindingContext().getIdentityClass(qName);
+ final Class<?> deserialized = this.bindingContextProvider.getBindingContext().getIdentityClass(qName);
if (deserialized == null) {
throw new IllegalStateException("Unable to retrieve identity class for " + qName + ", null response from "
- + bindingContextProvider.getBindingContext());
+ + this.bindingContextProvider.getBindingContext());
}
if (expectedBaseClass.isAssignableFrom(deserialized)) {
return (Class<T>) deserialized;
}
@Override
- public <T extends BaseIdentity> void validateIdentity(IdentityAttributeRef identityRef, Class<T> expectedBaseClass, JmxAttribute jmxAttribute) {
+ public <T extends BaseIdentity> void validateIdentity(final IdentityAttributeRef identityRef, final Class<T> expectedBaseClass, final JmxAttribute jmxAttribute) {
try {
resolveIdentity(identityRef, expectedBaseClass);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw JmxAttributeValidationException.wrap(e, jmxAttribute);
}
}
@Override
- public int compareTo(DependencyResolverImpl o) {
- transactionStatus.checkCommitStarted();
+ public int compareTo(final DependencyResolverImpl o) {
+ this.transactionStatus.checkCommitStarted();
return Integer.compare(getMaxDependencyDepth(),
o.getMaxDependencyDepth());
}
int getMaxDependencyDepth() {
- if (maxDependencyDepth == null) {
+ if (this.maxDependencyDepth == null) {
throw new IllegalStateException("Dependency depth was not computed");
}
- return maxDependencyDepth;
+ return this.maxDependencyDepth;
}
- void countMaxDependencyDepth(DependencyResolverManager manager) {
+ void countMaxDependencyDepth(final DependencyResolverManager manager) {
// We can calculate the dependency after second phase commit was started
// Second phase commit starts after validation and validation adds the dependencies into the dependency resolver, which are necessary for the calculation
// FIXME generated code for abstract module declares validate method as non-final
// Overriding the validate would cause recreate every time instead of reuse + also possibly wrong close order if there is another module depending
- transactionStatus.checkCommitStarted();
- if (maxDependencyDepth == null) {
- maxDependencyDepth = getMaxDepth(this, manager,
+ this.transactionStatus.checkCommitStarted();
+ if (this.maxDependencyDepth == null) {
+ this.maxDependencyDepth = getMaxDepth(this, manager,
new LinkedHashSet<>());
}
}
- private static int getMaxDepth(DependencyResolverImpl impl,
- DependencyResolverManager manager,
- LinkedHashSet<ModuleIdentifier> chainForDetectingCycles) {
+ private static int getMaxDepth(final DependencyResolverImpl impl,
+ final DependencyResolverManager manager,
+ final LinkedHashSet<ModuleIdentifier> chainForDetectingCycles) {
int maxDepth = 0;
- LinkedHashSet<ModuleIdentifier> chainForDetectingCycles2 = new LinkedHashSet<>(
+ final LinkedHashSet<ModuleIdentifier> chainForDetectingCycles2 = new LinkedHashSet<>(
chainForDetectingCycles);
chainForDetectingCycles2.add(impl.getIdentifier());
- for (ModuleIdentifier dependencyName : impl.dependencies) {
- DependencyResolverImpl dependentDRI = manager
+ for (final ModuleIdentifier dependencyName : impl.dependencies) {
+ final DependencyResolverImpl dependentDRI = manager
.getOrCreate(dependencyName);
if (chainForDetectingCycles2.contains(dependencyName)) {
throw new IllegalStateException(String.format(
chainForDetectingCycles2);
dependentDRI.maxDependencyDepth = subDepth;
}
- if (subDepth + 1 > maxDepth) {
+ if ((subDepth + 1) > maxDepth) {
maxDepth = subDepth + 1;
}
}
@Override
public ModuleIdentifier getIdentifier() {
- return name;
+ return this.name;
}
@Override
- public Object getAttribute(ObjectName name, String attribute)
+ public Object getAttribute(final ObjectName name, final String attribute)
throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
ObjectName newName = translateServiceRefIfPossible(name);
// add transaction name
- newName = ObjectNameUtil.withTransactionName(newName, transactionName);
- return mBeanServer.getAttribute(newName, attribute);
+ newName = ObjectNameUtil.withTransactionName(newName, this.transactionName);
+ return this.mBeanServer.getAttribute(newName, attribute);
}
@Override
- public <T> T newMXBeanProxy(ObjectName name, Class<T> interfaceClass) {
+ public <T> T newMXBeanProxy(final ObjectName name, final Class<T> interfaceClass) {
ObjectName newName = translateServiceRefIfPossible(name);
// add transaction name
- newName = ObjectNameUtil.withTransactionName(newName, transactionName);
- return JMX.newMXBeanProxy(mBeanServer, newName, interfaceClass);
+ newName = ObjectNameUtil.withTransactionName(newName, this.transactionName);
+ return JMX.newMXBeanProxy(this.mBeanServer, newName, interfaceClass);
}
}
import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry;
import org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil;
import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
public void start(final BundleContext context) {
try {
// the inner strategy is backed by thread context cl?
- ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
+ final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
- BindingContextProvider bindingContextProvider = new BindingContextProvider();
+ final BindingContextProvider bindingContextProvider = new BindingContextProvider();
- RefreshingSCPModuleInfoRegistry moduleInfoRegistryWrapper = new RefreshingSCPModuleInfoRegistry(
+ final RefreshingSCPModuleInfoRegistry moduleInfoRegistryWrapper = new RefreshingSCPModuleInfoRegistry(
moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, bindingContextProvider, context);
- ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker(context, moduleInfoRegistryWrapper);
+ final ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker(context, moduleInfoRegistryWrapper);
// start config registry
- BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver(
+ final BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver(
context);
- configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, configMBeanServer,
+ this.configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, this.configMBeanServer,
bindingContextProvider);
// track bundles containing factories
- BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker(
- configRegistry);
- ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker(
+ final BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker(
+ this.configRegistry);
+ final ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker(
blankTransactionServiceTracker);
- boolean scanResolvedBundlesForModuleInfo = true;
+ final boolean scanResolvedBundlesForModuleInfo = true;
BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> moduleInfoResolvedBundleTracker = null;
ExtensibleBundleTracker<?> moduleFactoryBundleTracker;
if(scanResolvedBundlesForModuleInfo) {
// Wrap config registry with JMX notification publishing adapter
final JMXNotifierConfigRegistry notifyingConfigRegistry =
- new JMXNotifierConfigRegistry(configRegistry, configMBeanServer);
+ new JMXNotifierConfigRegistry(this.configRegistry, this.configMBeanServer);
// register config registry to OSGi
- AutoCloseable clsReg = OsgiRegistrationUtil.registerService(context, moduleInfoBackedContext, ClassLoadingStrategy.class);
- AutoCloseable configRegReg = OsgiRegistrationUtil.registerService(context, notifyingConfigRegistry, ConfigRegistry.class);
+ final AutoCloseable clsReg = OsgiRegistrationUtil.registerService(context, moduleInfoBackedContext, ClassLoadingStrategy.class);
+ final AutoCloseable configRegReg = OsgiRegistrationUtil.registerService(context, notifyingConfigRegistry, ConfigRegistry.class);
// register config registry to jmx
- ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(configMBeanServer);
+ final ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(this.configMBeanServer);
try {
- configRegistryJMXRegistrator.registerToJMXNoNotifications(configRegistry);
- } catch (InstanceAlreadyExistsException e) {
+ configRegistryJMXRegistrator.registerToJMXNoNotifications(this.configRegistry);
+ } catch (final InstanceAlreadyExistsException e) {
configRegistryJMXRegistrator.close();
throw new IllegalStateException("Config Registry was already registered to JMX", e);
}
// register config registry to jmx
- final ConfigRegistryJMXRegistrator configRegistryJMXRegistratorWithNotifications = new ConfigRegistryJMXRegistrator(configMBeanServer);
+ final ConfigRegistryJMXRegistrator configRegistryJMXRegistratorWithNotifications = new ConfigRegistryJMXRegistrator(this.configMBeanServer);
try {
configRegistryJMXRegistrator.registerToJMX(notifyingConfigRegistry);
- } catch (InstanceAlreadyExistsException e) {
+ } catch (final InstanceAlreadyExistsException e) {
configRegistryJMXRegistrator.close();
configRegistryJMXRegistratorWithNotifications.close();
throw new IllegalStateException("Config Registry was already registered to JMX", e);
}
// TODO wire directly via moduleInfoBundleTracker
- ServiceTracker<ModuleFactory, Object> serviceTracker = new ServiceTracker<>(context, ModuleFactory.class,
+ final ServiceTracker<ModuleFactory, Object> serviceTracker = new ServiceTracker<>(context, ModuleFactory.class,
blankTransactionServiceTracker);
serviceTracker.open();
- AutoCloseable configMgrReg = OsgiRegistrationUtil.registerService(context, this, ConfigSystemService.class);
+ final AutoCloseable configMgrReg = OsgiRegistrationUtil.registerService(context, this, ConfigSystemService.class);
- List<AutoCloseable> list = Arrays.asList(bindingContextProvider, clsReg,
+ final List<AutoCloseable> list = Arrays.asList(bindingContextProvider, clsReg,
OsgiRegistrationUtil.wrap(moduleFactoryBundleTracker), moduleInfoBundleTracker,
configRegReg, configRegistryJMXRegistrator, configRegistryJMXRegistratorWithNotifications,
OsgiRegistrationUtil.wrap(serviceTracker), moduleInfoRegistryWrapper, notifyingConfigRegistry, configMgrReg);
- autoCloseable = OsgiRegistrationUtil.aggregate(list);
+ this.autoCloseable = OsgiRegistrationUtil.aggregate(list);
context.addBundleListener(this);
- } catch(Exception e) {
+ } catch(final Exception e) {
LOG.warn("Error starting config manager", e);
- } catch(Error e) {
+ } catch(final Error e) {
// Log JVM Error and re-throw. The OSGi container may silently fail the bundle and not always log
// the exception. This has been seen on initial feature install.
LOG.error("Error starting config manager", e);
@Override
public void stop(final BundleContext context) throws Exception {
context.removeBundleListener(this);
- autoCloseable.close();
+ this.autoCloseable.close();
}
@Override
- public void bundleChanged(BundleEvent event) {
- if(configRegistry == null) {
+ public void bundleChanged(final BundleEvent event) {
+ if(this.configRegistry == null) {
return;
}
// If the system bundle (id 0) is stopping close the ConfigRegistry so it destroys all modules. On
// shutdown the system bundle is stopped first.
- if(event.getBundle().getBundleId() == SYSTEM_BUNDLE_ID && event.getType() == BundleEvent.STOPPING) {
- configRegistry.close();
+ if((event.getBundle().getBundleId() == SYSTEM_BUNDLE_ID) && (event.getType() == BundleEvent.STOPPING)) {
+ this.configRegistry.close();
}
}
@Override
public void closeAllConfigModules() {
- if(configRegistry != null) {
- configRegistry.close();
+ if(this.configRegistry != null) {
+ this.configRegistry.close();
}
}
}
package org.opendaylight.controller.config.manager.impl.osgi.mapping;
import com.google.common.base.Preconditions;
-import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
/**
import java.util.Dictionary;
import java.util.Hashtable;
+import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.generator.api.ModuleInfoRegistry;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.api.ModuleInfoRegistry;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
this.classLoadingStrat = classLoadingStrat;
this.sourceProvider = sourceProvider;
this.bindingContextProvider = bindingContextProvider;
- osgiReg = bundleContext
+ this.osgiReg = bundleContext
.registerService(SchemaContextProvider.class, schemaContextProvider, new Hashtable<String, String>());
}
public void updateService() {
- if(osgiReg != null) {
+ if(this.osgiReg != null) {
try {
- bindingContextProvider.update(classLoadingStrat, schemaContextProvider);
+ this.bindingContextProvider.update(this.classLoadingStrat, this.schemaContextProvider);
final Dictionary<String, Object> props = new Hashtable<>();
- props.put(BindingRuntimeContext.class.getName(), bindingContextProvider.getBindingContext());
- props.put(SchemaSourceProvider.class.getName(), sourceProvider);
+ props.put(BindingRuntimeContext.class.getName(), this.bindingContextProvider.getBindingContext());
+ props.put(SchemaSourceProvider.class.getName(), this.sourceProvider);
// send modifiedService event
- osgiReg.setProperties(props);
- } catch (RuntimeException e) {
+ this.osgiReg.setProperties(props);
+ } catch (final RuntimeException e) {
// The ModuleInfoBackedContext throws a RuntimeException if it can't create the schema context.
LOG.warn("Error updating the BindingContextProvider", e);
}
@Override
public ObjectRegistration<YangModuleInfo> registerModuleInfo(final YangModuleInfo yangModuleInfo) {
- ObjectRegistration<YangModuleInfo> yangModuleInfoObjectRegistration = moduleInfoRegistry.registerModuleInfo(yangModuleInfo);
+ final ObjectRegistration<YangModuleInfo> yangModuleInfoObjectRegistration = this.moduleInfoRegistry.registerModuleInfo(yangModuleInfo);
return new ObjectRegistrationWrapper(yangModuleInfoObjectRegistration);
}
@Override
public void close() throws Exception {
- if(osgiReg != null) {
- osgiReg.unregister();
+ if(this.osgiReg != null) {
+ this.osgiReg.unregister();
}
- osgiReg = null;
+ this.osgiReg = null;
}
private class ObjectRegistrationWrapper implements ObjectRegistration<YangModuleInfo> {
@Override
public YangModuleInfo getInstance() {
- return inner.getInstance();
+ return this.inner.getInstance();
}
@Override
public void close() throws Exception {
- inner.close();
+ this.inner.close();
// send modify event when a bundle disappears
updateService();
}
@Override
public String toString() {
- return inner.toString();
+ return this.inner.toString();
}
}
}
import org.opendaylight.controller.config.spi.Module;
import org.opendaylight.controller.config.util.ConfigRegistryJMXClient;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
private final List<RegistrationHolder> registrations = new LinkedList<>();
@Override
public void handleServiceRegistration(final Class<?> clazz, final Object serviceInstance, final Dictionary<String, ?> props) {
- registrations.add(new RegistrationHolder(clazz, serviceInstance, props));
+ this.registrations.add(new RegistrationHolder(clazz, serviceInstance, props));
}
public List<RegistrationHolder> getRegistrations() {
- return registrations;
+ return this.registrations;
}
protected static class RegistrationHolder {
}
protected BundleContextServiceRegistrationHandler getBundleContextServiceRegistrationHandler(final Class<?> serviceType) {
- return currentBundleContextServiceRegistrationHandler;
+ return this.currentBundleContextServiceRegistrationHandler;
}
// this method should be called in @Before
final MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
- configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(platformMBeanServer);
+ this.configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(platformMBeanServer);
initBundleContext();
- baseJmxRegistrator = new BaseJMXRegistrator(platformMBeanServer);
+ this.baseJmxRegistrator = new BaseJMXRegistrator(platformMBeanServer);
- configRegistry = new ConfigRegistryImpl(resolver, platformMBeanServer, baseJmxRegistrator, new BindingContextProvider() {
+ this.configRegistry = new ConfigRegistryImpl(resolver, platformMBeanServer, this.baseJmxRegistrator, new BindingContextProvider() {
@Override
public synchronized void update(final ClassLoadingStrategy classLoadingStrategy, final SchemaContextProvider ctxProvider) {
// NOOP
return getBindingRuntimeContext();
}
});
- notifyingConfigRegistry = new JMXNotifierConfigRegistry(this.configRegistry, platformMBeanServer);
+ this.notifyingConfigRegistry = new JMXNotifierConfigRegistry(this.configRegistry, platformMBeanServer);
try {
- configRegistryJMXRegistrator.registerToJMXNoNotifications(configRegistry);
- configRegistryJMXRegistrator.registerToJMX(notifyingConfigRegistry);
- } catch (InstanceAlreadyExistsException e) {
+ this.configRegistryJMXRegistrator.registerToJMXNoNotifications(this.configRegistry);
+ this.configRegistryJMXRegistrator.registerToJMX(this.notifyingConfigRegistry);
+ } catch (final InstanceAlreadyExistsException e) {
throw new RuntimeException(e);
}
- configRegistryClient = new ConfigRegistryJMXClient(platformMBeanServer);
- currentBundleContextServiceRegistrationHandler = new RecordingBundleContextServiceRegistrationHandler();
+ this.configRegistryClient = new ConfigRegistryJMXClient(platformMBeanServer);
+ this.currentBundleContextServiceRegistrationHandler = new RecordingBundleContextServiceRegistrationHandler();
}
private void initBundleContext() {
- doNothing().when(mockedServiceRegistration).unregister();
- RegisterServiceAnswer answer = new RegisterServiceAnswer();
- doAnswer(answer).when(mockedContext).registerService(Matchers.<String>any(), any(), Matchers.<Dictionary<String, ?>>any());
- doAnswer(answer).when(mockedContext).registerService(Matchers.<Class>any(), any(), Matchers.<Dictionary<String, ?>>any());
+ doNothing().when(this.mockedServiceRegistration).unregister();
+ final RegisterServiceAnswer answer = new RegisterServiceAnswer();
+ doAnswer(answer).when(this.mockedContext).registerService(Matchers.<String>any(), any(), Matchers.<Dictionary<String, ?>>any());
+ doAnswer(answer).when(this.mockedContext).registerService(Matchers.<Class>any(), any(), Matchers.<Dictionary<String, ?>>any());
}
@After
public final void cleanUpConfigTransactionManagerImpl() {
- configRegistryJMXRegistrator.close();
- notifyingConfigRegistry.close();
- configRegistry.close();
+ this.configRegistryJMXRegistrator.close();
+ this.notifyingConfigRegistry.close();
+ this.configRegistry.close();
TestingFixedThreadPool.cleanUp();
TestingScheduledThreadPoolImpl.cleanUp();
}
* would be discarded by closing config beans in this method
*/
protected void destroyAllConfigBeans() throws Exception {
- ConfigTransactionJMXClient transaction = configRegistryClient
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient
.createTransaction();
Set<ObjectName> all = transaction.lookupConfigBeans();
// workaround for getting same Module more times
protected void assertBeanCount(final int i, final String configMXBeanName) {
- assertEquals(i, configRegistry.lookupConfigBeans(configMXBeanName).size());
+ assertEquals(i, this.configRegistry.lookupConfigBeans(configMXBeanName).size());
}
/**
private class RegisterServiceAnswer implements Answer<ServiceRegistration<?>> {
@Override
public ServiceRegistration<?> answer(final InvocationOnMock invocation) throws Throwable {
- Object[] args = invocation.getArguments();
+ final Object[] args = invocation.getArguments();
Preconditions.checkArgument(args.length == 3, "Unexpected arguments size (expected 3 was %s)", args.length);
- Object serviceTypeRaw = args[0];
- Object serviceInstance = args[1];
+ final Object serviceTypeRaw = args[0];
+ final Object serviceInstance = args[1];
@SuppressWarnings("unchecked")
+ final
Dictionary<String, ?> props = (Dictionary<String, ?>) args[2];
if (serviceTypeRaw instanceof Class) {
- Class<?> serviceType = (Class<?>) serviceTypeRaw;
+ final Class<?> serviceType = (Class<?>) serviceTypeRaw;
invokeServiceHandler(serviceInstance, serviceType, props);
} else if (serviceTypeRaw instanceof String[]) {
- for (String className : (String[]) serviceTypeRaw) {
+ for (final String className : (String[]) serviceTypeRaw) {
invokeServiceHandler(serviceInstance, className, props);
}
} else if (serviceTypeRaw instanceof String) {
throw new IllegalStateException("Not handling service registration of type, Unknown type" + serviceTypeRaw);
}
- return mockedServiceRegistration;
+ return AbstractConfigTest.this.mockedServiceRegistration;
}
public void invokeServiceHandler(final Object serviceInstance, final String className, final Dictionary<String, ?> props) {
try {
- Class<?> serviceType = Class.forName(className);
+ final Class<?> serviceType = Class.forName(className);
invokeServiceHandler(serviceInstance, serviceType, props);
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
throw new IllegalStateException("Not handling service registration of type " + className, e);
}
}
private void invokeServiceHandler(final Object serviceInstance, final Class<?> serviceType, final Dictionary<String, ?> props) {
- BundleContextServiceRegistrationHandler serviceRegistrationHandler = getBundleContextServiceRegistrationHandler(serviceType);
+ final BundleContextServiceRegistrationHandler serviceRegistrationHandler = getBundleContextServiceRegistrationHandler(serviceType);
if (serviceRegistrationHandler != null) {
serviceRegistrationHandler.handleServiceRegistration(serviceType, serviceInstance, props);
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
try {
return method.invoke(innerObject, args);
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
try {
throw e.getTargetException();
- } catch (RuntimeMBeanException e2) {
+ } catch (final RuntimeMBeanException e2) {
throw e2.getTargetException();
}
}
throw new IOException("Failed to list contents of " + dir);
}
- for (File file : files) {
+ for (final File file : files) {
if (file.isDirectory()) {
cleanDirectory(dir);
}
import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.config.manager.impl.osgi.mapping.BindingContextProvider;
import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry;
+import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.generator.api.ModuleInfoRegistry;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.api.ModuleInfoRegistry;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
@Test
public void testConstructor() throws Exception {
- ModuleInfoRegistry reg = mock(ModuleInfoRegistry.class);
- SchemaContextProvider prov = mock(SchemaContextProvider.class);
+ final ModuleInfoRegistry reg = mock(ModuleInfoRegistry.class);
+ final SchemaContextProvider prov = mock(SchemaContextProvider.class);
doReturn("string").when(prov).toString();
- BundleContext ctxt = mock(BundleContext.class);
- ServiceRegistration<?> servReg = mock(ServiceRegistration.class);
+ final BundleContext ctxt = mock(BundleContext.class);
+ final ServiceRegistration<?> servReg = mock(ServiceRegistration.class);
doReturn(servReg).when(ctxt).registerService(any(Class.class), any(SchemaContextProvider.class), any(Dictionary.class));
doReturn(servReg).when(ctxt).registerService(Mockito.anyString(), any(Object.class), any(Dictionary.class));
doNothing().when(servReg).setProperties(any(Dictionary.class));
doReturn("B-runtime-context").when(bindingRuntimeContext).toString();
doReturn(bindingRuntimeContext).when(codecRegistryProvider).getBindingContext();
- RefreshingSCPModuleInfoRegistry scpreg = new RefreshingSCPModuleInfoRegistry(reg, prov, classLoadingStrat, sourceProvider, codecRegistryProvider, ctxt);
+ final RefreshingSCPModuleInfoRegistry scpreg = new RefreshingSCPModuleInfoRegistry(reg, prov, classLoadingStrat, this.sourceProvider, codecRegistryProvider, ctxt);
doNothing().when(servReg).unregister();
- YangModuleInfo modInfo = mock(YangModuleInfo.class);
+ final YangModuleInfo modInfo = mock(YangModuleInfo.class);
doReturn("").when(modInfo).toString();
- ObjectRegistration<YangModuleInfo> ymi = mock(ObjectRegistration.class);
+ final ObjectRegistration<YangModuleInfo> ymi = mock(ObjectRegistration.class);
doReturn(ymi).when(reg).registerModuleInfo(modInfo);
scpreg.registerModuleInfo(modInfo);
import org.opendaylight.controller.config.yangjmxgenerator.PackageTranslator;
import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
-import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
"Null outputBaseDir received");
Preconditions
- .checkArgument(namespaceToPackageMapping != null && !namespaceToPackageMapping.isEmpty(),
+ .checkArgument((this.namespaceToPackageMapping != null) && !this.namespaceToPackageMapping.isEmpty(),
"No namespace to package mapping provided in additionalConfiguration");
- PackageTranslator packageTranslator = new PackageTranslator(namespaceToPackageMapping);
+ final PackageTranslator packageTranslator = new PackageTranslator(this.namespaceToPackageMapping);
if (!outputBaseDir.exists()) {
outputBaseDir.mkdirs();
}
- GeneratedFilesTracker generatedFiles = new GeneratedFilesTracker();
+ final GeneratedFilesTracker generatedFiles = new GeneratedFilesTracker();
// create SIE structure qNamesToSIEs
- Map<QName, ServiceInterfaceEntry> qNamesToSIEs = new HashMap<>();
+ final Map<QName, ServiceInterfaceEntry> qNamesToSIEs = new HashMap<>();
- Map<IdentitySchemaNode, ServiceInterfaceEntry> knownSEITracker = new HashMap<>();
- for (Module module : context.getModules()) {
- String packageName = packageTranslator.getPackageName(module);
- Map<QName, ServiceInterfaceEntry> namesToSIEntries = ServiceInterfaceEntry
+ final Map<IdentitySchemaNode, ServiceInterfaceEntry> knownSEITracker = new HashMap<>();
+ for (final Module module : context.getModules()) {
+ final String packageName = packageTranslator.getPackageName(module);
+ final Map<QName, ServiceInterfaceEntry> namesToSIEntries = ServiceInterfaceEntry
.create(module, packageName, knownSEITracker);
- for (Entry<QName, ServiceInterfaceEntry> sieEntry : namesToSIEntries
+ for (final Entry<QName, ServiceInterfaceEntry> sieEntry : namesToSIEntries
.entrySet()) {
// merge value into qNamesToSIEs
if (qNamesToSIEs.put(sieEntry.getKey(), sieEntry.getValue()) != null) {
}
if (yangModulesInCurrentMavenModule.contains(module)) {
// write this sie to disk
- for (ServiceInterfaceEntry sie : namesToSIEntries.values()) {
+ for (final ServiceInterfaceEntry sie : namesToSIEntries.values()) {
try {
- generatedFiles.addFile(codeWriter.writeSie(sie,
+ generatedFiles.addFile(this.codeWriter.writeSie(sie,
outputBaseDir));
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new RuntimeException(
"Error occurred during SIE source generate phase",
e);
}
}
- File mainBaseDir = concatFolders(projectBaseDir, "src", "main", "java");
- Preconditions.checkNotNull(resourceBaseDir,
+ final File mainBaseDir = concatFolders(this.projectBaseDir, "src", "main", "java");
+ Preconditions.checkNotNull(this.resourceBaseDir,
"resource base dir attribute was null");
- StringBuilder fullyQualifiedNamesOfFactories = new StringBuilder();
+ final StringBuilder fullyQualifiedNamesOfFactories = new StringBuilder();
// create MBEs
- for (Module module : yangModulesInCurrentMavenModule) {
- String packageName = packageTranslator.getPackageName(module);
- Map<String /* MB identity local name */, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry
+ for (final Module module : yangModulesInCurrentMavenModule) {
+ final String packageName = packageTranslator.getPackageName(module);
+ final Map<String /* MB identity local name */, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry
.create(module, qNamesToSIEs, context, new TypeProviderWrapper(new TypeProviderImpl(context)),
packageName);
- for (Entry<String, ModuleMXBeanEntry> mbeEntry : namesToMBEs
+ for (final Entry<String, ModuleMXBeanEntry> mbeEntry : namesToMBEs
.entrySet()) {
- ModuleMXBeanEntry mbe = mbeEntry.getValue();
+ final ModuleMXBeanEntry mbe = mbeEntry.getValue();
try {
- List<File> files1 = codeWriter.writeMbe(mbe, outputBaseDir,
+ final List<File> files1 = this.codeWriter.writeMbe(mbe, outputBaseDir,
mainBaseDir);
generatedFiles.addFile(files1);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new RuntimeException(
"Error occurred during MBE source generate phase",
e);
}
}
// create ModuleFactory file if needed
- if (fullyQualifiedNamesOfFactories.length() > 0
- && generateModuleFactoryFile) {
- File serviceLoaderFile = JMXGenerator.concatFolders(
- resourceBaseDir, "META-INF", "services",
+ if ((fullyQualifiedNamesOfFactories.length() > 0)
+ && this.generateModuleFactoryFile) {
+ final File serviceLoaderFile = JMXGenerator.concatFolders(
+ this.resourceBaseDir, "META-INF", "services",
ModuleFactory.class.getName());
// if this file does not exist, create empty file
serviceLoaderFile.getParentFile().mkdirs();
try {
serviceLoaderFile.createNewFile();
Files.write(fullyQualifiedNamesOfFactories.toString(), serviceLoaderFile, StandardCharsets.UTF_8);
- } catch (IOException e) {
- String message = "Cannot write to " + serviceLoaderFile;
+ } catch (final IOException e) {
+ final String message = "Cannot write to " + serviceLoaderFile;
LOG.error(message, e);
throw new RuntimeException(message, e);
}
@VisibleForTesting
static File concatFolders(final File projectBaseDir, final String... folderNames) {
File result = projectBaseDir;
- for (String folder: folderNames) {
+ for (final String folder: folderNames) {
result = new File(result, folder);
}
return result;
}
private static boolean extractModuleFactoryBoolean(final Map<String, String> additionalCfg) {
- String bool = additionalCfg.get(MODULE_FACTORY_FILE_BOOLEAN);
+ final String bool = additionalCfg.get(MODULE_FACTORY_FILE_BOOLEAN);
return !"false".equals(bool);
}
private static Map<String, String> extractNamespaceMapping(
final Map<String, String> additionalCfg) {
- Map<String, String> namespaceToPackage = Maps.newHashMap();
- for (String key : additionalCfg.keySet()) {
+ final Map<String, String> namespaceToPackage = Maps.newHashMap();
+ for (final String key : additionalCfg.keySet()) {
if (key.startsWith(NAMESPACE_TO_PACKAGE_PREFIX)) {
- String mapping = additionalCfg.get(key);
- NamespaceMapping mappingResolved = extractNamespaceMapping(mapping);
+ final String mapping = additionalCfg.get(key);
+ final NamespaceMapping mappingResolved = extractNamespaceMapping(mapping);
namespaceToPackage.put(mappingResolved.namespace,
mappingResolved.packageName);
}
}
private static NamespaceMapping extractNamespaceMapping(final String mapping) {
- Matcher matcher = NAMESPACE_MAPPING_PATTERN.matcher(mapping);
+ final Matcher matcher = NAMESPACE_MAPPING_PATTERN.matcher(mapping);
Preconditions.checkArgument(matcher.matches(),
"Namespace to package mapping:%s is in invalid format, requested format is: %s",
mapping, NAMESPACE_MAPPING_PATTERN);
@Override
public void setMavenProject(final MavenProject project) {
this.projectBaseDir = project.getBasedir();
- LOG.debug("{}: project base dir: {}", getClass().getCanonicalName(), projectBaseDir);
+ LOG.debug("{}: project base dir: {}", getClass().getCanonicalName(), this.projectBaseDir);
}
@VisibleForTesting
private final Set<File> files = Sets.newHashSet();
void addFile(final File file) {
- if (files.contains(file)) {
- List<File> undeletedFiles = Lists.newArrayList();
- for (File presentFile : files) {
+ if (this.files.contains(file)) {
+ final List<File> undeletedFiles = Lists.newArrayList();
+ for (final File presentFile : this.files) {
if (!presentFile.delete()) {
undeletedFiles.add(presentFile);
}
"Name conflict in generated files, file" + file
+ " present twice");
}
- files.add(file);
+ this.files.add(file);
}
void addFile(final Collection<File> files) {
- for (File file : files) {
+ for (final File file : files) {
addFile(file);
}
}
public Set<File> getFiles() {
- return files;
+ return this.files;
}
}
}
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.FullyQualifiedNameHelper;
-import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.ParameterizedType;
+import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.binding.BindingMapping;
public class TemplateFactory {
*/
public static Map<String, FtlTemplate> getTOAndMXInterfaceFtlFiles(
final RuntimeBeanEntry entry) {
- Map<String, FtlTemplate> result = new HashMap<>();
+ final Map<String, FtlTemplate> result = new HashMap<>();
{ // create GeneralInterfaceFtlFile for runtime MXBean. Attributes will
// be transformed to getter methods
- String mxBeanTypeName = entry.getJavaNameOfRuntimeMXBean();
- List<String> extendedInterfaces = Collections.singletonList(RuntimeBean.class
+ final String mxBeanTypeName = entry.getJavaNameOfRuntimeMXBean();
+ final List<String> extendedInterfaces = Collections.singletonList(RuntimeBean.class
.getCanonicalName());
- List<MethodDeclaration> methods = new ArrayList<>();
+ final List<MethodDeclaration> methods = new ArrayList<>();
// convert attributes to getters
- for (AttributeIfc attributeIfc : entry.getAttributes()) {
+ for (final AttributeIfc attributeIfc : entry.getAttributes()) {
String returnType;
returnType = getReturnType(attributeIfc);
- String getterName = "get"
+ final String getterName = "get"
+ attributeIfc.getUpperCaseCammelCase();
- MethodDeclaration getter = new MethodDeclaration(returnType,
+ final MethodDeclaration getter = new MethodDeclaration(returnType,
getterName, Collections.<Field> emptyList());
methods.add(getter);
}
// add rpc methods
- for (Rpc rpc : entry.getRpcs()) {
+ for (final Rpc rpc : entry.getRpcs()) {
// convert JavaAttribute parameters into fields
- List<Field> fields = new ArrayList<>();
- for (JavaAttribute ja : rpc.getParameters()) {
- Field field = new Field(Collections.emptyList(),
+ final List<Field> fields = new ArrayList<>();
+ for (final JavaAttribute ja : rpc.getParameters()) {
+ final Field field = new Field(Collections.emptyList(),
ja.getType().getFullyQualifiedName(),
ja.getLowerCaseCammelCase(), ja.getNullableDefaultWrappedForCode());
fields.add(field);
}
- MethodDeclaration operation = new MethodDeclaration(
+ final MethodDeclaration operation = new MethodDeclaration(
getReturnType(rpc.getReturnType()), rpc.getName(), fields);
methods.add(operation);
}
// FIXME header
- GeneralInterfaceTemplate runtimeMxBeanIfc = new GeneralInterfaceTemplate(
+ final GeneralInterfaceTemplate runtimeMxBeanIfc = new GeneralInterfaceTemplate(
null, entry.getPackageName(), mxBeanTypeName,
extendedInterfaces, methods);
// FIXME: put into Type.toString
static String serializeType(final Type type, final boolean addWildcards) {
if (type instanceof ParameterizedType){
- ParameterizedType parameterizedType = (ParameterizedType) type;
- StringBuilder sb = new StringBuilder();
+ final ParameterizedType parameterizedType = (ParameterizedType) type;
+ final StringBuilder sb = new StringBuilder();
sb.append(parameterizedType.getRawType().getFullyQualifiedName());
sb.append(addWildcards ? "<? extends " : "<");
boolean first = true;
- for(Type parameter: parameterizedType.getActualTypeArguments()) {
+ for(final Type parameter: parameterizedType.getActualTypeArguments()) {
if (first) {
first = false;
} else {
private static String getReturnType(final AttributeIfc attributeIfc) {
String returnType;
if (attributeIfc instanceof TypedAttribute) {
- Type type = ((TypedAttribute) attributeIfc).getType();
+ final Type type = ((TypedAttribute) attributeIfc).getType();
returnType = serializeType(type);
} else if (attributeIfc == VoidAttribute.getInstance()) {
return "void";
public static GeneralInterfaceTemplate serviceInterfaceFromSie(
final ServiceInterfaceEntry sie) {
- List<String> extendedInterfaces = Lists
+ final List<String> extendedInterfaces = Lists
.newArrayList(AbstractServiceInterface.class.getCanonicalName());
if (sie.getBase().isPresent()) {
extendedInterfaces.add(sie.getBase().get().getFullyQualifiedName());
}
// FIXME header
- GeneralInterfaceTemplate sieTemplate = new GeneralInterfaceTemplate(
+ final GeneralInterfaceTemplate sieTemplate = new GeneralInterfaceTemplate(
getHeaderFromEntry(sie), sie.getPackageName(),
sie.getTypeName(), extendedInterfaces,
Lists.<MethodDeclaration> newArrayList());
public static AbstractFactoryTemplate abstractFactoryTemplateFromMbe(
final ModuleMXBeanEntry mbe) {
- AbstractFactoryAttributesProcessor attrProcessor = new AbstractFactoryAttributesProcessor();
+ final AbstractFactoryAttributesProcessor attrProcessor = new AbstractFactoryAttributesProcessor();
attrProcessor.processAttributes(mbe.getAttributes());
public static AbstractModuleTemplate abstractModuleTemplateFromMbe(
final ModuleMXBeanEntry mbe) {
- AbstractModuleAttributesProcessor attrProcessor = new AbstractModuleAttributesProcessor(mbe.getAttributes());
+ final AbstractModuleAttributesProcessor attrProcessor = new AbstractModuleAttributesProcessor(mbe.getAttributes());
- List<ModuleField> moduleFields = attrProcessor.getModuleFields();
- List<String> implementedIfcs = Lists.newArrayList(
+ final List<ModuleField> moduleFields = attrProcessor.getModuleFields();
+ final List<String> implementedIfcs = Lists.newArrayList(
mbe.getFullyQualifiedName(mbe.getMXBeanInterfaceName()));
- for (String implementedService : mbe.getProvidedServices().keySet()) {
+ for (final String implementedService : mbe.getProvidedServices().keySet()) {
implementedIfcs.add(implementedService);
}
boolean generateRuntime = false;
String registratorFullyQualifiedName = null;
- if (mbe.getRuntimeBeans() != null
+ if ((mbe.getRuntimeBeans() != null)
&& !mbe.getRuntimeBeans().isEmpty()) {
generateRuntime = true;
- RuntimeBeanEntry rootEntry = RuntimeRegistratorFtlTemplate
+ final RuntimeBeanEntry rootEntry = RuntimeRegistratorFtlTemplate
.findRoot(mbe.getRuntimeBeans());
registratorFullyQualifiedName = rootEntry
.getPackageName()
.getCanonicalName());
}
- List<String> extendedClasses = Collections.singletonList(AbstractModule.class.getCanonicalName() + "<" + mbe.getAbstractModuleName() + ">");
+ final List<String> extendedClasses = Collections.singletonList(AbstractModule.class.getCanonicalName() + "<" + mbe.getAbstractModuleName() + ">");
- AbstractModuleTemplate abstractModuleTemplate = new AbstractModuleTemplate(
+ final AbstractModuleTemplate abstractModuleTemplate = new AbstractModuleTemplate(
getHeaderFromEntry(mbe), mbe.getPackageName(),
mbe.getAbstractModuleName(), extendedClasses, implementedIfcs, moduleFields,
attrProcessor.getMethods(), generateRuntime,
public static GeneralInterfaceTemplate mXBeanInterfaceTemplateFromMbe(
final ModuleMXBeanEntry mbe) {
- MXBeanInterfaceAttributesProcessor attrProcessor = new MXBeanInterfaceAttributesProcessor();
+ final MXBeanInterfaceAttributesProcessor attrProcessor = new MXBeanInterfaceAttributesProcessor();
attrProcessor.processAttributes(mbe.getAttributes());
- GeneralInterfaceTemplate ifcTemplate = new GeneralInterfaceTemplate(
+ final GeneralInterfaceTemplate ifcTemplate = new GeneralInterfaceTemplate(
getHeaderFromEntry(mbe), mbe.getPackageName(),
mbe.getMXBeanInterfaceName(), Lists.<String> newArrayList(),
attrProcessor.getMethods());
public static Map<String, GeneralClassTemplate> tOsFromMbe(
final ModuleMXBeanEntry mbe) {
- Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
- TOAttributesProcessor processor = new TOAttributesProcessor();
+ final Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
+ final TOAttributesProcessor processor = new TOAttributesProcessor();
processor.processAttributes(mbe.getAttributes());
- for (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory.TOAttributesProcessor.TOInternal to : processor
+ for (final org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory.TOAttributesProcessor.TOInternal to : processor
.getTOs()) {
- List<Constructor> constructors = Lists.newArrayList();
+ final List<Constructor> constructors = Lists.newArrayList();
constructors.add(new Constructor(to.getName(), "super();"));
- Header header = getHeaderFromEntry(mbe);
+ final Header header = getHeaderFromEntry(mbe);
retVal.put(
to.getType(),
new GeneralClassTemplate(header, mbe.getPackageName(), to
public static Map<String, GeneralClassTemplate> tOsFromRbe(
final RuntimeBeanEntry rbe) {
- Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
- TOAttributesProcessor processor = new TOAttributesProcessor();
- Map<String, AttributeIfc> yangPropertiesToTypesMap = Maps.newHashMap(rbe.getYangPropertiesToTypesMap());
+ final Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
+ final TOAttributesProcessor processor = new TOAttributesProcessor();
+ final Map<String, AttributeIfc> yangPropertiesToTypesMap = Maps.newHashMap(rbe.getYangPropertiesToTypesMap());
// Add TOs from output parameters
- for (Rpc rpc : rbe.getRpcs()) {
- AttributeIfc returnType = rpc.getReturnType();
+ for (final Rpc rpc : rbe.getRpcs()) {
+ final AttributeIfc returnType = rpc.getReturnType();
if (returnType == VoidAttribute.getInstance()) {
continue;
if (returnType instanceof JavaAttribute) {
continue;
}
- if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType) {
+ if ((returnType instanceof ListAttribute) && (returnType.getOpenType() instanceof SimpleType)) {
continue;
}
}
processor.processAttributes(yangPropertiesToTypesMap);
- for (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory.TOAttributesProcessor.TOInternal to : processor
+ for (final org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory.TOAttributesProcessor.TOInternal to : processor
.getTOs()) {
- List<Constructor> constructors = Lists.newArrayList();
+ final List<Constructor> constructors = Lists.newArrayList();
constructors.add(new Constructor(to.getName(), "super();"));
// TODO header
private final List<TOInternal> tos = Lists.newArrayList();
void processAttributes(final Map<String, AttributeIfc> attributes) {
- for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
- AttributeIfc attributeIfc = attrEntry.getValue();
+ for (final Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
+ final AttributeIfc attributeIfc = attrEntry.getValue();
if (attributeIfc instanceof TOAttribute) {
createTOInternal((TOAttribute) attributeIfc);
}
if (attributeIfc instanceof ListAttribute) {
- AttributeIfc innerAttr = ((ListAttribute) attributeIfc)
+ final AttributeIfc innerAttr = ((ListAttribute) attributeIfc)
.getInnerAttribute();
if (innerAttr instanceof TOAttribute) {
createTOInternal((TOAttribute) innerAttr);
private void createTOInternal(final TOAttribute toAttribute) {
- Map<String, AttributeIfc> attrs = toAttribute.getCapitalizedPropertiesToTypesMap();
+ final Map<String, AttributeIfc> attrs = toAttribute.getCapitalizedPropertiesToTypesMap();
// recursive processing of TO's attributes
processAttributes(attrs);
- tos.add(new TOInternal(toAttribute.getType(), attrs));
+ this.tos.add(new TOInternal(toAttribute.getType(), attrs));
}
List<TOInternal> getTOs() {
- return tos;
+ return this.tos;
}
private static class TOInternal {
private final static String dependencyResolverInjectMethodName = "injectDependencyResolver";
private void processAttrs(final Map<String, AttributeIfc> attrs, final String packageName) {
- fields = Lists.newArrayList();
- methods = Lists.newArrayList();
+ this.fields = Lists.newArrayList();
+ this.methods = Lists.newArrayList();
// FIXME conflict if "dependencyResolver" field from yang
- Field depRes = new Field(DependencyResolver.class.getName(), dependencyResolverVarName);
- fields.add(depRes);
- methods.add(new MethodDefinition("void", dependencyResolverInjectMethodName, Lists.newArrayList(depRes),
+ final Field depRes = new Field(DependencyResolver.class.getName(), dependencyResolverVarName);
+ this.fields.add(depRes);
+ this.methods.add(new MethodDefinition("void", dependencyResolverInjectMethodName, Lists.newArrayList(depRes),
"this." + dependencyResolverVarName + " = " + dependencyResolverVarName + ";"));
- for (Entry<String, AttributeIfc> attrEntry : attrs.entrySet()) {
- String innerName = attrEntry.getKey();
- String varName = BindingMapping.getPropertyName(attrEntry.getKey());
+ for (final Entry<String, AttributeIfc> attrEntry : attrs.entrySet()) {
+ final String innerName = attrEntry.getKey();
+ final String varName = BindingMapping.getPropertyName(attrEntry.getKey());
String fullyQualifiedName, nullableDefault = null;
if (attrEntry.getValue() instanceof TypedAttribute) {
nullableDefault = ((JavaAttribute)attrEntry.getValue()).getNullableDefaultWrappedForCode();
if(((JavaAttribute)attrEntry.getValue()).isIdentityRef()) {
- String fieldType = serializeType(type, true);
- String innerType = getInnerTypeFromIdentity(type);
- methods.add(new MethodDefinition(fieldType, "resolve" + attrEntry.getKey(), Collections.<Field>emptyList(),
+ final String fieldType = serializeType(type, true);
+ final String innerType = getInnerTypeFromIdentity(type);
+ this.methods.add(new MethodDefinition(fieldType, "resolve" + attrEntry.getKey(), Collections.<Field>emptyList(),
"return " + varName + ".resolveIdentity(" + dependencyResolverVarName + "," + innerType + ".class);"));
type = identityRefType;
}
fullyQualifiedName = FullyQualifiedNameHelper
.getFullyQualifiedName(packageName, attrEntry.getValue().getUpperCaseCammelCase());
}
- fields.add(new Field(fullyQualifiedName, varName, nullableDefault, needsDepResolver(attrEntry.getValue())));
+ this.fields.add(new Field(fullyQualifiedName, varName, nullableDefault, needsDepResolver(attrEntry.getValue())));
- String getterName = "get" + innerName;
- MethodDefinition getter = new MethodDefinition(
+ final String getterName = "get" + innerName;
+ final MethodDefinition getter = new MethodDefinition(
fullyQualifiedName, getterName,
Collections.<Field> emptyList(), "return "
+ varName + ";");
- String setterName = "set" + innerName;
- MethodDefinition setter = new MethodDefinition("void",
+ final String setterName = "set" + innerName;
+ final MethodDefinition setter = new MethodDefinition("void",
setterName, Lists.newArrayList(new Field(
fullyQualifiedName, varName)), "this."
+ varName + " = " + varName + ";");
- methods.add(getter);
- methods.add(setter);
+ this.methods.add(getter);
+ this.methods.add(setter);
}
// Add hashCode
final MethodDefinition hashCode = getHash(attrs);
- methods.add(hashCode);
+ this.methods.add(hashCode);
// Add equals
final MethodDefinition equals = getEquals(attrs);
- methods.add(equals);
+ this.methods.add(equals);
}
private MethodDefinition getEquals(final Map<String, AttributeIfc> attrs) {
" if (this == o) { return true; }\n" +
" if (o == null || getClass() != o.getClass()) { return false; }\n");
equalsBodyBuilder.append(String.format(
- " final %s that = (%s) o;\n", name, name));
- for (AttributeIfc s : attrs.values()) {
+ " final %s that = (%s) o;\n", this.name, this.name));
+ for (final AttributeIfc s : attrs.values()) {
equalsBodyBuilder.append(String.format(
" if (!java.util.Objects.equals(%1$s, that.%1$s)) {\n" +
" return false;\n" +
private static MethodDefinition getHash(final Map<String, AttributeIfc> attrs) {
final StringBuilder hashBodyBuilder = new StringBuilder(
" return java.util.Objects.hash(");
- for (AttributeIfc s : attrs.values()) {
+ for (final AttributeIfc s : attrs.values()) {
hashBodyBuilder.append(s.getLowerCaseCammelCase());
hashBodyBuilder.append(", ");
}
}
String getType() {
- return fullyQualifiedName;
+ return this.fullyQualifiedName;
}
String getName() {
- return name;
+ return this.name;
}
List<Field> getFields() {
- return fields;
+ return this.fields;
}
List<MethodDefinition> getMethods() {
- return methods;
+ return this.methods;
}
}
}
private final List<MethodDeclaration> methods = Lists.newArrayList();
void processAttributes(final Map<String, AttributeIfc> attributes) {
- for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
+ for (final Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
String returnType;
- AttributeIfc attributeIfc = attrEntry.getValue();
+ final AttributeIfc attributeIfc = attrEntry.getValue();
if (attributeIfc instanceof TypedAttribute) {
- TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
+ final TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
returnType = serializeType(typedAttribute.getType());
- if (attributeIfc instanceof JavaAttribute && ((JavaAttribute)attrEntry.getValue()).isIdentityRef()) {
+ if ((attributeIfc instanceof JavaAttribute) && ((JavaAttribute)attrEntry.getValue()).isIdentityRef()) {
returnType = serializeType(identityRefType);
}
+ attributeIfc.getClass());
}
- String getterName = "get"
+ final String getterName = "get"
+ attributeIfc.getUpperCaseCammelCase();
- MethodDeclaration getter = new MethodDeclaration(returnType,
+ final MethodDeclaration getter = new MethodDeclaration(returnType,
getterName, Collections.<Field> emptyList());
- String varName = BindingMapping.getPropertyName(attrEntry.getKey());
- String setterName = "set"
+ final String varName = BindingMapping.getPropertyName(attrEntry.getKey());
+ final String setterName = "set"
+ attributeIfc.getUpperCaseCammelCase();
- MethodDeclaration setter = new MethodDeclaration("void",
+ final MethodDeclaration setter = new MethodDeclaration("void",
setterName, Lists.newArrayList(new Field(returnType,
varName)));
- methods.add(getter);
- methods.add(setter);
+ this.methods.add(getter);
+ this.methods.add(setter);
if (attributeIfc.getNullableDescription() != null) {
setter.setJavadoc(attrEntry.getValue()
}
List<MethodDeclaration> getMethods() {
- return methods;
+ return this.methods;
}
}
@Override
public String getPackageName() {
- return IDENTITY_ATTRIBUTE_REF_CLASS.getPackage().getName();
+ return this.IDENTITY_ATTRIBUTE_REF_CLASS.getPackage().getName();
}
@Override
public String getName() {
- return IDENTITY_ATTRIBUTE_REF_CLASS.getSimpleName();
+ return this.IDENTITY_ATTRIBUTE_REF_CLASS.getSimpleName();
}
@Override
public String getFullyQualifiedName() {
- return IDENTITY_ATTRIBUTE_REF_CLASS.getName();
+ return this.IDENTITY_ATTRIBUTE_REF_CLASS.getName();
}
};
private final List<Field> fields = Lists.newArrayList();
void processAttributes(final Map<String, AttributeIfc> attributes) {
- for (AttributeIfc attributeIfc : attributes.values()) {
+ for (final AttributeIfc attributeIfc : attributes.values()) {
if (attributeIfc instanceof TypedAttribute) {
- TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
- String type = serializeType(typedAttribute.getType());
+ final TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
+ final String type = serializeType(typedAttribute.getType());
- fields.add(new Field(type, attributeIfc
+ this.fields.add(new Field(type, attributeIfc
.getUpperCaseCammelCase(), null));
} else {
throw new UnsupportedOperationException(
}
List<Field> getFields() {
- return fields;
+ return this.fields;
}
}
}
private static Holder processAttributes(final Map<String, AttributeIfc> attributes) {
- List<ModuleField> moduleFields = new ArrayList<>();
- List<MethodDefinition> methods = new ArrayList<>();
- for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
+ final List<ModuleField> moduleFields = new ArrayList<>();
+ final List<MethodDefinition> methods = new ArrayList<>();
+ for (final Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
String type, nullableDefaultWrapped = null;
- AttributeIfc attributeIfc = attrEntry.getValue();
+ final AttributeIfc attributeIfc = attrEntry.getValue();
boolean isIdentity = false;
- boolean needsDepResolver = needsDepResolver(attrEntry.getValue());
+ final boolean needsDepResolver = needsDepResolver(attrEntry.getValue());
if (attributeIfc instanceof TypedAttribute) {
- TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
+ final TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
type = serializeType(typedAttribute.getType());
if (attributeIfc instanceof JavaAttribute) {
nullableDefaultWrapped = ((JavaAttribute) attributeIfc).getNullableDefaultWrappedForCode();
boolean isDependency = false;
boolean isListOfDependencies = false;
Dependency dependency = null;
- Annotation overrideAnnotation = new Annotation("Override",
+ final Annotation overrideAnnotation = new Annotation("Override",
Collections.<Parameter> emptyList());
- List<Annotation> annotations = Lists
+ final List<Annotation> annotations = Lists
.newArrayList(overrideAnnotation);
if (attributeIfc instanceof AbstractDependencyAttribute) {
}
}
- String varName = BindingMapping.getPropertyName(attrEntry.getKey());
+ final String varName = BindingMapping.getPropertyName(attrEntry.getKey());
ModuleField field;
if (isIdentity) {
- String identityBaseClass = getInnerTypeFromIdentity(((TypedAttribute) attributeIfc).getType());
- IdentityRefModuleField identityField = new IdentityRefModuleField(type, varName,
+ final String identityBaseClass = getInnerTypeFromIdentity(((TypedAttribute) attributeIfc).getType());
+ final IdentityRefModuleField identityField = new IdentityRefModuleField(type, varName,
attributeIfc.getUpperCaseCammelCase(), identityBaseClass);
- String getterName = "get"
+ final String getterName = "get"
+ attributeIfc.getUpperCaseCammelCase() + "Identity";
- MethodDefinition additionalGetter = new MethodDefinition(type, getterName, Collections.<Field> emptyList(),
+ final MethodDefinition additionalGetter = new MethodDefinition(type, getterName, Collections.<Field> emptyList(),
Collections.<Annotation> emptyList(), "return " + identityField.getIdentityClassName()
+ ";");
methods.add(additionalGetter);
- String setterName = "set"
+ final String setterName = "set"
+ attributeIfc.getUpperCaseCammelCase();
- String setterBody = "this." + identityField.getIdentityClassName() + " = " + identityField.getIdentityClassName() + ";";
- MethodDefinition additionalSetter = new MethodDefinition("void",
+ final String setterBody = "this." + identityField.getIdentityClassName() + " = " + identityField.getIdentityClassName() + ";";
+ final MethodDefinition additionalSetter = new MethodDefinition("void",
setterName,
Lists.newArrayList(new Field(type, identityField.getIdentityClassName())),
Collections.<Annotation> emptyList(), setterBody);
moduleFields.add(field);
- String getterName = "get"
+ final String getterName = "get"
+ attributeIfc.getUpperCaseCammelCase();
- MethodDefinition getter = new MethodDefinition(type,
+ final MethodDefinition getter = new MethodDefinition(type,
getterName, Collections.<Field> emptyList(),
Lists.newArrayList(overrideAnnotation), "return "
+ varName + ";");
methods.add(getter);
- String setterName = "set"
+ final String setterName = "set"
+ attributeIfc.getUpperCaseCammelCase();
if (attributeIfc.getNullableDescription() != null) {
String setterBody = "this." + varName + " = " + varName + ";";
if (isListOfDependencies) {
- String nullCheck = String.format("if (%s == null) {\n%s = new java.util.ArrayList<>(); \n}%n",
+ final String nullCheck = String.format("if (%s == null) {\n%s = new java.util.ArrayList<>(); \n}%n",
varName, varName);
setterBody = nullCheck + setterBody;
}
- MethodDefinition setter = new MethodDefinition("void",
+ final MethodDefinition setter = new MethodDefinition("void",
setterName,
Lists.newArrayList(new Field(type, varName)),
annotations, setterBody);
}
List<ModuleField> getModuleFields() {
- return holder.moduleFields;
+ return this.holder.moduleFields;
}
List<MethodDefinition> getMethods() {
- return holder.methods;
+ return this.holder.methods;
}
}
return true;
}
if(value instanceof ListAttribute) {
- AttributeIfc innerAttribute = ((ListAttribute) value).getInnerAttribute();
+ final AttributeIfc innerAttribute = ((ListAttribute) value).getInnerAttribute();
return needsDepResolver(innerAttribute);
}
private static String getInnerTypeFromIdentity(final Type type) {
Preconditions.checkArgument(type instanceof ParameterizedType);
- Type[] args = ((ParameterizedType) type).getActualTypeArguments();
+ final Type[] args = ((ParameterizedType) type).getActualTypeArguments();
Preconditions.checkArgument(args.length ==1);
return serializeType(args[0]);
}
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-
import com.google.common.collect.Maps;
import java.util.Collections;
import java.util.Map;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.AbstractFactoryTemplate;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.Type;
public class ModuleMXBeanEntryTemplatesTest {
@Test
public void test() {
- ModuleMXBeanEntry mbe = mockMbe("package");
- AbstractFactoryTemplate template = TemplateFactory
+ final ModuleMXBeanEntry mbe = mockMbe("package");
+ final AbstractFactoryTemplate template = TemplateFactory
.abstractFactoryTemplateFromMbe(mbe);
assertNotNull(template);
}
- public static ModuleMXBeanEntry mockMbe(String packageName) {
- ModuleMXBeanEntry mbe = mock(ModuleMXBeanEntry.class);
- Map<String, AttributeIfc> a = Maps.newHashMap();
- JavaAttribute attr = mockJavaAttr();
+ public static ModuleMXBeanEntry mockMbe(final String packageName) {
+ final ModuleMXBeanEntry mbe = mock(ModuleMXBeanEntry.class);
+ final Map<String, AttributeIfc> a = Maps.newHashMap();
+ final JavaAttribute attr = mockJavaAttr();
a.put("attr1", attr);
doReturn(a).when(mbe).getAttributes();
}
public static JavaAttribute mockJavaAttr() {
- JavaAttribute attr = mock(JavaAttribute.class);
- Type typeA = mock(Type.class);
+ final JavaAttribute attr = mock(JavaAttribute.class);
+ final Type typeA = mock(Type.class);
doReturn("package").when(typeA).getName();
doReturn("type").when(typeA).getPackageName();
doReturn("package.type").when(typeA).getFullyQualifiedName();
import java.util.Map;
import java.util.Map.Entry;
-import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
+import org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil;
import org.opendaylight.yangtools.yang.model.api.Module;
/**
public class PackageTranslator {
private final Map<String, String> namespacePrefixToPackageMap;
- public PackageTranslator(Map<String, String> namespacePrefixToPackageMap) {
+ public PackageTranslator(final Map<String, String> namespacePrefixToPackageMap) {
this.namespacePrefixToPackageMap = namespacePrefixToPackageMap;
}
* @throws IllegalStateException
* if there is no mapping found.
*/
- public String getPackageName(Module module) {
+ public String getPackageName(final Module module) {
Entry<String, String> longestMatch = null;
int longestMatchLength = 0;
- String namespace = module.getNamespace().toString();
- for (Entry<String, String> entry : namespacePrefixToPackageMap
+ final String namespace = module.getNamespace().toString();
+ for (final Entry<String, String> entry : this.namespacePrefixToPackageMap
.entrySet()) {
if (namespace.startsWith(entry.getKey())
- && entry.getKey().length() > longestMatchLength) {
+ && (entry.getKey().length() > longestMatchLength)) {
longestMatch = entry;
longestMatchLength = entry.getKey().length();
}
}
// TODO add to PackageTranslator
- private static String sanitizePackage(String namespace) {
+ private static String sanitizePackage(final String namespace) {
String newNamespace = namespace;
newNamespace = newNamespace.replace("://", ".");
newNamespace = newNamespace.replace("/", ".");
*/
package org.opendaylight.controller.config.yangjmxgenerator;
-import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
-import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.generator.spi.TypeProvider;
+import org.opendaylight.mdsal.binding.generator.util.BindingGeneratorUtil;
+import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
public static String convertToJavaName(final SchemaNode schemaNode,
final boolean capitalizeFirstLetter) {
- for (UnknownSchemaNode unknownNode : schemaNode.getUnknownSchemaNodes()) {
+ for (final UnknownSchemaNode unknownNode : schemaNode.getUnknownSchemaNodes()) {
if (ConfigConstants.JAVA_NAME_PREFIX_EXTENSION_QNAME
.equals(unknownNode.getNodeType())) {
- String value = unknownNode.getNodeParameter();
+ final String value = unknownNode.getNodeParameter();
return convertToJavaName(value, capitalizeFirstLetter);
}
}
}
public Type getType(final LeafSchemaNode leaf) {
- TypeDefinition<?> type = CompatUtils.compatLeafType(leaf);
+ final TypeDefinition<?> type = CompatUtils.compatLeafType(leaf);
return getType(leaf, type);
}
public String getDefault(final LeafSchemaNode node) {
- return typeProvider.getTypeDefaultConstruction(node);
+ return this.typeProvider.getTypeDefaultConstruction(node);
}
public Type getType(final SchemaNode leaf, final TypeDefinition<?> type) {
Type javaType;
try {
- javaType = typeProvider.javaTypeForSchemaDefinitionType(
+ javaType = this.typeProvider.javaTypeForSchemaDefinitionType(
type, leaf);
if (javaType == null) {
throw new IllegalArgumentException("Unknown type received for "
+ leaf.toString());
}
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Error while resolving type of "
+ leaf, e);
}
public Type getType(final LeafListSchemaNode leaf) {
Type javaType;
try {
- javaType = typeProvider.javaTypeForSchemaDefinitionType(
+ javaType = this.typeProvider.javaTypeForSchemaDefinitionType(
leaf.getType(), leaf);
if (javaType == null) {
throw new IllegalArgumentException(
"Unknown type received for " + leaf.toString());
}
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Error while resolving type of "
+ leaf, e);
}
}
public String getJMXParamForBaseType(final TypeDefinition<?> baseType) {
- return typeProvider.getConstructorPropertyName(baseType);
+ return this.typeProvider.getConstructorPropertyName(baseType);
}
public String getJMXParamForUnionInnerType(final TypeDefinition<?> unionInnerType) {
- return typeProvider.getParamNameFromType(unionInnerType);
+ return this.typeProvider.getParamNameFromType(unionInnerType);
}
}
import javax.management.ObjectName;
import javax.management.openmbean.SimpleType;
import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
-import org.opendaylight.yangtools.binding.generator.util.Types;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.generator.util.Types;
+import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
public class DependencyAttribute extends AbstractDependencyAttribute {
- public DependencyAttribute(DataSchemaNode attrNode,
- ServiceInterfaceEntry sie, boolean mandatory,
- String nullableDescription) {
+ public DependencyAttribute(final DataSchemaNode attrNode,
+ final ServiceInterfaceEntry sie, final boolean mandatory,
+ final String nullableDescription) {
super(attrNode, sie, mandatory, nullableDescription);
}
import javax.management.openmbean.SimpleType;
import org.opendaylight.controller.config.api.IdentityAttributeRef;
import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
this.type = typeProviderWrapper.getType(leaf);
this.typeDefinition = leaf.getType();
this.typeProviderWrapper = typeProviderWrapper;
- this.nullableDefault = nullableDefaultWrappedForCode = null;
+ this.nullableDefault = this.nullableDefaultWrappedForCode = null;
this.nullableDescription = leaf.getDescription();
}
public boolean isUnion() {
- TypeDefinition<?> base = getBaseType(typeProviderWrapper, typeDefinition);
+ final TypeDefinition<?> base = getBaseType(this.typeProviderWrapper, this.typeDefinition);
return base instanceof UnionTypeDefinition;
}
public boolean isEnum() {
- TypeDefinition<?> base = getBaseType(typeProviderWrapper, typeDefinition);
+ final TypeDefinition<?> base = getBaseType(this.typeProviderWrapper, this.typeDefinition);
return base instanceof EnumTypeDefinition;
}
public TypeDefinition<?> getTypeDefinition() {
- return typeDefinition;
+ return this.typeDefinition;
}
/**
}
public String getNullableDefaultWrappedForCode() {
- return nullableDefaultWrappedForCode;
+ return this.nullableDefaultWrappedForCode;
}
@Override
public Type getType() {
- return type;
+ return this.type;
}
@Override
public String getNullableDescription() {
- return nullableDescription;
+ return this.nullableDescription;
}
@Override
public String getNullableDefault() {
- return nullableDefault;
+ return this.nullableDefault;
}
@Override
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if ((o == null) || (getClass() != o.getClass())) {
return false;
}
if (!super.equals(o)) {
return false;
}
- JavaAttribute that = (JavaAttribute) o;
+ final JavaAttribute that = (JavaAttribute) o;
- if (nullableDefault != null ? !nullableDefault
+ if (this.nullableDefault != null ? !this.nullableDefault
.equals(that.nullableDefault) : that.nullableDefault != null) {
return false;
}
- if (nullableDescription != null ? !nullableDescription
+ if (this.nullableDescription != null ? !this.nullableDescription
.equals(that.nullableDescription)
: that.nullableDescription != null) {
return false;
}
- if (type != null ? !type.equals(that.type) : that.type != null) {
+ if (this.type != null ? !this.type.equals(that.type) : that.type != null) {
return false;
}
@Override
public int hashCode() {
int result = super.hashCode();
- result = 31 * result + (type != null ? type.hashCode() : 0);
- result = 31
- * result
- + (nullableDescription != null ? nullableDescription.hashCode()
+ result = (31 * result) + (this.type != null ? this.type.hashCode() : 0);
+ result = (31
+ * result)
+ + (this.nullableDescription != null ? this.nullableDescription.hashCode()
: 0);
- result = 31 * result
- + (nullableDefault != null ? nullableDefault.hashCode() : 0);
+ result = (31 * result)
+ + (this.nullableDefault != null ? this.nullableDefault.hashCode() : 0);
return result;
}
@Override
public String toString() {
- return "JavaAttribute{" + getAttributeYangName() + "," + "type=" + type
+ return "JavaAttribute{" + getAttributeYangName() + "," + "type=" + this.type
+ '}';
}
@Override
public OpenType<?> getOpenType() {
- TypeDefinition<?> baseTypeDefinition = getBaseType(typeProviderWrapper, typeDefinition);
- Type baseType = typeProviderWrapper.getType(baseTypeDefinition, baseTypeDefinition);
+ final TypeDefinition<?> baseTypeDefinition = getBaseType(this.typeProviderWrapper, this.typeDefinition);
+ final Type baseType = this.typeProviderWrapper.getType(baseTypeDefinition, baseTypeDefinition);
if (isArray()) {
return getArrayType();
}
private OpenType<?> getEnumType(final TypeDefinition<?> baseType) {
- final String fullyQualifiedName = typeProviderWrapper.getType(node, getTypeDefinition()).getFullyQualifiedName();
+ final String fullyQualifiedName = this.typeProviderWrapper.getType(this.node, getTypeDefinition()).getFullyQualifiedName();
final String[] items = {"instance"};
- String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
+ final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
try {
return new CompositeType(fullyQualifiedName, description, items, items, new OpenType[]{SimpleType.STRING});
- } catch (OpenDataException e) {
+ } catch (final OpenDataException e) {
throw new RuntimeException("Unable to create enum type" + fullyQualifiedName + " as open type", e);
}
}
public boolean isIdentityRef() {
- return typeDefinition instanceof IdentityrefTypeDefinition;
+ return this.typeDefinition instanceof IdentityrefTypeDefinition;
}
private OpenType<?> getCompositeTypeForUnion(final TypeDefinition<?> baseTypeDefinition) {
Preconditions.checkArgument(baseTypeDefinition instanceof UnionTypeDefinition,
"Expected %s instance but was %s", UnionTypeDefinition.class, baseTypeDefinition);
- List<TypeDefinition<?>> types = ((UnionTypeDefinition) baseTypeDefinition).getTypes();
+ final List<TypeDefinition<?>> types = ((UnionTypeDefinition) baseTypeDefinition).getTypes();
- String[] itemNames = new String[types.size()+1];
- OpenType<?>[] itemTypes = new OpenType[itemNames.length];
+ final String[] itemNames = new String[types.size()+1];
+ final OpenType<?>[] itemTypes = new OpenType[itemNames.length];
addArtificialPropertyToUnionCompositeType(baseTypeDefinition, itemNames, itemTypes);
- String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
+ final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
int i = 1;
- for (TypeDefinition<?> innerTypeDefinition : types) {
+ for (final TypeDefinition<?> innerTypeDefinition : types) {
- Type innerType = typeProviderWrapper.getType(innerTypeDefinition, innerTypeDefinition);
+ final Type innerType = this.typeProviderWrapper.getType(innerTypeDefinition, innerTypeDefinition);
- TypeDefinition<?> baseInnerTypeDefinition = getBaseType(typeProviderWrapper, innerTypeDefinition);
- Type innerTypeBaseType = typeProviderWrapper.getType(baseInnerTypeDefinition, baseInnerTypeDefinition);
+ final TypeDefinition<?> baseInnerTypeDefinition = getBaseType(this.typeProviderWrapper, innerTypeDefinition);
+ final Type innerTypeBaseType = this.typeProviderWrapper.getType(baseInnerTypeDefinition, baseInnerTypeDefinition);
OpenType<?> innerCompositeType;
innerCompositeType = SimpleTypeResolver.getSimpleType(innerType);
}
- itemNames[i] = typeProviderWrapper.getJMXParamForUnionInnerType(innerTypeDefinition);
+ itemNames[i] = this.typeProviderWrapper.getJMXParamForUnionInnerType(innerTypeDefinition);
itemTypes[i++] = innerCompositeType;
}
- String[] descriptions = itemNames.clone();
+ final String[] descriptions = itemNames.clone();
descriptions[0] = DESCRIPTION_OF_VALUE_ATTRIBUTE_FOR_UNION;
try {
return new CompositeType(getUpperCaseCammelCase(), description, itemNames, descriptions, itemTypes);
- } catch (OpenDataException e) {
+ } catch (final OpenDataException e) {
throw new RuntimeException("Unable to create " + CompositeType.class + " with inner elements "
+ Arrays.toString(itemTypes), e);
}
public static final Class<Character> TYPE_OF_ARTIFICIAL_UNION_PROPERTY = char.class;
private void addArtificialPropertyToUnionCompositeType(final TypeDefinition<?> baseTypeDefinition, final String[] itemNames, final OpenType<?>[] itemTypes) {
- String artificialPropertyName = typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition);
+ final String artificialPropertyName = this.typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition);
itemNames[0] = artificialPropertyName;
- OpenType<?> artificialPropertyType = getArrayOpenTypeForSimpleType(TYPE_OF_ARTIFICIAL_UNION_PROPERTY.getName(),
+ final OpenType<?> artificialPropertyType = getArrayOpenTypeForSimpleType(TYPE_OF_ARTIFICIAL_UNION_PROPERTY.getName(),
SimpleTypeResolver.getSimpleType(TYPE_OF_ARTIFICIAL_UNION_PROPERTY.getName()));
itemTypes[0] = artificialPropertyType;
}
private OpenType<?> getSimpleType(final Type type) {
- SimpleType<?> simpleType = SimpleTypeResolver.getSimpleType(type);
+ final SimpleType<?> simpleType = SimpleTypeResolver.getSimpleType(type);
return simpleType;
}
private OpenType<?> getCompositeType(final Type baseType, final TypeDefinition<?> baseTypeDefinition) {
- SimpleType<?> innerItemType = SimpleTypeResolver.getSimpleType(baseType);
- String innerItemName = typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition);
+ final SimpleType<?> innerItemType = SimpleTypeResolver.getSimpleType(baseType);
+ final String innerItemName = this.typeProviderWrapper.getJMXParamForBaseType(baseTypeDefinition);
- String[] itemNames = new String[]{innerItemName};
- String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
+ final String[] itemNames = new String[]{innerItemName};
+ final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
- OpenType<?>[] itemTypes = new OpenType[]{innerItemType};
+ final OpenType<?>[] itemTypes = new OpenType[]{innerItemType};
try {
return new CompositeType(getUpperCaseCammelCase(), description, itemNames, itemNames, itemTypes);
- } catch (OpenDataException e) {
+ } catch (final OpenDataException e) {
throw new RuntimeException("Unable to create " + CompositeType.class + " with inner element of type "
+ itemTypes, e);
}
}
public OpenType<?> getCompositeTypeForIdentity() {
- String[] itemNames = new String[]{IdentityAttributeRef.QNAME_ATTR_NAME};
- String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
- OpenType<?>[] itemTypes = new OpenType[]{SimpleType.STRING};
+ final String[] itemNames = new String[]{IdentityAttributeRef.QNAME_ATTR_NAME};
+ final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
+ final OpenType<?>[] itemTypes = new OpenType[]{SimpleType.STRING};
try {
return new CompositeType(getUpperCaseCammelCase(), description, itemNames, itemNames, itemTypes);
- } catch (OpenDataException e) {
+ } catch (final OpenDataException e) {
throw new RuntimeException("Unable to create " + CompositeType.class + " with inner element of type "
+ itemTypes, e);
}
}
private OpenType<?> getArrayType() {
- String innerTypeFullyQName = getInnerType(getType());
- SimpleType<?> innerSimpleType = SimpleTypeResolver.getSimpleType(innerTypeFullyQName);
+ final String innerTypeFullyQName = getInnerType(getType());
+ final SimpleType<?> innerSimpleType = SimpleTypeResolver.getSimpleType(innerTypeFullyQName);
return getArrayOpenTypeForSimpleType(innerTypeFullyQName, innerSimpleType);
}
private OpenType<?> getArrayOpenTypeForSimpleType(final String innerTypeFullyQName, final SimpleType<?> innerSimpleType) {
try {
- ArrayType<Object> arrayType = isPrimitive(innerTypeFullyQName) ? new ArrayType<>(innerSimpleType, true)
+ final ArrayType<Object> arrayType = isPrimitive(innerTypeFullyQName) ? new ArrayType<>(innerSimpleType, true)
: new ArrayType<>(1, innerSimpleType);
return arrayType;
- } catch (OpenDataException e) {
+ } catch (final OpenDataException e) {
throw new RuntimeException("Unable to create " + ArrayType.class + " with inner element of type "
+ innerSimpleType, e);
}
}
private boolean isArray() {
- return type.getName().endsWith("[]");
+ return this.type.getName().endsWith("[]");
}
private boolean isDerivedType(final Type baseType, final Type currentType) {
}
private static String getInnerType(final Type type) {
- String fullyQualifiedName = type.getFullyQualifiedName();
+ final String fullyQualifiedName = type.getFullyQualifiedName();
return fullyQualifiedName.substring(0, fullyQualifiedName.length() - 2);
}
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
-import org.opendaylight.yangtools.binding.generator.util.Types;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.generator.util.Types;
+import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
private final String nullableDescription, nullableDefault;
private final TypedAttribute innerAttribute;
- public static ListAttribute create(ListSchemaNode node,
- TypeProviderWrapper typeProvider, String packageName) {
+ public static ListAttribute create(final ListSchemaNode node,
+ final TypeProviderWrapper typeProvider, final String packageName) {
- TOAttribute innerAttribute = TOAttribute.create(node, typeProvider, packageName);
+ final TOAttribute innerAttribute = TOAttribute.create(node, typeProvider, packageName);
return new ListAttribute(node, innerAttribute, node.getDescription());
}
- public static ListAttribute create(LeafListSchemaNode node,
- TypeProviderWrapper typeProvider) {
+ public static ListAttribute create(final LeafListSchemaNode node,
+ final TypeProviderWrapper typeProvider) {
- JavaAttribute innerAttribute = new JavaAttribute(node, typeProvider);
+ final JavaAttribute innerAttribute = new JavaAttribute(node, typeProvider);
return new ListAttribute(node, innerAttribute, node.getDescription());
}
- ListAttribute(DataSchemaNode attrNode, TypedAttribute innerAttribute,
- String description) {
+ ListAttribute(final DataSchemaNode attrNode, final TypedAttribute innerAttribute,
+ final String description) {
super(attrNode);
this.nullableDescription = description;
this.innerAttribute = innerAttribute;
@Override
public String getNullableDescription() {
- return nullableDescription;
+ return this.nullableDescription;
}
@Override
public String getNullableDefault() {
- return nullableDefault;
+ return this.nullableDefault;
}
public AttributeIfc getInnerAttribute() {
- return innerAttribute;
+ return this.innerAttribute;
}
@Override
public String toString() {
return "ListAttribute{" + getAttributeYangName() + "," + "to="
- + innerAttribute + '}';
+ + this.innerAttribute + '}';
}
@Override
public int hashCode() {
int result = super.hashCode();
- result = 31
- * result
- + (nullableDescription != null ? nullableDescription.hashCode()
+ result = (31
+ * result)
+ + (this.nullableDescription != null ? this.nullableDescription.hashCode()
: 0);
- result = 31 * result
- + (nullableDefault != null ? nullableDefault.hashCode() : 0);
+ result = (31 * result)
+ + (this.nullableDefault != null ? this.nullableDefault.hashCode() : 0);
return result;
}
@Override
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if ((o == null) || (getClass() != o.getClass())) {
return false;
}
if (!super.equals(o)) {
return false;
}
- ListAttribute that = (ListAttribute) o;
+ final ListAttribute that = (ListAttribute) o;
- if (nullableDefault != null ? !nullableDefault
+ if (this.nullableDefault != null ? !this.nullableDefault
.equals(that.nullableDefault) : that.nullableDefault != null) {
return false;
}
- if (nullableDescription != null ? !nullableDescription
+ if (this.nullableDescription != null ? !this.nullableDescription
.equals(that.nullableDescription)
: that.nullableDescription != null) {
return false;
@Override
public Type getType() {
- return Types.parameterizedTypeFor(Types.typeForClass(List.class), innerAttribute.getType());
+ return Types.parameterizedTypeFor(Types.typeForClass(List.class), this.innerAttribute.getType());
}
@Override
public ArrayType<?> getOpenType() {
- OpenType<?> innerOpenType = innerAttribute.getOpenType();
+ final OpenType<?> innerOpenType = this.innerAttribute.getOpenType();
return constructArrayType(innerOpenType);
}
- static ArrayType<?> constructArrayType(OpenType<?> innerOpenType){
+ static ArrayType<?> constructArrayType(final OpenType<?> innerOpenType){
try {
return new ArrayType<>(1, innerOpenType);
- } catch (OpenDataException e) {
+ } catch (final OpenDataException e) {
throw new RuntimeException("Unable to create " + ArrayType.class
+ " with inner element of type " + innerOpenType, e);
}
import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
-import org.opendaylight.yangtools.binding.generator.util.Types;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.generator.util.Types;
+import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
public class ListDependenciesAttribute extends AbstractDependencyAttribute {
- public ListDependenciesAttribute(DataSchemaNode attrNode, ServiceInterfaceEntry sie, boolean mandatory, String nullableDescription) {
+ public ListDependenciesAttribute(final DataSchemaNode attrNode, final ServiceInterfaceEntry sie, final boolean mandatory, final String nullableDescription) {
super(attrNode, sie, mandatory, nullableDescription);
}
@Override
public ArrayType<?> getOpenType() {
- OpenType<?> innerOpenType = SimpleType.OBJECTNAME;
+ final OpenType<?> innerOpenType = SimpleType.OBJECTNAME;
return ListAttribute.constructArrayType(innerOpenType);
}
import java.util.Date;
import java.util.Map;
import javax.management.openmbean.SimpleType;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.Type;
public class SimpleTypeResolver {
private SimpleTypeResolver() {
}
- public static SimpleType<?> getSimpleType(Type type) {
- SimpleType<?> expectedSimpleType = JAVA_TYPE_TO_SIMPLE_TYPE.get(type
+ public static SimpleType<?> getSimpleType(final Type type) {
+ final SimpleType<?> expectedSimpleType = JAVA_TYPE_TO_SIMPLE_TYPE.get(type
.getFullyQualifiedName());
Preconditions.checkState(expectedSimpleType != null,
"Cannot find simple type for " + type.getFullyQualifiedName());
return expectedSimpleType;
}
- public static boolean canResolve(Type type) {
+ public static boolean canResolve(final Type type) {
return JAVA_TYPE_TO_SIMPLE_TYPE.containsKey(type.getFullyQualifiedName());
}
- public static SimpleType<?> getSimpleType(String fullyQualifiedName) {
- SimpleType<?> expectedSimpleType = JAVA_TYPE_TO_SIMPLE_TYPE
+ public static SimpleType<?> getSimpleType(final String fullyQualifiedName) {
+ final SimpleType<?> expectedSimpleType = JAVA_TYPE_TO_SIMPLE_TYPE
.get(fullyQualifiedName);
Preconditions.checkState(expectedSimpleType != null,
"Cannot find simple type for " + fullyQualifiedName);
import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.OpenType;
import org.opendaylight.controller.config.yangjmxgenerator.TypeProviderWrapper;
-import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.generator.util.ReferencedTypeImpl;
+import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
}
public static <T extends DataNodeContainer & AugmentationTarget & DataSchemaNode> TOAttribute create(
- T containerSchemaNode, TypeProviderWrapper typeProviderWrapper, String packageName) {
+ final T containerSchemaNode, final TypeProviderWrapper typeProviderWrapper, final String packageName) {
// Transfer Object: get the leaves
- Map<String, AttributeIfc> map = new HashMap<>();
- Map<String, String> attributeNameMap = new HashMap<>();
- for (DataSchemaNode dataSchemaNode : containerSchemaNode
+ final Map<String, AttributeIfc> map = new HashMap<>();
+ final Map<String, String> attributeNameMap = new HashMap<>();
+ for (final DataSchemaNode dataSchemaNode : containerSchemaNode
.getChildNodes()) {
try {
- String yangName = dataSchemaNode.getQName().getLocalName();
+ final String yangName = dataSchemaNode.getQName().getLocalName();
map.put(yangName,
createInnerAttribute(dataSchemaNode,
typeProviderWrapper, packageName));
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
throw new IllegalStateException("Unable to create TO", e);
}
}
}
private static AttributeIfc createInnerAttribute(
- DataSchemaNode dataSchemaNode,
- TypeProviderWrapper typeProviderWrapper, String packageName) {
- Class<? extends DataSchemaNode> type = isAllowedType(dataSchemaNode);
+ final DataSchemaNode dataSchemaNode,
+ final TypeProviderWrapper typeProviderWrapper, final String packageName) {
+ final Class<? extends DataSchemaNode> type = isAllowedType(dataSchemaNode);
if (type.equals(LeafSchemaNode.class)) {
return new JavaAttribute((LeafSchemaNode) dataSchemaNode,
}
private static Class<? extends DataSchemaNode> isAllowedType(
- DataSchemaNode dataSchemaNode) {
- for (Class<? extends DataSchemaNode> allowedType : ALLOWED_CHILDREN) {
+ final DataSchemaNode dataSchemaNode) {
+ for (final Class<? extends DataSchemaNode> allowedType : ALLOWED_CHILDREN) {
if (allowedType.isAssignableFrom(dataSchemaNode.getClass()) == true) {
return allowedType;
}
+ ALLOWED_CHILDREN);
}
- private TOAttribute(DataSchemaNode attrNode,
- Map<String, AttributeIfc> transferObject,
- Map<String, String> attributeNameMap, String nullableDescription, String packageName) {
+ private TOAttribute(final DataSchemaNode attrNode,
+ final Map<String, AttributeIfc> transferObject,
+ final Map<String, String> attributeNameMap, final String nullableDescription, final String packageName) {
super(attrNode);
- yangNameToAttributeMap = transferObject;
+ this.yangNameToAttributeMap = transferObject;
this.attributeNameMap = attributeNameMap;
this.nullableDescription = nullableDescription;
- nullableDefault = null;
+ this.nullableDefault = null;
this.packageName = packageName;
}
public Map<String, String> getAttributeNameMap() {
- return attributeNameMap;
+ return this.attributeNameMap;
}
public Map<String, AttributeIfc> getCapitalizedPropertiesToTypesMap() {
- Map<String, AttributeIfc> capitalizedPropertiesToTypesMap = Maps
+ final Map<String, AttributeIfc> capitalizedPropertiesToTypesMap = Maps
.newHashMap();
- for (Entry<String, AttributeIfc> entry : yangNameToAttributeMap
+ for (final Entry<String, AttributeIfc> entry : this.yangNameToAttributeMap
.entrySet()) {
capitalizedPropertiesToTypesMap.put(
}
public Map<String, AttributeIfc> getJmxPropertiesToTypesMap() {
- Map<String, AttributeIfc> jmxPropertiesToTypesMap = Maps.newHashMap();
- for (Entry<String, AttributeIfc> entry : yangNameToAttributeMap
+ final Map<String, AttributeIfc> jmxPropertiesToTypesMap = Maps.newHashMap();
+ for (final Entry<String, AttributeIfc> entry : this.yangNameToAttributeMap
.entrySet()) {
jmxPropertiesToTypesMap.put(
}
public Map<String, AttributeIfc> getYangPropertiesToTypesMap() {
- return yangNameToAttributeMap;
+ return this.yangNameToAttributeMap;
}
@Override
public String getNullableDescription() {
- return nullableDescription;
+ return this.nullableDescription;
}
@Override
public String getNullableDefault() {
- return nullableDefault;
+ return this.nullableDefault;
}
@Override
- public boolean equals(Object o) {
+ public boolean equals(final Object o) {
if (this == o) {
return true;
}
- if (o == null || getClass() != o.getClass()) {
+ if ((o == null) || (getClass() != o.getClass())) {
return false;
}
if (!super.equals(o)) {
return false;
}
- TOAttribute that = (TOAttribute) o;
+ final TOAttribute that = (TOAttribute) o;
- if (nullableDefault != null ? !nullableDefault
+ if (this.nullableDefault != null ? !this.nullableDefault
.equals(that.nullableDefault) : that.nullableDefault != null) {
return false;
}
- if (nullableDescription != null ? !nullableDescription
+ if (this.nullableDescription != null ? !this.nullableDescription
.equals(that.nullableDescription)
: that.nullableDescription != null) {
return false;
}
- if (yangNameToAttributeMap != null ? !yangNameToAttributeMap
+ if (this.yangNameToAttributeMap != null ? !this.yangNameToAttributeMap
.equals(that.yangNameToAttributeMap)
: that.yangNameToAttributeMap != null) {
return false;
@Override
public int hashCode() {
int result = super.hashCode();
- result = 31
- * result
- + (nullableDescription != null ? nullableDescription.hashCode()
+ result = (31
+ * result)
+ + (this.nullableDescription != null ? this.nullableDescription.hashCode()
: 0);
- result = 31 * result
- + (nullableDefault != null ? nullableDefault.hashCode() : 0);
- result = 31
- * result
- + (yangNameToAttributeMap != null ? yangNameToAttributeMap
+ result = (31 * result)
+ + (this.nullableDefault != null ? this.nullableDefault.hashCode() : 0);
+ result = (31
+ * result)
+ + (this.yangNameToAttributeMap != null ? this.yangNameToAttributeMap
.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "TOAttribute{" + getAttributeYangName() + "," + "to="
- + yangNameToAttributeMap + '}';
+ + this.yangNameToAttributeMap + '}';
}
@Override
public Type getType() {
// TODO: ReferencedTypeImpl from Types
- return new ReferencedTypeImpl(packageName, getUpperCaseCammelCase());
+ return new ReferencedTypeImpl(this.packageName, getUpperCaseCammelCase());
}
@Override
public CompositeType getOpenType() {
- String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
+ final String description = getNullableDescription() == null ? getAttributeYangName() : getNullableDescription();
- FunctionImpl functionImpl = new FunctionImpl();
- Map<String, AttributeIfc> jmxPropertiesToTypesMap = getJmxPropertiesToTypesMap();
- OpenType<?>[] itemTypes = Collections2.transform(
+ final FunctionImpl functionImpl = new FunctionImpl();
+ final Map<String, AttributeIfc> jmxPropertiesToTypesMap = getJmxPropertiesToTypesMap();
+ final OpenType<?>[] itemTypes = Collections2.transform(
jmxPropertiesToTypesMap.entrySet(), functionImpl).toArray(
new OpenType<?>[] {});
- String[] itemNames = functionImpl.getItemNames();
+ final String[] itemNames = functionImpl.getItemNames();
try {
// TODO add package name to create fully qualified name for this
// type
- CompositeType compositeType = new CompositeType(
+ final CompositeType compositeType = new CompositeType(
getUpperCaseCammelCase(), description, itemNames,
itemNames, itemTypes);
return compositeType;
- } catch (OpenDataException e) {
+ } catch (final OpenDataException e) {
throw new RuntimeException("Unable to create CompositeType for "
+ this, e);
}
}
public String getPackageName() {
- return packageName;
+ return this.packageName;
}
}
private final List<String> itemNames = new ArrayList<>();
@Override
- public OpenType<?> apply(Entry<String, AttributeIfc> input) {
- AttributeIfc innerType = input.getValue();
- itemNames.add(input.getKey());
+ public OpenType<?> apply(final Entry<String, AttributeIfc> input) {
+ final AttributeIfc innerType = input.getValue();
+ this.itemNames.add(input.getKey());
return innerType.getOpenType();
}
public String[] getItemNames(){
- return itemNames.toArray(new String[itemNames.size()]);
+ return this.itemNames.toArray(new String[this.itemNames.size()]);
}
}
*/
package org.opendaylight.controller.config.yangjmxgenerator.attribute;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.Type;
public interface TypedAttribute extends AttributeIfc {
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
-
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import java.io.InputStream;
import org.junit.Assert;
import org.junit.Before;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils;
-import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
@Before
public void loadYangFiles() throws Exception {
- List<InputStream> yangISs = new ArrayList<>();
+ final List<InputStream> yangISs = new ArrayList<>();
yangISs.addAll(getStreams("/test-config-threads.yang",
"/test-config-threads-java.yang",
"/config-bgp-listener-impl.yang", "/ietf-inet-types.yang",
yangISs.addAll(getConfigApiYangInputStreams());
- context = YangParserTestUtils.parseYangStreams(yangISs);
+ this.context = YangParserTestUtils.parseYangStreams(yangISs);
// close ISs
- for (InputStream is : yangISs) {
+ for (final InputStream is : yangISs) {
is.close();
}
- namesToModules = YangModelSearchUtils.mapModulesByNames(context
+ this.namesToModules = YangModelSearchUtils.mapModulesByNames(this.context
.getModules());
- configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
- rpcContextModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
- threadsModule = namesToModules
+ this.configModule = this.namesToModules.get(ConfigConstants.CONFIG_MODULE);
+ this.rpcContextModule = this.namesToModules.get(ConfigConstants.CONFIG_MODULE);
+ this.threadsModule = this.namesToModules
.get(ConfigConstants.CONFIG_THREADS_MODULE);
- threadsJavaModule = namesToModules.get("config-threads-java");
- bgpListenerJavaModule = namesToModules.get("config-bgp-listener-impl");
- ietfInetTypesModule = namesToModules
+ this.threadsJavaModule = this.namesToModules.get("config-threads-java");
+ this.bgpListenerJavaModule = this.namesToModules.get("config-bgp-listener-impl");
+ this.ietfInetTypesModule = this.namesToModules
.get(ConfigConstants.IETF_INET_TYPES);
- jmxModule = namesToModules.get("config-jmx-it");
- jmxImplModule = namesToModules.get("config-jmx-it-impl");
- testFilesModule = namesToModules.get("test-config-files");
- testFiles1Module = namesToModules.get("test-config-files1");
+ this.jmxModule = this.namesToModules.get("config-jmx-it");
+ this.jmxImplModule = this.namesToModules.get("config-jmx-it-impl");
+ this.testFilesModule = this.namesToModules.get("test-config-files");
+ this.testFiles1Module = this.namesToModules.get("test-config-files1");
}
}
public Map<QName, IdentitySchemaNode> mapIdentitiesByQNames(final Module module) {
- Map<QName, IdentitySchemaNode> result = new HashMap<>();
- for (IdentitySchemaNode identitySchemaNode : module.getIdentities()) {
- QName qName = identitySchemaNode.getQName();
+ final Map<QName, IdentitySchemaNode> result = new HashMap<>();
+ for (final IdentitySchemaNode identitySchemaNode : module.getIdentities()) {
+ final QName qName = identitySchemaNode.getQName();
Preconditions.checkArgument(
result.containsKey(qName) == false,
"Two identities of %s contain same qname %s",
}
protected static List<InputStream> getStreams(final String... paths) {
- List<InputStream> result = new ArrayList<>();
- for (String path : paths) {
- InputStream is = AbstractYangTest.class.getResourceAsStream(path);
+ final List<InputStream> result = new ArrayList<>();
+ for (final String path : paths) {
+ final InputStream is = AbstractYangTest.class.getResourceAsStream(path);
assertNotNull(path + " is null", is);
result.add(is);
}
}
protected Map<QName, ServiceInterfaceEntry> loadThreadsServiceInterfaceEntries(final String packageName) {
- Map<IdentitySchemaNode, ServiceInterfaceEntry> identitiesToSIs = new HashMap<>();
- return ServiceInterfaceEntry.create(threadsModule, packageName,identitiesToSIs);
+ final Map<IdentitySchemaNode, ServiceInterfaceEntry> identitiesToSIs = new HashMap<>();
+ return ServiceInterfaceEntry.create(this.threadsModule, packageName,identitiesToSIs);
}
protected Map<String /* identity local name */, ModuleMXBeanEntry> loadThreadsJava(
final Map<QName, ServiceInterfaceEntry> modulesToSIEs, final String packageName) {
- Map<String /* identity local name */, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry
- .create(threadsJavaModule, modulesToSIEs, context, new TypeProviderWrapper(new TypeProviderImpl
- (context)), packageName);
+ final Map<String /* identity local name */, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry
+ .create(this.threadsJavaModule, modulesToSIEs, this.context, new TypeProviderWrapper(new TypeProviderImpl
+ (this.context)), packageName);
Assert.assertNotNull(namesToMBEs);
- Set<String> expectedMXBeanNames = Sets.newHashSet(EVENTBUS_MXB_NAME,
+ final Set<String> expectedMXBeanNames = Sets.newHashSet(EVENTBUS_MXB_NAME,
ASYNC_EVENTBUS_MXB_NAME, THREADFACTORY_NAMING_MXB_NAME,
THREADPOOL_DYNAMIC_MXB_NAME, THREADPOOL_REGISTRY_IMPL_NAME);
assertThat(namesToMBEs.keySet(), is(expectedMXBeanNames));
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-
import com.google.common.base.Preconditions;
import java.io.File;
import java.io.FileInputStream;
import org.junit.Test;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.NameConflictException;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.YangModelSearchUtils;
-import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
prepareSamples();
prepareExceptionAssertions();
- for (Map.Entry<File, String> currentTestEntry : testedFilesToYangModules
+ for (final Map.Entry<File, String> currentTestEntry : this.testedFilesToYangModules
.entrySet()) {
final String moduleName = currentTestEntry.getValue();
final File yangFile = currentTestEntry.getKey();
- Module testedModule = loadYangs(yangFile, moduleName);
+ final Module testedModule = loadYangs(yangFile, moduleName);
try {
LOG.debug("Testing {}", yangFile);
ModuleMXBeanEntry.create(testedModule,
- new HashMap<>(), context,
- new TypeProviderWrapper(new TypeProviderImpl(context)),
+ new HashMap<>(), this.context,
+ new TypeProviderWrapper(new TypeProviderImpl(this.context)),
PACKAGE_NAME);
fail(yangFile.toString()
+ " did not cause a name conflict and should");
- } catch (NameConflictException e) {
+ } catch (final NameConflictException e) {
assertEquals(
- testedYangModulesToExpectedConflictingName
+ this.testedYangModulesToExpectedConflictingName
.get(moduleName),
e.getConflictingName());
}
}
private void prepareSamples() {
- File first = new File(getClass().getResource(
+ final File first = new File(getClass().getResource(
"/duplicates/config-test-duplicate-attribute-in-list.yang")
.getFile());
- File dir = first.getParentFile();
+ final File dir = first.getParentFile();
- for (File testYang : dir.listFiles()) {
- String moduleName = getYangModuleName(testYang.getName());
- testedFilesToYangModules.put(testYang, moduleName);
+ for (final File testYang : dir.listFiles()) {
+ final String moduleName = getYangModuleName(testYang.getName());
+ this.testedFilesToYangModules.put(testYang, moduleName);
}
}
private void prepareExceptionAssertions() {
- testedYangModulesToExpectedConflictingName.put(
+ this.testedYangModulesToExpectedConflictingName.put(
"config-test-duplicate-attribute", "DtoA");
- testedYangModulesToExpectedConflictingName.put(
+ this.testedYangModulesToExpectedConflictingName.put(
"config-test-duplicate-attribute-in-list", "DtoA");
- testedYangModulesToExpectedConflictingName.put(
+ this.testedYangModulesToExpectedConflictingName.put(
"config-test-duplicate-attribute-runtime-bean", "DtoA");
- testedYangModulesToExpectedConflictingName.put(
+ this.testedYangModulesToExpectedConflictingName.put(
"config-test-generated-attributes-name-conflict", "StateB");
- testedYangModulesToExpectedConflictingName.put(
+ this.testedYangModulesToExpectedConflictingName.put(
"config-test-runtime-bean-list-name-conflict",
"StateARuntimeMXBean");
- testedYangModulesToExpectedConflictingName.put(
+ this.testedYangModulesToExpectedConflictingName.put(
"config-test-runtime-bean-list-name-conflict2",
"StateARuntimeMXBean");
- testedYangModulesToExpectedConflictingName
+ this.testedYangModulesToExpectedConflictingName
.put("config-test-runtime-bean-name-conflict", "StateARuntimeMXBean");
- testedYangModulesToExpectedConflictingName.put(
+ this.testedYangModulesToExpectedConflictingName.put(
"config-test-runtime-bean-name-conflict2",
"StateARuntimeMXBean");
- testedYangModulesToExpectedConflictingName.put(
+ this.testedYangModulesToExpectedConflictingName.put(
"config-test-duplicate-attribute-in-runtime-and-mxbean",
"port");
}
private static String getYangModuleName(final String name) {
- int startIndex = 0;
- int endIndex = name.indexOf(".yang");
+ final int startIndex = 0;
+ final int endIndex = name.indexOf(".yang");
return name.substring(startIndex, endIndex);
}
private Module loadYangs(final File testedModule, final String moduleName)
throws Exception {
- List<InputStream> yangISs = new ArrayList<>();
+ final List<InputStream> yangISs = new ArrayList<>();
yangISs.addAll(getStreams("/ietf-inet-types.yang"));
yangISs.add(new FileInputStream(testedModule));
yangISs.addAll(getConfigApiYangInputStreams());
- context = YangParserTestUtils.parseYangStreams(yangISs);
+ this.context = YangParserTestUtils.parseYangStreams(yangISs);
// close ISs
- for (InputStream is : yangISs) {
+ for (final InputStream is : yangISs) {
is.close();
}
- namesToModules = YangModelSearchUtils.mapModulesByNames(context
+ this.namesToModules = YangModelSearchUtils.mapModulesByNames(this.context
.getModules());
- configModule = namesToModules.get(ConfigConstants.CONFIG_MODULE);
- final Module module = namesToModules.get(moduleName);
+ this.configModule = this.namesToModules.get(ConfigConstants.CONFIG_MODULE);
+ final Module module = this.namesToModules.get(moduleName);
Preconditions.checkNotNull(module, "Cannot get module %s from %s",
- moduleName, namesToModules.keySet());
+ moduleName, this.namesToModules.keySet());
return module;
}
import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.TypedAttribute;
-import org.opendaylight.yangtools.binding.generator.util.Types;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.mdsal.binding.generator.util.Types;
+import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
try {
THREADS_NAMESPACE = new URI(ConfigConstants.CONFIG_NAMESPACE
+ ":threads");
- } catch (URISyntaxException e) {
+ } catch (final URISyntaxException e) {
throw new Error(e);
}
- SimpleDateFormat revisionFormat = new SimpleDateFormat("yyyy-MM-dd");
+ final SimpleDateFormat revisionFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
THREADS_REVISION_DATE = revisionFormat.parse("2013-04-09");
- } catch (ParseException e) {
+ } catch (final ParseException e) {
throw new Error(e);
}
}
@Before
public void setUp() {
- modulesToSIEs = loadThreadsServiceInterfaceEntries("packages.sis");
+ this.modulesToSIEs = loadThreadsServiceInterfaceEntries("packages.sis");
}
protected Map<String /* identity local name */, ModuleMXBeanEntry> loadThreadsJava() {
- return loadThreadsJava(modulesToSIEs, PACKAGE_NAME);
+ return loadThreadsJava(this.modulesToSIEs, PACKAGE_NAME);
}
@Test
public void test_jmxImplModule() {
- Map<IdentitySchemaNode, ServiceInterfaceEntry> identitiesToSIs = new HashMap<>();
- Map<QName, ServiceInterfaceEntry> modulesToSIEs = ServiceInterfaceEntry
- .create(threadsModule, PACKAGE_NAME,identitiesToSIs);
- modulesToSIEs.putAll(ServiceInterfaceEntry.create(jmxModule,
+ final Map<IdentitySchemaNode, ServiceInterfaceEntry> identitiesToSIs = new HashMap<>();
+ final Map<QName, ServiceInterfaceEntry> modulesToSIEs = ServiceInterfaceEntry
+ .create(this.threadsModule, PACKAGE_NAME,identitiesToSIs);
+ modulesToSIEs.putAll(ServiceInterfaceEntry.create(this.jmxModule,
PACKAGE_NAME,identitiesToSIs));
- Map<String /* identity local name */, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry
- .create(jmxImplModule, modulesToSIEs, context, new TypeProviderWrapper(new TypeProviderImpl(context))
+ final Map<String /* identity local name */, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry
+ .create(this.jmxImplModule, modulesToSIEs, this.context, new TypeProviderWrapper(new TypeProviderImpl(this.context))
, PACKAGE_NAME);
- Map<String, AttributeIfc> attributes = namesToMBEs.get("impl-netconf")
+ final Map<String, AttributeIfc> attributes = namesToMBEs.get("impl-netconf")
.getAttributes();
assertCorrectAttributesSize(namesToMBEs, attributes);
//
- DependencyAttribute threadFactoryAttribute = (DependencyAttribute) attributes
+ final DependencyAttribute threadFactoryAttribute = (DependencyAttribute) attributes
.get("thread-factory");
assertNotNull(threadFactoryAttribute);
assertFalse(threadFactoryAttribute.getDependency().isMandatory());
protected RuntimeBeanEntry findFirstByYangName(
final Collection<RuntimeBeanEntry> runtimeBeans, final String yangName) {
- for (RuntimeBeanEntry rb : runtimeBeans) {
+ for (final RuntimeBeanEntry rb : runtimeBeans) {
if (yangName.equals(rb.getYangName())) {
return rb;
}
}
protected RuntimeBeanEntry findFirstByNamePrefix(final Collection<RuntimeBeanEntry> runtimeBeans, final String namePrefix) {
- for (RuntimeBeanEntry rb : runtimeBeans) {
+ for (final RuntimeBeanEntry rb : runtimeBeans) {
if (namePrefix.equals(rb.getJavaNamePrefix())) {
return rb;
}
}
private void assertMatches(final String prefix, final String input) {
- RevisionAwareXPath whenConstraint = mock(RevisionAwareXPath.class);
+ final RevisionAwareXPath whenConstraint = mock(RevisionAwareXPath.class);
doReturn(input).when(whenConstraint).toString();
- Matcher output = ModuleMXBeanEntryBuilder.getWhenConditionMatcher(prefix,
+ final Matcher output = ModuleMXBeanEntryBuilder.getWhenConditionMatcher(prefix,
whenConstraint);
assertTrue(output.matches());
assertEquals("threadpool-dynamic", output.group(1));
@Test
public void testThreadsJava() {
- Map<String /* identity local name */, ModuleMXBeanEntry> namesToMBEs = loadThreadsJava();
+ final Map<String /* identity local name */, ModuleMXBeanEntry> namesToMBEs = loadThreadsJava();
{ // check threadpool-dynamic
- ModuleMXBeanEntry dynamicThreadPool = namesToMBEs
+ final ModuleMXBeanEntry dynamicThreadPool = namesToMBEs
.get(THREADPOOL_DYNAMIC_MXB_NAME);
- Map<String, AttributeIfc> attributes = dynamicThreadPool
+ final Map<String, AttributeIfc> attributes = dynamicThreadPool
.getAttributes();
// core-size, keepalive, maximum-size
// threadfactory
- Set<String> longAttribs = Sets.newHashSet("core-size",
+ final Set<String> longAttribs = Sets.newHashSet("core-size",
"maximum-size");
- for (String longAttrib : longAttribs) {
+ for (final String longAttrib : longAttribs) {
- TypedAttribute attribute = (TypedAttribute) attributes
+ final TypedAttribute attribute = (TypedAttribute) attributes
.get(longAttrib);
assertThat("Failed to check " + longAttrib,
attribute.getType(),
is((Type) Types.typeForClass(Long.class)));
}
// check dependency on thread factory
- QName threadfactoryQName = QName.create(THREADS_NAMESPACE,
+ final QName threadfactoryQName = QName.create(THREADS_NAMESPACE,
THREADS_REVISION_DATE, "threadfactory");
- ServiceInterfaceEntry threadFactorySIEntry = modulesToSIEs
+ final ServiceInterfaceEntry threadFactorySIEntry = this.modulesToSIEs
.get(threadfactoryQName);
assertNotNull(threadFactorySIEntry);
- boolean expectedMandatory = true;
- TypedAttribute actualThreadFactory = (TypedAttribute) attributes
+ final boolean expectedMandatory = true;
+ final TypedAttribute actualThreadFactory = (TypedAttribute) attributes
.get("threadfactory");
- DataSchemaNode mockedDataSchemaNode = mock(DataSchemaNode.class);
+ final DataSchemaNode mockedDataSchemaNode = mock(DataSchemaNode.class);
doReturn(Collections.emptyList()).when(mockedDataSchemaNode)
.getUnknownSchemaNodes();
doReturn(threadfactoryQName).when(mockedDataSchemaNode).getQName();
- AttributeIfc expectedDependencyAttribute = new DependencyAttribute(
+ final AttributeIfc expectedDependencyAttribute = new DependencyAttribute(
mockedDataSchemaNode, threadFactorySIEntry,
expectedMandatory, "threadfactory description");
assertThat(actualThreadFactory, is(expectedDependencyAttribute));
is(THREADPOOL_DYNAMIC_MXB_NAME));
// check root runtime bean
- Collection<RuntimeBeanEntry> runtimeBeans = dynamicThreadPool
+ final Collection<RuntimeBeanEntry> runtimeBeans = dynamicThreadPool
.getRuntimeBeans();
assertThat(runtimeBeans.size(), is(1));
- RuntimeBeanEntry rootRB = findFirstByYangName(runtimeBeans,
+ final RuntimeBeanEntry rootRB = findFirstByYangName(runtimeBeans,
THREADPOOL_DYNAMIC_MXB_NAME);
assertThat(rootRB.isRoot(), is(true));
assertThat(rootRB.getAttributes().size(), is(1));
- JavaAttribute attribute = (JavaAttribute) rootRB.getAttributes()
+ final JavaAttribute attribute = (JavaAttribute) rootRB.getAttributes()
.iterator().next();
assertThat(attribute.getAttributeYangName(), is("created-sessions"));
assertThat(rootRB.getYangName(), is(THREADPOOL_DYNAMIC_MXB_NAME));
is(Long.class.getName()));
}
{// check threadfactory-naming
- ModuleMXBeanEntry threadFactoryNaming = namesToMBEs
+ final ModuleMXBeanEntry threadFactoryNaming = namesToMBEs
.get(THREADFACTORY_NAMING_MXB_NAME);
- Collection<RuntimeBeanEntry> runtimeBeans = threadFactoryNaming
+ final Collection<RuntimeBeanEntry> runtimeBeans = threadFactoryNaming
.getRuntimeBeans();
assertThat(runtimeBeans.size(), is(4));
{
- RuntimeBeanEntry threadRB = findFirstByYangName(runtimeBeans,
+ final RuntimeBeanEntry threadRB = findFirstByYangName(runtimeBeans,
"thread");
assertNotNull(threadRB);
assertFalse(threadRB.isRoot());
assertEquals("name", threadRB.getKeyYangName().get());
assertEquals("Name", threadRB.getKeyJavaName().get());
assertThat(threadRB.getAttributes().size(), is(1));
- AttributeIfc threadNameAttr = threadRB.getAttributes()
+ final AttributeIfc threadNameAttr = threadRB.getAttributes()
.iterator().next();
assertThat(threadNameAttr.getAttributeYangName(), is("name"));
assertTrue(threadNameAttr instanceof JavaAttribute);
assertThat(threadRB.getRpcs().size(), is(2));
}
{
- RuntimeBeanEntry streamRB = findFirstByNamePrefix(runtimeBeans,
+ final RuntimeBeanEntry streamRB = findFirstByNamePrefix(runtimeBeans,
"ThreadStream");
assertNotNull(streamRB);
assertFalse(streamRB.getKeyYangName().isPresent());
assertFalse(streamRB.getKeyJavaName().isPresent());
- Map<String, AttributeIfc> attributeMap = streamRB
+ final Map<String, AttributeIfc> attributeMap = streamRB
.getYangPropertiesToTypesMap();
assertEquals(4, attributeMap.size());
- TOAttribute toAttr = (TOAttribute) attributeMap.get("peer");
+ final TOAttribute toAttr = (TOAttribute) attributeMap.get("peer");
assertNotNull(toAttr);
assertThat(toAttr.getAttributeYangName(), is("peer"));
assertThat(toAttr.getLowerCaseCammelCase(), is("peer"));
assertThat(toAttr.getJmxPropertiesToTypesMap().keySet(),
is(propsExpected));
- JavaAttribute timestampAttr = (JavaAttribute) attributeMap
+ final JavaAttribute timestampAttr = (JavaAttribute) attributeMap
.get("timestamp");
assertNotNull(timestampAttr);
- JavaAttribute stateAttr = (JavaAttribute) attributeMap
+ final JavaAttribute stateAttr = (JavaAttribute) attributeMap
.get("state");
assertNotNull(stateAttr);
- ListAttribute innerStream = (ListAttribute) attributeMap
+ final ListAttribute innerStream = (ListAttribute) attributeMap
.get("inner-stream-list");
assertNotNull(innerStream);
assertThat(innerStream.getAttributeYangName(),
}
{ // test multiple dependencies
- ModuleMXBeanEntry threadPoolRegistry = namesToMBEs.get(THREADPOOL_REGISTRY_IMPL_NAME);
- Map<String, AttributeIfc> attributes = threadPoolRegistry.getAttributes();
+ final ModuleMXBeanEntry threadPoolRegistry = namesToMBEs.get(THREADPOOL_REGISTRY_IMPL_NAME);
+ final Map<String, AttributeIfc> attributes = threadPoolRegistry.getAttributes();
assertEquals(1, attributes.size());
- AttributeIfc threadpoolsAttr = attributes.get("threadpools");
+ final AttributeIfc threadpoolsAttr = attributes.get("threadpools");
assertNotNull(threadpoolsAttr);
assertTrue(threadpoolsAttr instanceof ListDependenciesAttribute);
- ListDependenciesAttribute threadpools = (ListDependenciesAttribute) threadpoolsAttr;
+ final ListDependenciesAttribute threadpools = (ListDependenciesAttribute) threadpoolsAttr;
}
}
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
-import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
@Test
public void createRuntimeBean() {
- ChoiceCaseNode caseNode = Mockito.mock(ChoiceCaseNode.class);
+ final ChoiceCaseNode caseNode = Mockito.mock(ChoiceCaseNode.class);
doReturn(new HashSet<LeafSchemaNode>()).when(caseNode).getChildNodes();
doReturn(new ArrayList<UnknownSchemaNode>()).when(caseNode)
.getUnknownSchemaNodes();
- Map<String, RuntimeBeanEntry> runtimeBeans = RuntimeBeanEntry
+ final Map<String, RuntimeBeanEntry> runtimeBeans = RuntimeBeanEntry
.extractClassNameToRuntimeBeanMap(PACKAGE_NAME, caseNode, "test-name", new TypeProviderWrapper(new
- TypeProviderImpl(context)), "test", jmxImplModule, context);
+ TypeProviderImpl(this.context)), "test", this.jmxImplModule, this.context);
assertEquals(1, runtimeBeans.size());
- RuntimeBeanEntry runtimeMXBean = runtimeBeans.get("testRuntimeMXBean");
+ final RuntimeBeanEntry runtimeMXBean = runtimeBeans.get("testRuntimeMXBean");
assertTrue(runtimeMXBean.isRoot());
assertEquals("test-name", runtimeMXBean.getYangName());
}
@Test
public void runtimeBeanRPCTest() {
// create service interfaces
- Map<QName, ServiceInterfaceEntry> modulesToSIEs = ServiceInterfaceEntry
- .create(threadsModule, "packages.sis",identitiesToSIs);
+ final Map<QName, ServiceInterfaceEntry> modulesToSIEs = ServiceInterfaceEntry
+ .create(this.threadsModule, "packages.sis",identitiesToSIs);
assertNotNull(modulesToSIEs);
// create MXBeans map
- Map<String, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry.create(
- threadsJavaModule, modulesToSIEs, context,
- new TypeProviderWrapper(new TypeProviderImpl(context)),
+ final Map<String, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry.create(
+ this.threadsJavaModule, modulesToSIEs, this.context,
+ new TypeProviderWrapper(new TypeProviderImpl(this.context)),
PACKAGE_NAME);
assertFalse(namesToMBEs.isEmpty());
// get threadfactory-naming bean
- ModuleMXBeanEntry threadfactoryNamingMXBean = namesToMBEs
+ final ModuleMXBeanEntry threadfactoryNamingMXBean = namesToMBEs
.get(THREADFACTORY_NAMING_MXB_NAME);
assertNotNull(threadfactoryNamingMXBean);
// get runtime beans
- Collection<RuntimeBeanEntry> runtimeBeanEntries = threadfactoryNamingMXBean
+ final Collection<RuntimeBeanEntry> runtimeBeanEntries = threadfactoryNamingMXBean
.getRuntimeBeans();
assertFalse(runtimeBeanEntries.isEmpty());
// get root runtime bean
- RuntimeBeanEntry threadfactoryRuntimeBeanEntry = getRuntimeBeanEntryByJavaName(
+ final RuntimeBeanEntry threadfactoryRuntimeBeanEntry = getRuntimeBeanEntryByJavaName(
runtimeBeanEntries, "NamingThreadFactoryRuntimeMXBean");
assertNotNull(threadfactoryRuntimeBeanEntry);
assertTrue(threadfactoryRuntimeBeanEntry.isRoot());
// get thread runtime bean
- RuntimeBeanEntry runtimeBeanEntry = getRuntimeBeanEntryByJavaName(
+ final RuntimeBeanEntry runtimeBeanEntry = getRuntimeBeanEntryByJavaName(
runtimeBeanEntries, THREAD_RUNTIME_BEAN_JAVA_NAME);
assertNotNull(runtimeBeanEntry);
assertEquals(THREAD_RUNTIME_BEAN_YANG_NAME, runtimeBeanEntry.getYangName());
// get thread runtime bean rpcs
- List<RuntimeBeanEntry.Rpc> rpcs = new ArrayList<>(
+ final List<RuntimeBeanEntry.Rpc> rpcs = new ArrayList<>(
runtimeBeanEntry.getRpcs());
assertEquals(2, rpcs.size());
// get sleep rpc and test it
- RuntimeBeanEntry.Rpc rpc = getRpcByName(rpcs, SLEEP_RPC_NAME);
+ final RuntimeBeanEntry.Rpc rpc = getRpcByName(rpcs, SLEEP_RPC_NAME);
assertNotNull(rpc);
assertEquals(SLEEP_RPC_NAME, rpc.getYangName());
assertTrue(((JavaAttribute)rpc.getReturnType()).getType().getFullyQualifiedName().endsWith(SLEEP_RPC_OUTPUT));
// get sleep rpc input attribute and test it
- List<JavaAttribute> attributes = rpc.getParameters();
+ final List<JavaAttribute> attributes = rpc.getParameters();
assertEquals(1, attributes.size());
- JavaAttribute attribute = attributes.get(0);
+ final JavaAttribute attribute = attributes.get(0);
assertEquals(SLEEP_RPC_INPUT_NAME, attribute.getAttributeYangName());
assertEquals(SLEEP_RPC_INPUT_TYPE, attribute.getType().getName());
assertEquals(SLEEP_RPC_INPUT_NAME, attribute.getLowerCaseCammelCase());
private RuntimeBeanEntry getRuntimeBeanEntryByJavaName(
final Collection<RuntimeBeanEntry> runtimeBeanEntries,
final String javaName) {
- if (runtimeBeanEntries != null && !runtimeBeanEntries.isEmpty()) {
- for (RuntimeBeanEntry runtimeBeanEntry : runtimeBeanEntries) {
+ if ((runtimeBeanEntries != null) && !runtimeBeanEntries.isEmpty()) {
+ for (final RuntimeBeanEntry runtimeBeanEntry : runtimeBeanEntries) {
if (runtimeBeanEntry.getJavaNameOfRuntimeMXBean().equals(
javaName)) {
return runtimeBeanEntry;
private RuntimeBeanEntry.Rpc getRpcByName(
final List<RuntimeBeanEntry.Rpc> rpcs, final String name) {
- if (rpcs != null && !rpcs.isEmpty()) {
- for (RuntimeBeanEntry.Rpc rpc : rpcs) {
+ if ((rpcs != null) && !rpcs.isEmpty()) {
+ for (final RuntimeBeanEntry.Rpc rpc : rpcs) {
if (rpc.getName().equals(name)) {
return rpc;
}
import static org.apache.commons.lang3.StringUtils.capitalize;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-
import com.google.common.base.Optional;
import java.net.URI;
import java.util.Collections;
import org.junit.Test;
import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.model.api.Type;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
public class RuntimeRegistratorTest {
// TODO add more tests
- protected RuntimeBeanEntry prepareRootRB(List<RuntimeBeanEntry> children) {
+ protected RuntimeBeanEntry prepareRootRB(final List<RuntimeBeanEntry> children) {
- DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
+ final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
doReturn("DataSchemaNode").when(nodeContainer).toString();
return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
"module-name", "ModuleName", true, Optional.<String> absent(),
Collections.<Rpc> emptySet());
}
- protected RuntimeBeanEntry prepareChildRB(List<RuntimeBeanEntry> children,
- String prefix) {
- DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
+ protected RuntimeBeanEntry prepareChildRB(final List<RuntimeBeanEntry> children,
+ final String prefix) {
+ final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
doReturn("DataSchemaNode").when(nodeContainer).toString();
return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
prefix + "child-name", capitalize(prefix) + "ChildName", false,
@Test
public void testHierarchy() {
- LeafSchemaNode leaf = mock(LeafSchemaNode.class);
+ final LeafSchemaNode leaf = mock(LeafSchemaNode.class);
doReturn(new QName(URI.create("urn:x"), "leaf-local-name")).when(leaf)
.getQName();
doReturn(Collections.emptyList()).when(leaf).getUnknownSchemaNodes();
doReturn(null).when(leaf).getDefault();
doReturn(null).when(leaf).getDescription();
- TypeProviderWrapper typeProviderWrapper = mock(TypeProviderWrapper.class);
- Type mockedType = mock(Type.class);
+ final TypeProviderWrapper typeProviderWrapper = mock(TypeProviderWrapper.class);
+ final Type mockedType = mock(Type.class);
doReturn(mockedType).when(typeProviderWrapper).getType(leaf);
doReturn("java.lang.String").when(mockedType).getFullyQualifiedName();
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
-
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Collections;
import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.test.types.rev131127.TestIdentity2;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
public class NetconfTestImplModuleTest extends AbstractConfigTest {
@Before
public void setUp() {
- factory = new NetconfTestImplModuleFactory();
- super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext,factory,
+ this.factory = new NetconfTestImplModuleFactory();
+ super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext,this.factory,
new DepTestImplModuleFactory(), new IdentityTestModuleFactory()));
}
@Test
public void testIdentities() throws Exception {
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- ObjectName nameCreated = transaction.createModule(IdentityTestModuleFactory.NAME, instanceName);
- IdentityTestModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, IdentityTestModuleMXBean.class);
+ final ObjectName nameCreated = transaction.createModule(IdentityTestModuleFactory.NAME, this.instanceName);
+ final IdentityTestModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, IdentityTestModuleMXBean.class);
final IdentitiesContainer c = new IdentitiesContainer();
c.setAfi(new IdentityAttributeRef(TestIdentity2.QNAME.toString()));
@Test
public void testDependencyList() throws Exception {
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+ ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- ObjectName on = createInstance(transaction, instanceName, 4);
+ final ObjectName on = createInstance(transaction, this.instanceName, 4);
transaction.validateConfig();
- CommitStatus status1 = transaction.commit();
+ final CommitStatus status1 = transaction.commit();
- assertBeanCount(1, factory.getImplementationName());
+ assertBeanCount(1, this.factory.getImplementationName());
assertBeanCount(4 + 1, DepTestImplModuleFactory.NAME);
assertStatus(status1, 1 + 4 + 1, 0, 0);
- transaction = configRegistryClient.createTransaction();
+ transaction = this.configRegistryClient.createTransaction();
- NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(ObjectNameUtil.withoutTransactionName(on),
+ final NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(ObjectNameUtil.withoutTransactionName(on),
NetconfTestImplModuleMXBean.class);
proxy.getComplexList();
- List<ObjectName> testingDeps = proxy.getTestingDeps();
- ObjectName testingDep = proxy.getTestingDep();
+ final List<ObjectName> testingDeps = proxy.getTestingDeps();
+ final ObjectName testingDep = proxy.getTestingDep();
assertEquals(TESTING_DEP_PREFIX, ObjectNameUtil.getInstanceName(testingDep));
assertTestingDeps(testingDeps, 4);
transaction.abortConfig();
// check that reuse logic works - equals on list of dependencies.
- transaction = configRegistryClient.createTransaction();
- CommitStatus status2 = transaction.commit();
+ transaction = this.configRegistryClient.createTransaction();
+ final CommitStatus status2 = transaction.commit();
assertStatus(status2, 0, 0, 6);
// replace single dependency
- transaction = configRegistryClient.createTransaction();
- String instanceName1 = TESTING_DEP_PREFIX + 1;
+ transaction = this.configRegistryClient.createTransaction();
+ final String instanceName1 = TESTING_DEP_PREFIX + 1;
transaction.destroyModule(DepTestImplModuleFactory.NAME, instanceName1);
transaction.createModule(DepTestImplModuleFactory.NAME, instanceName1);
- CommitStatus status3 = transaction.commit();
+ final CommitStatus status3 = transaction.commit();
assertStatus(status3, 1, 1, 4);
}
@Test
public void testNullCheckInListOfDependencies() throws Exception {
- ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+ final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
- ObjectName on = createInstance(transaction, instanceName, 4);
- NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(on, NetconfTestImplModuleMXBean.class);
+ final ObjectName on = createInstance(transaction, this.instanceName, 4);
+ final NetconfTestImplModuleMXBean proxy = transaction.newMXBeanProxy(on, NetconfTestImplModuleMXBean.class);
proxy.setTestingDeps(null);
assertTrue(proxy.getTestingDeps().isEmpty());
proxy.setTestingDeps(Collections.<ObjectName>emptyList());
}
- private void assertTestingDeps(List<ObjectName> testingDeps, int i) {
+ private void assertTestingDeps(final List<ObjectName> testingDeps, final int i) {
assertEquals(i, testingDeps.size());
int c = 1;
- for (ObjectName testingDep : testingDeps) {
+ for (final ObjectName testingDep : testingDeps) {
assertEquals(TESTING_DEP_PREFIX + Integer.toString(c++), ObjectNameUtil.getInstanceName(testingDep));
}
}
- private ObjectName createInstance(ConfigTransactionJMXClient transaction, String instanceName, int depsCount)
+ private ObjectName createInstance(final ConfigTransactionJMXClient transaction, final String instanceName, final int depsCount)
throws InstanceAlreadyExistsException {
- ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), instanceName);
- NetconfTestImplModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, NetconfTestImplModuleMXBean.class);
+ final ObjectName nameCreated = transaction.createModule(this.factory.getImplementationName(), instanceName);
+ final NetconfTestImplModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, NetconfTestImplModuleMXBean.class);
ObjectName dep = transaction.createModule(DepTestImplModuleFactory.NAME, TESTING_DEP_PREFIX);
mxBean.setTestingDep(dep);
- ArrayList<ObjectName> testingDeps = Lists.newArrayList();
+ final ArrayList<ObjectName> testingDeps = Lists.newArrayList();
for (int i = 0; i < depsCount; i++) {
dep = transaction.createModule(DepTestImplModuleFactory.NAME, TESTING_DEP_PREFIX + Integer.toString(i + 1));
testingDeps.add(dep);
import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeFactory;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.binding.data.codec.impl.MissingSchemaException;
-import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.binding.BindingMapping;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.binding.DataObject;
YangInstanceIdentifier toYangInstanceIdentifierBlocking(final InstanceIdentifier<? extends DataObject> binding) {
try {
- return codecRegistry.toYangInstanceIdentifier(binding);
+ return this.codecRegistry.toYangInstanceIdentifier(binding);
} catch (final MissingSchemaException e) {
waitForSchema(decompose(binding),e);
- return codecRegistry.toYangInstanceIdentifier(binding);
+ return this.codecRegistry.toYangInstanceIdentifier(binding);
}
}
* If supplied Instance Identifier is not valid.
*/
public YangInstanceIdentifier toNormalized(final InstanceIdentifier<? extends DataObject> binding) {
- return codecRegistry.toYangInstanceIdentifier(binding);
+ return this.codecRegistry.toYangInstanceIdentifier(binding);
}
@Override
public YangInstanceIdentifier toYangInstanceIdentifier(final InstanceIdentifier<?> binding) {
- return codecRegistry.toYangInstanceIdentifier(binding);
+ return this.codecRegistry.toYangInstanceIdentifier(binding);
}
YangInstanceIdentifier toYangInstanceIdentifierCached(final InstanceIdentifier<?> binding) {
- return iiCache .getUnchecked(binding);
+ return this.iiCache .getUnchecked(binding);
}
@Override
public <T extends DataObject> Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> toNormalizedNode(
final InstanceIdentifier<T> path, final T data) {
- return codecRegistry.toNormalizedNode(path, data);
+ return this.codecRegistry.toNormalizedNode(path, data);
}
/**
@Override
public Entry<InstanceIdentifier<?>, DataObject> fromNormalizedNode(final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data) {
- return codecRegistry.fromNormalizedNode(path, data);
+ return this.codecRegistry.fromNormalizedNode(path, data);
}
@Override
public Notification fromNormalizedNodeNotification(final SchemaPath path, final ContainerNode data) {
- return codecRegistry.fromNormalizedNodeNotification(path, data);
+ return this.codecRegistry.fromNormalizedNodeNotification(path, data);
}
@Override
public DataObject fromNormalizedNodeRpcData(final SchemaPath path, final ContainerNode data) {
- return codecRegistry.fromNormalizedNodeRpcData(path, data);
+ return this.codecRegistry.fromNormalizedNodeRpcData(path, data);
}
@Override
public InstanceIdentifier<?> fromYangInstanceIdentifier(final YangInstanceIdentifier dom) {
- return codecRegistry.fromYangInstanceIdentifier(dom);
+ return this.codecRegistry.fromYangInstanceIdentifier(dom);
}
@Override
public ContainerNode toNormalizedNodeNotification(final Notification data) {
- return codecRegistry.toNormalizedNodeNotification(data);
+ return this.codecRegistry.toNormalizedNodeNotification(data);
}
@Override
public ContainerNode toNormalizedNodeRpcData(final DataContainer data) {
- return codecRegistry.toNormalizedNodeRpcData(data);
+ return this.codecRegistry.toNormalizedNodeRpcData(data);
}
/**
public Optional<InstanceIdentifier<? extends DataObject>> toBinding(final YangInstanceIdentifier normalized)
throws DeserializationException {
try {
- return Optional.<InstanceIdentifier<? extends DataObject>>fromNullable(codecRegistry.fromYangInstanceIdentifier(normalized));
+ return Optional.<InstanceIdentifier<? extends DataObject>>fromNullable(this.codecRegistry.fromYangInstanceIdentifier(normalized));
} catch (final IllegalArgumentException e) {
return Optional.absent();
}
}
public DataNormalizer getDataNormalizer() {
- return legacyToNormalized;
+ return this.legacyToNormalized;
}
public Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> toBinding(
*
*/
@SuppressWarnings("unchecked")
- final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = Entry.class.cast(codecRegistry.fromNormalizedNode(normalized.getKey(), normalized.getValue()));
+ final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = Entry.class.cast(this.codecRegistry.fromNormalizedNode(normalized.getKey(), normalized.getValue()));
return Optional.fromNullable(binding);
} catch (final IllegalArgumentException e) {
return Optional.absent();
@Override
public void onGlobalContextUpdated(final SchemaContext schemaContext) {
- legacyToNormalized = new DataNormalizer(schemaContext);
- BindingRuntimeContext runtimeContext = BindingRuntimeContext.create(classLoadingStrategy, schemaContext);
- codecRegistry.onBindingRuntimeContextUpdated(runtimeContext);
- futureSchema.onRuntimeContextUpdated(runtimeContext);
+ this.legacyToNormalized = new DataNormalizer(schemaContext);
+ final BindingRuntimeContext runtimeContext = BindingRuntimeContext.create(this.classLoadingStrategy, schemaContext);
+ this.codecRegistry.onBindingRuntimeContextUpdated(runtimeContext);
+ this.futureSchema.onRuntimeContextUpdated(runtimeContext);
}
public <T extends DataObject> Function<Optional<NormalizedNode<?, ?>>, Optional<T>> deserializeFunction(final InstanceIdentifier<T> path) {
- return codecRegistry.deserializeFunction(path);
+ return this.codecRegistry.deserializeFunction(path);
}
/**
*/
public NormalizedNode<?, ?> getDefaultNodeFor(final YangInstanceIdentifier path) {
final Iterator<PathArgument> iterator = path.getPathArguments().iterator();
- DataNormalizationOperation<?> currentOp = legacyToNormalized.getRootOperation();
+ DataNormalizationOperation<?> currentOp = this.legacyToNormalized.getRootOperation();
while (iterator.hasNext()) {
final PathArgument currentArg = iterator.next();
try {
}
public BindingNormalizedNodeCodecRegistry getCodecRegistry() {
- return codecRegistry;
+ return this.codecRegistry;
}
@Override
}
public BindingNormalizedNodeCodecRegistry getCodecFactory() {
- return codecRegistry;
+ return this.codecRegistry;
}
// FIXME: This should be probably part of Binding Runtime context
final URI namespace = moduleName.getNamespace();
final Date revision = moduleName.getRevision();
Module module = runtimeContext().getSchemaContext().findModuleByNamespaceAndRevision(namespace, revision);
- if(module == null && futureSchema.waitForSchema(namespace,revision)) {
+ if((module == null) && this.futureSchema.waitForSchema(namespace,revision)) {
module = runtimeContext().getSchemaContext().findModuleByNamespaceAndRevision(namespace, revision);
}
Preconditions.checkState(module != null, "Schema for %s is not available.", modeledClass);
}
private void waitForSchema(final Collection<Class<?>> binding, final MissingSchemaException e) {
- LOG.warn("Blocking thread to wait for schema convergence updates for {} {}", futureSchema.getDuration(),
- futureSchema.getUnit());
- if(futureSchema.waitForSchema(binding)) {
+ LOG.warn("Blocking thread to wait for schema convergence updates for {} {}", this.futureSchema.getDuration(),
+ this.futureSchema.getUnit());
+ if(this.futureSchema.waitForSchema(binding)) {
return;
}
}
private BindingRuntimeContext runtimeContext() {
- return futureSchema.runtimeContext();
+ return this.futureSchema.runtimeContext();
}
@Override
public BindingCodecTree create(final BindingRuntimeContext context) {
- return codecRegistry.create(context);
+ return this.codecRegistry.create(context);
}
@Override
public BindingCodecTree create(final SchemaContext context, final Class<?>... bindingClasses) {
- return codecRegistry.create(context, bindingClasses);
+ return this.codecRegistry.create(context, bindingClasses);
}
@Nonnull
protected Map.Entry<InstanceIdentifier<?>, BindingCodecTreeNode<?>> getSubtreeCodec(
final YangInstanceIdentifier domIdentifier) {
- final BindingCodecTree currentCodecTree = codecRegistry.getCodecContext();
- final InstanceIdentifier<?> bindingPath = codecRegistry.fromYangInstanceIdentifier(domIdentifier);
+ final BindingCodecTree currentCodecTree = this.codecRegistry.getCodecContext();
+ final InstanceIdentifier<?> bindingPath = this.codecRegistry.fromYangInstanceIdentifier(domIdentifier);
Preconditions.checkArgument(bindingPath != null);
/**
* If we are able to deserialize YANG instance identifier, getSubtreeCodec must
import java.util.Hashtable;
import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
* @return BindingToNormalizedNodeCodec instance
*/
@Deprecated
- public static BindingToNormalizedNodeCodec getOrCreateInstance(ClassLoadingStrategy classLoadingStrategy,
- SchemaService schemaService) {
- BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(
+ public static BindingToNormalizedNodeCodec getOrCreateInstance(final ClassLoadingStrategy classLoadingStrategy,
+ final SchemaService schemaService) {
+ final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(
StreamWriterGenerator.create(SingletonHolder.JAVASSIST));
- BindingToNormalizedNodeCodec instance = new BindingToNormalizedNodeCodec(
+ final BindingToNormalizedNodeCodec instance = new BindingToNormalizedNodeCodec(
classLoadingStrategy, codecRegistry, true);
schemaService.registerSchemaContextListener(instance);
return instance;
* @param classLoadingStrategy
* @return the BindingToNormalizedNodeCodec instance
*/
- public static BindingToNormalizedNodeCodec newInstance(ClassLoadingStrategy classLoadingStrategy) {
- BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(
+ public static BindingToNormalizedNodeCodec newInstance(final ClassLoadingStrategy classLoadingStrategy) {
+ final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(
StreamWriterGenerator.create(SingletonHolder.JAVASSIST));
return new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry, true);
}
* @param schemaService the SchemaService.
* @return the ListenerRegistration
*/
- public static ListenerRegistration<SchemaContextListener> registerInstance(BindingToNormalizedNodeCodec instance,
- SchemaService schemaService) {
+ public static ListenerRegistration<SchemaContextListener> registerInstance(final BindingToNormalizedNodeCodec instance,
+ final SchemaService schemaService) {
return schemaService.registerSchemaContextListener(instance);
}
* @param bundleContext the BundleContext
* @return ServiceRegistration instance
*/
- public static ServiceRegistration<BindingToNormalizedNodeCodec> registerOSGiService(BindingToNormalizedNodeCodec instance,
- BundleContext bundleContext) {
- Dictionary<String, String> props = new Hashtable<>();
+ public static ServiceRegistration<BindingToNormalizedNodeCodec> registerOSGiService(final BindingToNormalizedNodeCodec instance,
+ final BundleContext bundleContext) {
+ final Dictionary<String, String> props = new Hashtable<>();
// Set the appropriate service properties so the corresponding CSS module is restarted if this
// blueprint container is restarted
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import javax.annotation.concurrent.GuardedBy;
-import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
+import org.opendaylight.mdsal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.binding.Augmentation;
class FutureSchema implements AutoCloseable {
}
BindingRuntimeContext runtimeContext() {
- BindingRuntimeContext localRuntimeContext = runtimeContext;
+ final BindingRuntimeContext localRuntimeContext = this.runtimeContext;
if(localRuntimeContext != null) {
return localRuntimeContext;
}
if(waitForSchema(Collections.emptyList())) {
- return runtimeContext;
+ return this.runtimeContext;
}
throw new IllegalStateException("No SchemaContext is available");
}
void onRuntimeContextUpdated(final BindingRuntimeContext context) {
- synchronized(postponedOperations) {
- runtimeContext = context;
- for (final FutureSchemaPredicate op : postponedOperations) {
+ synchronized(this.postponedOperations) {
+ this.runtimeContext = context;
+ for (final FutureSchemaPredicate op : this.postponedOperations) {
op.unlockIfPossible(context);
}
}
}
long getDuration() {
- return duration;
+ return this.duration;
}
TimeUnit getUnit() {
- return unit;
+ return this.unit;
}
@Override
public void close() {
- synchronized(postponedOperations) {
- for (final FutureSchemaPredicate op : postponedOperations) {
+ synchronized(this.postponedOperations) {
+ for (final FutureSchemaPredicate op : this.postponedOperations) {
op.cancel();
}
}
});
}
- private boolean addPostponedOpAndWait(FutureSchemaPredicate postponedOp) {
- if(!waitEnabled) {
+ private boolean addPostponedOpAndWait(final FutureSchemaPredicate postponedOp) {
+ if(!this.waitEnabled) {
return false;
}
- BindingRuntimeContext localRuntimeContext = runtimeContext;
- synchronized(postponedOperations) {
- postponedOperations.add(postponedOp);
+ final BindingRuntimeContext localRuntimeContext = this.runtimeContext;
+ synchronized(this.postponedOperations) {
+ this.postponedOperations.add(postponedOp);
// If the runtimeContext changed, this op may now be satisfied so check it.
- if(localRuntimeContext != runtimeContext) {
- postponedOp.unlockIfPossible(runtimeContext);
+ if(localRuntimeContext != this.runtimeContext) {
+ postponedOp.unlockIfPossible(this.runtimeContext);
}
}
final boolean waitForSchema() {
try {
- schemaPromise.get(duration, unit);
+ this.schemaPromise.get(FutureSchema.this.duration, FutureSchema.this.unit);
return true;
} catch (final InterruptedException | ExecutionException e) {
throw Throwables.propagate(e);
} catch (final TimeoutException e) {
return false;
} finally {
- synchronized(postponedOperations) {
- postponedOperations.remove(this);
+ synchronized(FutureSchema.this.postponedOperations) {
+ FutureSchema.this.postponedOperations.remove(this);
}
}
}
final void unlockIfPossible(final BindingRuntimeContext context) {
- if (!schemaPromise.isDone() && apply(context)) {
- schemaPromise.set(null);
+ if (!this.schemaPromise.isDone() && apply(context)) {
+ this.schemaPromise.set(null);
}
}
final void cancel() {
- schemaPromise.cancel(true);
+ this.schemaPromise.cancel(true);
}
private final SettableFuture<?> schemaPromise = SettableFuture.create();
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
-import javassist.ClassPool;
import org.apache.commons.lang3.StringUtils;
-import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
+import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javassist.ClassPool;
public class SingletonHolder {
private static final Logger logger = LoggerFactory.getLogger(SingletonHolder.class);
<!-- Runtime binding/normalized mapping service -->
- <reference id="classLoadingStrategy" interface="org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy"/>
+ <reference id="classLoadingStrategy" interface="org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy"/>
<reference id="schemaService" interface="org.opendaylight.controller.sal.core.api.model.SchemaService" />
<bean id="mappingCodec" class="org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodecFactory"
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- doReturn(mockYangID).when(codecRegistry).toYangInstanceIdentifier(TOP_PATH);
+ doReturn(this.mockYangID).when(this.codecRegistry).toYangInstanceIdentifier(TOP_PATH);
}
@Test
public void testRegisterDataTreeChangeListener() {
- BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry);
+ final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
- DataTreeChangeService service = BindingDOMDataTreeChangeServiceAdapter.create(codec, mockDOMService);
+ final DataTreeChangeService service = BindingDOMDataTreeChangeServiceAdapter.create(codec, this.mockDOMService);
- doReturn(mockDOMReg).when(mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(mockYangID),
+ doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID),
any(DOMDataTreeChangeListener.class));
- DataTreeIdentifier<Top> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, TOP_PATH);
- TestClusteredDataTreeChangeListener mockClusteredListener = new TestClusteredDataTreeChangeListener();
+ final DataTreeIdentifier<Top> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, TOP_PATH);
+ final TestClusteredDataTreeChangeListener mockClusteredListener = new TestClusteredDataTreeChangeListener();
service.registerDataTreeChangeListener(treeId , mockClusteredListener);
- verify(mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(mockYangID),
+ verify(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID),
isA(ClusteredDOMDataTreeChangeListener.class));
- reset(mockDOMService);
- doReturn(mockDOMReg).when(mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(mockYangID),
+ reset(this.mockDOMService);
+ doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID),
any(DOMDataTreeChangeListener.class));
- TestDataTreeChangeListener mockNonClusteredListener = new TestDataTreeChangeListener();
+ final TestDataTreeChangeListener mockNonClusteredListener = new TestDataTreeChangeListener();
service.registerDataTreeChangeListener(treeId , mockNonClusteredListener);
- verify(mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(mockYangID),
+ verify(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID),
not(isA(ClusteredDOMDataTreeChangeListener.class)));
}
static DOMDataTreeIdentifier domDataTreeIdentifier(final YangInstanceIdentifier yangID) {
return Matchers.argThat(new ArgumentMatcher<DOMDataTreeIdentifier>() {
@Override
- public boolean matches(Object argument) {
- DOMDataTreeIdentifier treeId = (DOMDataTreeIdentifier) argument;
- return treeId.getDatastoreType() == LogicalDatastoreType.CONFIGURATION &&
+ public boolean matches(final Object argument) {
+ final DOMDataTreeIdentifier treeId = (DOMDataTreeIdentifier) argument;
+ return (treeId.getDatastoreType() == LogicalDatastoreType.CONFIGURATION) &&
yangID.equals(treeId.getRootIdentifier());
}
@Override
- public void describeTo(Description description) {
+ public void describeTo(final Description description) {
description.appendValue(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, yangID));
}
});
private static class TestClusteredDataTreeChangeListener implements ClusteredDataTreeChangeListener<Top> {
@Override
- public void onDataTreeChanged(Collection<DataTreeModification<Top>> changes) {
+ public void onDataTreeChanged(final Collection<DataTreeModification<Top>> changes) {
}
}
private static class TestDataTreeChangeListener implements DataTreeChangeListener<Top> {
@Override
- public void onDataTreeChanged(Collection<DataTreeModification<Top>> changes) {
+ public void onDataTreeChanged(final Collection<DataTreeModification<Top>> changes) {
}
}
}
import java.util.concurrent.atomic.AtomicReference;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest;
+import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeComplexUsesAugment;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.augment.rev140709.TreeLeafOnlyAugment;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
this.context = context;
final DataObjectSerializerGenerator streamWriter = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()));
final BindingNormalizedNodeCodecRegistry registry = new BindingNormalizedNodeCodecRegistry(streamWriter);
- codec = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), registry, true);
+ this.codec = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), registry, true);
}
@Test
public void testComplexAugmentationSerialization() {
- codec.onGlobalContextUpdated(context);
- final PathArgument lastArg = codec.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES).getLastPathArgument();
+ this.codec.onGlobalContextUpdated(this.context);
+ final PathArgument lastArg = this.codec.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES).getLastPathArgument();
assertTrue(lastArg instanceof AugmentationIdentifier);
}
@Test
public void testLeafOnlyAugmentationSerialization() {
- codec.onGlobalContextUpdated(context);
- final PathArgument leafOnlyLastArg = codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY).getLastPathArgument();
+ this.codec.onGlobalContextUpdated(this.context);
+ final PathArgument leafOnlyLastArg = this.codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY).getLastPathArgument();
assertTrue(leafOnlyLastArg instanceof AugmentationIdentifier);
assertTrue(((AugmentationIdentifier) leafOnlyLastArg).getPossibleChildNames().contains(SIMPLE_VALUE_QNAME));
}
@Test
public void testToYangInstanceIdentifierBlocking() {
- codec.onGlobalContextUpdated(new EmptySchemaContext());
+ this.codec.onGlobalContextUpdated(new EmptySchemaContext());
final CountDownLatch done = new CountDownLatch(1);
final AtomicReference<YangInstanceIdentifier> yangId = new AtomicReference<>();
@Override
public void run() {
try {
- yangId.set(codec.toYangInstanceIdentifierBlocking(BA_TOP_LEVEL_LIST));
- } catch(RuntimeException e) {
+ yangId.set(BindingNormalizedCodecTest.this.codec.toYangInstanceIdentifierBlocking(BA_TOP_LEVEL_LIST));
+ } catch(final RuntimeException e) {
error.set(e);
} finally {
done.countDown();
}.start();
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- codec.onGlobalContextUpdated(context);
+ this.codec.onGlobalContextUpdated(this.context);
assertEquals("toYangInstanceIdentifierBlocking completed", true,
Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS));
@Test
public void testGetRpcMethodToSchemaPathBlocking() {
- codec.onGlobalContextUpdated(new EmptySchemaContext());
+ this.codec.onGlobalContextUpdated(new EmptySchemaContext());
testGetRpcMethodToSchemaPath();
}
@Override
public void run() {
try {
- retMap.set(codec.getRpcMethodToSchemaPath(OpendaylightTestRpcServiceService.class));
- } catch(RuntimeException e) {
+ retMap.set(BindingNormalizedCodecTest.this.codec.getRpcMethodToSchemaPath(OpendaylightTestRpcServiceService.class));
+ } catch(final RuntimeException e) {
error.set(e);
} finally {
done.countDown();
}.start();
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- codec.onGlobalContextUpdated(context);
+ this.codec.onGlobalContextUpdated(this.context);
assertEquals("getRpcMethodToSchemaPath completed", true,
Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS));
throw error.get();
}
- for(Method method: retMap.get().keySet()) {
+ for(final Method method: retMap.get().keySet()) {
if(method.getName().equals("rockTheHouse")) {
return;
}
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@Test
public void testClusteredDataChangeListernerRegisteration() {
- BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(classLoadingStrategy, codecRegistry);
+ final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
- try (BindingDOMDataBrokerAdapter bindingDOMDataBrokerAdapter = new BindingDOMDataBrokerAdapter(dataBroker,
+ try (BindingDOMDataBrokerAdapter bindingDOMDataBrokerAdapter = new BindingDOMDataBrokerAdapter(this.dataBroker,
codec)) {
- Mockito.when(codecRegistry.toYangInstanceIdentifier(TOP_PATH)).thenReturn(yangInstanceIdentifier);
+ Mockito.when(this.codecRegistry.toYangInstanceIdentifier(TOP_PATH)).thenReturn(this.yangInstanceIdentifier);
- ArgumentCaptor<ClusteredDOMDataChangeListener> clusteredDOMListener = ArgumentCaptor
+ final ArgumentCaptor<ClusteredDOMDataChangeListener> clusteredDOMListener = ArgumentCaptor
.forClass(ClusteredDOMDataChangeListener.class);
- ArgumentCaptor<LogicalDatastoreType> logicalDatastoreType = ArgumentCaptor
+ final ArgumentCaptor<LogicalDatastoreType> logicalDatastoreType = ArgumentCaptor
.forClass(LogicalDatastoreType.class);
- ArgumentCaptor<AsyncDataBroker.DataChangeScope> dataChangeScope = ArgumentCaptor
+ final ArgumentCaptor<AsyncDataBroker.DataChangeScope> dataChangeScope = ArgumentCaptor
.forClass(AsyncDataBroker.DataChangeScope.class);
- ArgumentCaptor<YangInstanceIdentifier> yangInstanceIdentifier = ArgumentCaptor
+ final ArgumentCaptor<YangInstanceIdentifier> yangInstanceIdentifier = ArgumentCaptor
.forClass(YangInstanceIdentifier.class);
- TestListener listener = new TestListener();
+ final TestListener listener = new TestListener();
bindingDOMDataBrokerAdapter.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, TOP_PATH,
listener, AsyncDataBroker.DataChangeScope.BASE);
- Mockito.verify(dataBroker).registerDataChangeListener(logicalDatastoreType.capture(),
+ Mockito.verify(this.dataBroker).registerDataChangeListener(logicalDatastoreType.capture(),
yangInstanceIdentifier.capture(), clusteredDOMListener.capture(), dataChangeScope.capture());
}
private class TestListener implements ClusteredDataChangeListener {
@Override
- public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+ public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
}
}
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
-import javassist.ClassPool;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
import org.opendaylight.controller.sal.binding.test.util.MockSchemaService;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import javassist.ClassPool;
public abstract class AbstractDataBrokerTestCustomizer {
}
public AbstractDataBrokerTestCustomizer() {
- schemaService = new MockSchemaService();
+ this.schemaService = new MockSchemaService();
final ClassPool pool = ClassPool.getDefault();
final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(pool));
final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
- bindingToNormalized = new BindingToNormalizedNodeCodec(loading, codecRegistry);
- schemaService.registerSchemaContextListener(bindingToNormalized);
- domNotificationRouter = DOMNotificationRouter.create(16);
+ this.bindingToNormalized = new BindingToNormalizedNodeCodec(loading, codecRegistry);
+ this.schemaService.registerSchemaContextListener(this.bindingToNormalized);
+ this.domNotificationRouter = DOMNotificationRouter.create(16);
}
public DOMStore createConfigurationDatastore() {
final InMemoryDOMDataStore store = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
- schemaService.registerSchemaContextListener(store);
+ this.schemaService.registerSchemaContextListener(store);
return store;
}
public DOMStore createOperationalDatastore() {
final InMemoryDOMDataStore store = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
- schemaService.registerSchemaContextListener(store);
+ this.schemaService.registerSchemaContextListener(store);
return store;
}
}
public NotificationService createNotificationService() {
- return new BindingDOMNotificationServiceAdapter(bindingToNormalized.getCodecRegistry(), domNotificationRouter);
+ return new BindingDOMNotificationServiceAdapter(this.bindingToNormalized.getCodecRegistry(), this.domNotificationRouter);
}
public NotificationPublishService createNotificationPublishService() {
- return new BindingDOMNotificationPublishServiceAdapter(bindingToNormalized, domNotificationRouter);
+ return new BindingDOMNotificationPublishServiceAdapter(this.bindingToNormalized, this.domNotificationRouter);
}
public abstract ListeningExecutorService getCommitCoordinatorExecutor();
public DataBroker createDataBroker() {
- return new BindingDOMDataBrokerAdapter(getDOMDataBroker(), bindingToNormalized);
+ return new BindingDOMDataBrokerAdapter(getDOMDataBroker(), this.bindingToNormalized);
}
public BindingToNormalizedNodeCodec getBindingToNormalized() {
- return bindingToNormalized;
+ return this.bindingToNormalized;
}
public SchemaService getSchemaService() {
- return schemaService;
+ return this.schemaService;
}
private DOMDataBroker getDOMDataBroker() {
- if (domDataBroker == null) {
- domDataBroker = createDOMDataBroker();
+ if (this.domDataBroker == null) {
+ this.domDataBroker = createDOMDataBroker();
}
- return domDataBroker;
+ return this.domDataBroker;
}
private synchronized ImmutableMap<LogicalDatastoreType, DOMStore> getDatastores() {
- if (datastores == null) {
- datastores = createDatastores();
+ if (this.datastores == null) {
+ this.datastores = createDatastores();
}
- return datastores;
+ return this.datastores;
}
public void updateSchema(final SchemaContext ctx) {
- schemaService.changeSchema(ctx);
+ this.schemaService.changeSchema(ctx);
}
public DOMNotificationRouter getDomNotificationRouter() {
- return domNotificationRouter;
+ return this.domNotificationRouter;
}
}
package org.opendaylight.controller.md.sal.binding.test;
import org.junit.Before;
-import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
}
protected SchemaContext getSchemaContext() throws Exception {
- Iterable<YangModuleInfo> moduleInfos = getModuleInfos();
- ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
+ final Iterable<YangModuleInfo> moduleInfos = getModuleInfos();
+ final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
moduleContext.addModuleInfos(moduleInfos);
return moduleContext.tryToCreateSchemaContext().get();
}
package org.opendaylight.controller.sal.binding.test.util;
import static com.google.common.base.Preconditions.checkState;
-
import com.google.common.annotations.Beta;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.MutableClassToInstanceMap;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
-import javassist.ClassPool;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.MountPointService;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.core.api.BrokerService;
import org.opendaylight.controller.sal.core.spi.data.DOMStore;
import org.opendaylight.controller.sal.dom.broker.BrokerImpl;
+import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
+import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
-import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
-import org.opendaylight.yangtools.sal.binding.generator.util.JavassistUtils;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import javassist.ClassPool;
@Beta
public class BindingTestContext implements AutoCloseable {
public DOMDataBroker getDomAsyncDataBroker() {
- return newDOMDataBroker;
+ return this.newDOMDataBroker;
}
public BindingToNormalizedNodeCodec getCodec() {
- return codec;
+ return this.codec;
}
protected BindingTestContext(final ListeningExecutorService executor, final ClassPool classPool, final boolean startWithSchema) {
}
public void startNewDataBroker() {
- checkState(executor != null, "Executor needs to be set");
- checkState(newDOMDataBroker != null, "DOM Data Broker must be set");
- dataBroker = new BindingDOMDataBrokerAdapter(newDOMDataBroker, codec);
+ checkState(this.executor != null, "Executor needs to be set");
+ checkState(this.newDOMDataBroker != null, "DOM Data Broker must be set");
+ this.dataBroker = new BindingDOMDataBrokerAdapter(this.newDOMDataBroker, this.codec);
}
public void startNewDomDataBroker() {
- checkState(executor != null, "Executor needs to be set");
+ checkState(this.executor != null, "Executor needs to be set");
final InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER",
MoreExecutors.newDirectExecutorService());
final InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
MoreExecutors.newDirectExecutorService());
- newDatastores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
+ this.newDatastores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
.put(LogicalDatastoreType.OPERATIONAL, operStore)
.put(LogicalDatastoreType.CONFIGURATION, configStore)
.build();
- newDOMDataBroker = new SerializedDOMDataBroker(newDatastores, executor);
+ this.newDOMDataBroker = new SerializedDOMDataBroker(this.newDatastores, this.executor);
- mockSchemaService.registerSchemaContextListener(configStore);
- mockSchemaService.registerSchemaContextListener(operStore);
+ this.mockSchemaService.registerSchemaContextListener(configStore);
+ this.mockSchemaService.registerSchemaContextListener(operStore);
}
public void startBindingDataBroker() {
}
public void startBindingBroker() {
- checkState(executor != null, "Executor needs to be set");
- checkState(baData != null, "Binding Data Broker must be started");
- checkState(baNotifyImpl != null, "Notification Service must be started");
-
- baConsumerRpc = new BindingDOMRpcServiceAdapter(getDomRpcInvoker(), codec);
- baProviderRpc = new BindingDOMRpcProviderServiceAdapter(getDomRpcRegistry(), codec);
-
- baBrokerImpl = new RootBindingAwareBroker("test");
-
- final MountPointService mountService = new BindingDOMMountPointServiceAdapter(biMountImpl, codec);
- baBrokerImpl.setMountService(mountService);
- baBrokerImpl.setLegacyMountManager(new HydrogenMountProvisionServiceAdapter(mountService));
- baBrokerImpl.setRpcBroker(new HeliumRpcProviderRegistry(baConsumerRpc, baProviderRpc));
- baBrokerImpl.setLegacyDataBroker(baData);
- baBrokerImpl.setNotificationBroker(baNotifyImpl);
- baBrokerImpl.start();
+ checkState(this.executor != null, "Executor needs to be set");
+ checkState(this.baData != null, "Binding Data Broker must be started");
+ checkState(this.baNotifyImpl != null, "Notification Service must be started");
+
+ this.baConsumerRpc = new BindingDOMRpcServiceAdapter(getDomRpcInvoker(), this.codec);
+ this.baProviderRpc = new BindingDOMRpcProviderServiceAdapter(getDomRpcRegistry(), this.codec);
+
+ this.baBrokerImpl = new RootBindingAwareBroker("test");
+
+ final MountPointService mountService = new BindingDOMMountPointServiceAdapter(this.biMountImpl, this.codec);
+ this.baBrokerImpl.setMountService(mountService);
+ this.baBrokerImpl.setLegacyMountManager(new HydrogenMountProvisionServiceAdapter(mountService));
+ this.baBrokerImpl.setRpcBroker(new HeliumRpcProviderRegistry(this.baConsumerRpc, this.baProviderRpc));
+ this.baBrokerImpl.setLegacyDataBroker(this.baData);
+ this.baBrokerImpl.setNotificationBroker(this.baNotifyImpl);
+ this.baBrokerImpl.start();
}
public void startForwarding() {
}
public void startBindingToDomMappingService() {
- checkState(classPool != null, "ClassPool needs to be present");
+ checkState(this.classPool != null, "ClassPool needs to be present");
- final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(classPool));
+ final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(this.classPool));
final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
- codec = new BindingToNormalizedNodeCodec(loading, codecRegistry);
- mockSchemaService.registerSchemaContextListener(codec);
+ this.codec = new BindingToNormalizedNodeCodec(loading, codecRegistry);
+ this.mockSchemaService.registerSchemaContextListener(this.codec);
}
private void updateYangSchema(final ImmutableSet<YangModuleInfo> moduleInfos) {
- mockSchemaService.changeSchema(getContext(moduleInfos));
+ this.mockSchemaService.changeSchema(getContext(moduleInfos));
}
private SchemaContext getContext(final ImmutableSet<YangModuleInfo> moduleInfos) {
startBindingBroker();
startForwarding();
- if (startWithSchema) {
+ if (this.startWithSchema) {
loadYangSchemaFromClasspath();
}
}
public void startNewBindingDataBroker() {
- final HydrogenDataBrokerAdapter forwarded = new HydrogenDataBrokerAdapter(dataBroker);
- baData = forwarded;
+ final HydrogenDataBrokerAdapter forwarded = new HydrogenDataBrokerAdapter(this.dataBroker);
+ this.baData = forwarded;
}
private void startDomMountPoint() {
- biMountImpl = new DOMMountPointServiceImpl();
+ this.biMountImpl = new DOMMountPointServiceImpl();
}
private void startDomBroker() {
- checkState(executor != null);
+ checkState(this.executor != null);
- domRouter = new DOMRpcRouter();
- mockSchemaService.registerSchemaContextListener(domRouter);
+ this.domRouter = new DOMRpcRouter();
+ this.mockSchemaService.registerSchemaContextListener(this.domRouter);
final ClassToInstanceMap<BrokerService> services = MutableClassToInstanceMap.create();
- services.put(DOMRpcService.class, domRouter);
+ services.put(DOMRpcService.class, this.domRouter);
- biBrokerImpl = new BrokerImpl(domRouter,services);
+ this.biBrokerImpl = new BrokerImpl(this.domRouter,services);
}
public void startBindingNotificationBroker() {
- checkState(executor != null);
+ checkState(this.executor != null);
final DOMNotificationRouter router = DOMNotificationRouter.create(16);
- domPublishService = router;
- domListenService = router;
- publishService = new BindingDOMNotificationPublishServiceAdapter(codec, domPublishService);
- listenService = new BindingDOMNotificationServiceAdapter(codec, domListenService);
- baNotifyImpl = new HeliumNotificationProviderServiceAdapter(publishService,listenService);
+ this.domPublishService = router;
+ this.domListenService = router;
+ this.publishService = new BindingDOMNotificationPublishServiceAdapter(this.codec, this.domPublishService);
+ this.listenService = new BindingDOMNotificationServiceAdapter(this.codec, this.domListenService);
+ this.baNotifyImpl = new HeliumNotificationProviderServiceAdapter(this.publishService,this.listenService);
}
@Deprecated
public DataProviderService getBindingDataBroker() {
- return baData;
+ return this.baData;
}
public RpcProviderRegistry getBindingRpcRegistry() {
- return baBrokerImpl.getRoot();
+ return this.baBrokerImpl.getRoot();
}
public DOMRpcProviderService getDomRpcRegistry() {
- return domRouter;
+ return this.domRouter;
}
public DOMRpcService getDomRpcInvoker() {
- return domRouter;
+ return this.domRouter;
}
@Override
}
public MountProviderService getBindingMountProviderService() {
- return baBrokerImpl.getLegacyMount();
+ return this.baBrokerImpl.getLegacyMount();
}
public DOMMountPointService getDomMountProviderService() {
- return biMountImpl;
+ return this.biMountImpl;
}
public DataBroker getDataBroker() {
- return dataBroker;
+ return this.dataBroker;
}
import org.junit.Assert;
import org.junit.Before;
import org.opendaylight.controller.md.sal.dom.store.impl.DatastoreTestTask.WriteTransactionCustomizer;
+import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TwoLevelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.top.level.list.NestedList;
-import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
@Before
public final void setup() throws Exception {
- YangModuleInfo moduleInfo = BindingReflections
+ final YangModuleInfo moduleInfo = BindingReflections
.getModuleInfo(TwoLevelList.class);
- ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
+ final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
context.registerModuleInfo(moduleInfo);
- schemaContext = context.tryToCreateSchemaContext().get();
+ this.schemaContext = context.tryToCreateSchemaContext().get();
- dclExecutorService = new TestDCLExecutorService(
+ this.dclExecutorService = new TestDCLExecutorService(
SpecialExecutors.newBlockingBoundedFastThreadPool(1, 10, "DCL" ));
- datastore = new InMemoryDOMDataStore("TEST", dclExecutorService);
- datastore.onGlobalContextUpdated(schemaContext);
+ this.datastore = new InMemoryDOMDataStore("TEST", this.dclExecutorService);
+ this.datastore.onGlobalContextUpdated(this.schemaContext);
}
@After
public void tearDown() {
- if( dclExecutorService != null ) {
- dclExecutorService.shutdownNow();
+ if( this.dclExecutorService != null ) {
+ this.dclExecutorService.shutdownNow();
}
}
* children.
*/
public final DatastoreTestTask newTestTask() {
- return new DatastoreTestTask(datastore, dclExecutorService).cleanup(DatastoreTestTask
+ return new DatastoreTestTask(this.datastore, this.dclExecutorService).cleanup(DatastoreTestTask
.simpleDelete(TOP_LEVEL));
}
}
protected static <K> void assertContains(final Collection<K> set, final K... values) {
- for (K key : values) {
+ for (final K key : values) {
Assert.assertTrue(set.contains(key));
}
}
protected static <K> void assertNotContains(final Collection<K> set, final K... values) {
- for (K key : values) {
+ for (final K key : values) {
Assert.assertFalse(set.contains(key));
}
}
protected static <K> void assertContains(final Map<K,?> map, final K... values) {
- for (K key : values) {
+ for (final K key : values) {
Assert.assertTrue(map.containsKey(key));
}
}
protected static <K> void assertNotContains(final Map<K,?> map, final K... values) {
- for (K key : values) {
+ for (final K key : values) {
Assert.assertFalse(map.containsKey(key));
}
}
public static final WriteTransactionCustomizer writeOneTopMultipleNested(
final String topName, final String... nestedName) {
- CollectionNodeBuilder<MapEntryNode, OrderedMapNode> nestedMapBuilder = nestedMap();
- for (String nestedItem : nestedName) {
+ final CollectionNodeBuilder<MapEntryNode, OrderedMapNode> nestedMapBuilder = nestedMap();
+ for (final String nestedItem : nestedName) {
nestedMapBuilder.addChild(nestedList(nestedItem).build());
}
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
-import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@Before
public void setupStore() {
- domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
+ this.domStore = new InMemoryDOMDataStore("TEST", MoreExecutors.newDirectExecutorService());
loadSchemas(RockTheHouseInput.class);
}
public void loadSchemas(final Class<?>... classes) {
YangModuleInfo moduleInfo;
try {
- ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
- for (Class<?> clz : classes) {
+ final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
+ for (final Class<?> clz : classes) {
moduleInfo = BindingReflections.getModuleInfo(clz);
context.registerModuleInfo(moduleInfo);
}
- schemaContext = context.tryToCreateSchemaContext().get();
- domStore.onGlobalContextUpdated(schemaContext);
- } catch (Exception e) {
+ this.schemaContext = context.tryToCreateSchemaContext().get();
+ this.domStore.onGlobalContextUpdated(this.schemaContext);
+ } catch (final Exception e) {
Throwables.propagateIfPossible(e);
}
}
@Test
public void testTransactionSchemaUpdate() throws InterruptedException, ExecutionException {
- assertNotNull(domStore);
+ assertNotNull(this.domStore);
// We allocate transaction, initial schema context does not
// contain Lists model
- DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
+ final DOMStoreReadWriteTransaction writeTx = this.domStore.newReadWriteTransaction();
assertNotNull(writeTx);
// we trigger schema context update to contain Lists model
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.AddShardReplicaInput;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeYnlOutput;
import org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.WriteTransactionsInput;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;