You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/03/21 00:31:46 UTC
svn commit: r520656 [1/2] - in /incubator/tuscany/sandbox/rfeng/runtime: ./
embedded/ embedded/src/ embedded/src/main/ embedded/src/main/java/
embedded/src/main/java/org/ embedded/src/main/java/org/apache/
embedded/src/main/java/org/apache/tuscany/ emb...
Author: rfeng
Date: Tue Mar 20 16:31:41 2007
New Revision: 520656
URL: http://svn.apache.org/viewvc?view=rev&rev=520656
Log:
[sandbox] Add an embedded runtime to boot Tuscany system and application in the same classloader for simpler launching within an IDE
Added:
incubator/tuscany/sandbox/rfeng/runtime/
incubator/tuscany/sandbox/rfeng/runtime/embedded/ (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/LICENSE.txt (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/NOTICE.txt (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/pom.xml (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java (with props)
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/application.composite
incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/system.composite
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Mar 20 16:31:41 2007
@@ -0,0 +1,14 @@
+target
+*.iws
+*.ipr
+*.iml
+.project
+.classpath
+maven.log
+velocity.log*
+junit*.properties
+surefire*.properties
+.settings
+.deployables
+.wtpmodules
+
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/LICENSE.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/LICENSE.txt?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/LICENSE.txt (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/LICENSE.txt Tue Mar 20 16:31:41 2007
@@ -0,0 +1,202 @@
+
+ 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, serviceDefinition 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.
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/NOTICE.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/NOTICE.txt?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/NOTICE.txt (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/NOTICE.txt Tue Mar 20 16:31:41 2007
@@ -0,0 +1,14 @@
+${pom.name}
+Copyright (c) 2005 - 2006 The Apache Software Foundation
+
+Apache Tuscany is an effort undergoing incubation at The Apache Software
+Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is
+required of all newly accepted projects until a further review indicates that
+the infrastructure, communications, and decision making process have stabilized
+in a manner consistent with other successful ASF projects. While incubation
+status is not necessarily a reflection of the completeness or stability of the
+code, it does indicate that the project has yet to be fully endorsed by the ASF.
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/NOTICE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/pom.xml?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/pom.xml (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/pom.xml Tue Mar 20 16:31:41 2007
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>runtime</artifactId>
+ <version>2.0-alpha2-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.tuscany.sca.runtime.embedded</groupId>
+ <artifactId>embedded-host</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache Tuscany Embedded Runtime Host</name>
+ <description>Host code to support an embedded runtime</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca.kernel</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-alpha2-incubating-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,251 @@
+/*
+ * 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.api;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.osoa.sca.ComponentContext;
+
+/**
+ * SCARuntime is used to start a Tuscany SCA runtime.
+ */
+public abstract class SCARuntime {
+ public static final String DEFAULT_SYSTEM_SCDL = "META-INF/tuscany/default-system.composite";
+ public static final String SYSTEM_SCDL = "system.composite";
+ public static final String EXTENSION_SCDL = "META-INF/sca/extension.composite";
+ public static final String SERVICE_SCDL = "META-INF/sca/service.composite";
+ public static final String META_APPLICATION_SCDL = "META-INF/sca/application.composite";
+ public static final String APPLICATION_SCDL = "application.composite";
+
+ private static SCARuntime instance;
+
+ /**
+ * Read the service name from a configuration file
+ *
+ * @param classLoader
+ * @param name The name of the service class
+ * @return A class name which extends/implements the service class
+ * @throws IOException
+ */
+ private static String getServiceName(ClassLoader classLoader, String name) throws IOException {
+ InputStream is = classLoader.getResourceAsStream("META-INF/services/" + name);
+ if (is == null) {
+ return null;
+ }
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ while (true) {
+ String line = reader.readLine();
+ if (line == null) {
+ break;
+ } else if (!line.startsWith("#")) {
+ return line.trim();
+ }
+ }
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns a SCARuntime instance. If the system property "org.apache.tuscany.api.SCARuntime" is set, its value is
+ * used as the name of the implementation class. Otherwise, if the resource
+ * "META-INF/services/org.apache.tuscany.api.SCARuntime" can be loaded from the supplied classloader. Otherwise, it
+ * will use "org.apache.tuscany.runtime.embedded.DefaultSCARuntime" as the default. The named class is loaded from the
+ * supplied classloader and instantiated using its default (no-arg) constructor.
+ *
+ * @return
+ */
+ private static SCARuntime newInstance(final ClassLoader classLoader) {
+
+ try {
+ final String name = SCARuntime.class.getName();
+ String className = AccessController.doPrivileged(new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty(name);
+ }
+ });
+
+ if (className == null) {
+ className = getServiceName(classLoader, name);
+ }
+ if (className == null) {
+ className = "org.apache.tuscany.runtime.embedded.DefaultSCARuntime";
+ }
+ Class cls = Class.forName(className, true, classLoader);
+ return (SCARuntime)cls.newInstance(); // NOPMD lresende
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * Get an instance of SCA Runtime
+ *
+ * @return The instance
+ */
+ public synchronized static SCARuntime getInstance() { // NOPMD
+ if (instance != null) {
+ return instance;
+ }
+ ClassLoader classLoader = SCARuntime.class.getClassLoader();
+ instance = newInstance(classLoader);
+ return instance;
+ }
+
+ /**
+ * Start the Tuscany runtime using default SCDLs
+ */
+ public static void start() {
+ try {
+ getInstance().startup(null, null, null, null);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * Start the SCA Runtime with the given SCDLs
+ *
+ * @param system The URL for the system SCDL
+ * @param extensions An array of URLs for extensions
+ * @param application The URL for the application SCDL
+ */
+ public static void start(URL system, URL[] extensions, URL application, String compositePath) {
+ try {
+ getInstance().startup(system, extensions, application, compositePath);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * Start the SCA Runtime with the given SCDL
+ *
+ * @param application The URL for the application SCDL
+ */
+ public static void start(URL application, String compositePath) {
+ try {
+ getInstance().startup(null, null, application, compositePath);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * Start the SCA Runtime with the given SCDL
+ *
+ * @param compositePath The path of the application SCDL
+ */
+ public static void start(String compositePath) {
+ try {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL applicationURL = cl.getResource(compositePath);
+ getInstance().startup(null, null, applicationURL, compositePath);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * Start the SCA Runtime with the given SCDL
+ *
+ * @param compositePath The path of the system SCDL
+ * @param compositePath The path of the application SCDL
+ */
+ public static void start(String system, String compositePath) {
+ try {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ URL systemURL = cl.getResource(system);
+ URL applicationURL = cl.getResource(compositePath);
+ getInstance().startup(systemURL, null, applicationURL, compositePath);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ /**
+ * Get the ComponentContext by name
+ *
+ * @param componentName
+ * @return
+ */
+ public static ComponentContext getComponentContext(String componentName) {
+ return getInstance().getContext(componentName);
+ }
+
+ /**
+ * Get access to a system service
+ *
+ * @param serviceName
+ * @return
+ */
+ protected abstract Object getSystemService(String serviceName);
+
+ /**
+ * Stop the SCA Runtime
+ */
+ public static void stop() {
+ try {
+ getInstance().shutdown();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ } finally {
+ instance = null;
+ }
+ }
+
+ /**
+ * Look up the ComponentContext by name
+ *
+ * @param componentName
+ * @return
+ */
+ protected abstract ComponentContext getContext(String componentName);
+
+ /**
+ * Start up the runtime
+ *
+ * @param system The URL of the SCDL for tuscany system composite
+ * @param extensions The URLs of the SCDLs for tuscany extension composites
+ * @param application The URL of the SCDL for the application composite
+ * @param compositePath The path of the application composite relative to the application URL
+ * @throws Exception
+ */
+ protected abstract void startup(URL system, URL[] extensions, URL application, String compositePath)
+ throws Exception;
+
+ /**
+ * Shutdown the runtime
+ *
+ * @throws Exception
+ */
+ protected abstract void shutdown() throws Exception;
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/api/SCARuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,75 @@
+/*
+ * 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.runtime.embedded;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.tuscany.api.SCARuntime;
+import org.apache.tuscany.api.TuscanyException;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceUnavailableException;
+
+/**
+ * Default implementation of SCARuntime.
+ *
+ * @version $Rev$ $Date$
+ */
+@SuppressWarnings("deprecation")
+public class DefaultSCARuntime extends SCARuntime {
+
+ protected SimpleRuntime runtime;
+
+ protected void startup(URL system, URL[] exts, URL applicationSCDL, String compositePath) throws Exception {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ List<URL> extensions = exts == null ? null : Arrays.asList(exts);
+ URI contributionURI = URI.create("/default");
+ SimpleRuntimeInfo runtimeInfo = new SimpleRuntimeInfoImpl(cl, system, extensions, contributionURI,
+ applicationSCDL, compositePath);
+ runtime = new SimpleRuntimeImpl(runtimeInfo);
+
+ try {
+ runtime.start();
+ } catch (TuscanyException e) {
+ throw e;
+ }
+
+ }
+
+ protected void shutdown() throws Exception {
+ runtime.destroy();
+ }
+
+ @Override
+ protected ComponentContext getContext(String componentName) {
+ return runtime.getComponentContext(URI.create(SimpleRuntimeInfo.DEFAULT_COMPOSITE + "/" + componentName));
+ }
+
+ @Override
+ public Object getSystemService(String serviceName) {
+ try {
+ return runtime.getSystemService(Object.class, serviceName);
+ } catch (TargetResolutionException e) {
+ throw new ServiceUnavailableException(e);
+ }
+ }
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/DefaultSCARuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.runtime.embedded;
+
+import org.apache.tuscany.host.runtime.TuscanyRuntime;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+
+/**
+ * A simple runtime to host both Tuscany and application code on the same classpath
+ *
+ * @version $Rev$ $Date$
+ */
+public interface SimpleRuntime extends TuscanyRuntime<SimpleRuntimeInfo> {
+ /**
+ * Start the embedded Tuscany
+ * @return
+ * @throws Exception
+ */
+ Component start() throws Exception;
+
+ /**
+ * Look up system services by name
+ * @param <T>
+ * @param type
+ * @param name
+ * @return
+ * @throws TargetResolutionException
+ */
+ <T> T getSystemService(Class<T> type, String name) throws TargetResolutionException;
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,102 @@
+/*
+ * 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.runtime.embedded;
+
+import static org.apache.tuscany.runtime.embedded.SimpleRuntimeInfo.DEFAULT_COMPOSITE;
+
+import java.net.URI;
+import java.util.Collection;
+
+import org.apache.tuscany.api.annotation.LogLevel;
+import org.apache.tuscany.core.component.SimpleWorkContext;
+import org.apache.tuscany.core.implementation.PojoWorkContextTunnel;
+import org.apache.tuscany.core.runtime.AbstractRuntime;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.SCAObject;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.component.TargetResolutionException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleRuntimeImpl extends AbstractRuntime<SimpleRuntimeInfo> implements SimpleRuntime {
+ private ScopeContainer<URI> container;
+
+ public SimpleRuntimeImpl(SimpleRuntimeInfo runtimeInfo) {
+ super(SimpleRuntimeInfo.class);
+ ClassLoader hostClassLoader = ClassLoader.getSystemClassLoader();
+ setHostClassLoader(hostClassLoader);
+ setApplicationScdl(runtimeInfo.getApplicationSCDL());
+ setSystemScdl(runtimeInfo.getSystemSCDL());
+ setRuntimeInfo(runtimeInfo);
+ }
+
+ public interface SimpleMonitor {
+ @LogLevel("SEVERE")
+ void runError(Exception e);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Component start() throws Exception {
+ initialize();
+
+ CompositeImplementation impl = new CompositeImplementation();
+ impl.setScdlLocation(applicationScdl);
+ impl.setClassLoader(runtimeInfo.getClassLoader());
+
+ ComponentDefinition<CompositeImplementation> definition = new ComponentDefinition<CompositeImplementation>(
+ DEFAULT_COMPOSITE,
+ impl);
+ Collection<Component> components = getDeployer().deploy(null, definition);
+ for (Component component : components) {
+ component.start();
+ }
+ ScopeRegistry scopeRegistry = getScopeRegistry();
+ container = scopeRegistry.getScopeContainer(Scope.COMPOSITE);
+ container.startContext(DEFAULT_COMPOSITE, DEFAULT_COMPOSITE);
+ getWorkContext().setIdentifier(Scope.COMPOSITE, DEFAULT_COMPOSITE);
+ WorkContext workContext = new SimpleWorkContext();
+ workContext.setIdentifier(Scope.COMPOSITE, DEFAULT_COMPOSITE);
+ PojoWorkContextTunnel.setThreadWorkContext(workContext);
+ return components.iterator().next();
+ }
+
+ public <T> T getSystemService(Class<T> type, String name) throws TargetResolutionException {
+ SCAObject child = componentManager.getComponent(URI.create(name));
+ if (child == null) {
+ return null;
+ }
+ AtomicComponent service = (AtomicComponent)child;
+ return type.cast(service.getTargetInstance());
+ }
+
+ @Override
+ public void destroy() {
+ container.stopContext(DEFAULT_COMPOSITE);
+ getWorkContext().setIdentifier(Scope.COMPOSITE, null);
+ super.destroy();
+ }
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,56 @@
+/*
+ * 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.runtime.embedded;
+
+import java.net.URI;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.tuscany.host.RuntimeInfo;
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface SimpleRuntimeInfo extends RuntimeInfo {
+ URI DEFAULT_COMPOSITE = ComponentNames.TUSCANY_APPLICATION_ROOT.resolve("default");
+
+ String DEFAULT_SYSTEM_SCDL = "META-INF/tuscany/default-system.composite";
+ String SYSTEM_SCDL = "system.composite";
+ String EXTENSION_SCDL = "META-INF/sca/extension.composite";
+ String SERVICE_SCDL = "META-INF/sca/service.composite";
+ String META_APPLICATION_SCDL = "META-INF/sca/application.composite";
+ String APPLICATION_SCDL = "application.composite";
+
+ ClassLoader getClassLoader();
+
+ String getCompositePath();
+
+ URL getSystemSCDL();
+
+ URL getApplicationSCDL();
+
+ List<URL> getExtensionSCDLs();
+
+ URL getContributionRoot();
+
+ URI getContributionURI();
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfo.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,182 @@
+/*
+ * 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.runtime.embedded;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+import org.apache.tuscany.core.util.FileHelper;
+import org.apache.tuscany.host.AbstractRuntimeInfo;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleRuntimeInfoImpl extends AbstractRuntimeInfo implements SimpleRuntimeInfo {
+ private ClassLoader classLoader;
+ private String compositePath;
+
+ private List<URL> extensions;
+ private URL applicationSCDL;
+ private URL systemSCDL;
+
+ private URL contributionURL;
+ private URI contributionURI;
+
+ /**
+ * @param classLoader
+ * @param compositePath
+ * @param extensions
+ * @param applicationSCDL
+ * @param systemSCDL
+ */
+ public SimpleRuntimeInfoImpl(ClassLoader classLoader,
+ URL systemSCDL,
+ List<URL> extensions,
+ URI contributionURI,
+ URL applicationSCDL,
+ String compositePath) {
+ this(classLoader, compositePath);
+ this.extensions = extensions;
+ this.applicationSCDL = applicationSCDL;
+ this.systemSCDL = systemSCDL;
+ this.contributionURI = contributionURI;
+ }
+
+ public SimpleRuntimeInfoImpl(ClassLoader classLoader, String compositePath) {
+ // super(domain, applicationRootDirectory, baseUrl, online, runtimeId);
+ super(URI.create("sca://domain/local"), null, null, false, "simple");
+ if (classLoader != null) {
+ this.classLoader = classLoader;
+ } else {
+ classLoader = Thread.currentThread().getContextClassLoader();
+ }
+ this.compositePath = compositePath != null ? compositePath : APPLICATION_SCDL;
+ getApplicationSCDL();
+ this.contributionURI = URI.create("/default");
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public String getCompositePath() {
+ return compositePath;
+ }
+
+ public final URL getApplicationSCDL() {
+ if (applicationSCDL == null) {
+ applicationSCDL = classLoader.getResource(compositePath);
+ if (applicationSCDL == null) {
+ applicationSCDL = classLoader.getResource(APPLICATION_SCDL);
+ if (applicationSCDL == null) {
+ applicationSCDL = classLoader.getResource(META_APPLICATION_SCDL);
+ if (applicationSCDL != null) {
+ compositePath = META_APPLICATION_SCDL;
+ }
+ } else {
+ if (compositePath == null) {
+ compositePath = APPLICATION_SCDL;
+ }
+ }
+ if (applicationSCDL == null) {
+ throw new IllegalArgumentException("application SCDL not found: " + APPLICATION_SCDL);
+ }
+ }
+ }
+ return applicationSCDL;
+ }
+
+ public URL getContributionRoot() {
+ if (contributionURL == null) {
+ contributionURL = getContributionLocation(getApplicationSCDL(), compositePath);
+ }
+ return contributionURL;
+ }
+
+ public List<URL> getExtensionSCDLs() {
+ if (extensions == null) {
+ try {
+ List<URL> extensionURLs = new ArrayList<URL>();
+ Enumeration<URL> urls = classLoader.getResources(SERVICE_SCDL);
+ extensionURLs.addAll(Collections.list(urls));
+ urls = classLoader.getResources(EXTENSION_SCDL);
+ extensionURLs.addAll(Collections.list(urls));
+ if (extensions != null) {
+ for (URL ext : extensions) {
+ if (!extensionURLs.contains(ext)) {
+ extensionURLs.add(ext);
+ }
+ }
+ }
+ extensions = extensionURLs;
+ } catch (IOException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return extensions;
+ }
+
+ public URL getSystemSCDL() {
+ if (systemSCDL == null) {
+ systemSCDL = classLoader.getResource(SYSTEM_SCDL);
+ if (systemSCDL == null) {
+ systemSCDL = classLoader.getResource(DEFAULT_SYSTEM_SCDL);
+ }
+ }
+ return systemSCDL;
+ }
+
+ private static URL getContributionLocation(URL applicationSCDL, String compositePath) {
+ URL root = null;
+ // "jar:file://....../something.jar!/a/b/c/app.composite"
+ try {
+ String scdlUrl = applicationSCDL.toExternalForm();
+ String protocol = applicationSCDL.getProtocol();
+ if ("file".equals(protocol)) {
+ // directory contribution
+ if (scdlUrl.endsWith(compositePath)) {
+ String location = scdlUrl.substring(0, scdlUrl.lastIndexOf(compositePath));
+ // workaround from evil url/uri form maven
+ root = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+
+ } else if ("jar".equals(protocol)) {
+ // jar contribution
+ String location = scdlUrl.substring(4, scdlUrl.lastIndexOf("!/"));
+ // workaround from evil url/uri form maven
+ root = FileHelper.toFile(new URL(location)).toURI().toURL();
+ }
+ } catch (MalformedURLException mfe) {
+ throw new IllegalArgumentException(mfe);
+ }
+
+ return root;
+ }
+
+ public URI getContributionURI() {
+ return contributionURI;
+ }
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/main/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeInfoImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,25 @@
+/*
+ * 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 calculator;
+
+public interface AddService {
+
+ double add(double n1, double n2);
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * An implementation of the Add service
+ */
+public class AddServiceImpl implements AddService {
+
+ public double add(double n1, double n2) {
+ return n1 + n2;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/AddServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,35 @@
+/*
+ * 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 calculator;
+
+
+/**
+ * The Calculator service interface.
+ */
+public interface CalculatorService {
+
+ double add(double n1, double n2);
+
+ double subtract(double n1, double n2);
+
+ double multiply(double n1, double n2);
+
+ double divide(double n1, double n2);
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,70 @@
+/*
+ * 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 calculator;
+
+import org.osoa.sca.annotations.Reference;
+
+
+/**
+ * An implementation of the Calculator service.
+ */
+public class CalculatorServiceImpl implements CalculatorService {
+
+ private AddService addService;
+ private SubtractService subtractService;
+ private MultiplyService multiplyService;
+ private DivideService divideService;
+
+ @Reference
+ public void setAddService(AddService addService) {
+ this.addService = addService;
+ }
+
+ @Reference
+ public void setSubtractService(SubtractService subtractService) {
+ this.subtractService = subtractService;
+ }
+
+ @Reference
+ public void setDivideService(DivideService divideService) {
+ this.divideService = divideService;
+ }
+
+ @Reference
+ public void setMultiplyService(MultiplyService multiplyService) {
+ this.multiplyService = multiplyService;
+ }
+
+ public double add(double n1, double n2) {
+ return addService.add(n1, n2);
+ }
+
+ public double subtract(double n1, double n2) {
+ return subtractService.subtract(n1, n2);
+ }
+
+ public double multiply(double n1, double n2) {
+ return multiplyService.multiply(n1, n2);
+ }
+
+ public double divide(double n1, double n2) {
+ return divideService.divide(n1, n2);
+ }
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/CalculatorServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,25 @@
+/*
+ * 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 calculator;
+
+public interface DivideService {
+
+ double divide(double n1, double n2);
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * An implementation of the Divide service.
+ */
+public class DivideServiceImpl implements DivideService {
+
+ public double divide(double n1, double n2) {
+ return n1 / n2;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/DivideServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,25 @@
+/*
+ * 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 calculator;
+
+public interface MultiplyService {
+
+ double multiply(double n1, double n2);
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * An implementation of the Multiply service.
+ */
+public class MultiplyServiceImpl implements MultiplyService {
+
+ public double multiply(double n1, double n2) {
+ return n1 * n2;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/MultiplyServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,25 @@
+/*
+ * 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 calculator;
+
+public interface SubtractService {
+
+ double subtract(double n1, double n2);
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,30 @@
+/*
+ * 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 calculator;
+
+/**
+ * An implementation of the subtract service.
+ */
+public class SubtractServiceImpl implements SubtractService {
+
+ public double subtract(double n1, double n2) {
+ return n1 - n2;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/calculator/SubtractServiceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,59 @@
+/*
+ * 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.api;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.runtime.embedded.SimpleRuntime;
+import org.apache.tuscany.runtime.embedded.SimpleRuntimeImpl;
+import org.apache.tuscany.runtime.embedded.SimpleRuntimeInfo;
+import org.apache.tuscany.runtime.embedded.SimpleRuntimeInfoImpl;
+import org.osoa.sca.ComponentContext;
+
+import calculator.AddService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCARuntimeTestCase extends TestCase {
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void setUp() throws Exception {
+ SCARuntime.start();
+ }
+
+ public void testStart() throws Exception {
+ ComponentContext context = SCARuntime.getComponentContext("CalculatorServiceComponent");
+ assertNotNull(context);
+ AddService service = context.getService(AddService.class, "addService");
+ assertEquals(3.0, service.add(1.0, 2.0));
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void tearDown() throws Exception {
+ SCARuntime.stop();
+ }
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/api/SCARuntimeTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java Tue Mar 20 16:31:41 2007
@@ -0,0 +1,59 @@
+/*
+ * 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.runtime.embedded;
+
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+import org.osoa.sca.ComponentContext;
+
+import calculator.AddService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SimpleRuntimeImplTestCase extends TestCase {
+ private SimpleRuntime runtime;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void setUp() throws Exception {
+ SimpleRuntimeInfo runtimeInfo = new SimpleRuntimeInfoImpl(getClass().getClassLoader(), "application.composite");
+ runtime = new SimpleRuntimeImpl(runtimeInfo);
+ runtime.start();
+ }
+
+ public void testStart() throws Exception {
+ ComponentContext context = runtime.getComponentContext(URI.create("/composites/default/CalculatorServiceComponent"));
+ assertNotNull(context);
+ AddService service = context.getService(AddService.class, "addService");
+ assertEquals(3.0, service.add(1.0, 2.0));
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void tearDown() throws Exception {
+ runtime.destroy();
+ }
+
+}
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/java/org/apache/tuscany/runtime/embedded/SimpleRuntimeImplTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/application.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/application.composite?view=auto&rev=520656
==============================================================================
--- incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/application.composite (added)
+++ incubator/tuscany/sandbox/rfeng/runtime/embedded/src/test/resources/application.composite Tue Mar 20 16:31:41 2007
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ name="CalculatorComposite">
+
+ <component name="CalculatorServiceComponent">
+ <implementation.java class="calculator.CalculatorServiceImpl"/>
+ <reference name="addService" target="AddServiceComponent"/>
+ <reference name="subtractService" target="SubtractServiceComponent"/>
+ <reference name="multiplyService" target="MultiplyServiceComponent"/>
+ <reference name="divideService" target="DivideServiceComponent"/>
+ </component>
+
+ <component name="AddServiceComponent">
+ <implementation.java class="calculator.AddServiceImpl"/>
+ </component>
+
+ <component name="SubtractServiceComponent">
+ <implementation.java class="calculator.SubtractServiceImpl"/>
+ </component>
+
+ <component name="MultiplyServiceComponent">
+ <implementation.java class="calculator.MultiplyServiceImpl"/>
+ </component>
+
+ <component name="DivideServiceComponent">
+ <implementation.java class="calculator.DivideServiceImpl"/>
+ </component>
+
+</composite>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org