yangtools.git
2 weeks agoClean up AugmentationHolder's annotations
Robert Varga [Mon, 20 Jul 2020 12:41:17 +0000 (14:41 +0200)]
Clean up AugmentationHolder's annotations

We know AugmentationHolder must return a non-null, make sure we
have annotations documenting that.

Change-Id: Ie46791349c9ab0b3eb67fa8dd165d67702a993d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse bindingHashCode() generated for interfaces
Robert Varga [Wed, 4 Sep 2019 17:16:09 +0000 (19:16 +0200)]
Use bindingHashCode() generated for interfaces

As we are generating a default implementation of hashCode(), we
can defer to that implementation from runtime-generated proxies.

This results in:
- consistent results between compile-time and runtime implementations
- faster startup time, as there is only one dispatch implementation
- lower memory overhead, as runtime-generated classes are smaller
- more maintainable code, as the implementation can be examined at
  compile-time

JIRA: MDSAL-472
Change-Id: Ifc4d3b71a1c63508e01491a4bf57bc4b163b5816
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGenerate bindingHashCode() and use it in generated implementations
Robert Varga [Wed, 4 Sep 2019 15:44:12 +0000 (17:44 +0200)]
Generate bindingHashCode() and use it in generated implementations

As we are gearing towards generating default methods in interfaces,
we need the ability to completely analyze all a target type from
a template, not from a generator.

This ability was previously available to Builder*Template, now it
is part of JavaFileTemplate and hence can be picked up by
InterfaceTemplate as needed.

JIRA: MDSAL-471
Change-Id: I278c085da195df8b4153b62381203b8ddc7bd073
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove ModuleInfoBackedContext
Robert Varga [Sun, 19 Jul 2020 22:01:39 +0000 (00:01 +0200)]
Remove ModuleInfoBackedContext

We have a replacement in ModuleInfoSnapshotBuilder, which is more
appropriate. Remove this badly leaking class and remove all the cruft
associated with its contract.

Change-Id: I185a57dc488a248bc8387e3f26603772116a48f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse ModuleInfoSnapshot instead of ModuleInfoBackedContext
Robert Varga [Sun, 19 Jul 2020 21:52:36 +0000 (23:52 +0200)]
Use ModuleInfoSnapshot instead of ModuleInfoBackedContext

We do not need the entire dance around dynamic loading, use just
the bare minimum loader.

Change-Id: Ie04197083144fd24d11108edef013ec5941b2c90
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove GeneratedClassLoadingStrategy
Robert Varga [Sun, 19 Jul 2020 16:30:42 +0000 (18:30 +0200)]
Remove GeneratedClassLoadingStrategy

We do not need this particular class anymore, remove it and migrate
its final set of users.

Change-Id: Ifce3d2803e2c3864377f174c468e83ee3a14b210
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse bindingToString() generated for interfaces
illia.ihushev [Tue, 14 Jul 2020 08:21:49 +0000 (11:21 +0300)]
Use bindingToString() generated for interfaces

As we are generating a default implementation of toString(), we
can defer to that implementation from runtime-generated proxies.

This results in:
- consistent results between compile-time and runtime implementations
- faster startup time, as there is only one dispatch implementation
- lower memory overhead, as runtime-generated classes are smaller
- more maintainable code, as the implementation can be examined at
  compile-time

JIRA: MDSAL-480
Change-Id: I56aceeb70461f6d35fcd6487e924fdd127a1ba1c
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGenerate bindingToString() and use it in generated implementations
Ilya Igushev [Thu, 9 Jul 2020 09:52:02 +0000 (09:52 +0000)]
Generate bindingToString() and use it in generated implementations

As we are gearing towards generating default methods in interfaces,
we need the ability to completely analyze all a target type from
a template, not from a generator.

This ability was previously available to Builder*Template, now it
is part of JavaFileTemplate and hence can be picked up by
InterfaceTemplate as needed.

JIRA: MDSAL-479
Change-Id: I1e939aca15f2f77b82a83ca454503522c96bcabe
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCorrect mdsal-binding-runtime-{api,spi} packages
Robert Varga [Sun, 19 Jul 2020 15:35:56 +0000 (17:35 +0200)]
Correct mdsal-binding-runtime-{api,spi} packages

Previous iteration left these new interface in the wrong package,
correct that mistake.

JIRA: MDSAL-548
Change-Id: I65c51ff2c1fc6c66684325c1022f6dca79a9b837
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDeprecate binding.runtime.spi constructs
Robert Varga [Sun, 19 Jul 2020 15:23:37 +0000 (17:23 +0200)]
Deprecate binding.runtime.spi constructs

GeneratedClassLoadingStrategy is a relic, superseded by
ClassLoadingStrategy interface. Deprecate it for removal.

ModuleInfoBackedContext is an internal implementation detail, which
should not be used outside fo runtime-spi. Deprecate it for removal.

Change-Id: I520b7aa2bd60080e03c41f55087a5a9eca65ea8f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove deprecated Builder.addAugmentation() variant
Robert Varga [Sun, 19 Jul 2020 11:53:46 +0000 (13:53 +0200)]
Remove deprecated Builder.addAugmentation() variant

We only support a single-argument variant, remove the deprecated
one.

JIRA: MDSAL-575
Change-Id: Ib2d256516f03a3e4be532378ac2dac6833acf489
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove uses of deprecated Builder.addAugmentation()
Robert Varga [Sun, 19 Jul 2020 15:04:18 +0000 (17:04 +0200)]
Remove uses of deprecated Builder.addAugmentation()

We have a few tests which are using the deprecated addAugmentation()
method, remove them.

Change-Id: I3207588958610ee35eb1de2542ee31181467294f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 7.0.0-SNAPSHOT
Robert Varga [Fri, 17 Jul 2020 21:14:42 +0000 (23:14 +0200)]
Bump versions to 7.0.0-SNAPSHOT

