From 200a40b332420f94992eb39a6d0ea1cf1490ffc4 Mon Sep 17 00:00:00 2001 From: coreyg Date: Fri, 21 Nov 2014 09:30:19 +0000 Subject: 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 --- ...cany-sca-web-application-integration-story.html | 230 +++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 site/trunk/site-publish/tuscany-sca-web-application-integration-story.html (limited to 'site/trunk/site-publish/tuscany-sca-web-application-integration-story.html') diff --git a/site/trunk/site-publish/tuscany-sca-web-application-integration-story.html b/site/trunk/site-publish/tuscany-sca-web-application-integration-story.html new file mode 100644 index 0000000000..de5c7e5c44 --- /dev/null +++ b/site/trunk/site-publish/tuscany-sca-web-application-integration-story.html @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + Apache Tuscany : Tuscany SCA Web Application Integration Story + + + + + + + + + + + + + + + +
+ + + + +   + +
+ + +
+
+ + + + + + + + + +
+  Apache Tuscany > Home > SCA Overview > SCA Java > SCA Java Work-In-Progress > Tuscany SCA Web Application Integration Story + + User List | Dev List | Issue Tracker   +
+ + + + + + + +
+ + +
+ +
+
+

+ + + + + + +
+ +

Web Application Integration story goals

+ +
    +
  • Simplify the web application as a client application story
  • +
  • Use a simple approach, familiar to all web application developers
  • +
+ + +

Integrating using ServletContextLister

+ +

This approach register a context listener on the application web.xml that will bootstrap the runtime when the web-app is started, and closes the runtime when the web-app is shutdown.

+ +

Necessary updates in web.xml

+
+
+<listener>
+ <listener-class>org.apache.tuscany.sca.webapp.TuscanyContextListener</listener-class>
+</listener>
+
+
+ +

Then, once this integration part is defined, developers only need to get a reference to the SCADomain in their JSP and then get a reference to a service and start consuming it
+Below, you can find the JSP code snippet to get a SCARuntime reference :

+
+
+SCADomain domain = (SCADomain) application.getAttribute("org.apache.tuscany.sca.SCADomain");
+
+
+ +

In order to use this approach, you will need to specify a sca-contribution.xml inside the META-INF directory of your web-app, this file will be used to identify the root of the contribution as well as the list of deployable composites.

+ +

Here is a sample sca-contribution.xml used in the calculator-web application:

+ +
+
+<?xml version="1.0" encoding="UTF-8"?>
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0">
+   <deployable composite="Calculator"/>
+</contribution>
+
+
+ + +

Tuscany also supports the scenario where you would drop the SCA composite files inside the META-INF\sca-deployables directory, and this would also be used to identify the root of the contribution and the list of deployable composites.

+ +

pros: Consistent programming model between JSP and Servlets
+cons: require web.xml integration and sca-contribution.xml, although the trend is to make web apps simpler and web.xml is optional in newer specs of J2EE

+ +

Integrating using pure JSP code

+ +

Integration using useBean tag: This approach would be very simple, and would basically ask the developer to add a useBean to instantiate the domain, and a setProperty to set the deployableComposite/

+
+
+<jsp:useBean id="SCADomain" class="org.apache.tuscany.host.embedded.SCADomainBean" scope="application">
+ <jsp:setProperty property="deployableComposite" value="Calculator.composite" />
+</jsp:useBean>
+...
+<%
+ SCADomain domain = (SCADomain) application.getAttribute("SCADomain");
+ CalculatorService calculatorService = domain.getService(CalculatorService.class, "CalculatorServiceComponent");
+%>
+
+
+

Optional attributes can be defined by using the <jsp:setProperty> calls, if no attributes are specified, the sca-contribution.xml will be used to hint the root of the contribution as well as to find the deployable composites.

+ +

In this scenario, the SCADomain is stopped when the application goes out of scope and the garbage collection process the termination of the SCADomain.

+ +

pros: simple, does not involve changes on web.xml
+cons: leaves toping the sca domain/runtime to when garbage collection process the application scope bean, also introduce different programming model between JSP and Servlets.

+ + + +

References

+ +

http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
+http://java.sun.com/products/jsp/docs.html#syntax
+http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html
+http://java.sun.com/products/javabeans/docs/spec.html

+
+
+
+
+ + +
+ + + + + + website stats + + + + + + -- cgit v1.2.3