summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/documentation-2x/osgi-aware-programming-in-tuscany.html
diff options
context:
space:
mode:
authorcoreyg <coreyg@13f79535-47bb-0310-9956-ffa450edef68>2014-11-21 09:30:19 +0000
committercoreyg <coreyg@13f79535-47bb-0310-9956-ffa450edef68>2014-11-21 09:30:19 +0000
commit200a40b332420f94992eb39a6d0ea1cf1490ffc4 (patch)
tree1c76ef1d254c7bfc91128a313d319bd60da9d01e /site/trunk/site-publish/documentation-2x/osgi-aware-programming-in-tuscany.html
parent85f53ab6ab4f664d63774c94b672a875c9e52b8a (diff)
Adding tuscany's website to their svn repo for svnpubsub
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1640879 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'site/trunk/site-publish/documentation-2x/osgi-aware-programming-in-tuscany.html')
-rw-r--r--site/trunk/site-publish/documentation-2x/osgi-aware-programming-in-tuscany.html300
1 files changed, 300 insertions, 0 deletions
diff --git a/site/trunk/site-publish/documentation-2x/osgi-aware-programming-in-tuscany.html b/site/trunk/site-publish/documentation-2x/osgi-aware-programming-in-tuscany.html
new file mode 100644
index 0000000000..27910b1759
--- /dev/null
+++ b/site/trunk/site-publish/documentation-2x/osgi-aware-programming-in-tuscany.html
@@ -0,0 +1,300 @@
+
+
+
+
+
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<HTML>
+ <HEAD>
+ <META name="description" content="Apache Tuscany">
+ <META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture, sca, service component architecture, das, sdo, csa, ruby, opensource">
+
+ <LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
+ <LINK rel="SHORTCUT ICON" href="https://cwiki.apache.org/confluence/display/TUSCANYxDOCx2x/$images/favicon.ico">
+ <TITLE>OSGi Aware Programming in Tuscany : Apache Tuscany</TITLE>
+ <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
+
+ <STYLE>
+ .spacetree * ul {
+ padding-left:0px;
+ margin-left: 0px;
+ }
+ .spacetree * li {
+ margin-left: 5px;
+ padding-left:5px;
+ }
+ </STYLE>
+
+ <BODY onload="init()">
+ <!-- topNav -->
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+ <TR class="topBar">
+ <TD align="left" valign="middle" class="topBarDiv" align="left" nowrap="">
+ <A href="https://cwiki.apache.org/geronimo"> Home</A> &gt;&nbsp;<A href="index.html" title="Apache Tuscany Docs 2.x">Apache Tuscany Docs 2.x</A>&nbsp;&gt;&nbsp;<A href="index.html" title="Index">Index</A>&nbsp;&gt;&nbsp;<A href="development-guides.html" title="Development Guides">Development Guides</A>&nbsp;&gt;&nbsp;<A href="" title="OSGi Aware Programming in Tuscany">OSGi Aware Programming in Tuscany</A>
+ </TD>
+ <TD align="right" valign="middle" nowrap="">
+ <FORM name="search" action="http://www.google.com/search" method="get">
+ <INPUT type="hidden" name="ie" value="UTF-8">
+ <INPUT type="hidden" name="oe" value="UTF-8">
+ <INPUT type="hidden" name="domains" value="">
+ <INPUT type="hidden" name="sitesearch" value="">
+ <INPUT type="text" name="q" maxlength="255" value="">
+ <INPUT type="submit" name="btnG" value="Google Search">
+ </FORM>
+ </TD>
+ </TR>
+ </TABLE>
+
+
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+ <TR class="topBar">
+ <TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
+ &nbsp;<A href="index.html" title="Apache Tuscany Docs 2.x">Apache Tuscany Docs 2.x</A>&nbsp;&gt;&nbsp;<A href="index.html" title="Index">Index</A>&nbsp;&gt;&nbsp;<A href="development-guides.html" title="Development Guides">Development Guides</A>&nbsp;&gt;&nbsp;<A href="" title="OSGi Aware Programming in Tuscany">OSGi Aware Programming in Tuscany</A>
+ </TD>
+
+ <TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
+ <A href="http://tuscany.apache.org/">Tuscany Home</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
+ </TD>
+ </TR>
+ </TABLE>
+
+ <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
+ <TR>
+ <TD valign="top" align="left" width="22%" bgcolor="#F9F9F9" class="noprint">
+ <DIV class="tabletitle">Table of Contents</DIV>
+ <DIV class="spacetree">
+
+
+ </DIV>
+ </TD>
+ <TD align="left" valign="top" width="78%">
+ <!-- pageContent -->
+ <DIV id="PageContent">
+ <DIV class="pageheader" style="padding: 6px 0px 0px 0px;">
+ <!-- We'll enable this once we figure out how to access (and save) the logo resource -->
+ <!--img src="http://geronimo.apache.org/images/confluence_logo.gif" style="float: left; margin: 4px 4px 4px 10px;" border="0"-->
+ <DIV style="margin: 0px 10px 0px 10px" class="smalltext">Apache Tuscany Docs 2.x</DIV>
+ <DIV style="margin: 0px 10px 8px 10px" class="pagetitle">OSGi Aware Programming in Tuscany</DIV>
+
+ <DIV class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;">
+<!-- -->
+ <A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=109135">
+ <IMG src="http://geronimo.apache.org/images/icons/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
+ <A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=109135">Edit Page</A>
+ &nbsp;
+ <A href="https://cwiki.apache.org/confluence/pages/listpages.action?key=TUSCANYxDOCx2x">
+ <IMG src="http://geronimo.apache.org/images/icons/browse_space.gif" height="16" width="16" border="0" align="absmiddle" title="Browse Space"></A>
+ <A href="https://cwiki.apache.org/confluence/pages/listpages.action?key=TUSCANYxDOCx2x">Browse Space</A>
+ &nbsp;
+ <A href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANYxDOCx2x&fromPageId=109135">
+ <IMG src="http://geronimo.apache.org/images/icons/add_page_16.gif" height="16" width="16" border="0" align="absmiddle" title="Add Page"></A>
+ <A href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANYxDOCx2x&fromPageId=109135">Add Page</A>
+ &nbsp;
+ <A href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=TUSCANYxDOCx2x&fromPageId=109135">
+ <IMG src="http://geronimo.apache.org/images/icons/add_blogentry_16.gif" height="16" width="16" border="0" align="absmiddle" title="Add News"></A>
+ <A href="https://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=TUSCANYxDOCx2x&fromPageId=109135">Add News</A>
+<!-- -->
+ </DIV>
+ </DIV>
+
+ <DIV class="pagecontent">
+ <DIV class="wiki-content">
+ <H2><A name="OSGiAwareProgramminginTuscany-MotivationforOSGi"></A>Motivation for OSGi</H2>
+
+<P> The Apache Tuscany project has become a large project, with various extensions and component types that brings to the SCA Runtime different levels of dependencies. With its growth, Tuscany also started to have it's SPIs violated by some of these extensions, and some of the boundaries between sub-systems are broken, as there wasn't any enforcement of these boundaries.</P>
+
+<P> The OSGi model provides a very powerful and flexible framework to develop applications in a modular fashion with a high degree of control over classloading inter-dependencies over modules. An OSGi module (a.k.a bundle) have a manifest file (META-INF\manifest.mf) that contains module information such as &quot;name&quot;, &quot;version&quot; and also a list of what packages are being exported, and what packages are being imported from the given bundle, providing ways to easily enforce module boundaries.</P>
+
+<P> In summary:</P>
+<UL>
+ <LI>Better class loading mechanism for our modules</LI>
+ <LI>Create clean boundaries between sub-systems</LI>
+</UL>
+
+
+<H2><A name="OSGiAwareProgramminginTuscany-TuscanyandOSGi3rdpartydependencies"></A>Tuscany and OSGi - 3rd party dependencies</H2>
+
+<P> Currently we are wrapping the 3rd party dependencies as OSGi bundles, but leaving it unpacked (a.k.a folder structure). This allow use to use the same dependency jars in a OSGi environment as well as in a non-OSGI environment and generating no side effect on our distribution footprint.</P>
+
+<P> <SPAN class="image-wrap" style=""><IMG src="osgi-aware-programming-in-tuscany.data/osgi_3rd_party_dependencies.JPG" style="border: 0px solid black"></SPAN></P>
+
+
+<H2><A name="OSGiAwareProgramminginTuscany-TuscanyandOSGiGranularity"></A>Tuscany and OSGi - Granularity</H2>
+
+<P> The granularity used to define modules should be very familiar to all tuscany developers, </P>
+
+<P> Tuscany Modules --&gt; OSGi Bundles<BR>
+ 3rd Party Libraries --&gt; OSGi Bundles (using unpacked wrap style bundle)</P>
+
+<H2><A name="OSGiAwareProgramminginTuscany-ProperlydefiningnewTuscanymodulesasanOSGibundle"></A>Properly defining new Tuscany modules as an OSGi bundle</H2>
+
+<P> When adding new modules to the Tuscany project, the developer will need to create the OSGi Manifest to properly describe the new module as an OSGi bundle. These artifacts can be automatically generated using the Felix maven-bundle-plugin and should be available from svn repository once it's stable.</P>
+
+<H4><A name="OSGiAwareProgramminginTuscany-GeneratingOSGimanifestwithFelixmavenbundleplugin"></A>Generating OSGi manifest with Felix maven-bundle-plugin</H4>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;"><B>&quot;configuring maven to generate the OSGi manifest&quot;</B></DIV><DIV class="codeContent panelContent">
+<PRE class="code-java">
+&lt;plugin&gt;
+ &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
+ &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
+ &lt;configuration&gt;
+ &lt;instructions&gt;
+ &lt;!-- Bundle versioned from Tuscany version --&gt;
+ &lt;Bundle-Version&gt;${tuscany.version}&lt;/Bundle-Version&gt;
+ &lt;!-- Bundle Symbolic name --&gt;
+ &lt;Bundle-SymbolicName&gt;org.apache.tuscany.sca.api&lt;/Bundle-SymbolicName&gt;
+ &lt;!-- Bundle description from pom description --&gt;
+ &lt;Bundle-Description&gt;${pom.description}&lt;/Bundle-Description&gt;
+ &lt;!-- Export org.osoa.sca and all sub-packages --&gt;
+ &lt;Export-Package&gt;org.osoa.sca*&lt;/Export-Package&gt;
+ &lt;!-- No Import-Package so calculate imports from code dependencies --&gt;
+ &lt;/instructions&gt;
+ &lt;/configuration&gt;
+&lt;/plugin&gt;
+</PRE>
+</DIV></DIV>
+
+<P>Below is a manifest that was generated for one of the Tuscany modules using the felix maven-bundle-plugin.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;"><B>&quot;OSGi Manifest (META-INF\manifest.mf)&quot;</B></DIV><DIV class="codeContent panelContent">
+<PRE class="code-java">
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.assembly;uses:=&quot;javax.xml.xpath
+ ,org.apache.tuscany.sca.assembly.impl,org.apache.tuscany.sca.policy,o
+ rg.apache.tuscany.sca.interfacedef,javax.xml.namespace<SPAN class="code-quote">&quot;;version=&quot;</SPAN>1.4&quot;
+ ,org.apache.tuscany.sca.assembly.impl;uses:=&quot;javax.xml.xpath,org.apac
+ he.tuscany.sca.assembly,org.apache.tuscany.sca.policy,org.apache.tusc
+ any.sca.interfacedef,javax.xml.namespace<SPAN class="code-quote">&quot;;version=&quot;</SPAN>1.4&quot;,org.apache.tu
+ scany.sca.assembly.builder;uses:=&quot;org.apache.tuscany.sca.assembly,org
+ .apache.tuscany.sca.definitions,org.apache.tuscany.sca.core,org.apach
+ e.tuscany.sca.monitor,org.apache.tuscany.sca.interfacedef,org.apache.
+ tuscany.sca.extensibility<SPAN class="code-quote">&quot;;version=&quot;</SPAN>1.4&quot;
+Private-Package: org.apache.tuscany.sca.assembly.builder.impl;version=
+ <SPAN class="code-quote">&quot;1.4&quot;</SPAN>
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Assembly Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 1.4
+Bnd-LastModified: 1225397097203
+Bundle-ManifestVersion: 2
+Bundle-License: http:<SPAN class="code-comment">//www.apache.org/licenses/LICENSE-2.0.txt
+</SPAN>Bundle-Description: Apache Tuscany SCA Assembly Model
+Import-Package: javax.xml.namespace,javax.xml.parsers,javax.xml.transf
+ orm,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.xpath,o
+ rg.apache.tuscany.sca.assembly;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org.apache.tuscany.sca.a
+ ssembly.builder;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org.apache.tuscany.sca.assembly.impl;ve
+ rsion=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org.apache.tuscany.sca.core;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org.apache.tusc
+ any.sca.definitions;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org.apache.tuscany.sca.extensibilit
+ y;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org.apache.tuscany.sca.interfacedef;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org
+ .apache.tuscany.sca.monitor;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org.apache.tuscany.sca.poli
+ cy;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org.apache.tuscany.sca.policy.util;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>,org
+ .w3c.dom,org.xml.sax,junit.framework;resolution:=optional,org.apache.
+ tuscany.sca.interfacedef.impl;version=<SPAN class="code-quote">&quot;1.4&quot;</SPAN>;resolution:=optional,org.
+ junit;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.assembly
+Bundle-DocURL: http:<SPAN class="code-comment">//www.apache.org/</SPAN>
+</PRE>
+</DIV></DIV>
+
+<H2><A name="OSGiAwareProgramminginTuscany-TweakingtheOSGimanifest"></A>Tweaking the OSGi manifest</H2>
+
+<P> Eclipse PDE provides good tooling for editing and maintaining OSGi manifest files. There are various scenarios we might need to tweak the OSGi manifest manualy :</P>
+
+<UL>
+ <LI>Updating imported/exported packages</LI>
+ <LI>Marking test dependencies optional
+ <UL>
+ <LI>Avoid issues when tests have references to external packages</LI>
+ </UL>
+ </LI>
+</UL>
+
+
+<P> <SPAN class="image-wrap" style=""><IMG src="osgi-aware-programming-in-tuscany.data/osgi_manifest_editor.jpg" style="border: 0px solid black"></SPAN></P>
+
+<H2><A name="OSGiAwareProgramminginTuscany-PDEintegrationoftuscanymodules"></A>PDE integration of tuscany modules</H2>
+<P>1) We generate the .classpath from maven dependencies.</P>
+
+<P>2) For maven compile/provided dependencies, the modules explicit references <BR>
+these dependencies via packages. We define corresponding Import-Package <BR>
+header in the MANIFEST.MF for OSGi, and these get resolved to other bundles <BR>
+that export the matching packages. This magic comes from the <BR>
+&quot;org.eclipse.pde.core.requiredPlugins&quot; classpath container which is <BR>
+contributed by the Eclipse PDE. The classpath container resolves the OSGi <BR>
+dependencies such as Import-Package or Required-Bundle and automatically add <BR>
+the required bundles to the classpath as we see in Eclipse project under the <BR>
+&quot;Plugin Dependencies&quot;.</P>
+
+<P>3) The exported packages come from three types of sources:</P>
+<UL>
+ <LI>System packages (exported by the System Bundle, i.e., org.eclipse.osgi).<BR>
+Different JDK levels have different list of system packages, for example, <BR>
+javax.xml.stream is not in J2SE-1.5 but in JSEJava-1.6. You can find the <BR>
+complete list by looking the .profile files within osgi-&lt;version&gt;.jar.</LI>
+ <LI>Tuscany modules in the Eclipse workspace. The classpath entry will be<BR>
+listed as a project under &quot;Plugin Dependencies&quot;</LI>
+ <LI>3rd-party jars (already as OSGi bundles contributed by the target<BR>
+platform). The classpath entry will be listed as a jar under &quot;Plugin <BR>
+Dependencies&quot;</LI>
+</UL>
+
+
+<P>4) For maven runtime dependencies, there is no corresponding Import-Package <BR>
+and the dependencies are used in runtime. Ideally in OSGi, they could be a <BR>
+Required-Bundle or a bundle available at runtime. To run the project in JSE <BR>
+inside Eclipse, we generate an explicit classpath entry.</P>
+
+<P>5) For maven test dependencies, there are two types: one is for test <BR>
+compilation and the other for test runtime. For the first type, we use <BR>
+optional Import-Package to pull in the dependencies if the same project has <BR>
+the compile dependency for the same artifact. Otherwise, we generate an <BR>
+explicit classpath entry for JSE testing.</P>
+
+<P>6) For test cases which require extra dependencies in addition to the <BR>
+compile/provided/runtime dependencies for the main code, they probably <BR>
+should not be unit tests. We need to consider how to move them into the <BR>
+itest bucket.</P>
+
+
+
+
+ </DIV>
+
+ </DIV>
+ </DIV>
+ </TD>
+ </TR>
+ </TABLE>
+
+ <!-- footer -->
+ <TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
+ <TR>
+ <TD align="left" valign="middle" class="footer">
+ &nbsp;&nbsp;
+ <IMG src="http://static.delicious.com/img/delicious.small.gif" height="10" width="10" alt="Delicious">
+ <A href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'delicious','toolbar=no,width=550,height=550'); return false;">Bookmark this on Delicious</A>
+ &nbsp;&nbsp;
+ <IMG src="http://digg.com/img/badges/16x16-digg-guy.gif" width="16" height="16" alt="Digg!">
+ <A href="" onclick="window.open('http://digg.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&topic=programming');">Digg this</A>
+ <!-- Slicker, but no text
+ <script type="text/javascript">
+ digg_skin = 'icon';
+ digg_window = 'new';
+ digg_title = 'Apache Geronimo v2.2 Documentation : OSGi Aware Programming in Tuscany';
+ digg_topic = 'programming';
+ </script>
+ <script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script>
+ -->
+ &nbsp;&nbsp;
+ </TD>
+ <TD align="right" valign="middle" class="footer">
+ <A href="http://cwiki.apache.org/GMOxPMGT/geronimo-privacy-policy.html">Privacy Policy</A>&nbsp;&nbsp;-&nbsp;&nbsp;
+ Copyright &copy; 2003-2010, The Apache Software Foundation, Licensed under <A href="http://www.apache.org/licenses/LICENSE-2.0">ASL 2.0.</A>&nbsp;&nbsp;
+ </TD>
+ </TR>
+ </TABLE>
+
+ </BODY>
+</HTML> \ No newline at end of file