Open the next major release.

Change-Id: I85ddea18470708fbb4d4346b4476ca32198d4f55
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 6.0.4-SNAPSHOT
Robert Varga [Fri, 17 Jul 2020 21:13:30 +0000 (23:13 +0200)]
Bump versions to 6.0.4-SNAPSHOT

This starts the next development iteration.

Change-Id: Ie2e139ddea855c81f765e1b9b4dff02810230000
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump odlparent/yangtools to 7.0.4/5.0.4
Robert Varga [Wed, 15 Jul 2020 10:32:22 +0000 (12:32 +0200)]
Bump odlparent/yangtools to 7.0.4/5.0.4

Pick up latest fixes from upstream.

Change-Id: Ic6d8e45955d77401b0bbdc4535b0a9a5e3ca9732
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMake full type information accessible from InterfaceTemplate
illia.ihushev [Wed, 15 Jul 2020 11:35:26 +0000 (14:35 +0300)]
Make full type information accessible from InterfaceTemplate

As we are gearing towards generating default methods in interfaces,
we need the ability to completely analyze all a target type from
a template, not from a generator.

This ability was previously available to Builder*Template, now it
is part of JavaFileTemplate and hence can be picked up by
InterfaceTemplate as needed.

JIRA: MDSAL-470
Change-Id: I5a9b35ae31bfa7ecbffa2b555587d70a97fab93e
Signed-off-by: illia.ihushev <illia.ihushev@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSpeed up BuilderGenerator matcher
Robert Varga [Wed, 15 Jul 2020 15:43:28 +0000 (17:43 +0200)]
Speed up BuilderGenerator matcher

We do not need to establish FQCN, as we can compare just JavaTypeNames,
which is faster.

Change-Id: I3c387e841fbf2d450195d864a928608bab8128ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoInline single-use locals
Robert Varga [Mon, 13 Jul 2020 20:11:22 +0000 (22:11 +0200)]
Inline single-use locals

We are storing instrumented type in a local, and use that local
only once. Just inline the getter to trim down some generator
bytecode.

Change-Id: Ibfac0c2dc1d294643cbe2619d14e1672314d8bdf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoClean up CodecDataObjectGenerator documentation
Robert Varga [Mon, 13 Jul 2020 20:06:45 +0000 (22:06 +0200)]
Clean up CodecDataObjectGenerator documentation

We have a few typos and opportunities for cleanup.

Change-Id: Ibb9f5804ccc05c1b58c51d0ba1ac03fbaef7b223
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove GeneratorUtil.getTopParentTransportObject()
Robert Varga [Mon, 13 Jul 2020 11:12:34 +0000 (13:12 +0200)]
Remove GeneratorUtil.getTopParentTransportObject()

This method is not used anywhere and is quite inefficient, remove
it.

Change-Id: I3d381793c6c20fb056d03118b942a2257756a4bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEliminate use of addAugmentation(Class, DataObject)
Robert Varga [Mon, 15 Jun 2020 12:42:13 +0000 (14:42 +0200)]
Eliminate use of addAugmentation(Class, DataObject)

We have a replacement for this, migrate this user to remove
a warning.

Change-Id: Ib41c26cbd39766a8547edc88be03e3d8acf97265
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 6.0.3-SNAPSHOT
Robert Varga [Wed, 10 Jun 2020 20:19:00 +0000 (22:19 +0200)]
Bump versions to 6.0.3-SNAPSHOT

This starts the next development iteration.

Change-Id: Ice8a9c218fcc912a1e136b1063d83b13fcd50528
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix leafref-to-enum encoding
Peter Valka [Wed, 6 May 2020 07:54:18 +0000 (09:54 +0200)]
Fix leafref-to-enum encoding

When we have a leafref pointing to an enum via an absolute path,
in and RPC, we end up using a no-op codec, whereas we should be
extracting the name (from enum constant, or SchemaContext).

This ends up being a problem not in codec itself, as it is using
reflection to acquire the return type, defaulting to no-op.

The problem lies with AbstractTypeGenerator, which ends up not
being able to look up the generated type in case of RPC. The problem
here is the order in which types are generated, as the leaf being
referenced is generated after the RPC itself -- hence we cannot
find the definition.

While this is again highlighting the problem of single-pass code
generation, we can side-step the problem by moving RPC/notification
generation after the root data generation.

As a further complication, we need to record the enum/schema mapping,
as the codec needs to be able to find them via leafref types.

JIRA: MDSAL-552
Change-Id: Ifd92807029cdb7ba92dcad5655bb34d3ff4cef9d
Signed-off-by: Peter Valka <Peter.Valka@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump to odlparent-7.0.3/yangtools-5.0.3
Robert Varga [Tue, 9 Jun 2020 22:31:16 +0000 (00:31 +0200)]
Bump to odlparent-7.0.3/yangtools-5.0.3

Pick up latest updates from upstream.

Change-Id: I1f8ac05eecaeac0c7ba0d802543d82c3c7ea7548
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump byte-buddy to 1.10.11
Robert Varga [Mon, 8 Jun 2020 14:47:44 +0000 (16:47 +0200)]
Bump byte-buddy to 1.10.11

https://github.com/raphw/byte-buddy/blob/master/release-notes.md#4-june-2020-version-11011

Change-Id: I8538ecfa410bfc8fdbdbb87926914961ba2c6f1a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 6.0.2-SNAPSHOT
Robert Varga [Sat, 30 May 2020 13:30:08 +0000 (15:30 +0200)]
Bump versions to 6.0.2-SNAPSHOT

This starts next development iteration.

