X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fyang-jmx-generator%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyangjmxgenerator%2FServiceInterfaceEntry.java;h=d7a806568054e8c05c025c78813106c309067637;hp=ef40d9515b42c75ad3b6d6e56456ea83a1912688;hb=20a32e6459fd1e27e7669bf1ebc7742b96787b94;hpb=306f95ccf8d699e2eed111f193b2fc388fa03e70
diff --git a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ServiceInterfaceEntry.java b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ServiceInterfaceEntry.java
index ef40d9515b..d7a8065680 100644
--- a/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ServiceInterfaceEntry.java
+++ b/opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ServiceInterfaceEntry.java
@@ -7,6 +7,10 @@
*/
package org.opendaylight.controller.config.yangjmxgenerator;
+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;
@@ -21,9 +25,6 @@ import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-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;
/**
* Represents identity derived from {@link ConfigConstants#SERVICE_TYPE_Q_NAME}.
@@ -43,10 +44,9 @@ import static org.opendaylight.controller.config.yangjmxgenerator.ConfigConstant
*
*
*
- *
*/
public class ServiceInterfaceEntry extends AbstractEntry {
- private static final Logger logger = LoggerFactory
+ private static final Logger LOG = LoggerFactory
.getLogger(ServiceInterfaceEntry.class);
private static final String CLASS_NAME_SUFFIX = "ServiceInterface";
@@ -55,23 +55,27 @@ public class ServiceInterfaceEntry extends AbstractEntry {
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) {
+ private ServiceInterfaceEntry(final IdentitySchemaNode id, final String packageName, final QName yangModuleQName) {
this(Optional. absent(), id, packageName, yangModuleQName);
}
- private ServiceInterfaceEntry(Optional base,
- IdentitySchemaNode id, String packageName, QName yangModuleQName) {
+ private ServiceInterfaceEntry(final Optional base,
+ final IdentitySchemaNode id, final String packageName, final QName yangModuleQName) {
checkNotNull(base);
this.maybeBaseCache = base;
List unknownSchemaNodes = id.getUnknownSchemaNodes();
List 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",
@@ -86,15 +90,17 @@ public class ServiceInterfaceEntry extends AbstractEntry {
getClass(),
ConfigConstants.JAVA_CLASS_EXTENSION_QNAME, id));
}
+
+ this.registerToOsgi = !disableOsgiServiceRegistration;
this.exportedOsgiClassName = exportedOsgiClassNames.get(0);
qName = id.getQName();
- nullableDescription = id.getDescription();
+ nullableDescription = id.getDescription().orElse(null);
typeName = getSimpleName(exportedOsgiClassName) + CLASS_NAME_SUFFIX;
this.packageName = packageName;
this.yangModuleQName = yangModuleQName;
}
- private static final String getSimpleName(String fullyQualifiedName) {
+ private static final String getSimpleName(final String fullyQualifiedName) {
int lastDotPosition = fullyQualifiedName.lastIndexOf(".");
return fullyQualifiedName.substring(lastDotPosition + 1);
}
@@ -115,22 +121,26 @@ public class ServiceInterfaceEntry extends AbstractEntry {
return qName;
}
+ public boolean isRegisterToOsgi() {
+ return registerToOsgi;
+ }
+
/**
* @return Map of QNames as keys and ServiceInterfaceEntry instances as
* values
*/
- public static Map create(Module currentModule,
- String packageName,Map definedSEItracker) {
- logger.debug("Generating ServiceInterfaces from {} to package {}",
+ public static Map create(final Module currentModule,
+ final String packageName,final Map definedSEItracker) {
+ LOG.debug("Generating ServiceInterfaces from {} to package {}",
currentModule.getNamespace(), packageName);
Map identitiesToSIs = new HashMap<>();
Set notVisited = new HashSet<>(
currentModule.getIdentities());
int lastSize = notVisited.size() + 1;
- while (notVisited.size() > 0) {
+ while (!notVisited.isEmpty()) {
if (notVisited.size() == lastSize) {
- logger.debug(
+ LOG.debug(
"Following identities will be ignored while generating ServiceInterfaces, as they are not derived from {} : {}",
SERVICE_TYPE_Q_NAME, notVisited);
break;
@@ -140,17 +150,17 @@ public class ServiceInterfaceEntry extends AbstractEntry {
.hasNext();) {
IdentitySchemaNode identity = iterator.next();
ServiceInterfaceEntry created = null;
- if (identity.getBaseIdentity() == null) {
+ if (identity.getBaseIdentities().isEmpty()) {
// this can happen while loading config module, just skip
// the identity
continue;
- } else if (identity.getBaseIdentity().getQName()
+ } else if (identity.getBaseIdentities().iterator().next().getQName()
.equals(SERVICE_TYPE_Q_NAME)) {
// this is a base type
created = new ServiceInterfaceEntry(identity, packageName, ModuleUtil.getQName(currentModule));
} else {
ServiceInterfaceEntry foundBase = definedSEItracker
- .get(identity.getBaseIdentity());
+ .get(identity.getBaseIdentities().iterator().next());
// derived type, did we convert the parent?
if (foundBase != null) {
created = new ServiceInterfaceEntry(
@@ -175,7 +185,7 @@ public class ServiceInterfaceEntry extends AbstractEntry {
for (ServiceInterfaceEntry sie : identitiesToSIs.values()) {
resultMap.put(sie.getQName(), sie);
}
- logger.debug("Number of ServiceInterfaces to be generated: {}",
+ LOG.debug("Number of ServiceInterfaces to be generated: {}",
resultMap.size());
return resultMap;
}
@@ -197,26 +207,34 @@ public class ServiceInterfaceEntry extends AbstractEntry {
}
@Override
- public boolean equals(Object o) {
- if (this == 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;
+ }
ServiceInterfaceEntry that = (ServiceInterfaceEntry) o;
- if (!maybeBaseCache.equals(that.maybeBaseCache))
+ if (!maybeBaseCache.equals(that.maybeBaseCache)) {
return false;
- if (!nullableDescription.equals(that.nullableDescription))
+ }
+ if (!nullableDescription.equals(that.nullableDescription)) {
return false;
- if (!exportedOsgiClassName.equals(that.exportedOsgiClassName))
+ }
+ if (!exportedOsgiClassName.equals(that.exportedOsgiClassName)) {
return false;
- if (!qName.equals(that.qName))
+ }
+ if (!qName.equals(that.qName)) {
return false;
- if (!packageName.equals(that.packageName))
+ }
+ if (!packageName.equals(that.packageName)) {
return false;
- if (!typeName.equals(that.typeName))
+ }
+ if (!typeName.equals(that.typeName)) {
return false;
+ }
return true;
}