Thanks for the help!

> -----Original Message-----
> From: Stuart McCulloch [mailto:[email protected]]
> Sent: Tuesday, September 29, 2009 7:58 AM
> To: [email protected]
> Subject: Re: bnd & forced packages
> 
> 2009/9/29 Joel Schuster <[email protected]>
> 
> > It's been suggested to use DynamicImport-Package declaration. However,
> > based on my quick and limited research this is not a 'preferred' method.
> >
> > http://blog-o-lok.blogspot.com/2008/01/osgi-and-dynamicimport-
> package.html
> > http://www.osgi.org/blog/2007/06/osgi-and-hibernate.html
> >
> > In particular the second blog post on the OSGi Alliance web site from
> > 06/2007 suggests that "In the next release of the OSGi specification we
> must
> > find a solution to this problem."
> >
> > So, is using DynamicImport-Package the best way to solve my problem?
> >
> 
> Well it avoids the original issue because the OSGi DynamicImport-Package
> header supports wildcards,
> so bnd doesn't need do any matching and it will copy it to the final
> manifest (unlike the Import-Package
> case where bnd needs to expand any wildcards first, which I explained in
> my
> previous reply)
> 
> One important note about DynamicImport-Package - the wildcard denotes
> "deep"
> matching which means:
> 
>    DynamicImport-Package: oracle.jdbc.driver.*
> 
> will match against "oracle.jdbc.driver.foo" and
> "oracle.jdbc.driver.bar.wibble", but not "oracle.jdbc.driver"
> 
> To also match the main "oracle.jdbc.driver" package you would need:
> 
>    DynamicImport-Package: oracle.jdbc.driver, oracle.jdbc.driver.*
> 
> So basically when using bnd instructions...
> 
>    if you want to add extra required imports:  Import-Package:
> org.foo.extra, *
> 
>    if you want to add extra optional imports:  Import-Package:
> org.foo.extra;resolution:=optional, *
> 
>    if you want to add unknown/optional imports:  DynamicImport-Package:
> org.foo.unknown, org.foo.unknown.*
> 
> Also the current issue that JDBC driver classes must be imported by the
> bundle using DriverManager (etc.)
> will hopefully be addressed by OSGi RFC122, which is part of the ongoing
> Enterprise OSGi spec work.
> 
> HTH
> 
> ________________________________
> > From: Nima Kaviani [mailto:[email protected]]
> > Sent: Monday, September 28, 2009 5:55 PM
> > To: Joel Schuster
> > Subject: Re: bnd & forced packages
> >
> > Hi Joel
> >
> > try <DynamicImport-Package>oracle.jdbc.driver.*</DynamicImport-Package>
> in
> > your POM/BND file and see if it solves the problem.
> >
> > -Nima
> > On Mon, Sep 28, 2009 at 3:48 PM, Joel Schuster <[email protected]<mailto:
> > [email protected]>> wrote:
> > There have been a couple of times where I've been using systems where
> the
> > package/class that I'm trying to use is being loaded dynamically.
> >
> > For example, the 'standard' way to use a JDBC driver is something like
> > this:
> >
> > String driverName = "oracle.jdbc.driver.OracleDriver";
> > Class.forName(driverName);
> >
> > Or in the case of Jaxb and using JAXBContext with a marshaller:
> >
> >     JAXBContext jaxbContext = JAXBContext.newInstance( contextName);
> >
> >
> > In both these cases I've had a really hard time forcing the bnd ant task
> to
> > have Imports for the packages I need. Including them like this doesn't
> work:
> >
> > Import-Package: oracle.jdbc.driver.*
> >
> > Instead I've had to explicitly create a 'fake' instance of the Driver
> > (literally, new oracle.jdbc.driver.OracleDriver()) so that it's included
> in
> > the imports and then bnd seems to be able to pick it up.
> >
> > There has got to be a better way. What am I missing?
> >
> > ________________________________
> >
> > Joel Schuster
> > Senior Software Engineer
> > NAVSYS Corporation
> > 14960 Woodcarver Road, Colorado Springs, CO 80921
> > 719-481-4877
> >
> >
> >
> >
> >
> > --
> > http://nima.magic.ubc.ca
> >
> 
> 
> 
> --
> Cheers, Stuart

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to