SCA Java implementation.web (TUSCANY) edited by ant
Page:
http://cwiki.apache.org/confluence/display/TUSCANY/SCA+Java+implementation.web
Changes:
http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=92446&originalVersion=2&revisedVersion=3
Content:
---------------------------------------------------------------------
{section:border=false}
{column:width=15%}
{include: SCA Java Subproject Menu}
{include: Java SCA Menu New}
{column}
{column:width=85%}
h3. <implementation.web>
(!) This module is under development. What is described here reflects
unreleased trunk code and is subject to change. Your input and comments are
welcome
The Tuscany Java SCA runtime supports components implemented as JEE web modules
by using the <implementation.web> SCDL extension. Implementation.web is one of
the SCA extensions being formalized in the OASIS Open Composite Services
Architecture with a published [specification
|http://www.oasis-open.org/committees/download.php/28798/SCA_JAVAEE_Integration_V100.pdf]
document.
The web component implementation SCDL has the following format:
{code}
<implementation.web web-uri="<module name>" />
{code}
Implementation.web can be used by components such as Servlets, JSPs, and Web
2.0 style html pages. How it works depends on the way the Tuscany runtime is
being used.
h4. Using implementation.web with Servlets, Filters, and Event listeners
{code}
<component name="WebClient">
<implementation.web web-uri=""/>
<reference name="service" target="HelloworldService"/>
</component>
{code}
When using a JEE container with SCA integration (currently only a prototype for
Tomcat, see below) Servlets, Filters, and Event listeners can use annotations
to acquire references to the services wired to the component as shown in the
following Servlet code snippet:
{code}
public class HelloworldServlet extends HttpServlet {
@Reference
protected HelloworldService service;
. . .
}
{code}
When the container does not have SCA integration then injection via annotations
does not work, so to work around this the services need to be manually got from
the ComponentContext which may be obtained from the application context. This
is shown in the following code snippet:
{code}
public class HelloworldServlet extends HttpServlet {
public void init(ServletConfig config) {
ComponentContext context =
(ComponentContext)config.getServletContext().getAttribute("org.osoa.sca.ComponentContext");
HelloworldService service = context .getService(HelloworldService.class,
"service");
. . .
}
. . .
}
{code}
h4. Using implementation.web with JSPs
{code}
<component name="WebClient">
<implementation.web web-uri=""/>
<reference name="service" target="HelloworldService"/>
</component>
{code}
In the .jsp file:
{code}
<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %>
<sca:reference name="service" type="sample.HelloworldService" />
<html>
<body >
<%= service.sayHello("world") %>
</body>
</html>
{code}
h4. Using implementation.web with Web 2.0 style browser clients
{code}
<component name="WebClient">
<implementation.web web-uri=""/>
<reference name="service" target="HelloworldService">
<tuscany:binding.jsonrpc />
</reference>
</component>
{code}
In the html page:
{code}
<html>
<head>
<script type="text/javascript"
src="org.osoa.sca.componentContext.js"></script>
<script language="JavaScript">
function callSayHello() {
componentContext.getService("service").sayHello(
document.getElementById('name').value,
function(reply) {
document.getElementById('result').innerHTML=reply;
});
}
</script>
</head>
<body >
. . .
<input type="text" id="name" width="10">
<button name="submit" onclick="callSayHello()">Say hello</button>
<div id='result'></div>
. . .
</body>
</html>
{code}
h4. Using implementation.web with the Tuscany runtime embedded within a webapp
This is the style all the current Tuscany webapp samples use. When using
implementation.web with the Tuscany runtime embedded within a webapp the
implementation.web web-uri attribute is ignored.
h4. Using implementation.web with the Tuscany runtime integrated into a JEE
server such as Tomcat or Geronimo
The only code that is currently working is some prototype code in the Tuscany
runtime-tomcat module that supports injecting references into Servlets, Filters
and Event listeners using the @Reference annotation.
h4. Using implementation.web with the Tuscany standalone runtime
Nothing implemented yet
h4. Using implementation.web with the Tuscany distributed domain runtime
Nothing implemented yet
{column}
{section}
---------------------------------------------------------------------
CONFLUENCE INFORMATION
This message is automatically generated by Confluence
Unsubscribe or edit your notifications preferences
http://cwiki.apache.org/confluence/users/viewnotifications.action
If you think it was sent incorrectly contact one of the administrators
http://cwiki.apache.org/confluence/administrators.action
If you want more information on Confluence, or have a bug to report see
http://www.atlassian.com/software/confluence