You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/03/25 11:29:22 UTC
svn commit: r522186 [2/3] - in
/incubator/tuscany/sandbox/sebastien/java/sca/modules: ./
assembly/src/main/java/org/apache/tuscany/assembly/model/
assembly/src/main/java/org/apache/tuscany/assembly/model/impl/
assembly/src/main/java/org/apache/tuscany/...
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/CalculatorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/CalculatorTestCase.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/CalculatorTestCase.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/CalculatorTestCase.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,51 @@
+/*
+ * 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 test.model.variant;
+
+import junit.framework.TestCase;
+import calculator.CalculatorService;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class CalculatorTestCase extends TestCase {
+
+ private VariantRuntimeContext context;
+ private CalculatorService calculatorService;
+
+ protected void setUp() throws Exception {
+ context = new VariantRuntimeContext("Calculator.composite");
+
+ calculatorService = context.getService(CalculatorService.class, "CalculatorServiceComponent");
+ }
+
+ protected void tearDown() throws Exception {
+ context = null;
+ calculatorService = null;
+ }
+
+ public void testCalculator() throws Exception {
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0);
+ assertEquals(calculatorService.divide(3, 2), 1.5);
+
+ }
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/CalculatorTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/CalculatorTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeContext.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeContext.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeContext.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,97 @@
+/*
+ * 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 test.model.variant;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
+import org.apache.tuscany.assembly.util.CompositeUtil;
+import org.apache.tuscany.bean.impl.BeanAssemblyFactory;
+import org.apache.tuscany.java.bean.impl.BeanJavaFactory;
+import org.apache.tuscany.java.model.JavaFactory;
+import org.apache.tuscany.java.scdl.JavaConstants;
+import org.apache.tuscany.java.scdl.JavaHandler;
+import org.apache.tuscany.scdl.Constants;
+import org.apache.tuscany.scdl.impl.CompositeHandler;
+import org.apache.tuscany.scdl.impl.ImplementationHandlerRegistry;
+import org.apache.tuscany.scdl.impl.InterfaceHandlerRegistry;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * A mini test runtime that uses the SCA assembly model variant implementation
+ * backed by Spring bean definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class VariantRuntimeContext {
+
+ private DefaultListableBeanFactory beanFactory ;
+
+ public VariantRuntimeContext(String compositeFile) {
+
+ // Create Spring bean factory
+ beanFactory = new DefaultListableBeanFactory();
+
+ // Create SCA assembly and SCA Java factories
+ AssemblyFactory assemblyFactory = new BeanAssemblyFactory(new DefaultAssemblyFactory(), beanFactory);
+ JavaFactory javaFactory = new BeanJavaFactory(beanFactory);
+
+ // Populate interface and impl handlers
+ JavaHandler javaHandler = new JavaHandler(javaFactory);
+ InterfaceHandlerRegistry interfaceHandlers = new InterfaceHandlerRegistry();
+ interfaceHandlers.addHandler(Constants.SCA10_NS, JavaConstants.INTERFACE_JAVA, javaHandler);
+ ImplementationHandlerRegistry implementationHandlers = new ImplementationHandlerRegistry();
+ implementationHandlers.addHandler(Constants.SCA10_NS, JavaConstants.IMPLEMENTATION_JAVA, javaHandler);
+
+ // Create a composite handler
+ CompositeHandler handler = new CompositeHandler(assemblyFactory, interfaceHandlers, implementationHandlers, null);
+
+ // Parse the composite file
+ try {
+ XMLReader reader = XMLReaderFactory.createXMLReader();
+ reader.setFeature("http://xml.org/sax/features/namespaces", true);
+ reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
+ reader.setContentHandler(handler);
+ InputStream is = getClass().getClassLoader().getResourceAsStream(compositeFile);
+ reader.parse(new InputSource(is));
+ } catch (SAXException e) {
+ throw new VariantRuntimeException(e);
+ } catch (IOException e) {
+ throw new VariantRuntimeException(e);
+ }
+ Composite composite = handler.getComposite();
+
+ // Configure the composite
+ new CompositeUtil(assemblyFactory, composite).configure(null);
+
+ }
+
+ public <B> B getService(Class<B> businessInterface, String serviceName) {
+ Object bean = beanFactory.getBean(serviceName);
+ return businessInterface.cast(bean);
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeException.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeException.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeException.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,33 @@
+/*
+ * 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 test.model.variant;
+
+/**
+ * VariantRuntimeException
+ *
+ * @version $Rev$ $Date$
+ */
+public class VariantRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
+ public VariantRuntimeException(Exception e) {
+ super(e);
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/java/test/model/variant/VariantRuntimeException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/resources/Calculator.composite
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/resources/Calculator.composite?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/resources/Calculator.composite (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/resources/Calculator.composite Sun Mar 25 02:29:19 2007
@@ -0,0 +1,52 @@
+<?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"
+ xmlns:calc="http://sample.calculator"
+ name="calc:Calculator">
+
+ <service name="CalculatorService" promote="CalculatorServiceComponent">
+ <interface.java interface="calculator.CalculatorService"/>
+ </service>
+
+ <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>
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/resources/Calculator.composite
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean-test/src/test/resources/Calculator.composite
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/LICENSE.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/LICENSE.txt?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/LICENSE.txt (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/LICENSE.txt Sun Mar 25 02:29:19 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, 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.
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/LICENSE.txt
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/NOTICE.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/NOTICE.txt?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/NOTICE.txt (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/NOTICE.txt Sun Mar 25 02:29:19 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/sebastien/java/sca/modules/bean/NOTICE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/NOTICE.txt
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/pom.xml?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/pom.xml (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/pom.xml Sun Mar 25 02:29:19 2007
@@ -0,0 +1,82 @@
+<?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.modules</groupId>
+ <artifactId>parent</artifactId>
+ <version>0.1-sandbox-incubating-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>tuscany-assembly-bean</artifactId>
+ <name>Apache Tuscany Assembly Model Variant</name>
+ <description>A prototype of the SCA Assembly Model backed by Spring bean definitions</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.modules</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>0.1-sandbox-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca.modules</groupId>
+ <artifactId>tuscany-java</artifactId>
+ <version>0.1-sandbox-incubating-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>2.0.3</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>2.0.3</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>2.0.3</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.osoa</groupId>
+ <artifactId>sca-api-r1.0</artifactId>
+ <version>0.1-sandbox-incubating-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/CompositeApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/CompositeApplicationContext.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/CompositeApplicationContext.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/CompositeApplicationContext.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,118 @@
+/*
+ * 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.bean.context;
+
+import java.io.IOException;
+
+import org.apache.tuscany.assembly.model.Component;
+import org.apache.tuscany.assembly.model.ComponentReference;
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.CompositeReference;
+import org.apache.tuscany.assembly.model.CompositeService;
+import org.apache.tuscany.assembly.model.Contract;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.SCABinding;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.java.model.JavaImplementation;
+import org.apache.tuscany.java.model.JavaInterface;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.MutablePropertyValues;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.DefaultBeanNameGenerator;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.context.support.AbstractRefreshableApplicationContext;
+
+/**
+ * An implementation of a Spring ApplicationContext that turns an SCA Composite
+ * into an assembly of Spring BeanDefinitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeApplicationContext extends AbstractRefreshableApplicationContext {
+
+ private Composite composite;
+
+ public CompositeApplicationContext(Composite composite) {
+ this.composite = composite;
+ }
+
+ private RuntimeBeanReference getBeanReference(Contract contract) {
+ SCABinding binding = contract.getBinding(SCABinding.class);
+ String uri = binding.getURI();
+ int i = uri.indexOf('/');
+ if (i != -1) {
+ uri = uri.substring(0, i);
+ }
+ return new RuntimeBeanReference(uri);
+ }
+
+ protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws IOException, BeansException {
+ DefaultBeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
+
+ // Create bean definitions for the composite services
+ for (Service service: composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ RootBeanDefinition bean = new RootBeanDefinition(DummyCompositeServiceBean.class);
+ MutablePropertyValues propertyValues = bean.getPropertyValues();
+ propertyValues.addPropertyValue("name", compositeService.getName());
+ propertyValues.addPropertyValue("interface", ((JavaInterface)compositeService.getInterface()).getName());
+ ComponentService promotedService = compositeService.getPromotedService();
+ propertyValues.addPropertyValue("promote", getBeanReference(promotedService));
+ beanFactory.registerBeanDefinition(beanNameGenerator.generateBeanName(bean, beanFactory), bean);
+ }
+
+ // Create bean definitions for the composite references
+ for (Reference reference: composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ RootBeanDefinition bean = new RootBeanDefinition(DummyCompositeReferenceBean.class);
+ MutablePropertyValues propertyValues = bean.getPropertyValues();
+ propertyValues.addPropertyValue("name", compositeReference.getName());
+ propertyValues.addPropertyValue("interface", ((JavaInterface)compositeReference.getInterface()).getName());
+ // TODO handle multiple promoted references
+ Reference promotedReference = compositeReference.getPromotedReferences().get(0);
+ propertyValues.addPropertyValue("promote", getBeanReference(promotedReference));
+ beanFactory.registerBeanDefinition(beanNameGenerator.generateBeanName(bean, beanFactory), bean);
+ }
+
+ // Create bean definitions for the components
+ for (Component component: composite.getComponents()) {
+ RootBeanDefinition bean = new RootBeanDefinition();
+ JavaImplementation javaImplementation = (JavaImplementation)component.getImplementation();
+ bean.setBeanClassName(javaImplementation.getName());
+ MutablePropertyValues propertyValues = bean.getPropertyValues();
+
+ for (ComponentReference componentReference: component.getReferences()) {
+ //TODO handle multiplicity
+ ComponentService targetService = componentReference.getTargets().get(0);
+ propertyValues.addPropertyValue(componentReference.getName(),getBeanReference(targetService));
+ }
+
+ for (Property property: component.getProperties()) {
+ propertyValues.addPropertyValue(property.getName(), property.getDefaultValue());
+ }
+
+ beanFactory.registerBeanDefinition(component.getName(), bean);
+ }
+
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/CompositeApplicationContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/CompositeApplicationContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeReferenceBean.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeReferenceBean.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeReferenceBean.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeReferenceBean.java Sun Mar 25 02:29:19 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.bean.context;
+
+/**
+ * Dummy bean used as a placeholder for composite references for now.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DummyCompositeReferenceBean {
+
+ private String name;
+ private String interfaze;
+ private Object promote;
+
+ public String getInterface() {
+ return interfaze;
+ }
+
+ public void setInterface(String interfaze) {
+ this.interfaze = interfaze;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Object getPromote() {
+ return promote;
+ }
+
+ public void setPromote(Object promote) {
+ this.promote = promote;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeReferenceBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeReferenceBean.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeServiceBean.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeServiceBean.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeServiceBean.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeServiceBean.java Sun Mar 25 02:29:19 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.bean.context;
+
+/**
+ * Dummy bean used as a placeholder for composite references for now.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DummyCompositeServiceBean {
+
+ private String name;
+ private String interfaze;
+ private Object promote;
+
+ public String getInterface() {
+ return interfaze;
+ }
+
+ public void setInterface(String interfaze) {
+ this.interfaze = interfaze;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Object getPromote() {
+ return promote;
+ }
+
+ public void setPromote(Object promote) {
+ this.promote = promote;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeServiceBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/context/DummyCompositeServiceBean.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanAssemblyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanAssemblyFactory.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanAssemblyFactory.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanAssemblyFactory.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,129 @@
+/*
+ * 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.bean.impl;
+
+import org.apache.tuscany.assembly.model.AbstractProperty;
+import org.apache.tuscany.assembly.model.AbstractReference;
+import org.apache.tuscany.assembly.model.AbstractService;
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Callback;
+import org.apache.tuscany.assembly.model.Component;
+import org.apache.tuscany.assembly.model.ComponentProperty;
+import org.apache.tuscany.assembly.model.ComponentReference;
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.ComponentType;
+import org.apache.tuscany.assembly.model.Composite;
+import org.apache.tuscany.assembly.model.CompositeReference;
+import org.apache.tuscany.assembly.model.CompositeService;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.SCABinding;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.assembly.model.Wire;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+/**
+ * An alternate implementation of the SCA assembly model factory that creates SCA
+ * assembly model objects backed by Spring bean definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanAssemblyFactory implements AssemblyFactory {
+
+ private AssemblyFactory defaultFactory;
+ private BeanDefinitionRegistry beanRegistry;
+
+ public BeanAssemblyFactory(AssemblyFactory defaultFactory, BeanDefinitionRegistry beanRegistry) {
+ this.defaultFactory = defaultFactory;
+ this.beanRegistry = beanRegistry;
+ }
+
+ public AbstractProperty createAbstractProperty() {
+ return defaultFactory.createAbstractProperty();
+ }
+
+ public AbstractReference createAbstractReference() {
+ return defaultFactory.createAbstractReference();
+ }
+
+ public AbstractService createAbstractService() {
+ return defaultFactory.createAbstractService();
+ }
+
+ public Callback createCallback() {
+ return defaultFactory.createCallback();
+ }
+
+ public Component createComponent() {
+ return new BeanComponentImpl(beanRegistry);
+ }
+
+ public ComponentProperty createComponentProperty() {
+ return defaultFactory.createComponentProperty();
+ }
+
+ public ComponentReference createComponentReference() {
+ return defaultFactory.createComponentReference();
+ }
+
+ public ComponentService createComponentService() {
+ return defaultFactory.createComponentService();
+ }
+
+ public ComponentType createComponentType() {
+ return defaultFactory.createComponentType();
+ }
+
+ public Composite createComposite() {
+ return defaultFactory.createComposite();
+ }
+
+ public CompositeReference createCompositeReference() {
+ return defaultFactory.createCompositeReference();
+ }
+
+ public CompositeService createCompositeService() {
+ return defaultFactory.createCompositeService();
+ }
+
+ public ConstrainingType createConstrainingType() {
+ return defaultFactory.createConstrainingType();
+ }
+
+ public Property createProperty() {
+ return defaultFactory.createProperty();
+ }
+
+ public Reference createReference() {
+ return defaultFactory.createReference();
+ }
+
+ public Service createService() {
+ return defaultFactory.createService();
+ }
+
+ public Wire createWire() {
+ return defaultFactory.createWire();
+ }
+
+ public SCABinding createSCABinding() {
+ return defaultFactory.createSCABinding();
+ }
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanAssemblyFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanAssemblyFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanComponentImpl.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanComponentImpl.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanComponentImpl.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,160 @@
+/*
+ * 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.bean.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.assembly.model.Component;
+import org.apache.tuscany.assembly.model.ComponentProperty;
+import org.apache.tuscany.assembly.model.ComponentReference;
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.model.Implementation;
+import org.apache.tuscany.policy.model.Intent;
+import org.apache.tuscany.policy.model.PolicySet;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.ChildBeanDefinition;
+
+/**
+ * An implementation of the SCA assembly Component interface backed by a Spring
+ * Bean definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanComponentImpl extends ChildBeanDefinition implements Component {
+ private static final long serialVersionUID = 1L;
+
+ private ConstrainingType constrainingType;
+ private Implementation implementation;
+ private String name;
+ private List<ComponentService> services = new ArrayList<ComponentService>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<?> extensions = new ArrayList();
+ private boolean unresolved = false;
+ private BeanDefinitionRegistry beanRegistry;
+
+ public BeanComponentImpl(BeanDefinitionRegistry beanRegistry) {
+ super((String)"");
+ this.beanRegistry = beanRegistry;
+ }
+
+ public String getParentName() {
+ //TODO find a better name for bean definitions representing component types
+ return String.valueOf(System.identityHashCode(implementation));
+ }
+
+ public ConstrainingType getConstrainingType() {
+ return constrainingType;
+ }
+
+ public Implementation getImplementation() {
+ return implementation;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ //TODO use a better list implementation
+ private List<ComponentProperty> properties = new ArrayList<ComponentProperty>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a property
+ public boolean add(ComponentProperty property) {
+
+ // Add corresponding bean property value
+ getPropertyValues().addPropertyValue(property.getName(), property.getDefaultValue());
+
+ return super.add(property);
+ }
+ };
+
+ public List<ComponentProperty> getProperties() {
+ return properties;
+ }
+
+ //TODO use a better list implementation
+ private List<ComponentReference> references = new ArrayList<ComponentReference>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a reference
+ public boolean add(ComponentReference reference) {
+
+ // Add corresponding bean property value
+ BeanReferenceImpl beanReference = new BeanReferenceImpl(reference);
+ getPropertyValues().addPropertyValue(reference.getName(), beanReference);
+
+ return super.add(reference);
+ }
+ };
+
+ public List<ComponentReference> getReferences() {
+ return references;
+ }
+
+ public List<ComponentService> getServices() {
+ return services;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ this.constrainingType = constrainingType;
+ }
+
+ public void setImplementation(Implementation implementation) {
+ this.implementation = implementation;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+
+ // Register this bean definition in the bean registry
+ this.beanRegistry.registerBeanDefinition(name, this);
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public boolean isAutowire() {
+ return super.getAutowireMode() == AUTOWIRE_BY_TYPE;
+ }
+
+ public void setAutowire(boolean autowire) {
+ super.setAutowireMode(autowire? AUTOWIRE_BY_TYPE:AUTOWIRE_NO);
+ }
+
+ public List<?> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanComponentImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanComponentImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanReferenceImpl.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanReferenceImpl.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanReferenceImpl.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,71 @@
+/*
+ * 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.bean.impl;
+
+import org.apache.tuscany.assembly.model.ComponentService;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.SCABinding;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+
+/**
+ * An implementation of RuntimeBeanReference wrappering an SCA assembly Reference
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanReferenceImpl extends RuntimeBeanReference {
+ private Reference reference;
+
+ public BeanReferenceImpl(Reference reference) {
+ super("temp");
+ this.reference = reference;
+ }
+
+ public String getBeanName() {
+ //TODO handle multiplicity
+ ComponentService componentService = reference.getTargets().get(0);
+ String uri;
+ if (!componentService.isUnresolved()) {
+ SCABinding binding = componentService.getBinding(SCABinding.class);
+ uri = binding.getURI();
+ } else {
+ uri = componentService.getName();
+ }
+ int i = uri.indexOf('/');
+ if (i != -1) {
+ uri = uri.substring(0, i);
+ }
+ return uri;
+ }
+
+ public boolean equals(Object other) {
+ if (this != other) {
+ if (other instanceof RuntimeBeanReference) {
+ RuntimeBeanReference br = (RuntimeBeanReference) other;
+ return (getBeanName().equals(br.getBeanName()) && this.isToParent() == br.isToParent());
+ } else
+ return false;
+ } else
+ return true;
+ }
+
+ public int hashCode() {
+ return getBeanName().hashCode() * 29 + (this.isToParent() ? 1 : 0);
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanReferenceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/bean/impl/BeanReferenceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaFactory.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaFactory.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaFactory.java Sun Mar 25 02:29:19 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.java.bean.impl;
+
+import org.apache.tuscany.java.model.JavaFactory;
+import org.apache.tuscany.java.model.JavaImplementation;
+import org.apache.tuscany.java.model.JavaInterface;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+
+/**
+ * An alternate implementation of the SCA Java assembly model factory that creates SCA
+ * Java assembly model objects backed by Spring bean definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaFactory implements JavaFactory {
+
+ private BeanDefinitionRegistry beanRegistry;
+
+ public BeanJavaFactory(BeanDefinitionRegistry beanRegistry) {
+ this.beanRegistry = beanRegistry;
+ }
+
+ public JavaImplementation createJavaImplementation() {
+ return new BeanJavaImplementationImpl(beanRegistry);
+ }
+
+ public JavaInterface createJavaInterface() {
+ return new BeanJavaInterfaceImpl();
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaImplementationImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaImplementationImpl.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaImplementationImpl.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaImplementationImpl.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,154 @@
+/*
+ * 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.java.bean.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.model.Property;
+import org.apache.tuscany.assembly.model.Reference;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.java.model.JavaImplementation;
+import org.apache.tuscany.policy.model.Intent;
+import org.apache.tuscany.policy.model.PolicySet;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+
+/**
+ * An implementation of the SCA assembly JavaImplementation interface backed by a Spring
+ * Bean definition.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaImplementationImpl extends RootBeanDefinition implements JavaImplementation {
+ private static final long serialVersionUID = 1L;
+
+ private List<Service> services = new ArrayList<Service>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private ConstrainingType constrainingType;
+ private List<?> extensions = new ArrayList();
+ private boolean unresolved;
+ private BeanDefinitionRegistry beanRegistry;
+
+ public BeanJavaImplementationImpl(BeanDefinitionRegistry beanRegistry) {
+ this.beanRegistry = beanRegistry;
+
+ // Register this bean definition in the bean registry
+ //TODO find a better name for bean definitions representing component types
+ String name = String.valueOf(System.identityHashCode(this));
+ this.beanRegistry.registerBeanDefinition(name, this);
+ }
+
+ public Class<?> getJavaClass() {
+ return super.getBeanClass();
+ }
+
+ public String getName() {
+ return super.getBeanClassName();
+ }
+
+ public void setJavaClass(Class<?> javaClass) {
+ super.setBeanClass(javaClass);
+ }
+
+ public void setName(String className) {
+ super.setBeanClassName(className);
+ }
+
+ public ConstrainingType getConstrainingType() {
+ return constrainingType;
+ }
+
+ //TODO use a better list implementation
+ private List<Property> properties = new ArrayList<Property>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a property
+ public boolean add(Property property) {
+
+ // Add corresponding bean property value
+ getPropertyValues().addPropertyValue(property.getName(), property.getDefaultValue());
+
+ return super.add(property);
+ }
+ };
+
+ public List<Property> getProperties() {
+ return properties;
+ }
+
+ //TODO use a better list implementation
+ private List<Reference> references = new ArrayList<Reference>() {
+ private static final long serialVersionUID = 1L;
+
+ // Add a reference
+ public boolean add(Reference reference) {
+
+ // Add corresponding bean property value
+ String target;
+ if (!reference.getTargets().isEmpty()) {
+ //TODO handle multiplicity
+ target = reference.getTargets().get(0).getName();
+ int i = target.indexOf('/');
+ if (i != -1)
+ target = target.substring(0, i);
+ } else {
+ target = null;
+ }
+ getPropertyValues().addPropertyValue(reference.getName(), target);
+
+ return super.add(reference);
+ }
+ };
+
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ public List<Service> getServices() {
+ return services;
+ }
+
+ public void setConstrainingType(ConstrainingType constrainingType) {
+ this.constrainingType = constrainingType;
+ }
+
+ public List<?> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaImplementationImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaImplementationImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaInterfaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaInterfaceImpl.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaInterfaceImpl.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaInterfaceImpl.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,96 @@
+/*
+ * 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.java.bean.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.java.model.JavaInterface;
+import org.apache.tuscany.policy.model.Intent;
+
+/**
+ * An alternate implementation of the SCA Java assembly model JavaInterface
+ * interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public class BeanJavaInterfaceImpl implements JavaInterface {
+
+ private String className;
+ private Class<?> javaClass;
+ private boolean conversational;
+ private boolean remotable;
+ List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<?> extensions = new ArrayList();
+ private boolean unresolved = false;
+
+ public String getName() {
+ if (isUnresolved())
+ return className;
+ else
+ return javaClass.getName();
+ }
+
+ public void setName(String className) {
+ if (!isUnresolved())
+ throw new IllegalStateException();
+ this.className = className;
+ }
+
+ public Class<?> getJavaClass() {
+ return javaClass;
+ }
+
+ public void setJavaClass(Class<?> javaClass) {
+ this.javaClass = javaClass;
+ }
+
+ public boolean isConversational() {
+ return conversational;
+ }
+
+ public boolean isRemotable() {
+ return remotable;
+ }
+
+ public void setConversational(boolean conversational) {
+ this.conversational = conversational;
+ }
+
+ public void setRemotable(boolean local) {
+ this.remotable = local;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<?> getExtensions() {
+ return extensions;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean undefined) {
+ this.unresolved = undefined;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaInterfaceImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/bean/src/main/java/org/apache/tuscany/java/bean/impl/BeanJavaInterfaceImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/builder/src/main/java/org/apache/tuscany/assembly/builder/impl/AssemblyBuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/builder/src/main/java/org/apache/tuscany/assembly/builder/impl/AssemblyBuilderImpl.java?view=diff&rev=522186&r1=522185&r2=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/builder/src/main/java/org/apache/tuscany/assembly/builder/impl/AssemblyBuilderImpl.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/builder/src/main/java/org/apache/tuscany/assembly/builder/impl/AssemblyBuilderImpl.java Sun Mar 25 02:29:19 2007
@@ -26,9 +26,9 @@
import org.apache.tuscany.assembly.builder.ComponentReferenceBuilder;
import org.apache.tuscany.assembly.builder.ComponentServiceBuilder;
import org.apache.tuscany.assembly.builder.CompositeBuilder;
-import org.apache.tuscany.assembly.model.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
-public class AssemblyBuilderImpl extends AssemblyFactoryImpl implements AssemblyBuilder {
+public class AssemblyBuilderImpl extends DefaultAssemblyFactory implements AssemblyBuilder {
public ComponentBuilder component(String name) {
ComponentBuilderImpl component = new ComponentBuilderImpl();
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/crud-scdl/src/test/java/org/apache/tuscany/crud/scdl/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/crud-scdl/src/test/java/org/apache/tuscany/crud/scdl/ReadTestCase.java?view=diff&rev=522186&r1=522185&r2=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/crud-scdl/src/test/java/org/apache/tuscany/crud/scdl/ReadTestCase.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/crud-scdl/src/test/java/org/apache/tuscany/crud/scdl/ReadTestCase.java Sun Mar 25 02:29:19 2007
@@ -25,14 +25,14 @@
import org.apache.tuscany.assembly.model.AssemblyFactory;
import org.apache.tuscany.assembly.model.Service;
-import org.apache.tuscany.assembly.model.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
import org.apache.tuscany.assembly.util.CompositeUtil;
import org.apache.tuscany.assembly.util.PrintUtil;
import org.apache.tuscany.crud.CRUD;
-import org.apache.tuscany.crud.model.impl.CRUDFactoryImpl;
+import org.apache.tuscany.crud.model.impl.DefaultCRUDFactory;
import org.apache.tuscany.java.model.JavaFactory;
import org.apache.tuscany.java.model.JavaInterface;
-import org.apache.tuscany.java.model.impl.JavaFactoryImpl;
+import org.apache.tuscany.java.model.impl.DefaultJavaFactory;
import org.apache.tuscany.scdl.Constants;
import org.apache.tuscany.scdl.impl.CompositeHandler;
import org.apache.tuscany.scdl.impl.ImplementationHandlerRegistry;
@@ -59,10 +59,10 @@
reader.setFeature("http://xml.org/sax/features/namespaces", true);
reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
- assemblyFactory = new AssemblyFactoryImpl();
- JavaFactory javaFactory = new JavaFactoryImpl(assemblyFactory);
+ assemblyFactory = new DefaultAssemblyFactory();
+ JavaFactory javaFactory = new DefaultJavaFactory(assemblyFactory);
- CRUDHandler crudHandler = new CRUDHandler(new CRUDFactoryImpl(assemblyFactory, javaFactory));
+ CRUDHandler crudHandler = new CRUDHandler(new DefaultCRUDFactory(assemblyFactory, javaFactory));
implementationHandlers = new ImplementationHandlerRegistry();
implementationHandlers.addHandler(Constants.SCA10_NS, CRUDConstants.IMPLEMENTATION_CRUD, crudHandler);
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/main/java/org/apache/tuscany/crud/model/impl/DefaultCRUDFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/main/java/org/apache/tuscany/crud/model/impl/DefaultCRUDFactory.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/main/java/org/apache/tuscany/crud/model/impl/DefaultCRUDFactory.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/main/java/org/apache/tuscany/crud/model/impl/DefaultCRUDFactory.java Sun Mar 25 02:29:19 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.crud.model.impl;
+
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.crud.CRUD;
+import org.apache.tuscany.crud.model.CRUDFactory;
+import org.apache.tuscany.crud.model.CRUDImplementation;
+import org.apache.tuscany.java.model.JavaFactory;
+import org.apache.tuscany.java.model.JavaInterface;
+
+/**
+ * Factory for the CRUD component implementation model.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultCRUDFactory implements CRUDFactory {
+
+ private AssemblyFactory assemblyFactory;
+ private JavaFactory javaFactory;
+
+ public DefaultCRUDFactory(AssemblyFactory assemblyFactory, JavaFactory javaFactory) {
+ this.assemblyFactory = assemblyFactory;
+ this.javaFactory = javaFactory;
+ }
+
+ public CRUDImplementation createCRUDImplementation() {
+
+ // Create the CRUD implementation
+ CRUDImplementation implementation = new CRUDImplementationImpl();
+
+ // Create a fixed service, exposed by all CRUD implementations
+ Service service = assemblyFactory.createService();
+ JavaInterface javaInterface = javaFactory.createJavaInterface();
+ javaInterface.setJavaClass(CRUD.class);
+ service.setName("crud");
+ service.setInterface(javaInterface);
+ implementation.getServices().add(service);
+ return implementation;
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/main/java/org/apache/tuscany/crud/model/impl/DefaultCRUDFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/main/java/org/apache/tuscany/crud/model/impl/DefaultCRUDFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/test/java/org/apache/tuscany/crud/model/CRUDFactoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/test/java/org/apache/tuscany/crud/model/CRUDFactoryTestCase.java?view=diff&rev=522186&r1=522185&r2=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/test/java/org/apache/tuscany/crud/model/CRUDFactoryTestCase.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/crud/src/test/java/org/apache/tuscany/crud/model/CRUDFactoryTestCase.java Sun Mar 25 02:29:19 2007
@@ -19,21 +19,21 @@
package org.apache.tuscany.crud.model;
import org.apache.tuscany.assembly.model.AssemblyFactory;
-import org.apache.tuscany.assembly.model.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
import org.apache.tuscany.crud.CRUD;
-import org.apache.tuscany.crud.model.impl.CRUDFactoryImpl;
+import org.apache.tuscany.crud.model.impl.DefaultCRUDFactory;
import org.apache.tuscany.java.model.JavaFactory;
import org.apache.tuscany.java.model.JavaInterface;
-import org.apache.tuscany.java.model.impl.JavaFactoryImpl;
+import org.apache.tuscany.java.model.impl.DefaultJavaFactory;
import junit.framework.TestCase;
public class CRUDFactoryTestCase extends TestCase {
public void testFactory() {
- AssemblyFactory assemblyFactory = new AssemblyFactoryImpl();
- JavaFactory javaFactory = new JavaFactoryImpl(assemblyFactory);
- CRUDFactoryImpl factory = new CRUDFactoryImpl(assemblyFactory, javaFactory);
+ AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
+ JavaFactory javaFactory = new DefaultJavaFactory(assemblyFactory);
+ DefaultCRUDFactory factory = new DefaultCRUDFactory(assemblyFactory, javaFactory);
CRUDImplementation implementation = factory.createCRUDImplementation();
assertTrue(((JavaInterface)implementation.getServices().get(0).getInterface()).getJavaClass() == CRUD.class);
}
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/java/org/apache/tuscany/java/scdl/ReadTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/java/org/apache/tuscany/java/scdl/ReadTestCase.java?view=diff&rev=522186&r1=522185&r2=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/java/org/apache/tuscany/java/scdl/ReadTestCase.java (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/java-scdl/src/test/java/org/apache/tuscany/java/scdl/ReadTestCase.java Sun Mar 25 02:29:19 2007
@@ -24,10 +24,10 @@
import junit.framework.TestCase;
import org.apache.tuscany.assembly.model.AssemblyFactory;
-import org.apache.tuscany.assembly.model.impl.AssemblyFactoryImpl;
+import org.apache.tuscany.assembly.model.impl.DefaultAssemblyFactory;
import org.apache.tuscany.assembly.util.CompositeUtil;
import org.apache.tuscany.assembly.util.PrintUtil;
-import org.apache.tuscany.java.model.impl.JavaFactoryImpl;
+import org.apache.tuscany.java.model.impl.DefaultJavaFactory;
import org.apache.tuscany.scdl.Constants;
import org.apache.tuscany.scdl.impl.ComponentTypeHandler;
import org.apache.tuscany.scdl.impl.CompositeHandler;
@@ -56,9 +56,9 @@
reader.setFeature("http://xml.org/sax/features/namespaces", true);
reader.setFeature("http://xml.org/sax/features/namespace-prefixes", false);
- assemblyFactory = new AssemblyFactoryImpl();
+ assemblyFactory = new DefaultAssemblyFactory();
- JavaHandler javaHandler = new JavaHandler(new JavaFactoryImpl(assemblyFactory));
+ JavaHandler javaHandler = new JavaHandler(new DefaultJavaFactory(assemblyFactory));
interfaceHandlers = new InterfaceHandlerRegistry();
interfaceHandlers.addHandler(Constants.SCA10_NS, JavaConstants.INTERFACE_JAVA, javaHandler);
implementationHandlers = new ImplementationHandlerRegistry();
Added: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/DefaultJavaFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/DefaultJavaFactory.java?view=auto&rev=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/DefaultJavaFactory.java (added)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/DefaultJavaFactory.java Sun Mar 25 02:29:19 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.java.model.impl;
+
+/**
+ * A factory for the Java model.
+ */
+import org.apache.tuscany.assembly.model.AssemblyFactory;
+import org.apache.tuscany.assembly.model.Service;
+import org.apache.tuscany.java.model.JavaFactory;
+import org.apache.tuscany.java.model.JavaImplementation;
+import org.apache.tuscany.java.model.JavaInterface;
+
+public class DefaultJavaFactory implements JavaFactory {
+
+ private AssemblyFactory assemblyFactory;
+
+ public DefaultJavaFactory(AssemblyFactory assemblyFactory) {
+ this.assemblyFactory = assemblyFactory;
+ }
+
+ public JavaImplementation createJavaImplementation() {
+ JavaImplementation javaImplementation = new JavaImplementationImpl();
+
+ //TODO temporary, services should be created by introspecting
+ // the implementation
+ Service service = assemblyFactory.createService();
+ javaImplementation.getServices().add(service);
+ return javaImplementation;
+ }
+
+ public JavaInterface createJavaInterface() {
+ return new JavaInterfaceImpl();
+ }
+
+}
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/DefaultJavaFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/sebastien/java/sca/modules/java/src/main/java/org/apache/tuscany/java/model/impl/DefaultJavaFactory.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/sandbox/sebastien/java/sca/modules/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/sebastien/java/sca/modules/pom.xml?view=diff&rev=522186&r1=522185&r2=522186
==============================================================================
--- incubator/tuscany/sandbox/sebastien/java/sca/modules/pom.xml (original)
+++ incubator/tuscany/sandbox/sebastien/java/sca/modules/pom.xml Sun Mar 25 02:29:19 2007
@@ -45,6 +45,8 @@
<module>wsdl</module>
<module>wsdl-scdl</module>
<module>builder</module>
+ <module>bean</module>
+ <module>bean-test</module>
<module>crud</module>
<module>crud-scdl</module>
<module>http</module>
@@ -64,11 +66,11 @@
<module>wsdl</module>
<module>wsdl-scdl</module>
<module>builder</module>
+ <module>bean</module>
+ <module>bean-test</module>
<module>crud</module>
<module>crud-scdl</module>
<module>http</module>
- <module>http-jetty</module>
- <module>http-tomcat</module>
</modules>
</profile>
@@ -83,6 +85,8 @@
<module>wsdl</module>
<module>wsdl-scdl</module>
<module>builder</module>
+ <module>bean</module>
+ <module>bean-test</module>
<module>crud</module>
<module>crud-scdl</module>
<module>http</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org