java - OSGI Classloading & Object Sharing -


ok. know class instantiated classloadera can not passed directly classloaderb because in jvm's eyes, "class" of object different in different classloader.

i know serializing object send classloaderb slow , can't see osgi containers using method. if have bundlea exports service bundleb (which imports service) , method "servicemethod()" called returns objecta, how objecta passed bundlea bundleb?

thanks!

if import same package in 2 bundles both wired same classloader package. lets assume have bundle providing service interface , associated classes, bundle b providing service internal service impl , bundle c using service.

bundle b import service interface , other packages classes of service. if new on class imported package trigger own classloader (b) load class. classloader delegate classloader package imported. service classes loaded classloader a.

the same applies bundle c common classes imported loading delegated classloader a. both bundles able communicate using service interface , imported classes.

btw. can transport objects unknown bundle c. example bundle b create private class , return in service "object". bundle c still work class , use reflection on it. no need marshalling.

the case osgi classloading can go wrong if example bundle c embeds service interface jar a. these packages loaded classloader c. different ones known bundle b. stay away embedding if possible.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -