X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fdom%2Fserializer%2Fimpl%2FLazyGeneratedCodecRegistry.java;h=b81100836f7a422cdebca5de63010e512e5d7ac0;hb=0f14bf97fb20a4d506a7ed4826b2a6ed3b9ebeab;hp=e8e4c4375dba6548d7aa58fb81820c616d920f66;hpb=90e562e3dcc64e46a657ef4ab3047b2b709339c7;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java index e8e4c4375d..b81100836f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/dom/serializer/impl/LazyGeneratedCodecRegistry.java @@ -36,6 +36,7 @@ import org.opendaylight.yangtools.yang.binding.Augmentable; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.BindingCodec; import org.opendaylight.yangtools.yang.binding.DataContainer; +import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.Identifier; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; @@ -120,6 +121,9 @@ public class LazyGeneratedCodecRegistry implements // ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName()); @SuppressWarnings("rawtypes") WeakReference weakRef = typeToClass.get(typeref); + if(weakRef == null) { + LOG.error("Could not find loaded class for path: {} and type: {}",path,typeref.getFullyQualifiedName()); + } return weakRef.get(); } @@ -147,9 +151,29 @@ public class LazyGeneratedCodecRegistry implements // @Override @SuppressWarnings("rawtypes") public void bindingClassEncountered(Class cls) { + ConcreteType typeRef = Types.typeForClass(cls); + if(typeToClass.containsKey(typeRef)) { + return; + } + LOG.info("Binding Class {} encountered.",cls); WeakReference weakRef = new WeakReference<>(cls); typeToClass.put(typeRef, weakRef); + if(DataObject.class.isAssignableFrom(cls)) { + @SuppressWarnings({"unchecked","unused"}) + Object cdc = getCodecForDataObject((Class) cls); + } + } + + @Override + public void onClassProcessed(Class cls) { + ConcreteType typeRef = Types.typeForClass(cls); + if(typeToClass.containsKey(typeRef)) { + return; + } + LOG.info("Binding Class {} encountered.",cls); + WeakReference weakRef = new WeakReference<>((Class) cls); + typeToClass.put(typeRef, weakRef); } private DataSchemaNode getSchemaNode(List path) { @@ -280,6 +304,12 @@ public class LazyGeneratedCodecRegistry implements // ReferencedTypeImpl typeref = new ReferencedTypeImpl(caseNode.getValue().getPackageName(), caseNode .getValue().getName()); ChoiceCaseNode node = (ChoiceCaseNode) SchemaContextUtil.findDataSchemaNode(module, caseNode.getKey()); + if (node == null) { + LOG.error("YANGTools Bug: SchemaNode for {}, with path {} was not found in context.", + typeref.getFullyQualifiedName(), caseNode.getKey()); + continue; + } + @SuppressWarnings("rawtypes") ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl(node); typeToCaseNodes.putIfAbsent(typeref, value); @@ -300,7 +330,7 @@ public class LazyGeneratedCodecRegistry implements // BindingCodec, Object> delegate = newInstanceOf(choiceCodec); ChoiceCodecImpl newCodec = new ChoiceCodecImpl(delegate); choiceCodecs.put(choiceClass, newCodec); - CodecMapping.setClassToCaseMap(choiceCodec, (Map) classToCaseRawCodec); + CodecMapping.setClassToCaseMap(choiceCodec, (Map, BindingCodec>) classToCaseRawCodec); CodecMapping.setCompositeNodeToCaseMap(choiceCodec, newCodec.getCompositeToCase()); } @@ -540,7 +570,7 @@ public class LazyGeneratedCodecRegistry implements // public BindingCodec get(Object key) { if (key instanceof Class) { Class cls = (Class) key; - bindingClassEncountered(cls); + //bindingClassEncountered(cls); ChoiceCaseCodecImpl caseCodec = getCaseCodecFor(cls); return caseCodec.getDelegate(); } @@ -557,11 +587,6 @@ public class LazyGeneratedCodecRegistry implements // this.choiceCases = choiceCases; } - @Override - public Set> entrySet() { - return null; - } - @Override public BindingCodec get(Object key) { if (false == (key instanceof CompositeNode)) { @@ -575,6 +600,8 @@ public class LazyGeneratedCodecRegistry implements // } return null; } + + } /** @@ -585,7 +612,7 @@ public class LazyGeneratedCodecRegistry implements // * Key type */ @SuppressWarnings("rawtypes") - private static abstract class MapFacadeBase implements Map { + private static abstract class MapFacadeBase implements Map> { @Override public boolean containsKey(Object key) { @@ -613,7 +640,7 @@ public class LazyGeneratedCodecRegistry implements // } @Override - public Collection values() { + public Collection> values() { return null; } @@ -622,12 +649,12 @@ public class LazyGeneratedCodecRegistry implements // } @Override - public BindingCodec, Object> put(T key, BindingCodec value) { + public BindingCodec, Object> put(T key, BindingCodec value) { throw notModifiable(); } @Override - public void putAll(Map m) { + public void putAll(Map> m) { throw notModifiable(); } @@ -647,7 +674,8 @@ public class LazyGeneratedCodecRegistry implements // } @Override - public Set> entrySet() { + public Set>> entrySet() { + // TODO Auto-generated method stub return null; }