tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r543947 [1/2] - in /incubator/tuscany/java/sca/modules/extension-helper: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/tuscany/ src/main/java/org/apache/tuscany/sca/ src/main/java/org...
Date Sun, 03 Jun 2007 18:10:22 GMT
Author: antelder
Date: Sun Jun  3 11:10:20 2007
New Revision: 543947

URL: http://svn.apache.org/viewvc?view=rev&rev=543947
Log:
First cut of simplified extensions

Added:
    incubator/tuscany/java/sca/modules/extension-helper/   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/DISCLAIMER
    incubator/tuscany/java/sca/modules/extension-helper/LICENSE   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/NOTICE   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/pom.xml   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/InvokerFactory.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/DiscoveryUtils.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/UtilsModuleActivator.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractBinding.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractImplementation.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractStAXArtifactProcessor.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DefaultPropertyValueObjectFactory.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DynamicImplementation.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/PropertyValueObjectFactory.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/ResourceHelper.java   (with props)
    incubator/tuscany/java/sca/modules/extension-helper/src/main/resources/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/resources/META-INF/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/resources/META-INF/services/
    incubator/tuscany/java/sca/modules/extension-helper/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
    incubator/tuscany/java/sca/modules/extension-helper/src/test/
    incubator/tuscany/java/sca/modules/extension-helper/src/test/java/
    incubator/tuscany/java/sca/modules/extension-helper/src/test/java/org/
    incubator/tuscany/java/sca/modules/extension-helper/src/test/java/org/apache/
    incubator/tuscany/java/sca/modules/extension-helper/src/test/java/org/apache/tuscany/
    incubator/tuscany/java/sca/modules/extension-helper/src/test/resources/

