diff options
author | coreyg <coreyg@13f79535-47bb-0310-9956-ffa450edef68> | 2014-11-21 09:30:19 +0000 |
---|---|---|
committer | coreyg <coreyg@13f79535-47bb-0310-9956-ffa450edef68> | 2014-11-21 09:30:19 +0000 |
commit | 200a40b332420f94992eb39a6d0ea1cf1490ffc4 (patch) | |
tree | 1c76ef1d254c7bfc91128a313d319bd60da9d01e /site/trunk/site-publish/sca-java-extension-development-guide.html | |
parent | 85f53ab6ab4f664d63774c94b672a875c9e52b8a (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/sca-java-extension-development-guide.html')
-rw-r--r-- | site/trunk/site-publish/sca-java-extension-development-guide.html | 422 |
1 files changed, 422 insertions, 0 deletions
diff --git a/site/trunk/site-publish/sca-java-extension-development-guide.html b/site/trunk/site-publish/sca-java-extension-development-guide.html new file mode 100644 index 0000000000..16d6d7a64c --- /dev/null +++ b/site/trunk/site-publish/sca-java-extension-development-guide.html @@ -0,0 +1,422 @@ + +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE- 2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<HTML> + <HEAD> + <!-- generateKeywords macro --> + <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"> + <!-- generateKeywords macro end --> + + <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/TUSCANY/$images/favicon.ico"> + <TITLE>Apache Tuscany : SCA Java Extension Development Guide</TITLE> + <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD> + + <BODY onload="init()"> + <!-- topNav macro --> + <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="https://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%"> + + </TD> + + <!-- Adds the edit page link to the top banner--> + <TD valign="bottom"> + <DIV style="padding: 2px 10px; margin: 0px;"> + <A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=51879"> + <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> + <!-- topNav macro end --> + + <!-- breadCrumbs macro --> + <TABLE border="0" cellpadding="2" cellspacing="0" width="100%"> + <TR class="topBar"> + <TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%"> + <A href="home.html" title="Apache Tuscany">Apache Tuscany</A> > <A href="home.html" title="Home">Home</A> > <A href="sca-overview.html" title="SCA Overview">SCA Overview</A> > <A href="sca-java.html" title="SCA Java">SCA Java</A> > <A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Java SCA Documentation Menu</A> > <A href="" title="SCA Java Extension Development Guide">SCA Java Extension Development Guide</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> + </TD> + </TR> + </TABLE> + <!-- breadCrumbs macro end --> + + + <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF"> + <TR> + <TD align="left" valign="top"> + + <!-- pageContent macro --> + <DIV id="PageContent"> + + <DIV class="pagecontent"> + <DIV class="wiki-content"> + <TABLE class="sectionMacro" border="0" cellpadding="5" cellspacing="0" width="100%"><TBODY><TR><TD class="confluenceTd" valign="top" width="15%"> +<DIV class="panel" style="background-color: #ECF4D1;border-color: #C3CDA1;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #C3CDA1;background-color: #C3CDA1;"><B>General</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;"> +<P><A href="home.html" title="Home">Home</A><BR> +<A href="http://www.apache.org/licenses/LICENSE-2.0.html" class="external-link" rel="nofollow">License </A><BR> +<A href="sca-java-get-involved.html" title="SCA Java Get Involved">Get Involved</A><BR> +<A href="sca-java-found-a-bug.html" title="SCA Java Found A Bug">Found a Bug?</A></P> +</DIV></DIV> + +<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;"> +<P><A href="sca-java.html" title="SCA Java">SCA Java Home</A><BR> +<A href="tuscany-dashboard.html" title="Tuscany Dashboard">SCA Dashboard</A><BR> +<A href="java-sca-tools.html" title="Java SCA Tools">Tools </A><BR> +<A href="tuscany-sca-java-faq.html" title="Tuscany SCA Java - FAQ">FAQ</A></P> +</DIV></DIV> + +<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java 1.x</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;"> +<P><A href="sca-java-releases.html" title="SCA Java Releases">Downloads</A><BR> +<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Documentation</A><BR> +<A href="https://svn.apache.org/repos/asf/tuscany/sca-java-1.x/trunk/" class="external-link" rel="nofollow">1.x Source Code</A><BR> +<A href="http://tinyurl.com/8rlxd3" class="external-link" rel="nofollow">Roadmap</A></P> +</DIV></DIV> + +<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>SCA Java 2.x</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;"> +<P><A href="sca-java-2x-releases.html" title="SCA Java 2.x Releases">Downloads</A><BR> +<A href="http://tuscany.apache.org/documentation-2x/" class="external-link" rel="nofollow">Documentation</A><BR> +<A href="https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk/" class="external-link" rel="nofollow">2.x Source Code</A><BR> +<A href="http://tinyurl.com/8rlxd3" class="external-link" rel="nofollow">Roadmap</A></P> +</DIV></DIV> + + +<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>Documentation</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;"> +<P><A href="sca-java-user-guide.html" title="SCA Java User Guide">User Guide</A><BR> +<A href="sca-java-architecture-guide.html" title="SCA Java Architecture Guide">Architecture Guide</A><BR> +<A href="sca-java-development-guide.html" title="SCA Java Development Guide">Developer Guide</A><BR> +<A href="" title="SCA Java Extension Development Guide">Extension Developer Guide</A></P> +</DIV></DIV> + +<DIV class="panel" style="background-color: #ECF4D1;border-color: #b4b4b5;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #b4b4b5;background-color: #C3CDA1;"><B>Resources</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;"> +<P><A href="tuscany-sca-java-faq.html" title="Tuscany SCA Java - FAQ">FAQ</A><BR> +<A href="https://svn.apache.org/repos/asf/incubator/tuscany/java/sca" class="external-link" rel="nofollow">Source Code</A></P> +</DIV></DIV> +</TD><TD class="confluenceTd" valign="top" width="85%"> +<P><DIV class="panel" style="background-color: #ECF4D1;border-color: #C3CDA1;border-style: solid;border-width: 1px;"><DIV class="panelHeader" style="border-bottom-width: 1px;border-bottom-style: solid;border-bottom-color: #C3CDA1;background-color: #C3CDA1;"><B>Apache Tuscany SCA Java Extension Guide</B></DIV><DIV class="panelContent" style="background-color: #ECF4D1;"> +<P>This is a guide for developers who would like to extend Tuscany SCA Java.</P> +<UL> + <LI><A href="#SCAJavaExtensionDevelopmentGuide-extension">What is an extension?</A></LI> + <LI><A href="#SCAJavaExtensionDevelopmentGuide-component">How to add a new component implementation? </A></LI> + <LI><A href="#SCAJavaExtensionDevelopmentGuide-binding">How to add a new binding? </A></LI> + <LI><A href="#SCAJavaExtensionDevelopmentGuide-interface">How to add a new interface binding? </A></LI> +</UL> + + +<UL> + <LI><A href="#SCAJavaExtensionDevelopmentGuide-databinding">How to add a databinding </A></LI> + <LI><A href="#SCAJavaExtensionDevelopmentGuide-monitor">How to add a new monitor extension? </A></LI> + <LI><A href="#SCAJavaExtensionDevelopmentGuide-generalguide">General guide for developing extensions</A></LI> + <LI><A href="#SCAJavaExtensionDevelopmentGuide-details">Details on extension architecture</A> <B>can move to architecture doc</B></LI> + <LI><A href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANY&title=Java%20SCA%20Extension%20Modules&linkCreation=true&fromPageId=51879" class="createlink">Extension Modules</A></LI> +</UL> +</DIV></DIV></P> +<DIV class="panelMacro"><TABLE class="noteMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="https://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD><DIV class="" align="center">This page is under construction- You are welcome to help and complete it </DIV> +</TD></TR></TABLE></DIV> + +<H3><A name="SCAJavaExtensionDevelopmentGuide-"></A><A name="SCAJavaExtensionDevelopmentGuide-extension"></A> <DIV class="" style="background-color: #C3CDA1;">A presentation on how to extend Tuscany in Microsoft PowerPoint format </DIV> +</H3> + +<P><B>Extending Tuscany</B> <A href="sca-java-extension-development-guide.data/ExtendingTuscany1.ppt">PPT</A> <A href="sca-java-extension-development-guide.data/ExtendingTuscany1.pdf">PDF</A></P> + +<H3><A name="SCAJavaExtensionDevelopmentGuide-"></A><A name="SCAJavaExtensionDevelopmentGuide-extension"></A> <DIV class="" style="background-color: #C3CDA1;">What is an extension? </DIV> +</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> + +<H3><A name="SCAJavaExtensionDevelopmentGuide-Namespacesusedbyextensions"></A>Name spaces used by extensions</H3> + +<P>Extensions sometimes contribute addtional elements or attributes to the SCA XML configuration model. These elements or attributes should be qualified as follows:</P> +<UL> + <LI><A href="http://www.osoa.org/xmlns/sca/1.0:" class="external-link" rel="nofollow">http://www.osoa.org/xmlns/sca/1.0:</A> if the extension is defined by the SCA spec.</LI> + <LI><A href="http://tuscany.apache.org/xmlns/sca/1.0:" class="external-link" rel="nofollow">http://tuscany.apache.org/xmlns/sca/1.0:</A> if the extesion is defined by Tuscany</LI> +</UL> + + +<H3><A name="SCAJavaExtensionDevelopmentGuide-"></A><A name="SCAJavaExtensionDevelopmentGuide-component"></A> <DIV class="" style="background-color: #C3CDA1;">How to add a new component implementation? </DIV> +</H3> + +<P><A href="mike-edwards-ramble-through-adding-a-new-implementation-type.html" title="Mike Edwards Ramble through Adding a New Implementation Type">Musings on Adding a New Implementation Type by Mike E</A> </P> + +<H3><A name="SCAJavaExtensionDevelopmentGuide-"></A><A name="SCAJavaExtensionDevelopmentGuide-binding"></A> <DIV class="" style="background-color: #C3CDA1;">How to add a new binding? </DIV> +</H3> + + +<H3><A name="SCAJavaExtensionDevelopmentGuide-"></A><A name="SCAJavaExtensionDevelopmentGuide-interface"></A> <DIV class="" style="background-color: #C3CDA1;">How to add a new interface binding? </DIV> +</H3> + + +<H3><A name="SCAJavaExtensionDevelopmentGuide-"></A><A name="SCAJavaExtensionDevelopmentGuide-databinding"></A> <DIV class="" style="background-color: #C3CDA1;">How to add a new databinding? </DIV> +</H3> + + +<H3><A name="SCAJavaExtensionDevelopmentGuide-"></A><A name="SCAJavaExtensionDevelopmentGuide-monitor"></A> <DIV class="" style="background-color: #C3CDA1;">How to add a new monitor extension? </DIV> +</H3> + + +<H4><A name="SCAJavaExtensionDevelopmentGuide-NeedforMonitorExtension"></A>Need for Monitor Extension</H4> + +<P>The need for monitor extension came as a requirement, to have a customized exception handling on Tuscany runtime especially when the user input errors are determined while reading, resolving and building phase of the contribution within the Tuscany runtime. Here different users/vendors using Tuscany with their products wanted to ignore some of the user input errors and allow the runtime to proceed further, while the others wanted to stop processing when a error is determined at the end of each phase. Another important need for a monitor extension is to validate the user inputs (via contributions) and report all the issues identified in one go (Example: As how the java compiler does for java code).</P> + +<H4><A name="SCAJavaExtensionDevelopmentGuide-Understandingmessageconversionusingmonitor"></A>Understanding message conversion using monitor</H4> + +<P>1) Errors and warnings are logged with the monitor as problems and the processing continues. Exceptions won't be thrown, where ever possible. Processing here covers any processing of user input, i.e. contributions and the artifacts they contain.<BR> +2) After each phase namely read, resolve and build contribution, the problems are read from the monitor for display to the user (currently this will have already happened as our current monitor will just log errors and warnings as it receives them but you can imagine more capable monitors).<BR> +3) The controlling logic may look at the errors and warnings it is reporting to the user and prevent further processing occurring. Or it may allow processing to continue. This depends on which bit of processing we are talking about and what errors have been reported. Sample for the controlling logic is shown below</P> +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"> +<SPAN class="code-keyword">private</SPAN> void analyseProblems() <SPAN class="code-keyword">throws</SPAN> Exception { + <SPAN class="code-keyword">for</SPAN> (Problem problem : monitor.getProblems()){ + <SPAN class="code-comment">// look <SPAN class="code-keyword">for</SPAN> any reported errors. Schema errors are filtered +</SPAN> <SPAN class="code-comment">// out as there are several that are generally reported at the +</SPAN> <SPAN class="code-comment">// moment and we don't want to stop +</SPAN> <SPAN class="code-keyword">if</SPAN> ((problem.getSeverity() == Severity.ERROR) && (!problem.getMessageId().equals(<SPAN class="code-quote">"SchemaError"</SPAN>))) { + <SPAN class="code-keyword">if</SPAN> (problem.getCause() != <SPAN class="code-keyword">null</SPAN>){ + <SPAN class="code-keyword">throw</SPAN> <SPAN class="code-keyword">new</SPAN> Exception(problem.getCause()); + } <SPAN class="code-keyword">else</SPAN> { + <SPAN class="code-keyword">throw</SPAN> <SPAN class="code-keyword">new</SPAN> Exception(problem.toString()); + } + } + } +} +</PRE> +</DIV></DIV> + +<H4><A name="SCAJavaExtensionDevelopmentGuide-Creatinganewmonitorextension"></A>Creating a new monitor extension</H4> + +<P>NOTE: Please have a look at the interface design of Monitor, Problem and MonitorFactory from monitor module in the Tuscany source code.</P> + +<P>Step 1) Create a class MyMonitorImpl.java which implements the Monitor interface.</P> +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"> +<SPAN class="code-keyword">public</SPAN> class MyMonitorImpl <SPAN class="code-keyword">implements</SPAN> Monitor { + <SPAN class="code-keyword">private</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-keyword">final</SPAN> Logger logger = Logger.getLogger(DefaultMonitorImpl.class.getName()); + <SPAN class="code-comment">// Cache all the problem reported to monitor <SPAN class="code-keyword">for</SPAN> further analysis +</SPAN> <SPAN class="code-keyword">private</SPAN> List<Problem> problemCache = <SPAN class="code-keyword">new</SPAN> ArrayList<Problem>(); + <SPAN class="code-keyword">public</SPAN> void problem(Problem problem) { + <SPAN class="code-comment">// Your custom code to handle the problem +</SPAN> } + <SPAN class="code-comment">// Returns a list of reported problems. +</SPAN> <SPAN class="code-keyword">public</SPAN> List<Problem> getProblems(){ + <SPAN class="code-keyword">return</SPAN> problemCache; + } +} +</PRE> +</DIV></DIV> +<P>Step 2) Create a class MyMonitorFactoryImpl.java which implements the MonitorFactory interface.</P> +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"> +<SPAN class="code-keyword">public</SPAN> class MyMonitorFactoryImpl <SPAN class="code-keyword">implements</SPAN> MonitorFactory { + <SPAN class="code-keyword">private</SPAN> Monitor monitor = <SPAN class="code-keyword">null</SPAN>; + <SPAN class="code-keyword">public</SPAN> Monitor createMonitor() { + <SPAN class="code-keyword">if</SPAN> (monitor == <SPAN class="code-keyword">null</SPAN>) { + monitor = <SPAN class="code-keyword">new</SPAN> MyMonitorImpl(); + } + <SPAN class="code-keyword">return</SPAN> monitor ; + } +} +</PRE> +</DIV></DIV> +<P>Step 3) Create a plain text file named as "META- INF/services/org.apache.tuscany.sca.monitor.MonitorFactory"<BR> +Register the extension by adding a line in this file as (org.apache.tuscany.sca.monitor.impl.MyMonitorFactoryImpl)</P> + +<H4><A name="SCAJavaExtensionDevelopmentGuide-Initializeandcreateaninstanceofthemonitor"></A>Initialize and create an instance of the monitor</H4> + +<P>Monitors can be initialized using the utility extensions as shown below.</P> +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"> +UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); +MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class); +monitor = monitorFactory.createMonitor(); +</PRE> +</DIV></DIV> + +<H3><A name="SCAJavaExtensionDevelopmentGuide-"></A><A name="SCAJavaExtensionDevelopmentGuide-generalguide"></A> <DIV class="" style="background-color: #C3CDA1;">General guide for developing extensions </DIV> +</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="SCAJavaExtensionDevelopmentGuide-"></A><A name="SCAJavaExtensionDevelopmentGuide-details"></A> <DIV class="" style="background-color: #C3CDA1;">Detail on extension architecture </DIV> +</H3> + + +<H4><A name="SCAJavaExtensionDevelopmentGuide-TheExtensionPointRegistry"></A>The ExtensionPointRegistry</H4> + +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"> +<SPAN class="code-keyword">package</SPAN> org.apache.tuscany.sca.core; + + +/** +* The registry <SPAN class="code-keyword">for</SPAN> the Tuscany core extension points. As the point of contact +* <SPAN class="code-keyword">for</SPAN> all extension artifacts <SPAN class="code-keyword">this</SPAN> registry allows loaded extensions to find +* all other parts of the system and register themselves appropriately. +* +* @version $Rev: 539355 $ $Date: 2007-05-18 03:05:14 -0700 (Fri, 18 May 2007) $ +*/ +<SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">interface</SPAN> ExtensionPointRegistry { + +/** +* Add an extension point to the registry +* @param extensionPoint The instance of the extension point +*/ +void addExtensionPoint(<SPAN class="code-object">Object</SPAN> extensionPoint); + +/** +* Get the extension point by the <SPAN class="code-keyword">interface</SPAN> +* @param extensionPointType The lookup key (extension point <SPAN class="code-keyword">interface</SPAN>) +* @<SPAN class="code-keyword">return</SPAN> The instance of the extension point +*/ +<T> T getExtensionPoint(<SPAN class="code-object">Class</SPAN><T> extensionPointType); + +/** +* Remove an extension point +* @param extensionPoint The extension point to remove +*/ +void removeExtensionPoint(<SPAN class="code-object">Object</SPAN> extensionPoint); +} +</PRE> +</DIV></DIV> + +<H4><A name="SCAJavaExtensionDevelopmentGuide-TheModuleActivator"></A>The ModuleActivator</H4> + +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"> +<SPAN class="code-keyword">package</SPAN> org.apache.tuscany.sca.core; + + +/** +* 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 register the +* ModuleActivator implementation class by defining a file named +* +* <SPAN class="code-quote">"META-INF/services/org.apache.tuscany.core.ModuleActivator"</SPAN> +* +* The content of the file is the class name of the ModuleActivator 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. Note that the start and stop methods defined by <SPAN class="code-keyword">this</SPAN> <SPAN class="code-keyword">interface</SPAN> +* take a reference to the Tuscany SCA runtime ExtensionPointRegistry. This +* gives the ModuleActivator the oppotunity to add extension points to the +* registry as it is requested to start up and remove them when it is requested +* to shut down. +* +* @version $Rev: 564429 $ $Date: 2007-08-09 16:49:11 -0700 (Thu, 09 Aug 2007) $ +*/ +<SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">interface</SPAN> ModuleActivator { + +/** +* 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. Each module can optionally provide an implementation of this interface and<BR> +register the implementation class by defining a file named as "<FONT color="#0000ff">META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</FONT>". 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.</P> + +<P>During bootstraping, the following sequence will happen:</P> + +<P>1) All the module activators will be discovered by the presence of "<FONT color="#0000ff">META-INF/services/org.apache.tuscany.sca.core.ModuleActivator</FONT>"<BR> +2) The activator class is instantiated using the no-arg constructor.<BR> +3) ModuleActivator.getExtensionPoints() is invoked for all modules and the extension points contributed by each module are added to the ExtensionRegistry.<BR> +4) ModuleActivator.start(ExtensionRegistry) is invoked for all the modules. The module can then get interested extension points and contribute<BR> +extensions to them. The contract bwteen the extension and extension point is 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 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 perform cleanups. A module can choose to unregister the extension from the<BR> +extension points.</P> + +<H4><A name="SCAJavaExtensionDevelopmentGuide-Lazyinstantiationofextensions"></A>Lazy instantiation of extensions</H4> + +<P>To reduce the startup time and memory footprint, most of the extension points in Tuscany now supports lazy instantiation of the registered extensions. The following describes the pattern using org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor as an example.</P> + +<P>1) Create a plain text file named as "<FONT color="#0000ff">META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor</FONT>"<BR> +2) Register an extension by adding a line in the file</P> +<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent"> +<PRE class="code-java"> +org.apache.tuscany.sca.implementation.java.xml.JavaImplementationProcessor;qname=http:<SPAN class="code-comment">//www.osoa.org/xmlns/sca/1.0#implementation.java,model=org.apache.tuscany.sca.implementation.java.JavaImplementation</SPAN> +</PRE> +</DIV></DIV> +<P>The simple syntax is: <FONT color="#990000"><implementation_class_name></FONT><FONT color="#0000ff">;</FONT><FONT color="#990000"><parameter_name></FONT><FONT color="#0000ff">=</FONT><FONT color="#990000"><parameter_value></FONT><FONT color="#0000ff">,</FONT><FONT color="#990000"><parameter_name></FONT><FONT color="#0000ff">=</FONT><FONT color="#990000"><parameter_value></FONT></P></TD></TR></TBODY></TABLE> + </DIV> + </DIV> + </DIV> + <!-- pageContent macro end --> + + </TD> + </TR> + </TABLE> + + <!-- footer macro --> + <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 � 2003-2012, The Apache Software Foundation </BR> + Apache Tuscany and the Apache Tuscany project logo are trademarks of The Apache Software Foundation. + </DIV> + <!-- footer macro end --> + + </BODY> +</HTML> |