Change-Id: I6dd75c96d5e17bc6435539d44ecc4d0dcbe54daf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump to odlparent-7.0.2/yangtools-5.0.2
Robert Varga [Sat, 30 May 2020 09:10:19 +0000 (11:10 +0200)]
Bump to odlparent-7.0.2/yangtools-5.0.2

Pick up latest updates from upstream.

Change-Id: Ibe48d3cc3f1ba0896ff582d285261ea287a0a87b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump byte-buddy to 1.10.10
Robert Varga [Fri, 29 May 2020 20:49:02 +0000 (22:49 +0200)]
Bump byte-buddy to 1.10.10

https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.10.10

Change-Id: I536fc350302459e59245a87ab0d105d8df6ff3df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBackport controller's binding-broker tests
Robert Varga [Fri, 29 May 2020 11:11:04 +0000 (13:11 +0200)]
Backport controller's binding-broker tests

Pick up the class as it existed in controller as of
822e39fedebaf35ea9826067ad223dbfa98042ee.

JIRA: MDSAL-557
Change-Id: Ieaaeb594e33f8c5a4ac515d93c70db960cedb81c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDo not use raw superclass for CodecDataObject instances
Robert Varga [Sat, 11 May 2019 09:47:38 +0000 (11:47 +0200)]
Do not use raw superclass for CodecDataObject instances

We can improve generated class accuracy by specifying generic type
argument of CodecDataObject, thus making generated classes look
not like raw subclasses.

JIRA: MDSAL-550
Change-Id: If0581ea7186793539c9bc149c5e62c6db906616b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd lazily-instantiated maps
Robert Varga [Mon, 4 May 2020 12:34:27 +0000 (14:34 +0200)]
Add lazily-instantiated maps

Instantiating an ImmutableMap on each access is quite wasteful,
as there are a number of cases where we do not need the entire
mapping to be instantiated.

Typical uses touch the Map only once -- either to lookup a value
based on the key, or to iterate through the values. Others are
possible, but those two cover most of the patterns.

We add the prerequisite indirection and two implementations to
support each of the cases. The iterator part is optimized to
perform lazy object instantiation -- similar to LazyBindingList.

The lookup part works in a rather similar way, except it keeps
a lookup ConcurrentHashMap as the primary storage and values
are seen as expendable secondary storage. This makes iteration
order unstable, which might be seen as a violation of immutable
contract -- but our contract is a Map and mappings remain stable.

JIRA: MDSAL-539
Change-Id: I7c095065915f3c0d7b180d4aa1494e15d6374a11
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd lazily-instantiated lists
Robert Varga [Tue, 5 May 2020 20:03:26 +0000 (22:03 +0200)]
Add lazily-instantiated lists

Lists are usually searched linearly. For large lists we can end
up instantiating a large number of items upfront, some of which is
wasteful.

The cutoff point can be configured via a JVM property, which is
interpreted as a dynamic constant.

JIRA: MDSAL-551
Change-Id: I9e7c987929481143b931e763f4ef0313745a5c89
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGuarantee non-null in CodecDataObject.codecKey()
Robert Varga [Mon, 4 May 2020 13:49:50 +0000 (15:49 +0200)]
Guarantee non-null in CodecDataObject.codecKey()

The key loaded is guaranteed to be non-null, propagate that
annotation outwards.

Change-Id: If6bf3f4a7d5cabd760da603abb9038bb1e665b37
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoEliminate KeyedListNodeCodecContext.Unordered.getKey()
Robert Varga [Mon, 4 May 2020 12:40:40 +0000 (14:40 +0200)]
Eliminate KeyedListNodeCodecContext.Unordered.getKey()

This method and the methodhandle invoker are completely superfluous,
as we can directly access key() from the created object. While capturing
a MethodHandle lowers what method can be invoked, it does not really
buy us much, as the observed class will we always the same.

That property is visible enough (wired through an invokeExact() on the
constructor), hence JIT should be able to optimize without this help.

Change-Id: Id24eac8e74782f750576c90d60485b2dcbdcff9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoTake advantage of MapNode.size()
Robert Varga [Mon, 4 May 2020 11:17:34 +0000 (13:17 +0200)]
Take advantage of MapNode.size()

Checking the size allows us to skip instantiating values, plus we
can pass it down to map construction, where a correct strategy
can be taken based on the size.

JIRA: MDSAL-539
Change-Id: Ib42e290571cf162150b6e94b24df4aca5a9762ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove semicolons in comments
Robert Varga [Thu, 30 Apr 2020 07:31:29 +0000 (09:31 +0200)]
Remove semicolons in comments

sonarcloud insists this is commented-out code, which it is for
documentation purposes. Eliminating the trailing semicolon fools
it just enough to not notice.

Change-Id: I0546beb3b7584e426c2470c95bd4e8c177617bde
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd InstanceIdentifier.verifyTarget()
Robert Varga [Sun, 3 May 2020 08:04:18 +0000 (10:04 +0200)]
Add InstanceIdentifier.verifyTarget()

There are a number of places where users are casting InstanceIdentifiers,
just to restore type-safety after a type-unsafe operation, such as
going through serialization. Add InstanceIdentifier.verifyTarget(),
which restores type safety.

Change-Id: I2bfa69eb938b4a6b86b88e4054369b3abadf7c7d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump versions to 6.0.1-SNAPSHOT
Robert Varga [Wed, 22 Apr 2020 18:34:49 +0000 (20:34 +0200)]
Bump versions to 6.0.1-SNAPSHOT

This starts the next development iteration.

Change-Id: I047dbba41739424eaeca008143fbe8ed7e466daf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRevert "Remove deprecated uint migration elements"
Robert Varga [Sun, 26 Apr 2020 13:06:09 +0000 (15:06 +0200)]
Revert "Remove deprecated uint migration elements"

This reverts commit 48af8df68d7abc7108e692eeefff3bf30c9c291d,
reinstating generation of compatibility elements.

JIRA: MDSAL-490
Change-Id: Ia59eb16f3f0e534ce7339c46c24fc4d0b22d6f05
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump to yangtools-5.0.1
Robert Varga [Thu, 23 Apr 2020 15:39:25 +0000 (17:39 +0200)]
Bump to yangtools-5.0.1

We need further changes to tie together netconf and us.

Change-Id: Ia3668c7a79221f060159696c5554ef1c21e38782
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCleanup BindingRuntimeHelpers
Robert Varga [Thu, 23 Apr 2020 11:38:04 +0000 (13:38 +0200)]
Cleanup BindingRuntimeHelpers

We need to differentiate between testing (static context) and dynamic
contexts. This makes it possible to use these helpers in OSGi if we
inject the right set of services.

Change-Id: Ibc22b1597320956408217b98d44c9ea3fdd98c32
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoGenerate legacy List adaptation
Robert Varga [Thu, 23 Apr 2020 10:50:53 +0000 (12:50 +0200)]
Generate legacy List adaptation

In order to lower the pain of migration, generate legacy setFoo()
methods with List argument. These internally perform translation
to an ImmutableMap with unique index.

JIRA: MDSAL-434
Change-Id: If364c50a1f48d94b72520c674cbd033fe53646a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFurther deprecate addAugmentation()
Robert Varga [Thu, 23 Apr 2020 10:31:54 +0000 (12:31 +0200)]
Further deprecate addAugmentation()

We want to remove this method in next major release. Make sure
its deprecated for removal.

JIRA: MDSAL-183
Change-Id: I8d76a1eeab07e9fd40f6d970be391dbf3b26f542
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove AbstractBindingRuntimeContext.toString()
Robert Varga [Thu, 23 Apr 2020 09:08:31 +0000 (11:08 +0200)]
Remove AbstractBindingRuntimeContext.toString()

BindingRuntimeTypes can have a huge string representation, which
hurts when combined with a subclass of it being present in OSGi SR
and bundle-diag printing out services.

Change-Id: I38a95c6283454930674f5d6311829d7450559f0c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUpdate BindingRuntime{Context,Generator,Types}
Robert Varga [Wed, 22 Apr 2020 22:13:54 +0000 (00:13 +0200)]
Update BindingRuntime{Context,Generator,Types}

These interfaces should be operating on EffectiveModelContext to
provide smooth transition to downstreams. Fix that, along with
implementation and tests.

JIRA: MDSAL-435
Change-Id: Idfb155984d1261203d225c8293189941d5d345e9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoReduce use of BaseTemplate.getterMethodName()
Robert Varga [Wed, 22 Apr 2020 12:24:55 +0000 (14:24 +0200)]
Reduce use of BaseTemplate.getterMethodName()

We are using BuilderGeneratedProperty in Builder(Impl)Template,
and this class has access to the getter method. We therefore do
not need to construct the getter name, but rather can access it
directly.

Change-Id: I1b61c347d2919acf763d1f7d11ca9471b8a25f0f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDeprecate misnamed FooBuilder.addAugmentation()
Robert Varga [Tue, 21 Apr 2020 09:26:47 +0000 (11:26 +0200)]
Deprecate misnamed FooBuilder.addAugmentation()

Add explicit documentation to generated methods and deprecate
the two-argument addAugmetation() variant. Steer users towards
the one-argument variant or removeAugmentation().

JIRA: MDSAL-183
Change-Id: I496cfa542cb1f35cec975cd8288ef79e2b38fba6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoClean up GeneratedProperty use
Robert Varga [Wed, 22 Apr 2020 10:25:20 +0000 (12:25 +0200)]
Clean up GeneratedProperty use

Previous patch made a bit of a mess in GeneratedProperty. Clean this
up by creating a dedicated BuilderGeneratedProperty to hold the
properties created in java-api-generator.

Also add a few dedicated tests to ensure generated builders what
they are supposed to do.

JIRA: MDSAL-451
Change-Id: I594475019a997277560f77d4ef51144f2b281ffe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSquash empty lists/maps
Robert Varga [Tue, 21 Apr 2020 13:11:41 +0000 (15:11 +0200)]
Squash empty lists/maps

Dealing with lists requires us to interfere with what the user
is giving us in builders, effectively creating new mechanics.

This patch adds the model metadata to carry these around, exposing
just how badly broken some binding.model.api construcs are misused.
We do not fix the misuse, but make it slightly worse, but also mark
the mess for future cleanup.

JIRA: MDSAL-451
Change-Id: I43b3ddccff69bec9a4e98b3c8e73aac4679c1d1f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCentralize non-key property copies
Robert Varga [Tue, 21 Apr 2020 12:44:25 +0000 (14:44 +0200)]
Centralize non-key property copies

AbstractBuilderTemplate can discern between a copied key property
and other properties. Make sure we split the second part into a
separte method, allowing it to be customized.

The immediate benefit here is that we do not end up copying properties
if there are no keys.

JIRA: MDSAL-451
Change-Id: Ic1ba59d12cd65e7e8991345d50dc80db3fc029bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFixup DataObjectCodecContext.createBindingProxy() nullness
Robert Varga [Tue, 21 Apr 2020 09:50:35 +0000 (11:50 +0200)]
Fixup DataObjectCodecContext.createBindingProxy() nullness

This method cannot return a null, nor can anything which ultimately
uses it as its sole return.

Change-Id: Ia7bc32fa050777130a635d3929fbce6da705bb22
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSquash empty MapNode/UnkeyedListNode objects to null
Robert Varga [Tue, 21 Apr 2020 09:43:55 +0000 (11:43 +0200)]
Squash empty MapNode/UnkeyedListNode objects to null

