Closes #718 improvement to OSGi serialization strategies (writing Class instances, and discussion of more)
Discovered that the current deserialization strategy for OSGi does not work in the following case: `foo-wrapped` extending yaml type `foo` which depends on bundle `foo-bundle` and extends java type `foo.Foo` in `foo-bundle`. The class-loading-context for `foo-wrapped` does not look in `foo-bundle`. Creating `foo-wrapped` works because it creates `foo` but trying to load class `foo.Foo` using the CLC for `foo-wrapped` fails. This impacts _specs_: we fail if we rebind a cluster whose member spec is a `foo-wrapped` for this reason. The serialized form of `EntitySpec` records `type` as `foo.Foo` and -- for lookup purposes -- `catalogItemId` `foo-wrapped`. So far this just adds a failing test, but provides a better place for discussing than IRC. I will summarise IRC discussion here and @geomacy @neykov @aledsage we can continue the discussion. Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/42f1a5d8 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/42f1a5d8 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/42f1a5d8 Branch: refs/heads/master Commit: 42f1a5d82dd2e5eb6bc6f41b693d4d941b1aa7d2 Parents: 381b7e6 3a2bf5a Author: Svetoslav Neykov <svetoslav.ney...@cloudsoftcorp.com> Authored: Thu Jun 8 12:37:18 2017 +0300 Committer: Svetoslav Neykov <svetoslav.ney...@cloudsoftcorp.com> Committed: Thu Jun 8 12:37:18 2017 +0300 ---------------------------------------------------------------------- .../brooklyn/api/typereg/RegisteredType.java | 10 ++ .../CatalogOsgiVersionMoreEntityRebindTest.java | 76 +++++++++ .../BrooklynClassLoadingContextSequential.java | 2 - ...rFromStackOfBrooklynClassLoadingContext.java | 145 ++++++++++++++++ .../brooklyn/core/mgmt/ha/OsgiManager.java | 2 +- .../core/mgmt/persist/OsgiClassPrefixer.java | 82 --------- .../core/mgmt/persist/XmlMementoSerializer.java | 170 ++----------------- .../mgmt/rebind/dto/MementosGenerators.java | 2 +- .../util/core/xstream/ClassRenamingMapper.java | 22 +-- .../util/core/xstream/OsgiClassPrefixer.java | 82 +++++++++ .../util/core/xstream/OsgiClassnameMapper.java | 85 ++++++++++ .../util/core/xstream/XmlSerializer.java | 67 ++++++-- ...mStackOfBrooklynClassLoadingContextTest.java | 143 ++++++++++++++++ .../core/mgmt/osgi/OsgiStandaloneTest.java | 21 --- .../mgmt/persist/OsgiClassPrefixerTest.java | 111 ------------ ...entoSerializerDelegatingClassLoaderTest.java | 143 ---------------- .../brooklyn/util/core/osgi/OsgiTestBase.java | 23 +++ .../core/xstream/OsgiClassPrefixerTest.java | 111 ++++++++++++ .../core/xstream/XmlSerializerOsgiTest.java | 111 ++++++++++++ .../brooklyn/util/osgi/OsgiTestResources.java | 3 +- 20 files changed, 869 insertions(+), 542 deletions(-) ----------------------------------------------------------------------