Propchange: incubator/tuscany/java/sca/modules/extension-helper/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Jun  3 11:10:20 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/java/sca/modules/extension-helper/DISCLAIMER
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/DISCLAIMER?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/DISCLAIMER (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/DISCLAIMER Sun Jun  3 11:10:20 2007
@@ -0,0 +1,8 @@
+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.
+

Added: incubator/tuscany/java/sca/modules/extension-helper/LICENSE
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/LICENSE?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/LICENSE (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/LICENSE Sun Jun  3 11:10:20 2007
@@ -0,0 +1,205 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+
+

Propchange: incubator/tuscany/java/sca/modules/extension-helper/LICENSE
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/LICENSE
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/tuscany/java/sca/modules/extension-helper/NOTICE
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/NOTICE?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/NOTICE (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/NOTICE Sun Jun  3 11:10:20 2007
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2007 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Propchange: incubator/tuscany/java/sca/modules/extension-helper/NOTICE
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/NOTICE
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/tuscany/java/sca/modules/extension-helper/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/pom.xml?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/pom.xml (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/pom.xml Sun Jun  3 11:10:20 2007
@@ -0,0 +1,63 @@
+<?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>
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>1.0-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>tuscany-extension-helper</artifactId>
+    <name>Apache Tuscany Extension Helper</name>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-databinding</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>                                      
+            <artifactId>junit</artifactId>
+            <version>3.8.1</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <version>2.2</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+</project>

Propchange: incubator/tuscany/java/sca/modules/extension-helper/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/tuscany/java/sca/modules/extension-helper/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public interface BindingActivator<B extends Binding> {
+
+    Class<B> getModelType();
+
+    StAXArtifactProcessor<B> getSCDLProcessor();
+    
+    ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent rc, RuntimeComponentReference rcr, B b);
+    
+    ServiceBindingProvider createServiceBindingProvider(RuntimeComponent rc, RuntimeComponentService rcs, B b);
+    
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/BindingActivator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public interface ImplementationActivator<T extends Implementation> {
+
+    QName getSCDLQName();
+    
+    Class<T> getImplementationClass();
+
+    InvokerFactory createInvokerFactory(RuntimeComponent rc, T implementation);
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/ImplementationActivator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/InvokerFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/InvokerFactory.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/InvokerFactory.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/InvokerFactory.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+
+public interface InvokerFactory {
+
+    public Invoker createInvoker(Operation operation);
+    
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/InvokerFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/InvokerFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/DiscoveryUtils.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/DiscoveryUtils.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/DiscoveryUtils.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/DiscoveryUtils.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi.impl;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+
+/**
+ * Discovers Activators in the classpath using the J2SE
+ * jar file extensions for Service Provider discovery
+ */
+public class DiscoveryUtils {
+
+    public static <T> List<T> discoverActivators(Class<T> activatorClass, ClassLoader classLoader, ExtensionPointRegistry registry) {
+        Set<Class> activatorClasses = getServiceClasses(classLoader, activatorClass);
+        List<T> activators = new ArrayList<T>();
+        for (Class<T> c : activatorClasses) {
+            try {
+                activators.add(c.cast(instantiateActivator(c, registry)));
+            } catch (Throwable e) {
+                e.printStackTrace(); // TODO: log
+            }
+        }
+        return activators;
+    }
+
+    static Object instantiateActivator(Class activator, ExtensionPointRegistry registry) {
+        Constructor[] cs = activator.getConstructors();
+        if (cs.length != 1) {
+            throw new RuntimeException("Activator must have only one constructors");
+        }
+        
+        Class<?>[] paramTypes = cs[0].getParameterTypes();
+        Object[] extensions = new Object[paramTypes.length];
+
+        for (int i=0; i< paramTypes.length; i++) {
+            extensions[i] = registry.getExtensionPoint(paramTypes[i]);
+        }
+        
+        try {
+
+            return cs[0].newInstance(extensions);
+
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    static Set<Class> getServiceClasses(ClassLoader classLoader, Class name) {
+        try {
+
+            Set<Class> set = new HashSet<Class>();
+            Enumeration<URL> urls = classLoader.getResources("META-INF/services/" + name.getName());
+            while (urls.hasMoreElements()) {
+                URL url = urls.nextElement();
+                Set<String> services = getServiceClassNames(url);
+                if (services != null) {
+                    for (String className : services) {
+                        try {
+                            set.add(Class.forName(className, true, classLoader));
+                        } catch (Throwable e) {
+                            // TODO: log 
+                        }
+                    }
+                }
+            }
+            return set;
+
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    static Set<String> getServiceClassNames(URL url) throws IOException {
+        Set<String> names = new HashSet<String>();
+        InputStream is = url.openStream();
+        BufferedReader reader = null;
+        try {
+            reader = new BufferedReader(new InputStreamReader(is));
+            while (true) {
+                String line = reader.readLine();
+                if (line == null) {
+                    break;
+                }
+                line = line.trim();
+                if (!line.startsWith("#") && !"".equals(line)) {
+                    names.add(line.trim());
+                }
+            }
+        } finally {
+            if (reader != null) {
+                reader.close();
+            }
+            
+            if (is != null){
+                try {
+                    is.close();
+                } catch( IOException ioe) {
+                    //ignore
+                }
+            }
+        }
+        return names;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/DiscoveryUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/DiscoveryUtils.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.spi.ImplementationActivator;
+import org.apache.tuscany.sca.spi.InvokerFactory;
+
+/**
+ * The ImplementationProvider createInvoker method is called before the start method
+ * but the runtime isn't properly setup until the start method is called. This means
+ * that Invoker's can't initialize things like the services, references and  properties
+ * until start is called. This class tries to get around that by using an Invoker
+ * proxy that delays creating the real Invoker till start is called.
+ */
+public class ImplementationImplementationProvider implements ImplementationProvider {
+
+    ImplementationActivator implementationActivator;
+    RuntimeComponent runtimeComponent;
+    Implementation impl;
+    
+    List<InvokerProxy> invokers = new ArrayList<InvokerProxy>();
+    
+    public ImplementationImplementationProvider(ImplementationActivator implementationActivator, RuntimeComponent rc, Implementation impl) {
+        this.implementationActivator = implementationActivator;
+        this.runtimeComponent = rc;
+        this.impl = impl;
+    }
+
+    public Invoker createInvoker(RuntimeComponentService arg0, final Operation op) {
+        InvokerProxy invoker = new InvokerProxy(op);
+        invokers.add(invoker);    
+        return invoker;
+    }
+
+    public Invoker createCallbackInvoker(Operation operation) {
+        throw new RuntimeException("TODO: callbacks not yet implemented"); 
+    }
+
+    public void start() {
+        InvokerFactory factory = implementationActivator.createInvokerFactory(runtimeComponent, impl);
+        for (InvokerProxy invoker : invokers) {
+            invoker.start(factory);
+        }
+    }
+
+    public void stop() {
+    }
+
+    class InvokerProxy implements Invoker {
+        Invoker invoker;
+        Operation op;
+        InvokerProxy(Operation op) {
+            this.op = op;
+        }
+        public Message invoke(Message arg0) {
+            return invoker.invoke(arg0);
+        }
+        public void start(InvokerFactory factory) {
+            invoker = factory.createInvoker(op);
+        }
+     }
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationImplementationProvider.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi.impl;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.spi.ImplementationActivator;
+import org.apache.tuscany.sca.spi.utils.DefaultPropertyValueObjectFactory;
+import org.apache.tuscany.sca.spi.utils.PropertyValueObjectFactory;
+
+/**
+ * A Tuscany ModuleActivator which acitvates all the ImplementationActivators
+ */
+public class ImplementationsActivator implements ModuleActivator {
+
+    protected List<ImplementationActivator> implementationActivators;
+    
+    public void start(ExtensionPointRegistry registry) {
+
+        ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class);
+        AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+        DataBindingExtensionPoint dataBindings = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+        TransformerExtensionPoint transformers = registry.getExtensionPoint(TransformerExtensionPoint.class); 
+        MediatorImpl mediator = new MediatorImpl(dataBindings, transformers);
+        PropertyValueObjectFactory propertyFactory = new DefaultPropertyValueObjectFactory(mediator);
+        registry.addExtensionPoint(propertyFactory);
+
+        this.implementationActivators = DiscoveryUtils.discoverActivators(ImplementationActivator.class, getClass().getClassLoader(), registry);
+
+        StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+        ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+        for (final ImplementationActivator implementationActivator : implementationActivators) {
+
+            Class<Implementation> implClass = implementationActivator.getImplementationClass();
+            QName scdlQName = implementationActivator.getSCDLQName();
+            staxProcessors.addArtifactProcessor(new SCDLProcessor(assemblyFactory, scdlQName, implClass));
+
+            if (implementationActivator.getImplementationClass() != null && providerFactories != null) {
+                addImplementationProvider(implementationActivator, providerFactories);
+            }
+        }
+    }
+
+    public void stop(ExtensionPointRegistry registry) {
+        StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+        for (final ImplementationActivator implementationActivator : implementationActivators) {
+            if (staxProcessors != null && implementationActivator.getSCDLQName() != null) {
+                StAXArtifactProcessor processor = staxProcessors.getProcessor(implementationActivator.getSCDLQName());
+                if (processor != null) {
+                    staxProcessors.removeArtifactProcessor(processor);
+                }
+            }
+        }
+    }
+
+    private void addImplementationProvider(final ImplementationActivator implementationActivator, ProviderFactoryExtensionPoint providerFactories) {
+
+        providerFactories.addProviderFactory(new ImplementationProviderFactory() {
+            public ImplementationProvider createImplementationProvider(final RuntimeComponent rc, final Implementation impl) {
+                return new ImplementationImplementationProvider(implementationActivator, rc, impl);
+            }
+            public Class getModelType() {
+                return implementationActivator.getImplementationClass();
+            }
+        });
+    }
+
+    public Object[] getExtensionPoints() {
+        return null;
+    }
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/ImplementationsActivator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi.impl;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.spi.utils.AbstractStAXArtifactProcessor;
+import org.apache.tuscany.sca.spi.utils.DynamicImplementation;
+
+/**
+ * An SCDL ArtifactProcessor which uses the Implementation class getters/setters
+ * to define the SCDL attributes.
+ */
+public class SCDLProcessor extends AbstractStAXArtifactProcessor<Implementation> {
+
+    protected QName scdlQName;
+    protected Class<Implementation> implementationClass;
+
+    protected Map<String, Method> attributeSetters;
+    protected Method elementTextSetter;
+
+    public SCDLProcessor(AssemblyFactory assemblyFactory, QName scdlQName, Class<Implementation> implementationClass) {
+        super(assemblyFactory);
+        this.scdlQName = scdlQName;
+        this.implementationClass = implementationClass;
+        initAttributes();
+    }
+
+    protected void initAttributes() {
+        attributeSetters = new HashMap<String, Method>();
+        Set<Method> methods = new HashSet<Method>(Arrays.asList(implementationClass.getMethods()));
+        methods.removeAll(Arrays.asList(DynamicImplementation.class.getMethods()));
+        for (Method m : methods) {
+            if ("setElementText".equals(m.getName())) {
+                elementTextSetter = m;
+            } else if ((m.getName().startsWith("set"))) {
+                attributeSetters.put(m.getName().substring(3).toLowerCase(), m);
+            }
+        }
+    }
+
+    public QName getArtifactType() {
+        return scdlQName;
+    }
+
+    public Class<Implementation> getModelType() {
+        return implementationClass;
+    }
+
+    public Implementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        Implementation impl;
+        try {
+            impl = implementationClass.newInstance();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+
+        for (String attribute : attributeSetters.keySet()) {
+            String value = reader.getAttributeValue(null, attribute);
+            if (value != null && value.length() > 0) {
+                try {
+                    attributeSetters.get(attribute).invoke(impl, new Object[] {value});
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+
+        if (elementTextSetter != null) {
+            try {
+                String value = reader.getElementText();
+                if (value != null && value.length() > 0) {
+                    elementTextSetter.invoke(impl, value);
+                }
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+
+        while (!(reader.getEventType() == END_ELEMENT && scdlQName.equals(reader.getName())) && reader.hasNext()) {
+            reader.next();
+        }
+
+        return impl;
+    }
+
+    public void write(Implementation arg0, XMLStreamWriter arg1) throws ContributionWriteException, XMLStreamException {
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/SCDLProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/UtilsModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/UtilsModuleActivator.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/UtilsModuleActivator.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/UtilsModuleActivator.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.spi.BindingActivator;
+import org.apache.tuscany.sca.spi.ImplementationActivator;
+import org.apache.tuscany.sca.spi.InvokerFactory;
+import org.apache.tuscany.sca.spi.utils.PropertyValueObjectFactory;
+import org.apache.tuscany.sca.spi.utils.DefaultPropertyValueObjectFactory;
+
+public class UtilsModuleActivator implements ModuleActivator {
+
+    List<BindingActivator> bindingActivators;
+    List<ImplementationActivator> implementationActivators;
+    private AssemblyFactory assemblyFactory;
+    
+    public void start(ExtensionPointRegistry registry) {
+
+        ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class);
+        this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+        DataBindingExtensionPoint dataBindings = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+        TransformerExtensionPoint transformers = registry.getExtensionPoint(TransformerExtensionPoint.class); 
+        MediatorImpl mediator = new MediatorImpl(dataBindings, transformers);
+        PropertyValueObjectFactory propertyFactory = new DefaultPropertyValueObjectFactory(mediator);
+        registry.addExtensionPoint(propertyFactory);
+
+        startBindings(registry);
+        startImplementations(registry);
+    }
+
+    public void stop(ExtensionPointRegistry registry) {
+        stopBindings(registry);
+        stopImplementations(registry);
+    }
+
+    @SuppressWarnings("unchecked")
+    public void startBindings(ExtensionPointRegistry registry) {
+
+        this.bindingActivators = DiscoveryUtils.discoverActivators(BindingActivator.class, getClass().getClassLoader(), registry);
+
+        StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+        for (final BindingActivator bindingActivator : bindingActivators) {
+
+            staxProcessors.addArtifactProcessor(bindingActivator.getSCDLProcessor());
+
+            if (bindingActivator.getModelType() != null) {
+                // Add a ProviderFactory
+                ProviderFactoryExtensionPoint providerFactories =
+                    registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+                providerFactories.addProviderFactory(new BindingProviderFactory() {
+                    public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent rc,
+                                                                                   RuntimeComponentReference rcr,
+                                                                                   Binding b) {
+                        return bindingActivator.createReferenceBindingProvider(rc, rcr, b);
+                    }
+
+                    public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent rc,
+                                                                               RuntimeComponentService rcs,
+                                                                               Binding b) {
+                        return bindingActivator.createServiceBindingProvider(rc, rcs, b);
+                    }
+
+                    public Class getModelType() {
+                        return bindingActivator.getModelType();
+                    }
+                });
+            }
+        }
+    }
+
+    public void stopBindings(ExtensionPointRegistry registry) {
+        StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+        ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+        for (final BindingActivator bindingActivator : bindingActivators) {
+
+            // Remove the binding SCDL processor from the runtime
+            if (staxProcessors != null && bindingActivator.getSCDLProcessor() != null) {
+                StAXArtifactProcessor processor = staxProcessors.getProcessor(bindingActivator.getSCDLProcessor().getClass());
+                if (processor != null) {
+                    staxProcessors.removeArtifactProcessor(processor);
+                }
+            }
+
+            // Remove the ProviderFactory from the runtime
+            if (providerFactories != null && bindingActivator.getModelType() != null) {
+                ProviderFactory factory = providerFactories.getProviderFactory(bindingActivator.getModelType());
+                if (factory != null) {
+                    providerFactories.removeProviderFactory(factory);
+                }
+            }
+        }
+    }
+
+    protected void startImplementations(ExtensionPointRegistry registry) {
+        this.implementationActivators = DiscoveryUtils.discoverActivators(ImplementationActivator.class, getClass().getClassLoader(), registry);
+
+        StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+        for (final ImplementationActivator implementationActivator : implementationActivators) {
+
+            SCDLProcessor scdlProcessor = new SCDLProcessor(assemblyFactory, implementationActivator.getSCDLQName(), implementationActivator.getImplementationClass());
+            staxProcessors.addArtifactProcessor(scdlProcessor);
+
+            ProviderFactoryExtensionPoint providerFactories = registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+            if (implementationActivator.getImplementationClass() != null && providerFactories != null) {
+
+                providerFactories.addProviderFactory(new ImplementationProviderFactory() {
+                    public ImplementationProvider createImplementationProvider(final RuntimeComponent rc, final Implementation impl) {
+                        return new ImplementationProvider() {
+                            List<DelegaterInvoker> invokers = new ArrayList<DelegaterInvoker>();
+                            public Invoker createInvoker(RuntimeComponentService arg0, final Operation op) {
+                                DelegaterInvoker invoker = new DelegaterInvoker();
+                                invoker.op = op;
+                                invokers.add(invoker);    
+                                return invoker;
+                            }
+                            public Invoker createCallbackInvoker(Operation arg0) {
+                                throw new RuntimeException("TODO: callbacks not yet implemented"); 
+                            }
+                            public void start() {
+                                InvokerFactory factory = implementationActivator.createInvokerFactory(rc, impl);
+                                for (DelegaterInvoker invoker : invokers) {
+                                    invoker.start(factory);
+                                }
+                            }
+                            public void stop() {
+                            }
+                            class DelegaterInvoker implements Invoker {
+                                Invoker invoker;
+                                Operation op;
+                                public Message invoke(Message arg0) {
+                                    return invoker.invoke(arg0);
+                                }
+                                public void start(InvokerFactory factory) {
+                                    invoker = factory.createInvoker(op);
+                                }
+                             }
+                            };
+                    }
+                    public Class getModelType() {
+                        return implementationActivator.getImplementationClass();
+                    }
+                });
+            }
+        }
+    }
+
+    protected void stopImplementations(ExtensionPointRegistry registry) {
+        StAXArtifactProcessorExtensionPoint staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+
+        for (final ImplementationActivator implementationActivator : implementationActivators) {
+            if (staxProcessors != null && implementationActivator.getSCDLQName() != null) {
+                StAXArtifactProcessor processor = staxProcessors.getProcessor(implementationActivator.getSCDLQName());
+                if (processor != null) {
+                    staxProcessors.removeArtifactProcessor(processor);
+                }
+            }
+        }
+    }
+
+    public Object[] getExtensionPoints() {
+        return null; // not used by binding or implementation extensions
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/UtilsModuleActivator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/impl/UtilsModuleActivator.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractBinding.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractBinding.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractBinding.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi.utils;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Helper for implementing Bindings, implements all the
+ * standard getters and setters on the binding interface.
+ */
+public class AbstractBinding implements Binding {
+
+    private String name;
+    private String uri;
+    private List<Object> extensions;
+    private boolean unresolved;
+    private List<Intent> requiredIntents;
+    private List<PolicySet> policySets;
+
+    public String getName() {
+        return name;
+    }
+
+    public String getURI() {
+        return uri;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    public List<Object> 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/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractBinding.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractImplementation.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractImplementation.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractImplementation.java Sun Jun  3 11:10:20 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.sca.spi.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Helper for implementing Implementations, implements all the
+ * standard getters and setters on the Implementation interface.
+ */
+public abstract class AbstractImplementation implements Implementation {
+
+    private List<Service> services = new ArrayList<Service>();
+    private List<Reference> references = new ArrayList<Reference>();
+    private List<Property> properties = new ArrayList<Property>();
+    private ConstrainingType constrainingType;
+    private String uri;
+    private boolean unresolved = true;
+    private List<Intent> intents;
+    private List<PolicySet> policySets;
+
+    public AbstractImplementation() {
+    }
+
+    public List<Property> getProperties() {
+        return properties;
+    }
+
+    public List<Reference> getReferences() {
+        return references;
+    }
+
+    public List<Service> getServices() {
+        return services;
+    }
+
+    public String getURI() {
+        return uri;
+    }
+
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    public ConstrainingType getConstrainingType() {
+        return constrainingType;
+    }
+
+    public void setConstrainingType(ConstrainingType constrainingType) {
+        this.constrainingType = constrainingType;
+    }
+
+    public List<Intent> getRequiredIntents() {
+        return intents;
+    }
+
+    public List<PolicySet> getPolicySets() {
+        return policySets;
+    }
+
+    public List<Object> getExtensions() {
+        // TODO what is this for?
+        return null;
+    }
+
+    public boolean isUnresolved() {
+        return unresolved;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+        this.unresolved = unresolved;
+    }
+
+    public Service getService(String name) {
+        for (Service service : getServices()) {
+            if (service.getName().equals(name)) {
+                return service;
+            }
+        }
+        return null;
+    }
+
+    public Reference getReference(String name) {
+        for (Reference reference : getReferences()) {
+            if (reference.getName().equals(name)) {
+                return reference;
+            }
+        }
+        return null;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractImplementation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractImplementation.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractStAXArtifactProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractStAXArtifactProcessor.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractStAXArtifactProcessor.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractStAXArtifactProcessor.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.spi.utils;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceContractImpl;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
+
+/**
+ * TODO: couldn't something like this class be provided by the runtime?
+ * Each impl shouldn't have to have their own .componentType merging code
+ */
+public abstract class AbstractStAXArtifactProcessor<I extends Implementation> implements StAXArtifactProcessor<I> {
+
+    protected AssemblyFactory assemblyFactory;
+
+    public AbstractStAXArtifactProcessor(AssemblyFactory assemblyFactory) {
+        this.assemblyFactory = assemblyFactory;
+    }
+
+    public void resolve(I model, ModelResolver resolver) throws ContributionResolveException {
+
+      addSideFileComponentType(model.getURI(), model, resolver);
+
+      if (model instanceof DynamicImplementation) {
+          // if no services have been defined then add a dynamic one
+          if (model.getServices().size() < 1) {
+              Service dynamicService = createDynamicService();
+              model.getServices().add(dynamicService);
+          }
+      }
+
+      model.setUnresolved(false);
+    }
+
+    protected void addSideFileComponentType(String name, Implementation impl, ModelResolver resolver) {
+        if (name == null) {
+            return;
+        }
+        int lastDot = name.lastIndexOf('.');
+        if (lastDot < 0) {
+            return;
+        }
+        String sideFileName = name.substring(0, lastDot) + ".componentType";
+
+        ComponentType componentType = assemblyFactory.createComponentType();
+        componentType.setURI(sideFileName);
+        componentType.setUnresolved(true);
+
+        componentType = resolver.resolveModel(ComponentType.class, componentType);
+
+        if (!componentType.isUnresolved()) {
+            for (Reference reference : componentType.getReferences()) {
+                impl.getReferences().add(reference);
+            }
+            for (Service service : componentType.getServices()) {
+                impl.getServices().add(service);
+            }
+            for (Property property : componentType.getProperties()) {
+                impl.getProperties().add(property);
+            }
+            if (componentType.getConstrainingType() != null) {
+                impl.setConstrainingType(componentType.getConstrainingType());
+            }
+        }
+    }
+
+    protected Service createDynamicService() {
+        Service dynamicService = assemblyFactory.createService();
+        dynamicService.setName("$dynamic$");
+        InterfaceContract dynamicInterfaceContract = new InterfaceContractImpl() {};
+        Interface dynamicInterface = new InterfaceImpl() {
+            public boolean isDynamic() {
+                return true;
+            }
+        };
+        Operation dynamicOperation = assemblyFactory.createOperation();
+        dynamicOperation.setDynamic(true);
+        dynamicInterface.getOperations().add(dynamicOperation);
+        dynamicInterfaceContract.setInterface(dynamicInterface);
+        dynamicService.setInterfaceContract(dynamicInterfaceContract);
+
+        return dynamicService;
+    }
+
+}
\ No newline at end of file

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractStAXArtifactProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/AbstractStAXArtifactProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DefaultPropertyValueObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DefaultPropertyValueObjectFactory.java?view=auto&rev=543947
==============================================================================
--- incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DefaultPropertyValueObjectFactory.java (added)
+++ incubator/tuscany/java/sca/modules/extension-helper/src/main/java/org/apache/tuscany/sca/spi/utils/DefaultPropertyValueObjectFactory.java Sun Jun  3 11:10:20 2007
@@ -0,0 +1,229 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.spi.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.factory.ObjectCreationException;
+import org.apache.tuscany.sca.factory.ObjectFactory;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * TODO: Shouldn't this class be provided by the runtime?
+ */
+public class DefaultPropertyValueObjectFactory implements PropertyValueObjectFactory {
+    // protected DataBindingRegistry dbRegistry = new DataBindingRegistryImpl();
+    protected Mediator mediator = null;
+    protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl();
+    boolean isSimpleType;
+    
+    public DefaultPropertyValueObjectFactory(Mediator mediator) {
+        this.mediator = mediator;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.tuscany.sca.spi.utils.PVOF#createValueFactory(org.apache.tuscany.sca.assembly.Property)
+     */
+    public ObjectFactory createValueFactory(Property property) {
+        isSimpleType = isSimpleType(property);
+        Document doc = (Document)property.getValue();
+        Element rootElement = doc.getDocumentElement();
+        
+        //FIXME : since scripts use dynamic types we need to generate a dynamic java type using the 
+        //xml structure of the property value.  Should this be done in the JavaBeansDataBinding... 
+        Class javaType = null;
+        
+        if (property.isMany()) {
+            if (isSimpleType) {
+                String value = "";
+                if (rootElement.getChildNodes().getLength() > 0) {
+                    value = rootElement.getChildNodes().item(0).getTextContent();
+                }
+                List<String> values = 
+                    getSimplePropertyValues(value, javaType);
+                return new ListObjectFactoryImpl(property, 
+                                                 values,
+                                                 isSimpleType,
+                                                 javaType);
+            } else {
+                return new ListObjectFactoryImpl(property,
+                                                 getComplexPropertyValues(doc),
+                                                 isSimpleType,
+                                                 javaType);
+            }
+        } else {
+            if (isSimpleType) {
+                String value = "";
+                if (rootElement.getChildNodes().getLength() > 0) {
+                    value = rootElement.getChildNodes().item(0).getTextContent();
+                }
+                return new ObjectFactoryImpl(property,
+                                             value,
+                                             isSimpleType,
+                                             javaType);
+            } else {
+                Object value = getComplexPropertyValues(doc).get(0);
+                return new ObjectFactoryImpl(property,
+                                             value,
+                                             isSimpleType,
+                                             javaType);
+            }
+            
+        }
+    }
+    
+    private boolean isSimpleType(Property property) {
+        if (property.getXSDType() != null) {
+            return SimpleTypeMapperImpl.isSimpleXSDType(property.getXSDType());
+        } else {
+            if (property instanceof Document) {
+                Document doc = (Document)property;
+                Element element = doc.getDocumentElement(); 
+                if (element.getChildNodes().getLength() == 1 && 
+                    element.getChildNodes().item(0).getNodeType() == Element.TEXT_NODE) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    
+    private List<String> getSimplePropertyValues(String concatenatedValue, Class javaType) {
+        List<String> propValues = new ArrayList<String>();
+        StringTokenizer st = null;
+        if ( javaType.getName().equals("java.lang.String")) {
+            st = new StringTokenizer(concatenatedValue, "\"");
+        } else {
+            st = new StringTokenizer(concatenatedValue);
+        }
+        String aToken = null;
+        while (st.hasMoreTokens()) {
+            aToken = st.nextToken();
+            if (aToken.trim().length() > 0) {
+                propValues.add(aToken);
+            }
+        }
+        return propValues;
+    }
+    
+    private List<Node> getComplexPropertyValues(Document document) {
+        Element rootElement = document.getDocumentElement();
+        List<Node> propValues = new ArrayList<Node>();
+        for (int count = 0 ; count < rootElement.getChildNodes().getLength() ; ++count) {
+            if (rootElement.getChildNodes().item(count).getNodeType() == Document.ELEMENT_NODE) {
+                propValues.add(rootElement.getChildNodes().item(count));
+            }
+        }
+        return propValues;
+    }
+    
+    public abstract class ObjectFactoryImplBase  implements ObjectFactory {
+        protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl();
+        protected Property property;
+        protected Object propertyValue;
+        protected Class javaType;
+        protected DataType<XMLType> sourceDataType;
+        protected DataType<?> targetDataType;
+        boolean isSimpleType;
+
+        public ObjectFactoryImplBase(Property property, Object propertyValue, boolean isSimpleType, Class javaType)  {
+            
+            this.isSimpleType = isSimpleType;
+            this.property = property;
+            this.propertyValue = propertyValue;
+            this.javaType = javaType;
+            //FIXME : fix this when we have managed to generate dynamic java types
+            /*sourceDataType =
+                new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, 
+                    new XMLType(null, this.property.getXSDType()));
+            TypeInfo typeInfo = null;
+            if (this.property.getXSDType() != null) {
+                if (SimpleTypeMapperExtension.isSimpleXSDType(this.property.getXSDType())) {
+                    typeInfo = new TypeInfo(property.getXSDType(), true, null);
+                } else {
+                    typeInfo = new TypeInfo(property.getXSDType(), false, null);
+                }
+            } else {
+                typeInfo = new TypeInfo(property.getXSDType(), false, null);
+            }
+
+            XMLType xmlType = new XMLType(typeInfo);
+            String dataBinding = null; //(String)property.getExtensions().get(DataBinding.class.getName());
+            if (dataBinding != null) {
+                targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+            } else {
+                targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+                mediator.getDataBindingRegistry().introspectType(targetDataType, null);  
+            }*/
+        }
+    }
+    
+    public class ObjectFactoryImpl extends ObjectFactoryImplBase {
+        public ObjectFactoryImpl(Property property, Object propertyValue, boolean isSimpleType, Class javaType) {
+            super(property, propertyValue, isSimpleType, javaType);
+        }
+
+        @SuppressWarnings("unchecked")
+        public Object getInstance() throws ObjectCreationException {
+            if (isSimpleType) {
+                return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
+            } else {
+                return mediator.mediate(propertyValue, sourceDataType, targetDataType, null);
+                //return null;
+            }
+        }
+    }
+
+    public class ListObjectFactoryImpl extends ObjectFactoryImplBase  {
+        public ListObjectFactoryImpl(Property property, List<?>propertyValues, boolean isSimpleType, Class javaType) {
+            super(property, propertyValues, isSimpleType, javaType);
+        }
+
+        @SuppressWarnings("unchecked")
+        public List<?> getInstance() throws ObjectCreationException {
+            if (isSimpleType) {
+                List<Object> values = new ArrayList<Object>();
+                for (String aValue : (List<String>)propertyValue) {
+                    values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+                }
+                return values;
+            } else {
+                List instances = new ArrayList();
+                for (Node aValue : (List<Node>)propertyValue) {
+                    instances.add(mediator.mediate(aValue,
+                                                      sourceDataType,
+                                                      targetDataType,
+                                                      null));
+                }
+                return instances;
+            }
+        }
+    }
+}
+      
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message