When we encounter an empty keyed/unkeyed list, we need to treat
it as it were not present. This adjusts the appropriate codecs
to ensure that is the case.

JIRA: MDSAL-452
Change-Id: Iba70207642e014d59a94cc09a69da988ee71c63f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSimplify builder's addAugmentation() method
Robert Varga [Mon, 20 Apr 2020 23:15:06 +0000 (01:15 +0200)]
Simplify builder's addAugmentation() method

All augmentation already extend DataObject, which really is to say
that Augmentation should be doing the same. This has the benefit
of giving us access to DataContainer.implementedInterface(), which
we can use to add a simplified addAugmentation() method.

JIRA: MDSAL-183
Change-Id: I053a2d23e6bf95e07fa58e4078a37661e6e726a3
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove explicit UOE throws
Robert Varga [Tue, 21 Apr 2020 05:50:55 +0000 (07:50 +0200)]
Remove explicit UOE throws

Private constructors do not really have to be that defensive.
Remove exception throws and related tests.

Change-Id: I245264a78607d136d92a4c18d68f5d5df17a4832
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd CodeHelper.emptyToNull()
Robert Varga [Mon, 20 Apr 2020 22:30:16 +0000 (00:30 +0200)]
Add CodeHelper.emptyToNull()

We will need to be squashing empty collections to nulls, add
utility methods to do that.

JIRA: MDSAL-451
Change-Id: I28510efc2e10cef6181a9241d52f88c9cfd884e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove CodeHelpers.nonNullValue()
Robert Varga [Mon, 20 Apr 2020 22:27:29 +0000 (00:27 +0200)]
Remove CodeHelpers.nonNullValue()

This method is used only with augmentations. Remove it and update
callers to use Objects.requireNonNull() instead.

This removes a source of IAEs in favor of more consistent NPE
as well as trims down a few bytes from builder classes.

Change-Id: I57ee77c19230f57b34bf85eb5e31863f17372437
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd CodeHelper documentation
Robert Varga [Mon, 20 Apr 2020 22:19:33 +0000 (00:19 +0200)]
Add CodeHelper documentation

We are missing documentation for generic method types, add a few
words.

Change-Id: I3c3faa2836f4a6b55283028d04f5528728149bff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoImprove often-used class imports
Robert Varga [Mon, 20 Apr 2020 18:28:29 +0000 (20:28 +0200)]
Improve often-used class imports

importedName(Class) is slightly slower than importName(JavaTypeName),
hence improve performance by creating a few more often-used constants.

Change-Id: I2af9ad97bc2122a83c26cd247faf15e136bdb768
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoReorder encapsulation checks
Robert Varga [Mon, 20 Apr 2020 18:03:04 +0000 (20:03 +0200)]
Reorder encapsulation checks

Reordering checks provides a small speed up due to fewer checks
being made on average, as we take care of most popular types first.

Change-Id: I0acc2e77007054c7c35ad159d98bb3be1cdabfee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCorrect ClassTemplate's check for types
Robert Varga [Mon, 20 Apr 2020 11:51:53 +0000 (13:51 +0200)]
Correct ClassTemplate's check for types

ClassTemplate's checks run against Java Types, which is fine, except
that we should be referencing them through BaseYangTypes, so that we
have the incidental alignment well covered.

Furthermore the checks rely on FQCN, which is potentially slow to
compute, while the new checks rely on plain type equality -- hence
potentially speeding up things and lowering the number of branches.

We also drop a FIXMEs to clarify situation around InstanceIdentifier.

Change-Id: I3328199a8ec56e28d58582c076f1344fb4459103
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCorrect UnionTemplate's check for types
Robert Varga [Mon, 20 Apr 2020 11:35:50 +0000 (13:35 +0200)]
Correct UnionTemplate's check for types

UnionTemplate's checks run against Java Types, which is fine, except
that we should be referencing them through BaseYangTypes, so that we
have the incidental alignment well covered.

Change-Id: I5be3708d80ee5c376178df14dbc76333a01e06ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMove BaseYangtypes to binding.model.util
Robert Varga [Mon, 20 Apr 2020 11:31:37 +0000 (13:31 +0200)]
Move BaseYangtypes to binding.model.util

These constants sit between Types and BindingTypes, hence they should
not be in a completely different package.

Change-Id: If9894102e27b8dd3568493ef615c40328d213ca9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSplit out BaseYangTypesProvider
Robert Varga [Mon, 20 Apr 2020 11:18:09 +0000 (13:18 +0200)]
Split out BaseYangTypesProvider

BaseYangTypes is related to binding.model.api, while the type provider
is related to binding.generator.api. Split out
BaseYangTypes.BASE_YANG_TYPES_PROVIDER as a BaseYangTypesProvider.INSTANCE,
separating these two concerns.

Change-Id: I61dc6ed7f39ba233017bb9938eaab151a7c41e3e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCleanup java-api-generator Constants
Robert Varga [Mon, 20 Apr 2020 11:05:11 +0000 (13:05 +0200)]
Cleanup java-api-generator Constants

We have a number of useless constants here, remove them along with
the not-so-useful test.

Change-Id: I71ac7da20a035a7274d8e25017e2e937c1fefcf1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoTag TypeObjects which wrap a value with ScalarTypeObject
Robert Varga [Tue, 24 Mar 2020 15:58:29 +0000 (16:58 +0100)]
Tag TypeObjects which wrap a value with ScalarTypeObject

Capturing this type of objects has a nice side-effect of being
able to specialize code generation. It is furthermore useful
for providing a common definition of getValue() method.

This is an unfortunate side-effect of changing the API
mapping for boolean typedefs: the accessor changes from isValue()
to getValue().

JIRA: MDSAL-530
Change-Id: Ie40e50bbe566a747d0a5d3e9ff84e428c2960a94
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove executable bits
Robert Varga [Sun, 19 Apr 2020 13:34:44 +0000 (15:34 +0200)]
Remove executable bits

