brand-zz / jing-trang

Automatically exported from code.google.com/p/jing-trang
Other
0 stars 0 forks source link

OSGI headers for Jing #109

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be helpful if Jing would provide a "Export-Package" header in the
MANIFEST.MF so it can be used within an OSGi environment. 

Every user can create a OSGified version of Jing via aQute bnd [1] but it
would be cool if this wouldn't be necessary.

[1] http://www.aqute.biz/Code/Bnd

Original issue reported on code.google.com by lars.he...@gmail.com on 7 May 2010 at 1:55

GoogleCodeExporter commented 9 years ago
I recognize that OSGI is important and it would be nice to make things easy for 
people using OSGI.

Original comment by jjc.jclark.com on 24 Aug 2010 at 4:31

GoogleCodeExporter commented 9 years ago
Would you accept a modified MANIFEST.MF? I could try to invest some time 
(should be minimal) so it could get into the release asap.

Original comment by tilman.schlenker on 17 Sep 2010 at 5:11

GoogleCodeExporter commented 9 years ago
Attached is a patch that modifies Jing's build system to produce an OSGi bundle 
for Jing:

It uses the bnd tool to create an OSGified jar out of the jar produced by the 
default build.

 - an osgi element is added to the mod.xml of the jing module. This element contains a list of bnd instruction, notably to declare package import/exports
 - the build.xsl is modified to:
   - declare the bnd Ant task
   - produce an "echo" task in the module's jar target to create a bnd configuration file in the module's build directory
   - produce a "bnd" task in the module's jar target to create an OSGi jar after the plain old jar
 - bnd.jar is added to the lib directory

This changes will produce a jing-osgi.jar OSGi bundle for Jing in the build 
directory when calling the default build (or just the jar target).

The osgi element added to jingo's module description is:

  <osgi>
Export-Package= org.relaxng.datatype,\
                org.relaxng.datatype.helpers,\
                com.thaiopensource.util,\
                com.thaiopensource.validate.*,\
                com.thaiopensource.xml.sax
Import-Package= com.icl.saxon;resolution:=optional,\
                net.sf.saxon;resolution:=optional,\
                org.apache.tools.ant.*;resolution:=optional,\
                org.apache.xalan.*;resolution:=optional,\
                org.apache.xerces.*;resolution:=optional,\
                org.apache.xml.resolver.*;resolution:=optional,\
                org.apache.tools.ant.*;resolution:=optional,\
                org.iso_relax.*;resolution:=optional,\
                *
Private-Package= com.thaiopensource.*,\
                 org.relaxng.datatype.*
  </osgi>

A similar osgi element can be added to other modules (trang, dtdinst), the 
build.xsl changes are not specific to jing.

This create an OSGi bundle with all required headers. More work would need to 
be done to make Jing a better citizen in an OSGi runtime, notably to offer 
alternative options to load service classes (instead of the ServiceLoader-like 
approach used in the com.thaiopensource.util.Service class).

Note: osgi.patch contains the full diff including binary files - produced with 
'svn diff --force' , build.xsl.patch only includes the changes to build.xsl in 
case the binary diff is not working.

Original comment by rdeltour@gmail.com on 1 May 2012 at 12:52

Attachments: