Search in sources :

Example 1 with ServiceReference

use of org.opendaylight.controller.config.manager.impl.jmx.ServiceReference in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method removeServiceReference.

@Override
public synchronized void removeServiceReference(final String serviceInterfaceName, final String refName) throws InstanceNotFoundException {
    ServiceReference serviceReference = new ServiceReference(serviceInterfaceName, refName);
    removeServiceReference(serviceReference);
}
Also used : ServiceReference(org.opendaylight.controller.config.manager.impl.jmx.ServiceReference)

Example 2 with ServiceReference

use of org.opendaylight.controller.config.manager.impl.jmx.ServiceReference in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method lookupConfigBeanByServiceInterfaceName.

@Override
public synchronized ObjectName lookupConfigBeanByServiceInterfaceName(final String serviceInterfaceQName, final String refName) {
    ServiceReference serviceReference = new ServiceReference(serviceInterfaceQName, refName);
    ModuleIdentifier moduleIdentifier = refNames.get(serviceReference);
    if (moduleIdentifier == null) {
        LOG.error("Cannot find qname {} and refName {} in {}", serviceInterfaceQName, refName, refName);
        throw new IllegalArgumentException("Cannot find " + serviceReference);
    }
    return getObjectName(moduleIdentifier);
}
Also used : ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) ServiceReference(org.opendaylight.controller.config.manager.impl.jmx.ServiceReference)

Example 3 with ServiceReference

use of org.opendaylight.controller.config.manager.impl.jmx.ServiceReference in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method saveServiceReference.

@Override
public synchronized ObjectName saveServiceReference(final String serviceInterfaceName, final String refName, final ObjectName moduleON) throws InstanceNotFoundException {
    assertWritable();
    ServiceReference serviceReference = new ServiceReference(serviceInterfaceName, refName);
    return saveServiceReference(serviceReference, moduleON);
}
Also used : ServiceReference(org.opendaylight.controller.config.manager.impl.jmx.ServiceReference)

Example 4 with ServiceReference

use of org.opendaylight.controller.config.manager.impl.jmx.ServiceReference in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method findServiceReferencesLinkingTo.

private Set<ServiceReference> findServiceReferencesLinkingTo(final ObjectName moduleObjectName, final Set<String> serviceInterfaceQNames) {
    String factoryName = ObjectNameUtil.getFactoryName(moduleObjectName);
    if (serviceInterfaceQNames == null) {
        LOG.warn("Possible error in code: cannot find factoryName {} in {}, object name {}", factoryName, factoryNamesToQNames, moduleObjectName);
        throw new IllegalStateException("Possible error in code: cannot find annotations of existing factory " + factoryName);
    }
    String instanceName = ObjectNameUtil.getInstanceName(moduleObjectName);
    ModuleIdentifier moduleIdentifier = new ModuleIdentifier(factoryName, instanceName);
    Set<ServiceReference> result = new HashSet<>();
    for (Entry<ServiceReference, ModuleIdentifier> entry : refNames.entrySet()) {
        if (entry.getValue().equals(moduleIdentifier)) {
            result.add(entry.getKey());
        }
    }
    return result;
}
Also used : ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) ServiceReference(org.opendaylight.controller.config.manager.impl.jmx.ServiceReference) HashSet(java.util.HashSet)

Example 5 with ServiceReference

use of org.opendaylight.controller.config.manager.impl.jmx.ServiceReference in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method copy.

private static void copy(final ServiceReferenceRegistryImpl old, final ServiceReferenceRegistryImpl newRegistry, final String nullableDstTransactionName) {
    for (Entry<ServiceReference, Entry<ServiceReferenceMXBeanImpl, ServiceReferenceJMXRegistration>> refNameEntry : old.managementBeans.entrySet()) {
        ObjectName currentImplementation;
        ObjectName currentImplementationSrc = refNameEntry.getValue().getKey().getCurrentImplementation();
        if (nullableDstTransactionName != null) {
            currentImplementation = ObjectNameUtil.withTransactionName(currentImplementationSrc, nullableDstTransactionName);
        } else {
            currentImplementation = ObjectNameUtil.withoutTransactionName(currentImplementationSrc);
        }
        try {
            boolean skipChecks = true;
            newRegistry.saveServiceReference(refNameEntry.getKey(), currentImplementation, skipChecks);
        } catch (final InstanceNotFoundException e) {
            LOG.error("Cannot save service reference({}, {})", refNameEntry.getKey(), currentImplementation);
            throw new IllegalStateException("Possible code error", e);
        }
    }
}
Also used : SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) Entry(java.util.Map.Entry) InstanceNotFoundException(javax.management.InstanceNotFoundException) ServiceReference(org.opendaylight.controller.config.manager.impl.jmx.ServiceReference) ObjectName(javax.management.ObjectName)

Aggregations

ServiceReference (org.opendaylight.controller.config.manager.impl.jmx.ServiceReference)7 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 ModuleIdentifier (org.opendaylight.controller.config.api.ModuleIdentifier)2 SimpleImmutableEntry (java.util.AbstractMap.SimpleImmutableEntry)1 HashSet (java.util.HashSet)1 Entry (java.util.Map.Entry)1 ObjectName (javax.management.ObjectName)1