Plain files should not be executable, correct that mistake.

Change-Id: Ic3ea7299e9402c5a4c4ac1e4a9b25f93e0aa0593
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump yangtools to 5.0.0
Robert Varga [Sat, 18 Apr 2020 12:14:22 +0000 (14:14 +0200)]
Bump yangtools to 5.0.0

Adopt released yangtools-5.0.0, ending snapshot integration.

Change-Id: I08af2bba59aed2ab61838795f496e3d0a7cdb3e1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBUG-3128: make context reference mandatory
Robert Varga [Wed, 25 Jan 2017 12:07:42 +0000 (13:07 +0100)]
BUG-3128: make context reference mandatory

It does not make quite sense to have an optional context
reference: the RPC is either routed (action, with a reference)
or not. If the leaf is not mandatory, there is is a mismatch
between providers and consumers with regard to what is it
that invoking an action as an RPC really means.

Change-Id: I4f86acdc205192e3771fe9c480a71f38e1fe3e6f
Signed-off-by: Robert Varga <rovarga@cisco.com>
2 weeks agoRefactor binding-dom-adapter
Robert Varga [Sun, 12 Apr 2020 11:35:02 +0000 (13:35 +0200)]
Refactor binding-dom-adapter

BindingNormalizedNodeCodecRegistry is a serializer which allows
dynamic updates to its backing codec. Rather than referencing this
implementation, reference either BindingNormalizedNodeSerializer
(interface) or BindingCodecContext, which is the simple implentation.

This makes it obvious we are not using BindingNormalizedNodeCodecRegistry
in the context of mdsal-binding-dom-codec at all, making it a good
candidate to move to mdsal-binding-dom-adapter. Except we do not want
to just move it, but refactor so that it is properly controlled.

Change-Id: I2be67ed78ac89da5c5b5ec7322d03e769d2826c6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoImprove verification message
Robert Varga [Sat, 11 Apr 2020 02:46:48 +0000 (04:46 +0200)]
Improve verification message

Since we have the class identity available, let's use it to diagnoze
failures to supply a proper resource name.

Change-Id: I9b159e9ca8c16565b8e63b82637696ea90a42bc6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix mdsal-binding-dom-codec exports
Robert Varga [Sat, 11 Apr 2020 01:40:47 +0000 (03:40 +0200)]
Fix mdsal-binding-dom-codec exports

We only need the .impl package exported, as we do not want to
embed our -api artifact, as that just wrecks source code lookups.

Change-Id: I9c85c7ba0e121c0497cd17e0fcfdc2b7133ddfc8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd more error context to ResourceYangModuleInfo
Robert Varga [Thu, 9 Apr 2020 17:55:32 +0000 (19:55 +0200)]
Add more error context to ResourceYangModuleInfo

In case we end up failing to load a resource, log the subclass
and potentially the ClassLoader where the problem occured.

Change-Id: Id5cbe9875734d0c8f185d7cbbd8cc2cd3f09ee3f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump byte-buddy to 1.10.9
Robert Varga [Tue, 7 Apr 2020 09:52:49 +0000 (11:52 +0200)]
Bump byte-buddy to 1.10.9

https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.10.8
https://github.com/raphw/byte-buddy/releases/tag/byte-buddy-1.10.9

Change-Id: I6dd7ef731fefd5de334b268f23c9a24bf5ae0a41
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd a simple Binding query language
Robert Varga [Fri, 20 Mar 2020 16:22:09 +0000 (17:22 +0100)]
Add a simple Binding query language

Offloading some amount of data matching towards the storage engine
can give use two-fold improvement:

1) skip instantiation of Binding DTOs, as the query can be realized
   in terms of DOM matches
2) potentially skip transfer of large amount of data

For Binding layer we want to have something type-safe, where we are
in control of the flow the language.

This provides a first cut at the structure, which may end up being
further evolved.

Change-Id: Ica52158c889c0df9a6004227c0b64092590f67af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSimplify empty checking
Robert Varga [Wed, 25 Mar 2020 14:34:22 +0000 (15:34 +0100)]
Simplify empty checking

Use a simple negation instead of an equality check -- not that it
makes much difference in generated code.

Change-Id: If7c73a3884544c5acb5590b8154df712d4af2c55
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRefactor "value" property access
Robert Varga [Tue, 24 Mar 2020 15:15:19 +0000 (16:15 +0100)]
Refactor "value" property access

There are a number of callers open-coding the way to acquire 'value'
property. Centralize them.

JIRA: MDSAL-530
Change-Id: I6fdf17b204c7f491eb667747a68d6d80daf55b78
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd ScalarTypeObject
Robert Varga [Tue, 24 Mar 2020 13:55:09 +0000 (14:55 +0100)]
Add ScalarTypeObject

TypeObjects are used for encapsulated values, which expose a getValue()
method, which is guaranteed to be non-null and can have additional
validation implied.

JIRA: MDSAL-530
Change-Id: I3ec4a5b4d7e04ff0c220144c9d1796fb44b2a80b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix import order
Robert Varga [Wed, 25 Mar 2020 11:35:13 +0000 (12:35 +0100)]
Fix import order

xtend plugin does not automatically order imports, fix a misorder.

Change-Id: I099bbe07debe6a37b1f94fd6f39ec42d6d87f917
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoJavaFileTemplate.findProperty() should be static
Robert Varga [Tue, 24 Mar 2020 14:15:11 +0000 (15:15 +0100)]
JavaFileTemplate.findProperty() should be static

This method does not touch any local state -- hence it is truly
a static utility that can be moved to a properly-bound state.

Change-Id: Iad3b70d129e758a24aaa0558a1549728f529f236
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRefactor OSGi ModuleInfoSnapshot/BindingRuntimeContext
Robert Varga [Mon, 2 Mar 2020 07:18:31 +0000 (08:18 +0100)]
Refactor OSGi ModuleInfoSnapshot/BindingRuntimeContext

All components acting on EffectiveModel should end up reacting
to new generation by publishing components based on it before
tearing down the previous instance.

Refactor lifecycle by introducing this into both mdsal-dom-schema-osgi
and mdsal-binding-runtime-osgi -- providing the infrastructure for
mdsal-binding-dom-codec doing the same.

This leads to mdsal-binding-dom-codec-osgi to provide atomic updates
of BindingDOMCodecServices (and its constituent services), hence we
no longer want binding-dom-adapter to publish
BindingNormalizedNodeSerializer from its internal service.

JIRA: MDSAL-525
Change-Id: Ia6757b3db8068d585638bd8e2d3d17aaadb08955
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoFix YANG snippet escaping
Robert Varga [Mon, 2 Mar 2020 12:58:50 +0000 (13:58 +0100)]
Fix YANG snippet escaping

This is the non-javadoc path for module generation, where we are
failing to escape potential unicode references. Add the proper
callout and also optimize it to be a faster no-op when not
applicable, properly documenting what is going on.

JIRA: MDSAL-529
Change-Id: Ib21ed4f15555d49aaa7eb3dac61043c4b2e90451
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoCentralize BindingCodecContext services
Robert Varga [Sun, 1 Mar 2020 18:46:28 +0000 (19:46 +0100)]
Centralize BindingCodecContext services

BindingCodecContext provides an immutable class providing a number
of services. It really should provide all services, so that
downstreams can make a proper decision around lifecycle.

We do not want to expose BindingCodecContext itself, as it provides
other, implementation-internal, services -- hence create
BindingDOMCodecServices to hold the interface specification.

Missing methods come from BindingNormalizedNodeSerializer, which
can perhaps be re-formulated externally, but including it here
makes this more obvious for BindingNormalizedNodeCodecRegistry.

JIRA: MDSAL-825
Change-Id: I2a37f9c36b25bf4ef43c76bf81a170edfe75b60c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump odlparent to 7.0.0-SNAPSHOT
Robert Varga [Wed, 4 Mar 2020 12:14:43 +0000 (13:14 +0100)]
Bump odlparent to 7.0.0-SNAPSHOT

This picks up upgraded odlparent, notably for pre-installed SCR.

Change-Id: Icaab7aaab204e0959dc6606d319f947779040688
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBindingCodecContext implements BindingNormalizedNodeWriterFactory
Robert Varga [Sun, 1 Mar 2020 13:34:45 +0000 (14:34 +0100)]
BindingCodecContext implements BindingNormalizedNodeWriterFactory

There is slight confusion between BindingCodecContext and
BindingNormalizedNodeCodecRegistry -- the registry implements this
interface and uses internal methods with exact signatures for most
of them. There's a few methods missing, leading to confusion as to
what is what.

Move the two methods and make BindingCodecContext be the Immutable
reference implementation. This also shows that we have a lifecycle
issue, where we can end up reading codecContext twice.

Fix that race by properly encapsulating state before referring to
the (now static) common method. This has the nice side-effect of
removing state capture of 'this', leading to the indirection lambda
being stateless.

JIRA: MDSAL-825
Change-Id: I81e26ad6865c48035b64d1973bae1bb396d584f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMove AbstractLazyActionContainerNode to SPI
Robert Varga [Sun, 1 Mar 2020 12:22:00 +0000 (13:22 +0100)]
Move AbstractLazyActionContainerNode to SPI

While this is an implementation detail, it can be shared between
implementations quite reasonably. Pull it out of
binding-dom-codec-impl.

JIRA: MDSAL-825
Change-Id: I21b79bee5b73583a406d17665dfd9aff1376c3c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUpdate BindingInstanceIdentifierCodec documentation
Robert Varga [Sun, 1 Mar 2020 12:05:40 +0000 (13:05 +0100)]
Update BindingInstanceIdentifierCodec documentation

Document IllegalArgumentException being thrown and add FIXMEs.

Change-Id: I44e8a8c86b2dd180dc09f23a8a930b23f01b3c75
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoReduce BindingNormalizedNodeCodecRegistry proliferation
Robert Varga [Sat, 29 Feb 2020 15:36:35 +0000 (16:36 +0100)]
Reduce BindingNormalizedNodeCodecRegistry proliferation

Most functional blocks require only a
BindingNormalizedNodeSerializer implementation, not the concrete
implementation. This allows us to disconnect component lifecycle
from BindingCodecContext updates without relying on magic class.

BindingNormalizedNodeCodecRegistry provides a globally updated
holder for these implementations, so that they end up refreshing
their codec based on latest global state.

A follow-up patch will introduce an explicit component, which can
be used in these contexts.

JIRA: MDSAL-525
Change-Id: I6938e23e30656b9dbc960bd6b2ca17c068b67b35
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoAdd type parameter documentation
Robert Varga [Sat, 29 Feb 2020 15:16:49 +0000 (16:16 +0100)]
Add type parameter documentation

'C' here is undocumented, add at least a single line.

Change-Id: I06f4471983c0ea1fcbff49f45f6e263661030db4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoExpose BindingInstanceIdentifierCodec from BindingCodecTree
Robert Varga [Sat, 29 Feb 2020 14:38:05 +0000 (15:38 +0100)]
Expose BindingInstanceIdentifierCodec from BindingCodecTree

This codec is in similar class as IdentityCodec -- make sure it is
available to users.

JIRA: MDSAL-522
JIRA: MDSAL-525
Change-Id: I08371dfbbb264991d6d5840838c0736b35921b8f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoHide BindingCodecContext methods
Robert Varga [Fri, 28 Feb 2020 17:29:10 +0000 (18:29 +0100)]
Hide BindingCodecContext methods

BindingCodecContext is package-private, so should be its methods.

Change-Id: Ic371d8f63597d0e00f0287903be81cf3e5e49e45
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMake OSGiModuleInfoSnapshot generation unsigned
Robert Varga [Fri, 28 Feb 2020 15:02:58 +0000 (16:02 +0100)]
Make OSGiModuleInfoSnapshot generation unsigned

The intent is to have this an unsigned counter, expose it as such.

JIRA: MDSAL-392
Change-Id: I7d240933ae35288be0ba6a5f8a047587ab179803
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoDo not expose DataObjectSerializerRegistry outside of codec
Robert Varga [Fri, 28 Feb 2020 14:25:18 +0000 (15:25 +0100)]
Do not expose DataObjectSerializerRegistry outside of codec

BindingNormalizedNodeCodecRegistry should not implement this
interface directly, as it is only used internally.

Change-Id: I02956b6ae399eabb27634a2048c837f05f6ab3ea
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRework binding component instantiation
Robert Varga [Mon, 24 Feb 2020 11:40:56 +0000 (12:40 +0100)]
Rework binding component instantiation

This reshuffles how DOM and Binding interoperate where schema is
concerned. Since Binding requires Classloader information available
at scanning time, we refactor mdsal-dom-schema-service-osgi to
actually perform Binding-aware scanning, so that this information
is available in ModuleInfoSnapshot.

These are published as OSGiModuleInfoSnapshot along with generation
number for easier reference by a new component, OSGiModelRuntime.

DOMSchemaService is realized on top of ServiceRegistry, where it
listens for OSGiModelRuntime and for SchemaContextListeners, driving
an OSGi whiteboard pattern.

This renders mdsal-binding-dom-codec-osgi completely superfluous,
as there is not enough magic going on to justify it.

mdsal-binding-runtime-osgi is also hooked onto OSGiModuleInfoSnapshot,
providing BindingRuntimeContexts as needed and retaining generation
inforation.

JIRA: MDSAL-392
Change-Id: I083caf3abbc3d7e2212d1df14e45d2745096b5f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBindingReflections.getModuleInfo() returns @NonNull
Robert Varga [Thu, 27 Feb 2020 15:38:47 +0000 (16:38 +0100)]
BindingReflections.getModuleInfo() returns @NonNull

A null return here would be an API violation, make sure we catch
these in BindingReflections and do not bother users with potential
nulls.

Change-Id: I1670a46d1de4aeac0730538822157ec6ae216011
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUntangle BindingCodecContext/BindingNormalizedNodeCodecRegistry
Robert Varga [Tue, 25 Feb 2020 11:15:01 +0000 (12:15 +0100)]
Untangle BindingCodecContext/BindingNormalizedNodeCodecRegistry

The relationship here should be clear -- a BindingCodecContext is
self-contained and should not be subject to dynamism. The registry
maintains a 'current' codec.

Achieving this is very simple -- just do not perform upcalls to
Registry when we are looking for a streamer, it would just loop
back to BindingCodecContext and we want to be consistent, i.e. do
not try to upcall to a different BindingCodecContext.

JIRA: MDSAL-392
Change-Id: I720738f122ba89974e32c91ed8c7f3a059c21690
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoSplit off DefaultBindingCodecTreeFactory
Robert Varga [Tue, 25 Feb 2020 11:07:34 +0000 (12:07 +0100)]
Split off DefaultBindingCodecTreeFactory

BindingCodecTreeFactory is a simple interface which should be backed
by a simple implementation, rather than munging it with the codec
itself. Split it out of BindingNormalizedNodeCodecRegistry and back
it by the corresponding context.

JIRA: MDSAL-392
Change-Id: I1c35d39ab1b7d3b40a6cc3eacd69d3677306c081
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoUse only BundleContext in BindingClassLoadingStrategy
Robert Varga [Mon, 24 Feb 2020 12:23:16 +0000 (13:23 +0100)]
Use only BundleContext in BindingClassLoadingStrategy

OSGi DS allows us to inject BundleContext directly, do not bother
with ComponentContext.

JIRA: MDSAL-392
Change-Id: I679d981d36a2e9e8d7df09bc79f87b4e803b1e8d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoMigrate assertThat() imports
Robert Varga [Mon, 24 Feb 2020 13:28:09 +0000 (14:28 +0100)]
Migrate assertThat() imports

Assert.assertThat() has been deprecated, with MatcherAssert.assertThat()
being its replacement.

Change-Id: Ifd0f0243756e78f0788f39867514958109d1ab24
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoBump yangtools to 5.0.0-SNAPSHOT
Robert Varga [Thu, 23 Jan 2020 07:01:07 +0000 (08:01 +0100)]
Bump yangtools to 5.0.0-SNAPSHOT

This adopts yangtools-5.0.0 at snapshots, so we can shake out
integation issues and base our development on yt-5.0.0 changes.

This forces us to refactor mdsal-binding-dom-codec-osgi, which
is done in this patch. We adopt OSGi DS for tracking services.

JIRA: MDSAL-392
Change-Id: Ib5f7cb9817869ca5fc9053af4620d9536a27dcbf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 weeks agoRemove BindingRuntimeContext{Listener,Service}
Robert Varga [Sun, 23 Feb 2020 21:26:25 +0000 (22:26 +0100)]
Remove BindingRuntimeContext{Listener,Service}

These are not used anywhere and we'll be publishing the context
to the SR anyway. Remove the code while preparing to have it
refactored with DS.

Change-Id: I7639a7ae64edbbc52789eaa0ce388ce7698ff2d7
JIRA: MDSAL-392
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>