By wire admin I assume you don't really mean the WireAdmin service [1].
That service is completely on top of the framework and not related to
bundle wiring.

Here I assume you mean the bundle wiring API [2].  First I will tell you
how it can be done, but then I want you to give the reason you need to do
this, because there likely is a better way to accomplish what you need.

The only way you can dynamically add package imports is to use a
WeavingHook [3].  For each bundle class load your WeavingHook.weave method
will be called with a WovenClass object.  The WovenClass object has a
method getDynamicImports [5] that allows a hook to add more dynamic imports
to the bundle as needed.  The intended purpose of this method is to allow a
weaving hook to add more package imports that may be needed by the code
that is being woven into the class.  But you obviously can choose to do it
for any other reason you want to.  Keep in mind the dynamic imports added
by weaving hooks are not persistent and have to be redone each time a new
class loader is created for the bundle (i.e. on framework restart or bundle
refresh).

Tom

[1]
http://www.osgi.org/javadoc/r5/cmpn/org/osgi/service/wireadmin/package-summary.html
[2]
http://www.osgi.org/javadoc/r6/core/org/osgi/framework/wiring/package-summary.html
[3]
http://www.osgi.org/javadoc/r6/core/org/osgi/framework/hooks/weaving/WeavingHook.html

[4]
http://www.osgi.org/javadoc/r6/core/org/osgi/framework/hooks/weaving/WeavingHook.html#weave
(org.osgi.framework.hooks.weaving.WovenClass)
[5]
http://www.osgi.org/javadoc/r6/core/org/osgi/framework/hooks/weaving/WovenClass.html#getDynamicImports
()



From:   Raymond Auge <raymond.a...@liferay.com>
To:     OSGi Developer Mail List <osgi-dev@mail.osgi.org>
Date:   06/09/2014 09:04 AM
Subject:        [osgi-dev] wire admin add packages
Sent by:        osgi-dev-boun...@mail.osgi.org



Is it possible to use wireadmin to add new package imports to bundles
dynamically?

--
Raymond Augé (@rotty3000)
Senior Software Architect
Liferay, Inc. (@Liferay)
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to