summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/sca-java-get-started-with-coding.html
diff options
context:
space:
mode:
Diffstat (limited to 'site/trunk/site-publish/sca-java-get-started-with-coding.html')
-rw-r--r--site/trunk/site-publish/sca-java-get-started-with-coding.html202
1 files changed, 202 insertions, 0 deletions
diff --git a/site/trunk/site-publish/sca-java-get-started-with-coding.html b/site/trunk/site-publish/sca-java-get-started-with-coding.html
new file mode 100644
index 0000000000..71ddf24f5b
--- /dev/null
+++ b/site/trunk/site-publish/sca-java-get-started-with-coding.html
@@ -0,0 +1,202 @@
+
+<!--
+
+ 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 Get Started with Coding</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%">
+ &nbsp;
+ </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=64177">
+ <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%">
+ &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="SCA Java Get Started with Coding">SCA Java Get Started with Coding</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>
+ <!-- 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">
+ <P><IMG class="emoticon" src="https://cwiki.apache.org/confluence/images/icons/emoticons/lightbulb_on.gif" height="16" width="16" align="absmiddle" alt="" border="0"> This page is in progress. Goal is to provide developers with a quick walk through of key methods so that they can get started coding/debugging. <B>Please help update this page. Thanks.</B></P>
+
+<H1><A name="SCAJavaGetStartedwithCoding-BringingUpAStandaloneTuscanyRuntime."></A>Bringing Up A Standalone Tuscany Runtime. </H1>
+<P>When starting to look at the Tuscany SCA Java runtime it is useful to understand what top level calls are made and why. Currently there are several implementations of a &quot;Domain&quot; object that can be used to start up Tuscany.</P>
+
+<UL>
+ <LI>DefaultSCADomain - a simple domain implementation that hides most of the details. Used in most test cases to date</LI>
+ <LI>EmbeddedSCADomain - used for embedding Tuscany into other systems</LI>
+ <LI>HotUpdateSCADomain - an example that automatically loads contributions as they change</LI>
+ <LI>EmbeddedNode - A node in a distributed domain</LI>
+</UL>
+
+
+<P>Looking at EmbeddedSCADomain gives a good view of what is necessary to bring up the runtime. The class can be seen in svn <A href="http://svn.apache.org/repos/asf/tuscany/java/sca/modules/host-embedded/src/main/java/org/apache/tuscany/sca/host/embedded/impl/EmbeddedSCADomain.java" class="external-link" rel="nofollow">here</A> and a test program that uses it can be seen <A href="http://svn.apache.org/repos/asf/tuscany/java/sca/modules/host-embedded/src/test/java/org/apache/tuscany/sca/host/embedded/SCADomainTestCase.java" class="external-link" rel="nofollow">here</A>.</P>
+
+<P>The EmbeddedSCADomain class provides an implementation of an SCA domain that holds all the parts of the runtime together within a single VM. Creating and embedded domain is straighforward.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+domain = <SPAN class="code-keyword">new</SPAN> EmbeddedSCADomain(cl, domainName);
+domain.start();
+</PRE>
+</DIV></DIV>
+
+<P>Calling the start methd on the domain causes all the runtime artifacts to be built. In particular all the runtime extensions, e.g. implementation, binding, databinding, host, are loaded and initialized using the java META-INF/services mechanism. </P>
+
+<P>The next thing to do is load and SCA application into the domain. SCA applications are deployed as contributions. A contribution brings together composite file with all the resources required by the composite file, e.g. .java, .xml. xsd. wsdl etc. in a structure defined by the SCA assembly specification. The EmbeddedSCADomain provides a contribution service for reading contributions. Here the contribution service is retrieved and a contribution, identified by a URL, is added to it. </P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+ContributionService contributionService = domain.getContributionService();
+Contribution contribution = contributionService.contribute(<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//calculator&quot;</SPAN>,
+</SPAN> contributionURL,
+ <SPAN class="code-keyword">null</SPAN>, <SPAN class="code-comment">//resolver,
+</SPAN> <SPAN class="code-keyword">false</SPAN>);
+</PRE>
+</DIV></DIV>
+
+<P>This results in an in memory assembly model (see the assembly module).You can get at the deployable parts of the model by asking the resulting contribution. </P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+Composite composite = contribution.getDeployables().get(0);
+</PRE>
+</DIV></DIV>
+
+<P>The root of the deployable model is a composite which contains a hierarchy of components that will run in the Tuscany runtime. Various steps are now taken to turn the logical assembly model into runnable artifacts so that the components can be started. </P>
+
+<P>First the the model composite gets added to a top level composite that the local domain controls.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+domain.getDomainComposite().getIncludes().add(composite);
+</PRE>
+</DIV></DIV>
+
+<P>Then there is a build stage where the parts of the logical model are linked together, references to services etc.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+domain.getCompositeBuilder().build(composite);
+</PRE>
+</DIV></DIV>
+
+<P>Then finally the runtime artifacts are created based on the logical model, these include the service endpoints and clients. </P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+domain.getCompositeActivator().activate(composite);
+</PRE>
+</DIV></DIV>
+
+<P>Once all this is done, each composite in the domain can be started independently. It is at this stage, for example, that the servlets required to support web services on an HTTP transport are actually deployed.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">for</SPAN> (Composite composite : domain.getDomainComposite().getIncludes()){
+ domain.getCompositeActivator().start(composite);
+}
+</PRE>
+</DIV></DIV>
+
+<H1><A name="SCAJavaGetStartedwithCoding-TheDistrubutedRuntime"></A>The Distrubuted Runtime</H1>
+
+<P>When a domain is distributed across more than one VM an extra step is required. Once the logical model has been through the build stage there is a step where information is provided to the runtime so that remote services can be resolved automatically across the network. I.e. we link all of the services and reference in the assembly model into the notion of a distributed domain.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+distributedDomain.addDistributedDomainToBindings(composite);
+</PRE>
+</DIV></DIV>
+
+ </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&nbsp;&nbsp;</BR>
+ Apache Tuscany and the Apache Tuscany project logo are trademarks of The Apache Software Foundation.
+ </DIV>
+ <!-- footer macro end -->
+
+ </BODY>
+</HTML>