Mark will and appreciate it!
On Sep 7, 2011 7:22 AM, "Mark Nuttall" <mnutt...@apache.org> wrote:
> Hi Matt,
> Please see section 3.13.2 of the OSGi Service Platform Core Specification,
> version 4.2 - "Fragments During Runtime". If you don't have a copy handy,
> you can obtain one from http://www.osgi.org/Release4/Download. The section
> has moved to 3.14.2 in the latest version, 4.3.
>
> Regards,
> Mark
>
> On 7 September 2011 12:43, Matt Madhavan <mattmadha...@gmail.com> wrote:
>
>> Hello,
>> Thank you very much for the answers. One more question. Can the bundle
>> fragment have a resource in its own classpath and that resource can be
>> loaded by the host bundle?
>>
>> Thanks
>> Matt
>> On Sep 7, 2011 3:11 AM, "Timothy Ward" <timothyjw...@apache.org> wrote:
>> >
>> > Hi,
>> >
>> > From the original question I would say "No, there is no way for a host
>> bundle to receive a notification when a fragment attaches". Fragments
only
>> attach at resolution time, therefore the host bundle can never see the
>> attachment because it is, by definition, not resolved yet!
>> >
>> > What you can do is the following at startup (On OSGi 4.3):
>> >
>> > public void start(BundleContext ctx) throws BundleException {
>> >
>> > Bundle hostBundle = ctx.getBundle();
>> >
>> > BundleWiring wiring = hostBundle.adapt(BundleWiring.class);
>> >
>> > Collection<BundleWire> fragmentWires = wiring.
>> > getProvidedWires(BundleRevision.HOST_NAMESPACE);
>> >
>> > for(BundleWire wire : fragmentWires) {
>> > Bundle fragment = wire.getRequirerWiring().getBundle();
>> > //Do some stuff with this fragment
>> > }
>> > }
>> >
>> > This will allow you to find out which fragments were wired to your
bundle
>> when it resolved.
>> >
>> > Regards,
>> >
>> > Tim
>> >
>> > From: mnutt...@apache.org
>> > Date: Wed, 7 Sep 2011 08:54:57 +0100
>> > Subject: Re: OSGi (Blueprint) fragment and host bundle notification
>> > To: user@aries.apache.org
>> >
>> > Hi Matt, A web search for "osgi bundle tracker fragment" yields this
>> article: http://java.dzone.com/articles/osgi-junit-test-extender-using.
>> This uses a BundleTrackerCustomizer,
>> >
>> >
>> >
>> >
>> > bundleTracker = new BundleTracker(context, Bundle.RESOLVED,
>> testExtender);
>> >
>> > bundleTracker.open();
>> >
>> >
>> > Which then tests to see if it's been given a fragment:
>> > String fragment =
>> bundle.getHeaders().get(org.osgi.framework.Constants.FRAGMENT_HOST) + "";
>> >
>> >
>> >> Thanks in advance!
>> > You're welcome!
>> > Regards, Mark
>> >
>> > On 6 September 2011 23:14, Matt Madhavan <mattmadha...@gmail.com>
wrote:
>> >
>> >
>> > Hello,I would like to know when a new BluePrint fragment attaches it
self
>> to a host bundle will the host bundle be notified? I would like to do
some
>> work inside of the host bundle anytime a fragment attaches itself to a
host.
>> >
>> >
>> >
>> > Any ideas?
>> > Thanks in advance!Matt Madhavan
>> >
>> >
>>

Reply via email to