diff options
Diffstat (limited to '')
-rw-r--r-- | site/trunk/site-publish/java-sca-extension-guide.html | 297 |
1 files changed, 297 insertions, 0 deletions
diff --git a/site/trunk/site-publish/java-sca-extension-guide.html b/site/trunk/site-publish/java-sca-extension-guide.html new file mode 100644 index 0000000000..ddd87b18d9 --- /dev/null +++ b/site/trunk/site-publish/java-sca-extension-guide.html @@ -0,0 +1,297 @@ + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<HTML> + <HEAD> + <LINK type="text/css" rel="stylesheet" href="resources/space.css"> + <STYLE type="text/css"> + .footer { + background-image: url('http://cwiki.apache.org/confluence/images/border/border_bottom.gif'); + background-repeat: repeat-x; + background-position: left top; + padding-top: 4px; + color: #666; + } + </STYLE> + <SCRIPT type="text/javascript" language="javascript"> + var hide = null; + var show = null; + var children = null; + + function init() { + /* Search form initialization */ + var form = document.forms['search']; + if (form != null) { + form.elements['domains'].value = location.hostname; + form.elements['sitesearch'].value = location.hostname; + } + + /* Children initialization */ + hide = document.getElementById('hide'); + show = document.getElementById('show'); + children = document.all != null ? + document.all['children'] : + document.getElementById('children'); + if (children != null) { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + } + + function showChildren() { + children.style.display = 'block'; + show.style.display = 'none'; + hide.style.display = 'inline'; + } + + function hideChildren() { + children.style.display = 'none'; + show.style.display = 'inline'; + hide.style.display = 'none'; + } + </SCRIPT> + <TITLE>Java SCA Extension Guide</TITLE> + <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD> + <BODY onload="init()"> + <TABLE border="0" cellpadding="2" cellspacing="0" width="100%"> + <TR class="topBar"> + <TD align="left" valign="middle" class="topBarDiv" nowrap=""> + <A href="home.html" title="Apache Tuscany">Apache Tuscany</A> > <A href="home.html" title="Home">Home</A> > <A href="java-sca-subproject.html" title="Java SCA Subproject">Java SCA Subproject</A> > <A href="java-sca-menu.html" title="Java SCA Menu">Java SCA Menu</A> > <A href="" title="Java SCA Extension Guide">Java SCA Extension Guide</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> + + <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="/wiki/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</DIV> + <DIV style="margin: 0px 10px 8px 10px" class="pagetitle">Java SCA Extension Guide</DIV> + + <DIV class="greynavbar" align="right" style="padding: 2px 10px; margin: 0px;"> + <A href="http://cwiki.apache.org/confluence/pages/editpage.action?pageId=51879"> + <IMG src="http://cwiki.apache.org/confluence/images/icons/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A> + <A href="http://cwiki.apache.org/confluence/pages/editpage.action?pageId=51879">Edit Page</A> + + <A href="http://cwiki.apache.org/confluence/pages/listpages.action?key=TUSCANY"> + <IMG src="http://cwiki.apache.org/confluence/images/icons/browse_space.gif" height="16" width="16" border="0" align="absmiddle" title="Browse Space"></A> + <A href="http://cwiki.apache.org/confluence/pages/listpages.action?key=TUSCANY">Browse Space</A> + + <A href="http://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANY&fromPageId=51879"> + <IMG src="http://cwiki.apache.org/confluence/images/icons/add_page_16.gif" height="16" width="16" border="0" align="absmiddle" title="Add Page"></A> + <A href="http://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANY&fromPageId=51879">Add Page</A> + + <A href="http://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=TUSCANY&fromPageId=51879"> + <IMG src="http://cwiki.apache.org/confluence/images/icons/add_blogentry_16.gif" height="16" width="16" border="0" align="absmiddle" title="Add News"></A> + <A href="http://cwiki.apache.org/confluence/pages/createblogpost.action?spaceKey=TUSCANY&fromPageId=51879">Add News</A> + </DIV> + </DIV> + <DIV class="pagesubheading" style="margin: 0px 10px 0px 10px;"> + Added by <A href="http://cwiki.apache.org/confluence/display/~rfeng/Index">Raymond Feng</A>, last edited by <A href="http://cwiki.apache.org/confluence/users/viewuserprofile.action?username=edwardsmj">Mike Edwards</A> on May 03, 2007 + (<A href="http://cwiki.apache.org/confluence/pages/diffpages.action?pageId=51879&originalId=53223">view change</A>) + + </DIV> + + <DIV class="pagecontent"> + <DIV class="wiki-content"> + <DIV class="panel" style="border-style: solid; border-color: #6699ff; "><DIV class="panelHeader" style="border-bottom-style: solid; border-bottom-color: #6699ff; background-color: #D5EFFF; "><B>Apache Tuscany SCA Java Extension Guide</B></DIV><DIV class="panelContent" style="background-color: #ffffff; "> +<P><B>This page is work in progress. Thanks for your contribution</B> <IMG class="emoticon" src="http://cwiki.apache.org/confluence/images/icons/emoticons/smile.gif" height="20" width="20" align="absmiddle" alt="" border="0"><BR> +This is a guide for developers who would like to extend Tuscany SCA Java.</P> +<UL> + <LI><A href="#JavaSCAExtensionGuide-extension" title="extension on Java SCA Extension Guide">What is an extension?</A></LI> + <LI><A href="#JavaSCAExtensionGuide-component" title="component on Java SCA Extension Guide">How to add a new component implementation? </A></LI> + <LI><A href="#JavaSCAExtensionGuide-binding" title="binding on Java SCA Extension Guide">How to add a new binding? </A></LI> + <LI><A href="#JavaSCAExtensionGuide-interface" title="interface on Java SCA Extension Guide">How to add a new interface binding? </A></LI> +</UL> + + +<UL> + <LI><A href="#JavaSCAExtensionGuide-databinding" title="databinding on Java SCA Extension Guide">How to add a databinding </A></LI> + <LI><A href="#JavaSCAExtensionGuide-generalguide" title="general guide on Java SCA Extension Guide">General guide for developing extensions</A></LI> + <LI><A href="#JavaSCAExtensionGuide-details" title="details on Java SCA Extension Guide">Details on extension architecture</A> <B>can move to architecture doc</B> +<BR clear="all"> + </LI> +</UL> +</DIV></DIV> +<TABLE class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><TBODY><TR></TR></TBODY></TABLE> + +<H3><A name="JavaSCAExtensionGuide-"></A><A name="JavaSCAExtensionGuide-extension"></A><FONT color="#0099cc">What is an extension?</FONT></H3> + +<P>Extension is a module (or a set of modules),when built with Tuscany SCA, can extend it to work with additional bindings, language implementations, programming models or databindings.</P> + +<P>SCA assembly model is defined such that extensions can be added for new interface types or for new implementation types such as ruby and python, or new binding types such as CXF. However, the definition of extension SPIs is left to the implementor. Tuscany SCA Java provides a simple set of SPIs for implementing extensions. It also defines additional extension points such as data binding, for example support for SDO and JAXB.</P> + +<P>This guide explains the steps to add each of these extension types. Please help us refine the guide as you go through the steps of adding extensions.</P> + +<H4><A name="JavaSCAExtensionGuide-Namespacesusedbyextensions"></A>Name spaces used by extensions</H4> + + +<H3><A name="JavaSCAExtensionGuide-"></A><A name="JavaSCAExtensionGuide-component"></A><FONT color="#0099cc">How to add a new component implementation?</FONT></H3> + +<P><A href="mike-edwards-ramble-through-adding-a-new-component-type.html" title="Mike Edwards Ramble through Adding a New Component Type">Musings on Adding a New Component Type by Mike E</A> </P> + +<H3><A name="JavaSCAExtensionGuide-"></A><A name="JavaSCAExtensionGuide-binding"></A><FONT color="#0099cc">How to add a new binding?</FONT></H3> + + +<H3><A name="JavaSCAExtensionGuide-"></A><A name="JavaSCAExtensionGuide-interface"></A><FONT color="#0099cc">How to add a new interface binding?</FONT></H3> + + +<H3><A name="JavaSCAExtensionGuide-"></A><A name="JavaSCAExtensionGuide-databinding"></A><FONT color="#0099cc">How to add a new databinding?</FONT></H3> + + +<H3><A name="JavaSCAExtensionGuide-"></A><A name="JavaSCAExtensionGuide-generalguide"></A><FONT color="#0099cc">General guide for developing extensions</FONT></H3> + +<UL> + <LI>Familiarize yourself with SCA 1.0 Assembly and the SCA Java 1.0 programming model. Specifications can be found at www.osoa.org.</LI> + <LI>Never reference any classes in core. These classes are implementation-specific and subject to change; they are not part of the public SPI contract.</LI> + <LI>Use autowire when assembling extension components.</LI> + <LI>Do not play with classloaders such as setting the current context classloader unless it is absolutely necessary, i.e. a library used by an extension makes assumptions about context classloaders. Ideally the library can be refactored to not make these assumptions. If not, make sure the extension properly resets the current context classloader.</LI> +</UL> + + +<H3><A name="JavaSCAExtensionGuide-"></A><A name="JavaSCAExtensionGuide-details"></A><FONT color="#0099cc">Detail on extension architecture</FONT></H3> + + +<H4><A name="JavaSCAExtensionGuide-TheExtensionPointRegistry"></A>The ExtensionPointRegistry</H4> + +<DIV class="code"><DIV class="codeContent"> +<PRE class="code-java"><SPAN class="code-keyword">package</SPAN> org.apache.tuscany.core; + +/** + * The registry <SPAN class="code-keyword">for</SPAN> the Tuscany core extension points. + * + * @version $Rev: 529327 $ $Date: 2007-04-16 10:10:43 -0700 (Mon, 16 Apr 2007) $ + */ +<SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">interface</SPAN> ExtensionPointRegistry { + + /** + * Add an extension point to the registry + * @param <T> + * @param extensionPointType The <SPAN class="code-keyword">interface</SPAN> of the extension point + * @param extensionPoint The instance of the extension point + */ + <T> void addExtensionPoint(<SPAN class="code-object">Class</SPAN><T> extensionPointType, T extensionPoint); + + /** + * Get the extension point by the <SPAN class="code-keyword">interface</SPAN> + * @param <T> + * @param extensionPointType + * @<SPAN class="code-keyword">return</SPAN> + */ + <T> T getExtensionPoint(<SPAN class="code-object">Class</SPAN><T> extensionPointType); + + /** + * Remove an extension point + * @param extensionPoint + */ + void removeExtensionPoint(<SPAN class="code-object">Class</SPAN> extensionPoint); +}</PRE> +</DIV></DIV> + +<H4><A name="JavaSCAExtensionGuide-TheModuleActivator"></A>The ModuleActivator</H4> + +<DIV class="code"><DIV class="codeContent"> +<PRE class="code-java"><SPAN class="code-keyword">package</SPAN> org.apache.tuscany.core; + +<SPAN class="code-keyword">import</SPAN> java.util.Map; + +/** + * ModuleActivator represents a module that plugs into the Tuscany system. Each module should + * provide an implementation of <SPAN class="code-keyword">this</SPAN> <SPAN class="code-keyword">interface</SPAN> and registry the implementation class by defining + * a file named as <SPAN class="code-quote">"META-INF/services/org.apache.tuscany.spi.bootstrp.ModuleActivator"</SPAN>. The + * content of the file is the class name of the implementation. The implementation class must + * have a no-arg constructor. The same instance will be used to invoke all the methods during + * different phases of the module activation. + * + * @version $Rev: 529327 $ $Date: 2007-04-16 10:10:43 -0700 (Mon, 16 Apr 2007) $ + */ +<SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">interface</SPAN> ModuleActivator { + /** + * Get a map of the extension points defined by <SPAN class="code-keyword">this</SPAN> module. The key is the + * java <SPAN class="code-keyword">interface</SPAN> to represent the extension point and the the value is the + * instance of the implementation of the <SPAN class="code-keyword">interface</SPAN>. + * + * @<SPAN class="code-keyword">return</SPAN> All the extension points defined by <SPAN class="code-keyword">this</SPAN> module + */ + Map<<SPAN class="code-object">Class</SPAN>, <SPAN class="code-object">Object</SPAN>> getExtensionPoints(); + + /** + * This method is invoked when the module is started by the Tuscany system. + * It can be used by <SPAN class="code-keyword">this</SPAN> module to registr extensions against extension + * points. + * + * @param registry The extension point registry + */ + void start(ExtensionPointRegistry registry); + + /** + * This method is invoked when the module is stopped by the Tuscany system. + * It can be used by <SPAN class="code-keyword">this</SPAN> module to unregister extensions against the + * extension points. + * + * @param registry The extension point registry + */ + void stop(ExtensionPointRegistry registry); +}</PRE> +</DIV></DIV> +<P>The ModuleActivator represents a module that plugs into the Tuscany system.<BR> +Each module should provide an implementation <SPAN class="nobr"><A href="http://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANY&title=3&linkCreation=true&fromPageId=51879" title="Create Page: 3" class="createlink">3<SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/plus.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN> of this interface and<BR> +registry the implementation class by defining a file named as<BR> +"META-INF/services/org.apache.tuscany.spi.bootstrp.ModuleActivator" <SPAN class="nobr"><A href="http://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANY&title=4&linkCreation=true&fromPageId=51879" title="Create Page: 4" class="createlink">4<SUP><IMG class="rendericon" src="http://cwiki.apache.org/confluence/images/icons/plus.gif" height="7" width="7" align="absmiddle" alt="" border="0"></SUP></A></SPAN>. The<BR> +content of the file is the class name of the implementation. The<BR> +implementation class must have a no-arg constructor. The same instance will<BR> +be used to invoke all the methods during different phases of the module<BR> +activation.</P> + +<P>During bootstraping, the following sequence will happen:</P> + +<P>1) All the module activators will be discovered by the presence of<BR> +META-INF/services/org.apache.tuscany.spi.bootstrp.ModuleActivator<BR> +2) The activator class is instantiated using the no-arg constructor.<BR> +3) ModuleActivator.getExtensionPoints() is invoked for all modules and the<BR> +extension points contributed by each module are added to the<BR> +ExtensionRegistry.<BR> +4) ModuleActivator.start(ExtensionRegistry) is invoked for all the modules.<BR> +The module can then get interested extension points and contribute<BR> +extensions to them. The contract bwteen the extension and extension point is<BR> +private to the extension point. The extension point can follow similar<BR> +patterns such as Registry. If it happens that one extension point has a<BR> +dependency on another extension point, they can linked at this phase.</P> + +<P>During shutting down, the stop() method is invoked for all the modules to<BR> +perform cleanups. A module can choose to unregister the extension from the<BR> +extension points.</P> + </DIV> + + <DIV class="tabletitle"> + Children + <SPAN class="smalltext" id="show" style="display: inline;"> + <A href="javascript:showChildren()">Show Children</A></SPAN> + <SPAN class="smalltext" id="hide" style="display: none;"> + <A href="javascript:hideChildren()">Hide Children</A></SPAN> + </DIV> + <DIV class="greybox" id="children" style="display: none;"> + <A href="mike-edwards-ramble-through-adding-a-new-component-type.html" title="Mike Edwards Ramble through Adding a New Component Type">Mike Edwards Ramble through Adding a New Component Type</A> + <SPAN class="smalltext">(Apache Tuscany)</SPAN> + <BR> + </DIV> + + </DIV> + </DIV> + <DIV class="footer"> + Generated by + <A href="http://www.atlassian.com/confluence/">Atlassian Confluence</A> (Version: 2.2.9 Build: 527 Sep 07, 2006) + <A href="http://could.it/autoexport/">AutoExport Plugin</A> (Version: Unknown - PluginManager Error) + </DIV> + </BODY> +</HTML>
\ No newline at end of file |