Thanks Stuart,

I've just tested on my real bundle -replaced Export-Package with 
_exportcontents, and it worked.

Best regards,

Anne

-----Message d'origine-----
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Stuart McCulloch
Envoyé : vendredi 21 décembre 2007 14:38
À : [email protected]
Objet : Re: Classes duplicated when using Embed-dependency

On 21/12/2007, Stuart McCulloch <[EMAIL PROTECTED]> wrote:
>
> On 21/12/2007, GERODOLLE Anne RD-MAPS-GRE < 
> [EMAIL PROTECTED]> wrote:
> >
> >  Hi everybody,
> >
> > I have noticed that when using Embed-Dependency, if it occurs that 
> > one of the packages in the embedded library is either exported or 
> > declared as private, classes of this package are also put in the 
> > jar, so that they are present twice in the bundle classpath (once in 
> > the embedded jar, and once directly in the bundle)..
> >
>
> this is primarily because the BND tool is generic, and doesn't know 
> about Maven dependencies...
>
> therefore to support embedding of dependencies the bundleplugin 
> translates the Embed-Dependency instruction and the list of 
> dependencies provided by Maven into Include-Resource and 
> Bundle-ClassPath equivalents
>
> now, because BND uses Include-Resource, Export-Package and 
> Private-Package to decide the contents of the bundle, if you ask it to 
> embed a jar and then ask it to pull some classes into the bundle you 
> may of course find some duplication if the same classes are also in 
> the embedded jar
>
> Is that possible to avoid this, if so how ?
> >
>
> yes - but rather than adding complex code to detect such duplication 
> (which would get very messy) the solution involves using a different 
> BND instruction (called
> -exportcontents) which lets you set the exported packages without 
> affecting the bundle contents
>

just realized this option is missing from the online bundleplugin docs - will 
add it later today :)

for example, to wrap Log4J you'd embed the dependency and use exportcontents
> to expose the API:
>
>   <configuration>
>     <instructions>
>       <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
>       <_exportcontents>org.apache.log4j</_exportcontents>
>       <Import-Package>
>                 !javax.mail,
>                 !javax.management,
>                 !javax.jms,
>                 !javax.*,
>                 !com.sun.jdmk.comm,
>                 *
>       </Import-Package>
>       <Embed-Dependency>*</Embed-Dependency>
>     </instructions>
>   </configuration>
>
> there's no need to set Private-Package because the jar is already 
> embedded
> - btw, you
> can use <Embed-Dependency>*;inline=true</Embed-Dependency> to inline 
> the jar
>
> Note that in XML we use <_exportcontents> due to rules on valid tag 
> names, in a BND properties file we would use -exportcontents ( see 
> http://aqute.biz/Code/Bnd#directives
> )
>
> couple of follow-up points:
>
> 1) if you want a good logging service for OSGi, try Pax-Logging which 
> is on it's second RC:
>
>
> http://wiki.ops4j.org/confluence/display/ops4j/2007/12/19/Pax-Logging+
> 1.0+RC2
>
>   it provides the Log4J API and many others and logging can be 
> configured through OSGi
>
> 2) you can quickly create wrapper poms for third party libraries using
> pax-wrap-jar:
>
>       http://www.ops4j.org/projects/pax/construct/help/wrap-jar.html
>
>    which is part of the Pax-Construct tools (also provides bundle + 
> bean
> archetypes)
>
> HTH
>
> As an illustration, I'm including a pom.xml that builds a bundle 
> embedding
> > log4j (this is derivated from the felix log4j bundle).
> >
> > Thanks in advance,
> >
> > Anne
> >
> > * *
> >
> > * *
> >
> > *Anne Gérodolle
> > FT/RD/MAPS/AMS/SUME*
> >
> > *architecture de systèmes répartis*
> >
> > *distributed system architecture
> > +33 4 76 76 41 78
> > [EMAIL PROTECTED]
> >
> > * *
> >
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> Cheers, Stuart
>



--
Cheers, Stuart

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to