From 4ed0ed906e82c9484b384419fa4ef4c980768731 Mon Sep 17 00:00:00 2001
From: lresende
Date: Thu, 13 Nov 2008 20:02:36 +0000
Subject: Creating Java SCA 1.x branch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@713805 13f79535-47bb-0310-9956-ffa450edef68
---
.../demos/alert-aggregator-webapp/LICENSE | 205 +++++++
.../demos/alert-aggregator-webapp/NOTICE | 6 +
.../demos/alert-aggregator-webapp/README | 82 +++
.../alert-aggregator-webapp/alert-aggregator.png | Bin 0 -> 36819 bytes
.../alert-aggregator-webapp/alert-aggregator.svg | 627 +++++++++++++++++++++
.../demos/alert-aggregator-webapp/build-dojo.xml | 92 +++
.../demos/alert-aggregator-webapp/build.xml | 148 +++++
.../demos/alert-aggregator-webapp/pom.xml | 345 ++++++++++++
.../sca/demos/aggregator/AlertTypeNonSDOImpl.java | 339 +++++++++++
.../demos/aggregator/AlertsFeedServiceImpl.java | 106 ++++
.../sca/demos/aggregator/AlertsService.java | 40 ++
.../sca/demos/aggregator/AlertsServiceImpl.java | 126 +++++
.../sca/demos/aggregator/AlertsSourcesService.java | 69 +++
.../demos/aggregator/AlertsSourcesServiceImpl.java | 183 ++++++
.../sca/demos/aggregator/AlertsTypeNonSDOImpl.java | 74 +++
.../sca/demos/aggregator/ConfigTypeNonSDOImpl.java | 55 ++
.../sca/demos/aggregator/RSSCheckerService.java | 30 +
.../demos/aggregator/RSSCheckerServiceImpl.java | 91 +++
.../sca/demos/aggregator/SourceTypeNonSDOImpl.java | 536 ++++++++++++++++++
.../src/main/resources/Alerts.wsdl | 88 +++
.../src/main/resources/Alerts.xsd | 80 +++
.../src/main/resources/AlertsSources.wsdl | 124 ++++
.../src/main/resources/alerts-client.composite | 49 ++
.../src/main/resources/alerts.composite | 85 +++
.../src/main/resources/sources.xml | 34 ++
.../src/main/webapp/AlertAggregator.html | 330 +++++++++++
.../src/main/webapp/META-INF/sca-contribution.xml | 26 +
.../src/main/webapp/WEB-INF/geronimo-web.xml | 37 ++
.../src/main/webapp/WEB-INF/web.xml | 41 ++
.../src/main/webapp/pop.png | Bin 0 -> 244 bytes
.../src/main/webapp/rss.png | Bin 0 -> 689 bytes
.../src/main/webapp/service.smd | 1 +
.../src/main/webapp/sources.smd | 1 +
.../src/main/webapp/style.css | 176 ++++++
.../demos/aggregator/AlertsIntegrationTest.java | 97 ++++
35 files changed, 4323 insertions(+)
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/LICENSE
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/NOTICE
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/README
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/alert-aggregator.png
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/alert-aggregator.svg
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/build-dojo.xml
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/build.xml
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/pom.xml
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/ConfigTypeNonSDOImpl.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerService.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/RSSCheckerServiceImpl.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/SourceTypeNonSDOImpl.java
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/resources/Alerts.wsdl
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/resources/Alerts.xsd
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/resources/AlertsSources.wsdl
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/resources/alerts-client.composite
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/resources/alerts.composite
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/resources/sources.xml
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/webapp/AlertAggregator.html
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/webapp/META-INF/sca-contribution.xml
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/geronimo-web.xml
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/webapp/WEB-INF/web.xml
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/webapp/pop.png
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/webapp/rss.png
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/webapp/service.smd
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/webapp/sources.smd
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/webapp/style.css
create mode 100644 branches/sca-java-1.x/demos/alert-aggregator-webapp/src/test/java/org/apache/tuscany/sca/demos/aggregator/AlertsIntegrationTest.java
(limited to 'branches/sca-java-1.x/demos/alert-aggregator-webapp')
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/LICENSE b/branches/sca-java-1.x/demos/alert-aggregator-webapp/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/LICENSE
@@ -0,0 +1,205 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+
+
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/NOTICE b/branches/sca-java-1.x/demos/alert-aggregator-webapp/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/NOTICE
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/README b/branches/sca-java-1.x/demos/alert-aggregator-webapp/README
new file mode 100644
index 0000000000..3ec27ef65f
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/README
@@ -0,0 +1,82 @@
+Apache Tuscany Alert Aggregator Demo
+====================================
+
+The alert aggregator demo provides an application, implemented using SCA, that
+aggregates feeds together and exposes them using the following bindings.
+
+binding.ws
+binding.jsonrpc
+binding.feed
+
+The easiest way to get going is to build the demo
+
+cd alert-aggregator-webapp
+ant package
+
+This will build a war file
+
+demo-alert-aggregator-webapp.war
+
+This war can be deployed to you web application container and tested (the war
+has been tested with Tomcat 6.0.10).
+
+The Web Application
+-------------------
+
+Once deployed point your browser at
+
+http://localhost:8080/demo-alert-aggregator-webapp
+
+Taking care to ensure the host name and port number match you local
+configuration.
+
+This launches a Javascript application in the browser that uses JSONRPC
+to contact the server and retrived a list of alert sources and alerts that
+these sources are providing.
+
+There default sources that you see are stored in a file in the following
+file
+
+demo-alert-aggregator-webapp/WEB-INF/classes/sources.xml
+
+This files has the following contents
+
+
+
+ BBC News
+ http://news.bbc.co.uk/
+ 10-Jun-2007 16:34:03
+ http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/world/rss.xml
+
+
+ Engadget
+ http://www.engadget.com
+ 10-Jun-2007 16:34:03
+ http://www.engadget.com/rss.xml
+
+
+
+You may want to adjust the "LastChecked" values to change the number of
+alerts that are displayed in the first instance
+
+Using A Feed Reader
+-------------------
+
+As this SCA application also uses the binding.feed binding you can use your
+favourite feed reader to read the aggregated alerts. To do this point your
+feed reader at
+
+http://localhost:8080/demo-alert-aggregator-webapp/services/AlertsFeedServiceRSS
+
+Again taking care to ensure that the host name and port number match you
+local configuration.
+
+Using Web Services
+------------------
+
+The SCA application also uses binding.ws to provide a SOAP/HTTP interface.
+The demo client that uses this interface is not yet available.
+
+
+
+
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/alert-aggregator.png b/branches/sca-java-1.x/demos/alert-aggregator-webapp/alert-aggregator.png
new file mode 100644
index 0000000000..ae429cca94
Binary files /dev/null and b/branches/sca-java-1.x/demos/alert-aggregator-webapp/alert-aggregator.png differ
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/alert-aggregator.svg b/branches/sca-java-1.x/demos/alert-aggregator-webapp/alert-aggregator.svg
new file mode 100644
index 0000000000..807416135e
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/alert-aggregator.svg
@@ -0,0 +1,627 @@
+
+
+
+
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/build-dojo.xml b/branches/sca-java-1.x/demos/alert-aggregator-webapp/build-dojo.xml
new file mode 100644
index 0000000000..c31c9adee8
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/build-dojo.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/build.xml b/branches/sca-java-1.x/demos/alert-aggregator-webapp/build.xml
new file mode 100644
index 0000000000..b75842d08c
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/build.xml
@@ -0,0 +1,148 @@
+
+
+]>
+
+
+ &buildDependency;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/pom.xml b/branches/sca-java-1.x/demos/alert-aggregator-webapp/pom.xml
new file mode 100644
index 0000000000..71c59ae984
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/pom.xml
@@ -0,0 +1,345 @@
+
+
+
+ 4.0.0
+
+
+ org.apache.tuscany.sca
+ tuscany-demos
+ 1.4-SNAPSHOT
+ ../pom.xml
+
+
+ org.apache.tuscany.sca
+ demo-alert-aggregator-webapp
+ war
+ 1.4-SNAPSHOT
+ Apache Tuscany SCA Alert Aggregator Demo
+ http://cwiki.apache.org/TUSCANY
+
+
+
+ junit
+ junit
+ 4.5
+ test
+
+
+ httpunit
+ httpunit
+ 1.6.1
+ test
+
+
+ org.apache.tuscany.sdo
+ tuscany-sdo-api-r2.1
+ 1.1.1
+
+
+ org.apache.tuscany.sdo
+ tuscany-sdo-impl
+ 1.1.1
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-ws-axis2
+ ${pom.version}
+ runtime
+
+
+ org.apache.tuscany.sca
+ tuscany-core-databinding
+ ${pom.version}
+ runtime
+
+
+ org.apache.tuscany.sca
+ tuscany-databinding-jaxb
+ ${pom.version}
+ runtime
+
+
+ org.apache.tuscany.sca
+ tuscany-databinding-sdo
+ ${pom.version}
+ compile
+
+
+ org.apache.tuscany.sca
+ tuscany-databinding-axiom
+ ${pom.version}
+ compile
+
+
+ org.apache.tuscany.sca
+ tuscany-host-embedded
+ ${pom.version}
+ compile
+
+
+ org.apache.tuscany.sca
+ tuscany-implementation-java-runtime
+ ${pom.version}
+ compile
+
+
+ org.apache.tuscany.sca
+ tuscany-interface-java-xml
+ ${pom.version}
+ compile
+
+
+ org.apache.tuscany.sca
+ tuscany-host-webapp
+ 1.4-SNAPSHOT
+ runtime
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-jsonrpc-runtime
+ 1.4-SNAPSHOT
+ runtime
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-atom-abdera
+ 1.4-SNAPSHOT
+
+
+ org.apache.tuscany.sca
+ tuscany-binding-rss-rome
+ 1.4-SNAPSHOT
+
+
+ org.codehaus.woodstox
+ wstx-asl
+ 3.2.1
+ runtime
+
+
+
+
+ demo-alert-aggregator-webapp
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.0
+
+
+ add-test-source
+ generate-sources
+
+ add-test-source
+
+
+
+ target/sdo-source
+
+
+
+
+
+
+ org.apache.tuscany.sdo
+ tuscany-sdo-plugin
+ 1.1.1
+
+
+ generate-sdo
+ generate-sources
+
+
+
+ ${basedir}/src/main/resources/Alerts.wsdl
+ org.apache.tuscany.sca.demos.aggregator.service
+
+
+ ${basedir}/src/main/resources/AlertsSources.wsdl
+ org.apache.tuscany.sca.demos.aggregator.sources
+
+
+ ${basedir}/src/main/resources/Alerts.xsd
+ org.apache.tuscany.sca.demos.aggregator.types
+
+
+ true
+ true
+ true
+
+
+ generate
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 1.1
+
+
+
+ ant
+ ant-trax
+ 1.6.5
+
+
+
+
+
+ install-dojo
+ validate
+
+ run
+
+
+
+
+
+
+
+
+
+
+ copy-dojo-files
+ generate-resources
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+ clean-dojo-files
+ clean
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+
+ surefire-it
+ integration-test
+
+ test
+
+
+
+ **/*AlertsIntegrationTest.java
+
+
+
+
+
+
+
+ org.codehaus.cargo
+ cargo-maven2-plugin
+ 1.0-alpha-5
+
+
+ start-container
+ pre-integration-test
+
+ start
+
+
+
+ stop-container
+ post-integration-test
+
+ stop
+
+
+
+
+
+ jetty6x
+ embedded
+
+ org.apache.commons.logging.impl.SimpleLog
+
+
+ false
+
+
+ 8085
+
+
+
+
+ ${project.build.directory}/${project.build.finalName}.${project.packaging}
+
+ http://localhost:8085/AlertsSourcesServiceJSONRPC
+
+
+ ${project.build.directory}/cargo-jetty
+
+
+
+
+
+ org.apache.tuscany.sca
+ tuscany-maven-ant-generator
+ 1.4-SNAPSHOT
+
+
+
+ true
+
+
+ generate
+
+
+
+
+
+
+
+
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java
new file mode 100644
index 0000000000..808374030c
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertTypeNonSDOImpl.java
@@ -0,0 +1,339 @@
+/*
+ * 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.
+ */
+package org.apache.tuscany.sca.demos.aggregator;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertType;
+
+
+public class AlertTypeNonSDOImpl implements AlertType
+{
+ private static final long serialVersionUID = 670364038865656196L;
+
+/**
+ * The default value of the '{@link #getTitle() Title}' attribute.
+ *
+ *
+ * @see #getTitle()
+ * @generated
+ * @ordered
+ */
+ protected static final String TITLE_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getTitle() Title}' attribute.
+ *
+ *
+ * @see #getTitle()
+ * @generated
+ * @ordered
+ */
+ protected String title = TITLE_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getSummary() Summary}' attribute.
+ *
+ *
+ * @see #getSummary()
+ * @generated
+ * @ordered
+ */
+ protected static final String SUMMARY_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getSummary() Summary}' attribute.
+ *
+ *
+ * @see #getSummary()
+ * @generated
+ * @ordered
+ */
+ protected String summary = SUMMARY_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getAddress() Address}' attribute.
+ *
+ *
+ * @see #getAddress()
+ * @generated
+ * @ordered
+ */
+ protected static final String ADDRESS_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getAddress() Address}' attribute.
+ *
+ *
+ * @see #getAddress()
+ * @generated
+ * @ordered
+ */
+ protected String address = ADDRESS_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getDate() Date}' attribute.
+ *
+ *
+ * @see #getDate()
+ * @generated
+ * @ordered
+ */
+ protected static final String DATE_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getDate() Date}' attribute.
+ *
+ *
+ * @see #getDate()
+ * @generated
+ * @ordered
+ */
+ protected String date = DATE_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getSourceId() Source Id}' attribute.
+ *
+ *
+ * @see #getSourceId()
+ * @generated
+ * @ordered
+ */
+ protected static final String SOURCE_ID_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getSourceId() Source Id}' attribute.
+ *
+ *
+ * @see #getSourceId()
+ * @generated
+ * @ordered
+ */
+ protected String sourceId = SOURCE_ID_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #isUnread() Unread}' attribute.
+ *
+ *
+ * @see #isUnread()
+ * @generated
+ * @ordered
+ */
+ protected static final boolean UNREAD_DEFAULT_ = false;
+
+ /**
+ * The cached value of the '{@link #isUnread() Unread}' attribute.
+ *
+ *
+ * @see #isUnread()
+ * @generated
+ * @ordered
+ */
+ protected boolean unread = UNREAD_DEFAULT_;
+
+ /**
+ * The default value of the '{@link #getId() Id}' attribute.
+ *
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected static final String ID_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getId() Id}' attribute.
+ *
+ *
+ * @see #getId()
+ * @generated
+ * @ordered
+ */
+ protected String id = ID_DEFAULT_;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public AlertTypeNonSDOImpl()
+ {
+ super();
+ }
+
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getTitle()
+ {
+ return title;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setTitle(String newTitle)
+ {
+ title = newTitle;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getSummary()
+ {
+ return summary;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setSummary(String newSummary)
+ {
+ summary = newSummary;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getAddress()
+ {
+ return address;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setAddress(String newAddress)
+ {
+ address = newAddress;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getDate()
+ {
+ return date;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setDate(String newDate)
+ {
+ date = newDate;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getSourceId()
+ {
+ return sourceId;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setSourceId(String newSourceId)
+ {
+ sourceId = newSourceId;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public boolean isUnread()
+ {
+ return unread;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setUnread(boolean newUnread)
+ {
+ unread = newUnread;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ public String getId()
+ {
+ return id;
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ public void setId(String newId)
+ {
+ id = newId;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public String toString()
+ {
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (Title: ");
+ result.append(title);
+ result.append(", Summary: ");
+ result.append(summary);
+ result.append(", Address: ");
+ result.append(address);
+ result.append(", Date: ");
+ result.append(date);
+ result.append(", SourceId: ");
+ result.append(sourceId);
+ result.append(", Unread: ");
+ result.append(unread);
+ result.append(", Id: ");
+ result.append(id);
+ result.append(')');
+ return result.toString();
+ }
+
+} //AlertTypeImpl
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java
new file mode 100644
index 0000000000..e070e0b8f1
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsFeedServiceImpl.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package org.apache.tuscany.sca.demos.aggregator;
+
+import java.text.DateFormat;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.tuscany.sca.binding.atom.collection.Collection;
+import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
+import org.apache.tuscany.sca.demos.aggregator.types.AlertType;
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Read all new alerts from the specified sources
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(Collection.class)
+public class AlertsFeedServiceImpl implements Collection {
+
+ private AlertsService alerts;
+
+ @Reference
+ public void setAlerts(AlertsService alerts) {
+ this.alerts = alerts;
+ }
+
+ DateFormat dateFormatter = DateFormat.getDateTimeInstance();
+
+ /**
+ * Return the alerts as a feed.
+ *
+ * @return the structure containing alerts
+ */
+ public org.apache.abdera.model.Feed getFeed() {
+
+ // Create a new Feed
+ Factory factory = Abdera.getNewFactory();
+ Feed feed = factory.newFeed();
+ feed.setTitle("Apache Tuscany Feed Aggregator");
+ feed.setSubtitle("A sample showing an SCA application to aggregate various types of feeds");
+ feed.addAuthor("Apache Tuscany");
+ feed.addLink("http://tuscany.apache.org");
+
+ // Aggregate entries from feed1 and feed2
+ try {
+ AlertsType alerts = this.alerts.getAllNewAlerts("");
+
+ for( Object alertObject : alerts.getAlert() ){
+ AlertType alert = ((AlertType)alertObject);
+ Entry entry = factory.newEntry();
+ entry.setTitle(alert.getTitle());
+ //entry.(alert.getSummary());
+ entry.addLink(alert.getAddress());
+ entry.setPublished(dateFormatter.parse(alert.getDate()));
+
+ feed.addEntry(entry);
+ }
+ } catch(Exception ex) {
+ System.err.println("Exception " + ex.toString());
+ }
+
+ return feed;
+ }
+
+ public Feed query(String queryString) {
+ return getFeed();
+ }
+
+ public void delete(String id) throws NotFoundException {
+ }
+
+ public Entry get(String id) throws NotFoundException {
+ return null;
+ }
+
+ public Entry post(Entry entry) {
+ return null;
+ }
+
+ public void put(String id, Entry entry) throws NotFoundException {
+ }
+
+}
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java
new file mode 100644
index 0000000000..c4bf13ce7a
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsService.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+
+package org.apache.tuscany.sca.demos.aggregator;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Retrieve and manage alerts
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface AlertsService {
+
+ /**
+ * Return a structure holding all of the new alerts that have been found
+ *
+ * @return the structure containing alerts
+ */
+ public AlertsType getAllNewAlerts(String id);
+
+}
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java
new file mode 100644
index 0000000000..28e27a9978
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsServiceImpl.java
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+
+package org.apache.tuscany.sca.demos.aggregator;
+
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertType;
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+import org.apache.tuscany.sca.demos.aggregator.types.ConfigType;
+import org.apache.tuscany.sca.demos.aggregator.types.SourceType;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * Read all new alerts from the specified sources
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(AlertsService.class)
+public class AlertsServiceImpl implements AlertsService {
+
+ private RSSCheckerService rssChecker;
+
+ private AlertsSourcesService alertsSources;
+
+ @Reference
+ public void setRssChecker(RSSCheckerService rssChecker) {
+ this.rssChecker = rssChecker;
+ }
+
+ @Reference
+ public void setAlertsSources(AlertsSourcesService alertsSources) {
+ this.alertsSources = alertsSources;
+ }
+
+ DateFormat dateFormatter = DateFormat.getDateTimeInstance();
+
+ /**
+ * Return a structure holding all of the new alerts that have been found
+ *
+ * @return the structure containing alerts
+ */
+ public AlertsType getAllNewAlerts(String id)
+ {
+ System.err.println("getAllNewAlerts(" + id + ")");
+
+ //TypesFactory factory = TypesFactory.INSTANCE;
+ //AlertsType returnAlerts = factory.createAlertsType();
+ AlertsType returnAlerts = new AlertsTypeNonSDOImpl();
+ List returnAlertList = returnAlerts.getAlert();
+
+ // get the date/time now so that we can update the
+ // alert source record so that next time we
+ // only get the latest alerts
+ Date now = new Date();
+ String nowString = dateFormatter.format(now);
+
+ try {
+ ConfigType alertSourceConfig = alertsSources.getAlertSources(id);
+
+ for (Object source : alertSourceConfig.getSource()){
+ SourceType sourceType = (SourceType)source;
+
+ AlertsType alerts = null;
+
+ if ( sourceType.getFeedType().equals("rss")){
+ alerts = rssChecker.getNewAlerts(sourceType.getFeedAddress(),
+ sourceType.getLastChecked());
+ } else {
+
+ }
+
+ // extend return list with any alerts we found
+ for( Object alert : alerts.getAlert() ){
+
+ // set the id on the alert so we know which source it
+ // came from
+ ((AlertType)alert).setSourceId(sourceType.getId());
+
+ // convert from SDO to POJO so that the
+ // JSONRPC binding will work. It can't currently
+ // handle SDOs
+ AlertType newAlert = new AlertTypeNonSDOImpl();
+
+ newAlert.setSourceId(((AlertType)alert).getSourceId());
+ newAlert.setTitle(((AlertType)alert).getTitle());
+ newAlert.setSummary(((AlertType)alert).getSummary());
+ newAlert.setAddress(((AlertType)alert).getAddress());
+ newAlert.setDate(((AlertType)alert).getDate());
+ newAlert.setId(((AlertType)alert).getId());
+ newAlert.setUnread(((AlertType)alert).isUnread());
+
+ returnAlertList.add(newAlert);
+ }
+
+ // update the time last checked for this source
+ sourceType.setLastChecked(nowString);
+ //alertsSources.updateAlertSource(sourceType);
+ }
+ } catch(Exception ex) {
+ System.err.println("Exception " + ex.toString());
+ }
+
+ return returnAlerts ;
+
+ }
+}
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java
new file mode 100644
index 0000000000..7b943b1b45
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesService.java
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+package org.apache.tuscany.sca.demos.aggregator;
+
+import org.apache.tuscany.sca.demos.aggregator.types.ConfigType;
+import org.apache.tuscany.sca.demos.aggregator.types.SourceType;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Retrieve and manage alert sources
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+public interface AlertsSourcesService {
+
+ /**
+ * Return all of the configured alert sources.
+ *
+ * @return the list of alert sources
+ */
+ public ConfigType getAlertSources (String id);
+
+ /**
+ * Return a single alert source.
+ * @param id not currently used
+ * @return the alert source
+ */
+ public SourceType getAlertSource (String id);
+
+ /**
+ * Update an alert source.
+ *
+ * @param updatedSource the alert source to update
+ */
+ public void updateAlertSource (SourceType updatedSource);
+
+ /**
+ * Add an alert source.
+ *
+ * @param newSource the alert source to add
+ */
+ public String addAlertSource (SourceType newSource);
+
+ /**
+ * Remove an alert source.
+ *
+ * @param oldSource the alert source to remove
+ */
+ public void removeAlertSource (String id);
+
+}
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java
new file mode 100644
index 0000000000..ca2fc95b4a
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsSourcesServiceImpl.java
@@ -0,0 +1,183 @@
+/*
+ * 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.
+ */
+
+package org.apache.tuscany.sca.demos.aggregator;
+
+import java.io.InputStream;
+import java.text.DateFormat;
+import java.util.Date;
+
+import org.apache.tuscany.sca.demos.aggregator.types.ConfigType;
+import org.apache.tuscany.sca.demos.aggregator.types.SourceType;
+import org.apache.tuscany.sca.demos.aggregator.types.TypesFactory;
+import org.apache.tuscany.sca.demos.aggregator.types.impl.SourceTypeImpl;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ * Retrieve and manage alert sources
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(AlertsSourcesService.class)
+@Scope("COMPOSITE")
+public class AlertsSourcesServiceImpl implements AlertsSourcesService {
+
+ ConfigType alertSources;
+
+ /**
+ * Constructor reads the configuration to provide
+ * the initial list of alert sources
+ */
+ public AlertsSourcesServiceImpl(){
+ System.err.println("AlertsSourcesServiceImpl()");
+ try {
+ // read the alerts config from an XML file
+ InputStream is = this.getClass().getClassLoader().getResourceAsStream("sources.xml");
+
+ if (is == null) {
+ throw new Exception("Can;t find sources.xml");
+ } else {
+ HelperContext helperContext = HelperProvider.getDefaultContext();
+ TypesFactory.INSTANCE.register(helperContext);
+ XMLDocument xmlDoc = helperContext.getXMLHelper().load(is);
+ alertSources = (ConfigType)xmlDoc.getRootObject();
+ }
+ } catch (Exception ex) {
+ System.err.println("Exception " + ex.toString());
+ }
+ }
+
+ /**
+ * Return all of the configured alert sources.
+ *
+ * @return the list of alert sources
+ */
+ public ConfigType getAlertSources (String id)
+ {
+ System.err.println("getAlertSources(" + id + ")");
+
+ // convert alert sources to POJOs so that
+ // the JSONRPC binding will work
+ ConfigTypeNonSDOImpl sources = new ConfigTypeNonSDOImpl();
+
+ for (Object source : alertSources.getSource()) {
+ SourceTypeNonSDOImpl newSource = new SourceTypeNonSDOImpl();
+ newSource.setAddress(((SourceTypeImpl)source).getAddress());
+ newSource.setFeedAddress(((SourceTypeImpl)source).getFeedAddress());
+ newSource.setId(((SourceTypeImpl)source).getId());
+ newSource.setLastChecked(((SourceTypeImpl)source).getLastChecked());
+ newSource.setName(((SourceTypeImpl)source).getName());
+ newSource.setFeedType(((SourceTypeImpl)source).getFeedType());
+ sources.getSource().add(newSource);
+ }
+
+ return sources;
+ }
+
+ /**
+ * Return a single alert source.
+ * @param id the alert source id number
+ * @return the alert source
+ */
+ public SourceType getAlertSource (String id)
+ {
+ System.err.println("getAlertSource(" + id + ")");
+ SourceType alertSource = null;
+
+ for (Object source : alertSources.getSource()) {
+ if ( ((SourceType)source).getId().equals(id)) {
+ alertSource = (SourceType)source;
+ }
+ }
+ return alertSource;
+ }
+
+ /**
+ * Update an alert source.
+ *
+ * @param updatedSource the alert source to update
+ */
+ public void updateAlertSource (SourceType updatedSource)
+ {
+ System.err.println("updateAlertSource()");
+
+ Object originalSource = null;
+
+ for (Object source : alertSources.getSource()) {
+ if ( ((SourceType)source).getId().equals(updatedSource.getId())) {
+ originalSource = source;
+ break;
+ }
+ }
+
+ if (originalSource != null){
+ alertSources.getSource().add(updatedSource);
+ alertSources.getSource().remove(originalSource);
+ }
+ }
+
+ /**
+ * Add an alert source.
+ *
+ * @param newSource the alert source to add
+ */
+ public String addAlertSource (SourceType newSource)
+ {
+ System.err.println("addAlertSource()");
+ // set the date to now less 2 hours so we
+ // get some alerts straight away
+ DateFormat dateFormatter = DateFormat.getDateTimeInstance();
+ Date now = new Date();
+ now.setHours(now.getHours()-2);
+ String nowString = dateFormatter.format(now);
+ newSource.setLastChecked(nowString);
+ alertSources.getSource().add(newSource);
+ return "Done";
+ }
+
+ /**
+ * Remove an alert source.
+ *
+ * @param oldSource the alert source to remove
+ */
+ public void removeAlertSource (String id)
+ {
+ System.err.println("removeAlertSource()");
+
+ Object originalSource = null;
+
+ for (Object source : alertSources.getSource()) {
+ if ( ((SourceType)source).getId().equals(id)) {
+ originalSource = source;
+ break;
+ }
+ }
+
+ if (originalSource != null) {
+ alertSources.getSource().remove(originalSource);
+ }
+
+ }
+
+}
diff --git a/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java
new file mode 100644
index 0000000000..2962defb25
--- /dev/null
+++ b/branches/sca-java-1.x/demos/alert-aggregator-webapp/src/main/java/org/apache/tuscany/sca/demos/aggregator/AlertsTypeNonSDOImpl.java
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+package org.apache.tuscany.sca.demos.aggregator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.demos.aggregator.types.AlertsType;
+
+/**
+ *
+ * An implementation of the model object 'Alerts Type'.
+ *
+ *