Justin, > Why does this design require that these classes be exported? As long as the > bundle registering them as services has access to the dynamic classes, no > other bundle needs to.
That is correct, and the recipient of a proxy service objects have no legitimate interest in its implementation; it should be happy that it implements the interface they want and has whatever properties were specified in the filter (if any). But before we can create any proxy instance, the class needs to exist which means that some ClassLoader somewhere has to call defineClass(). Or am I missing something? > Alternatively, you could register a special Classloader as a service which > could be used to load them. Hm, that doesn't smell too good (creating custom ClassLoaders in an OSGi system), but it might work. Need to examine that more closely. Thx Chris > Justin > > On Sun, Mar 18, 2012 at 5:07 PM, <[email protected]> wrote: > >> Hello all, >> I am working on a design which involves generating new classes at runtime, >> so that afterwards I can create one or more instances which will be registered as services. Generating the class files (or byte arrays) goes >> fine, introducing them into the environment is less obvious; I need to somehow persuade some bundle classloader to read in my hand-crafted bytes >> and pass them to defineClass(). The best I have been able to come up with >> so far is to wrap up the generated class in a bundle fragment and ask the >> framework to install this - which seems a little baroque, so I am just wondering if there is some API I've missed which would do this more naturally? >> If I wanted to modify the original class I could of course use weaving hooks, but I would really prefer to create a new class. >> Thanks, >> Chris >> _______________________________________________ >> OSGi Developer Mail List >> [email protected] >> https://mail.osgi.org/mailman/listinfo/osgi-dev > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
