| <html><head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | |
| <title>6. Developing OSGi Bundles</title><link rel="stylesheet" href="css/stylesheet.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="Virgo Tools Guide"><link rel="up" href="index.html" title="Virgo Tools Guide"><link rel="prev" href="ch05s05.html" title="5.5 Server Console Page"><link rel="next" href="ch06s02.html" title="6.2 Editing the Manifest"><!--Begin Google Analytics code--><script type="text/javascript"> | |
| var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); | |
| document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); | |
| </script><script type="text/javascript"> | |
| var pageTracker = _gat._getTracker("UA-2728886-3"); | |
| pageTracker._setDomainName("none"); | |
| pageTracker._setAllowLinker(true); | |
| pageTracker._trackPageview(); | |
| </script><!--End Google Analytics code--></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">6. Developing OSGi Bundles</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch05s05.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch06s02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="developing"></a>6. Developing OSGi Bundles</h2></div></div></div><p>The Tools provide functionality that makes developing OSGi bundles, especially the editing of MANIFEST.MF files, | |
| easier. | |
| </p><div class="section" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="tooling-developing-resolving-bundle-dependencies"></a>6.1 Resolving Bundle Dependencies</h2></div></div></div><p> | |
| While working with OSGi bundles, one of the most interesting and challenging aspects is defining the package, bundle, | |
| and library imports in the manifest and then keeping this in sync with your compile classpath either in Ant and Maven | |
| or Eclipse. In most cases you would typically be required to manually set up the Eclipse classpath. Ultimately, the | |
| Eclipse compile classpath is still different from the bundle runtime classpath, as normally an entire JAR file is | |
| being made available on the Eclipse classpath but not necessarily at runtime due to the explicit visibility rules | |
| defined in | |
| <code class="code">Import-Package</code> | |
| headers. | |
| </p><p> | |
| The Tools address this problem by providing an Eclipse classpath container that uses an | |
| Virgo Runtime Environment-specific dependency resolution mechanism. This classpath container makes resolved | |
| dependencies available on the project’s classpath but allows only access to those package that are imported | |
| explicitly (e.g., via | |
| <code class="code">Import-Package</code> | |
| ) or implicitly by using | |
| <code class="code">Import-Library</code> | |
| or | |
| <code class="code">Import-Bundle</code> | |
| . | |
| </p><p> To use the automatic dependency resolution, an OSGi bundle or PAR project needs to be targeted to a configured | |
| Virgo Runtime Environment instance. This can be done from the project’s preferences by selecting the runtime on | |
| the "Targeted Runtimes" preference page. </p><p> | |
| </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.gif"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"> | |
| In most scenarios it is sufficient to target the PAR project to a runtime. The nested bundles will then | |
| automatically inherit this setting. | |
| </td></tr></table></div><p> | |
| </p><p> | |
| <img src="images/tooling-classpath.png"> | |
| </p><p> After targeting the project or PAR you will see a "Bundle Dependencies" classpath container in your Java | |
| project. It is now safe to remove any manually configured classpath entries. </p><p> The classpath container will automatically attach Java source code to the classpath entries by looking for | |
| source JARs next to the binary JARs in the Virgo Runtime Environment’s repository. You can also manually override | |
| the source code attachment by using the properties dialog on a single JAR entry. This manual attachment will always | |
| override the convention-based attachment. </p></div></div><!--Begin LoopFuse code--><script src="http://loopfuse.net/webrecorder/js/listen.js" type="text/javascript"></script><script type="text/javascript"> | |
| _lf_cid = "LF_48be82fa"; | |
| _lf_remora(); | |
| </script><!--End LoopFuse code--><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch05s05.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch06s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.5 Server Console Page </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 6.2 Editing the Manifest</td></tr></table></div></body></html> |