summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/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/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/osgi-aware-programming-in-tuscany.html')
-rw-r--r--site/trunk/site-publish/osgi-aware-programming-in-tuscany.html348
1 files changed, 348 insertions, 0 deletions
diff --git a/site/trunk/site-publish/osgi-aware-programming-in-tuscany.html b/site/trunk/site-publish/osgi-aware-programming-in-tuscany.html
new file mode 100644
index 0000000000..ba033043a3
--- /dev/null
+++ b/site/trunk/site-publish/osgi-aware-programming-in-tuscany.html
@@ -0,0 +1,348 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<!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="http://cwiki.apache.org/confluence/display/TUSCANY/$images/favicon.ico">
+
+ <TITLE>OSGi Aware Programming in Tuscany : Apache Tuscany</TITLE>
+
+ <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
+
+
+
+ <BODY onload="init()">
+
+
+
+
+ <TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg">
+
+ <TR>
+
+ <TD valing="top" align="left">
+
+ <A href="http://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
+
+ </TD>
+
+ <TD>
+
+ <A href="http://tuscany.apache.org/"><IMG src="http://tuscany.apache.org/images/TuscanyLogo.jpg" border="0"></A>
+
+ </TD>
+
+
+
+ <TD width="100%">
+
+ &nbsp;
+
+ </TD>
+
+ <!--td align="right">
+
+ <img src="http://incubator.apache.org/tuscany/images/apache- incubator- logo.png" border="0">
+
+ </td-->
+
+
+
+ <!-- Adds the edit page link to the top banner-->
+
+ <TD valign="bottom">
+
+ <DIV style="padding: 2px 10px; margin: 0px;">
+
+ <A href="http://cwiki.apache.org/confluence/pages/editpage.action?pageId=101617">
+
+ <IMG src="http://tuscany.apache.org/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
+
+ </DIV>
+
+ </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="home.html" title="Apache Tuscany">Apache Tuscany</A>&nbsp;&gt;&nbsp;<A href="home.html" title="Home">Home</A>&nbsp;&gt;&nbsp;<A href="sca-overview.html" title="SCA Overview">SCA Overview</A>&nbsp;&gt;&nbsp;<A href="sca-java.html" title="SCA Java">SCA Java</A>&nbsp;&gt;&nbsp;<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Java SCA Documentation Menu</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://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 align="left" valign="top">
+
+
+ <DIV id="PageContent">
+
+
+
+
+ <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> <IMG src="osgi-aware-programming-in-tuscany.data/osgi_3rd_party_dependencies.JPG" align="absmiddle" border="0"></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> <IMG src="osgi-aware-programming-in-tuscany.data/osgi_manifest_editor.jpg" align="absmiddle" border="0"></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>
+
+
+
+
+
+ <SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
+
+ </SCRIPT>
+
+ <SCRIPT type="text/javascript">
+
+ _uacct = "UA-1174707-5";
+
+ urchinTracker();
+
+ </SCRIPT>
+
+
+
+
+ <A href="http://www.statcounter.com/" target="_blank"><IMG src="http://c26.statcounter.com/counter.php?sc_project=2619156&java=0&security=94bd7e7d&invisible=0" alt="website stats" border="0"></A>
+
+
+
+ <DIV class="footer">
+
+ Copyright &copy; 2003-2008, The Apache Software Foundation&nbsp;&nbsp;
+
+ </DIV>
+
+
+
+
+ </BODY>
+
+</HTML>