package org.opendaylight.controller.config.manager.impl.osgi;
import static com.google.common.base.Preconditions.checkState;
-
import java.util.Dictionary;
import java.util.HashSet;
import java.util.Hashtable;
Map<ServiceInterfaceAnnotation, String /* service ref name */> serviceNamesToAnnotations) {
Set<ServiceRegistration<?>> serviceRegistrations = new HashSet<>();
for (Entry<ServiceInterfaceAnnotation, String /* service ref name */> entry : serviceNamesToAnnotations.entrySet()) {
- Class<?> requiredInterface = entry.getKey().osgiRegistrationType();
+ ServiceInterfaceAnnotation annotation = entry.getKey();
+ Class<?> requiredInterface = annotation.osgiRegistrationType();
+
+ if(!annotation.registerToOsgi()) {
+ LOG.debug("registerToOsgi for service interface {} is false - not registering", requiredInterface);
+ continue;
+ }
+
checkState(requiredInterface.isInstance(instance), instance.getClass().getName() +
" instance should implement " + requiredInterface.getName());
Dictionary<String, String> propertiesForOsgi = createProps(entry.getValue());
{
List<Parameter> params = Lists.newArrayList(new Parameter("value", q(sie.getQName().toString())));
params.add(new Parameter("osgiRegistrationType", exportedClassName + ".class"));
-
+ params.add(new Parameter("registerToOsgi", Boolean.toString(sie.isRegisterToOsgi())));
params.add(new Parameter("namespace", q(sie.getQName().getNamespace().toString())));
params.add(new Parameter("revision", q(sie.getQName().getFormattedRevision())));
params.add(new Parameter("localName", q(sie.getQName().getLocalName())));
public static final QName SERVICE_TYPE_Q_NAME = createConfigQName("service-type");
public static final QName MODULE_TYPE_Q_NAME = createConfigQName("module-type");
public static final QName JAVA_CLASS_EXTENSION_QNAME = createConfigQName("java-class");
+ public static final QName DISABLE_OSGI_SERVICE_REG_QNAME = createConfigQName("disable-osgi-service-registration");
public static final QName REQUIRED_IDENTITY_EXTENSION_QNAME = createConfigQName("required-identity");
public static final QName INNER_STATE_BEAN_EXTENSION_QNAME = createConfigQName("inner-state-bean");
public static final QName PROVIDED_SERVICE_EXTENSION_QNAME = createConfigQName("provided-service");
import static com.google.common.base.Preconditions.checkNotNull;
import static java.lang.String.format;
import static org.opendaylight.controller.config.yangjmxgenerator.ConfigConstants.SERVICE_TYPE_Q_NAME;
-
import com.google.common.base.Optional;
import java.util.ArrayList;
import java.util.HashMap;
private final QName qName;
private final String nullableDescription, packageName, typeName;
private final QName yangModuleQName;
+ private final boolean registerToOsgi;
private ServiceInterfaceEntry(IdentitySchemaNode id, String packageName, QName yangModuleQName) {
this(Optional.<ServiceInterfaceEntry> absent(), id, packageName, yangModuleQName);
List<UnknownSchemaNode> unknownSchemaNodes = id.getUnknownSchemaNodes();
List<String> exportedOsgiClassNames = new ArrayList<>(
unknownSchemaNodes.size());
+
+ boolean disableOsgiServiceRegistration = false;
for (UnknownSchemaNode usn : unknownSchemaNodes) {
- if (ConfigConstants.JAVA_CLASS_EXTENSION_QNAME.equals(usn
- .getNodeType())) {
+ if (ConfigConstants.JAVA_CLASS_EXTENSION_QNAME.equals(usn.getNodeType())) {
String localName = usn.getNodeParameter();
exportedOsgiClassNames.add(localName);
+ } else if (ConfigConstants.DISABLE_OSGI_SERVICE_REG_QNAME.equals(usn.getNodeType())) {
+ disableOsgiServiceRegistration = true;
} else {
throw new IllegalStateException(format(
"Unexpected unknown schema node. Expected %s, got %s",
getClass(),
ConfigConstants.JAVA_CLASS_EXTENSION_QNAME, id));
}
+
+ this.registerToOsgi = !disableOsgiServiceRegistration;
this.exportedOsgiClassName = exportedOsgiClassNames.get(0);
qName = id.getQName();
nullableDescription = id.getDescription();
return qName;
}
+ public boolean isRegisterToOsgi() {
+ return registerToOsgi;
+ }
+
/**
* @return Map of QNames as keys and ServiceInterfaceEntry instances as
* values