You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/03/20 19:26:11 UTC

svn commit: r520509 [1/2] - in /incubator/tuscany/java/sca/kernel/databinding: ./ 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/core/ src/main/java/org/apac...

Author: rfeng
Date: Tue Mar 20 11:26:09 2007
New Revision: 520509

URL: http://svn.apache.org/viewvc?view=rev&rev=520509
Log:
Add tuscany-core-databinding module which provides integration between core and the databinding framework

Added:
    incubator/tuscany/java/sca/kernel/databinding/   (with props)
    incubator/tuscany/java/sca/kernel/databinding/.checkstyle
    incubator/tuscany/java/sca/kernel/databinding/.pmd
    incubator/tuscany/java/sca/kernel/databinding/.ruleset
    incubator/tuscany/java/sca/kernel/databinding/LICENSE.txt   (with props)
    incubator/tuscany/java/sca/kernel/databinding/NOTICE.txt   (with props)
    incubator/tuscany/java/sca/kernel/databinding/pom.xml   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/
    incubator/tuscany/java/sca/kernel/databinding/src/main/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/loader/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/loader/DataTypeLoader.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/DataBindingJavaInterfaceProcessor.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/JavaInterfaceIntrospector.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Exception2ExceptionTransformer.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Input2InputTransformer.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Output2OutputTransformer.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/wire/
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessor.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/main/resources/
    incubator/tuscany/java/sca/kernel/databinding/src/main/resources/org/
    incubator/tuscany/java/sca/kernel/databinding/src/main/resources/org/apache/
    incubator/tuscany/java/sca/kernel/databinding/src/main/resources/org/apache/tuscany/
    incubator/tuscany/java/sca/kernel/databinding/src/main/resources/org/apache/tuscany/core/
    incubator/tuscany/java/sca/kernel/databinding/src/main/resources/org/apache/tuscany/core/databinding.scdl
    incubator/tuscany/java/sca/kernel/databinding/src/test/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/loader/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/loader/DataBindingLoaderTestCase.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/processor/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/processor/DataBindingJavaInterfaceProcessorTestCase.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/transformers/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/transformers/IDLTransformerTestCase.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/wire/
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingInterceptorTestCase.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorOptimizationTestCase.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/test/java/org/apache/tuscany/core/databinding/wire/DataBindingWirePostProcessorTestCase.java   (with props)
    incubator/tuscany/java/sca/kernel/databinding/src/test/resources/

Propchange: incubator/tuscany/java/sca/kernel/databinding/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Mar 20 11:26:09 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/kernel/databinding/.checkstyle
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/.checkstyle?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/.checkstyle (added)
+++ incubator/tuscany/java/sca/kernel/databinding/.checkstyle Tue Mar 20 11:26:09 2007
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fileset-config file-format-version="1.2.0" simple-config="true">
+    <fileset name="all" enabled="true" check-config-name="Tuscany Checks" local="false">
+        <file-match-pattern match-pattern="." include-pattern="true"/>
+    </fileset>
+</fileset-config>

Added: incubator/tuscany/java/sca/kernel/databinding/.pmd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/.pmd?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/.pmd (added)
+++ incubator/tuscany/java/sca/kernel/databinding/.pmd Tue Mar 20 11:26:09 2007
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pmd><useProjectRuleSet>true</useProjectRuleSet><rules/><includeDerivedFiles>false</includeDerivedFiles></pmd>
\ No newline at end of file

Added: incubator/tuscany/java/sca/kernel/databinding/.ruleset
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/.ruleset?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/.ruleset (added)
+++ incubator/tuscany/java/sca/kernel/databinding/.ruleset Tue Mar 20 11:26:09 2007
@@ -0,0 +1,190 @@
+<?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.
+-->
+<ruleset name="pmd-eclipse">
+  <description>PMD Plugin preferences rule set</description>
+  
+  
+  <rule ref="rulesets/basic.xml/BooleanInstantiation"/>
+  <rule ref="rulesets/basic.xml/CollapsibleIfStatements"/>
+  <rule ref="rulesets/basic.xml/DoubleCheckedLocking"/>
+<!--<rule ref="rulesets/basic.xml/EmptyCatchBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyFinallyBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyIfStmt"/>-->
+  <rule ref="rulesets/basic.xml/EmptyStatementNotInLoop"/>
+<!--<rule ref="rulesets/basic.xml/EmptyStaticInitializer"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySwitchStatements"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptySynchronizedBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyTryBlock"/>-->
+<!--<rule ref="rulesets/basic.xml/EmptyWhileStmt"/>-->
+  <rule ref="rulesets/basic.xml/ForLoopShouldBeWhileLoop"/>
+  <rule ref="rulesets/basic.xml/JumbledIncrementer"/>
+<!--<rule ref="rulesets/basic.xml/OverrideBothEqualsAndHashcode"/>-->
+  <rule ref="rulesets/basic.xml/ReturnFromFinallyBlock"/>
+  <rule ref="rulesets/basic.xml/UnconditionalIfStatement"/>
+  <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/>
+  <rule ref="rulesets/basic.xml/UnnecessaryFinalModifier"/>
+  <rule ref="rulesets/basic.xml/UnnecessaryReturn"/>
+<!--<rule ref="rulesets/basic.xml/UselessOverridingMethod"/>-->
+  
+<!--<rule ref="rulesets/braces.xml/ForLoopsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfElseStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/IfStmtsMustUseBraces"/>-->
+<!--<rule ref="rulesets/braces.xml/WhileLoopsMustUseBraces"/>-->
+
+<!--<rule ref="rulesets/clone.xml/CloneMethodMustImplementCloneable"/>-->
+<!--<rule ref="rulesets/clone.xml/CloneThrowsCloneNotSupportedException"/>-->
+<!--<rule ref="rulesets/clone.xml/ProperCloneImplementation"/>-->
+  
+<!--<rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>-->
+<!--<rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>-->
+<!--<rule ref="rulesets/codesize.xml/TooManyFields"/>-->
+
+<rule ref="rulesets/controversial.xml/AssignmentInOperand"/>
+<!--<rule ref="rulesets/controversial.xml/AtLeastOneConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/CallSuperInConstructor"/>-->
+<!--<rule ref="rulesets/controversial.xml/DontImportSun"/>-->
+<!--<rule ref="rulesets/controversial.xml/NullAssignment"/>-->
+<!--<rule ref="rulesets/controversial.xml/OnlyOneReturn"/>-->
+<!--<rule ref="rulesets/controversial.xml/SingularField"/>-->
+<!--<rule ref="rulesets/controversial.xml/SuspiciousOctalEscape"/>-->
+<!--<rule ref="rulesets/controversial.xml/UnnecessaryConstructor"/>-->
+<rule ref="rulesets/controversial.xml/UnnecessaryParentheses"/>
+<!--<rule ref="rulesets/controversial.xml/UnusedModifier"/>-->
+
+<!--<rule ref="rulesets/coupling.xml/CouplingBetweenObjects"/>-->
+<!--<rule ref="rulesets/coupling.xml/ExcessiveImports"/>-->
+<!--<rule ref="rulesets/coupling.xml/LooseCoupling"/>-->
+
+<!--<rule ref="rulesets/design.xml/AbstractClassWithoutAbstractMethod"/>-->
+<!--<rule ref="rulesets/design.xml/AccessorClassGeneration"/>-->
+<!--<rule ref="rulesets/design.xml/AssignmentToNonFinalStatic"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidDeeplyNestedIfStmts"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidInstanceofChecksInCatchClause"/>-->
+<rule ref="rulesets/design.xml/AvoidProtectedFieldInFinalClass"/>
+<!--<rule ref="rulesets/design.xml/AvoidReassigningParameters"/>-->
+<!--<rule ref="rulesets/design.xml/AvoidSynchronizedAtMethodLevel"/>-->
+<!--<rule ref="rulesets/design.xml/BadComparison"/>-->
+<!--<rule ref="rulesets/design.xml/CloseConnection"/>-->
+<!--<rule ref="rulesets/design.xml/CompareObjectsWithEquals"/>-->
+<!--<rule ref="rulesets/design.xml/ConfusingTernary"/>-->
+<rule ref="rulesets/design.xml/ConstructorCallsOverridableMethod"/>
+<!--<rule ref="rulesets/design.xml/DefaultLabelNotLastInSwitchStmt"/>-->
+<!--<rule ref="rulesets/design.xml/FinalFieldCouldBeStatic"/>-->
+<rule ref="rulesets/design.xml/IdempotentOperations"/>
+<!--<rule ref="rulesets/design.xml/ImmutableField"/>-->
+<!--<rule ref="rulesets/design.xml/InstantiationToGetClass"/>-->
+<!--<rule ref="rulesets/design.xml/MissingBreakInSwitch"/>-->
+<!--<rule ref="rulesets/design.xml/MissingStaticMethodInNonInstantiatableClass"/>-->
+<!--<rule ref="rulesets/design.xml/NonCaseLabelInSwitchStatement"/>-->
+<!--<rule ref="rulesets/design.xml/NonStaticInitializer"/>-->
+<rule ref="rulesets/design.xml/OptimizableToArrayCall"/>
+<rule ref="rulesets/design.xml/PositionLiteralsFirstInComparisons"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanExpressions"/>
+<rule ref="rulesets/design.xml/SimplifyBooleanReturns"/>
+<rule ref="rulesets/design.xml/SimplifyConditional"/>
+<!--<rule ref="rulesets/design.xml/SwitchDensity"/>-->
+<!--<rule ref="rulesets/design.xml/SwitchStmtsShouldHaveDefault"/>-->
+<!--<rule ref="rulesets/design.xml/UnnecessaryLocalBeforeReturn"/>-->
+<!--<rule ref="rulesets/design.xml/UseLocaleWithCaseConversions"/>-->
+<!--<rule ref="rulesets/design.xml/UseNotifyAllInsteadOfNotify"/>-->
+<!--<rule ref="rulesets/design.xml/UseSingleton"/>-->
+
+<!--<rule ref="rulesets/finalizers.xml/EmptyFinalizer"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOnlyCallsSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeOverloaded"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeDoesNotCallSuperFinalize"/>-->
+<!--<rule ref="rulesets/finalizers.xml/FinalizeShouldBeProtected"/>-->
+<!--<rule ref="rulesets/finalizers.xml/AvoidCallingFinalize"/>-->
+
+<!--<rule ref="rulesets/imports.xml/DuplicateImports"/>-->
+<!--<rule ref="rulesets/imports.xml/DontImportJavaLang"/>-->
+<!--<rule ref="rulesets/imports.xml/UnusedImports"/>-->
+<!--<rule ref="rulesets/imports.xml/ImportFromSamePackage"/>-->
+
+<!--<rule ref="rulesets/javabeans.xml/BeanMembersShouldSerialize"/>-->
+<!--<rule ref="rulesets/javabeans.xml/MissingSerialVersionUID"/>-->
+
+<!--<rule ref="rulesets/junit.xml/JUnitStaticSuite"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitSpelling"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitAssertionsShouldIncludeMessage"/>-->
+<!--<rule ref="rulesets/junit.xml/JUnitTestsShouldIncludeAssert"/>-->
+<!--<rule ref="rulesets/junit.xml/TestClassWithoutTestCases"/>-->
+<!--<rule ref="rulesets/junit.xml/UnnecessaryBooleanAssertion"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertEqualsInsteadOfAssertTrue"/>-->
+<!--<rule ref="rulesets/junit.xml/UseAssertSameInsteadOfAssertTrue"/>-->
+
+  <!--<rule ref="rulesets/logging-java.xml/AvoidPrintStackTrace"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/MoreThanOneLogger"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/LoggerIsNotStaticFinal"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/LogBlockWithoutIf"/>-->
+  <!--<rule ref="rulesets/logging-java.xml/SystemPrintln"/>-->
+  <!--<rule ref="rulesets/logging-jakarta-commons.xml/UseCorrectExceptionLogging"/>-->
+  <!--<rule ref="rulesets/logging-jakarta-commons.xml/ProperLogger"/>-->
+  
+  <!--<rule ref="rulesets/naming.xml/ShortVariable"/>-->
+  <!--<rule ref="rulesets/naming.xml/LongVariable"/>-->
+  <!--<rule ref="rulesets/naming.xml/ShortMethodName"/>-->
+  <!--<rule ref="rulesets/naming.xml/VariableNamingConventions"/>-->
+  <!--<rule ref="rulesets/naming.xml/MethodNamingConventions"/>-->
+  <!--<rule ref="rulesets/naming.xml/ClassNamingConventions"/>-->
+  <!--<rule ref="rulesets/naming.xml/AbstractNaming"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidDollarSigns"/>-->
+  <!--<rule ref="rulesets/naming.xml/MethodWithSameNameAsEnclosingClass"/>-->
+  <!--<rule ref="rulesets/naming.xml/SuspiciousHashcodeMethodName"/>-->
+  <!--<rule ref="rulesets/naming.xml/SuspiciousConstantFieldName"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingTypeName"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidFieldNameMatchingMethodName"/>-->
+  <!--<rule ref="rulesets/naming.xml/AvoidNonConstructorMethodsWithClassName"/>-->
+  <!--<rule ref="rulesets/naming.xml/NoPackage"/>-->
+  <!--<rule ref="rulesets/naming.xml/PackageCase"/>-->
+
+  <!--<rule ref="rulesets/optimizations.xml/LocalVariableCouldBeFinal"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/MethodArgumentCouldBeFinal"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/AvoidInstantiatingObjectsInLoops"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/UseArrayListInsteadOfVector"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/SimplifyStartsWith"/>-->
+  <!--<rule ref="rulesets/optimizations.xml/UseStringBufferForStringAppends"/>-->
+
+  <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingThrowable"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/SignatureDeclareThrowsException"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/ExceptionAsFlowControl"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/AvoidCatchingNPE"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingRawExceptionTypes"/>-->
+  <!--<rule ref="rulesets/strictexception.xml/AvoidThrowingNullPointerException"/>-->
+ 
+  <!--<rule ref="rulesets/strings.xml/AvoidDuplicateLiterals"/>-->
+  <!--<rule ref="rulesets/strings.xml/StringInstantiation"/>-->
+  <!--<rule ref="rulesets/strings.xml/StringToString"/>-->
+  <!--<rule ref="rulesets/strings.xml/AvoidConcatenatingNonLiteralsInStringBuffer"/>-->
+  <!--<rule ref="rulesets/strings.xml/UnnecessaryCaseChange"/>-->
+  
+  <!--<rule ref="rulesets/sunsecure.xml/MethodReturnsInternalArray"/>-->
+  <!--<rule ref="rulesets/sunsecure.xml/ArrayIsStoredDirectly"/>-->
+  
+  <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+  <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+  <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+  <!--<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>-->
+  
+</ruleset>

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

Propchange: incubator/tuscany/java/sca/kernel/databinding/LICENSE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tuscany/java/sca/kernel/databinding/NOTICE.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/NOTICE.txt?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/NOTICE.txt (added)
+++ incubator/tuscany/java/sca/kernel/databinding/NOTICE.txt Tue Mar 20 11:26:09 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/java/sca/kernel/databinding/NOTICE.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/tuscany/java/sca/kernel/databinding/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/pom.xml?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/pom.xml (added)
+++ incubator/tuscany/java/sca/kernel/databinding/pom.xml Tue Mar 20 11:26:09 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>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>kernel</artifactId>
+        <version>2.0-alpha2-incubating-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.tuscany.sca.kernel</groupId>
+    <artifactId>tuscany-core-databinding</artifactId>
+    <packaging>jar</packaging>
+    <name>Apache Tuscany Core/DataBinding Integration</name>
+    <description>Apache Tuscany Core/DataBinding Integration</description>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca.services.databinding</groupId>
+            <artifactId>databinding-framework</artifactId>
+            <version>${project.version}</version>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.codehaus.woodstox</groupId>
+            <artifactId>wstx-asl</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>stax</groupId>
+            <artifactId>stax-api</artifactId>
+            <version>1.0.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.2</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Propchange: incubator/tuscany/java/sca/kernel/databinding/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/databinding/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/loader/DataTypeLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/loader/DataTypeLoader.java?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/loader/DataTypeLoader.java (added)
+++ incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/loader/DataTypeLoader.java Tue Mar 20 11:26:09 2007
@@ -0,0 +1,64 @@
+/*
+ * 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.core.databinding.loader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.extension.LoaderExtension;
+import org.apache.tuscany.spi.loader.InvalidValueException;
+import org.apache.tuscany.spi.loader.LoaderException;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.loader.LoaderUtil;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.ModelObject;
+import org.osoa.sca.annotations.Constructor;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * The StAX loader for data type
+ */
+public class DataTypeLoader extends LoaderExtension<DataType> {
+    public static final QName DATA_BINDING =
+        new QName("http://tuscany.apache.org/xmlns/sca/databinding/1.0", "databinding");
+
+    @Constructor({"registry"})
+    public DataTypeLoader(@Reference LoaderRegistry registry) {
+        super(registry);
+    }
+
+    @Override
+    public QName getXMLType() {
+        return DATA_BINDING;
+    }
+
+    public DataType load(ModelObject object, XMLStreamReader reader,
+                         DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
+        assert DATA_BINDING.equals(reader.getName());
+        String name = reader.getAttributeValue(null, "name");
+        LoaderUtil.skipToEndElement(reader);
+        if (name == null) {
+            throw new InvalidValueException("The 'name' attrbiute is required");
+        }
+        DataType dataType = new DataType<Class>(name, Object.class, Object.class);
+        return dataType;
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/loader/DataTypeLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/loader/DataTypeLoader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/DataBindingJavaInterfaceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/DataBindingJavaInterfaceProcessor.java?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/DataBindingJavaInterfaceProcessor.java (added)
+++ incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/DataBindingJavaInterfaceProcessor.java Tue Mar 20 11:26:09 2007
@@ -0,0 +1,125 @@
+/*
+ * 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.core.databinding.processor;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.apache.tuscany.api.annotation.DataType;
+import org.apache.tuscany.spi.databinding.DataBindingRegistry;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorExtension;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * The databinding annotation processor for java interfaces
+ * 
+ * @version $Rev$ $Date$
+ */
+public class DataBindingJavaInterfaceProcessor extends JavaInterfaceProcessorExtension {
+    private static final Class[] SIMPLE_JAVA_TYPES =
+        {Byte.class, Character.class, Short.class, Integer.class, Long.class, Float.class, Double.class, Date.class,
+         Calendar.class, GregorianCalendar.class, Duration.class, XMLGregorianCalendar.class, BigInteger.class,
+         BigDecimal.class};
+
+    private static final Set<Class> SIMPLE_TYPE_SET = new HashSet<Class>(Arrays.asList(SIMPLE_JAVA_TYPES));
+
+    private DataBindingRegistry dataBindingRegistry;
+
+    public DataBindingJavaInterfaceProcessor(@Reference
+    DataBindingRegistry dataBindingRegistry) {
+        super();
+        this.dataBindingRegistry = dataBindingRegistry;
+    }
+
+    public void visitInterface(Class<?> clazz, Class<?> callbackClass, JavaServiceContract contract)
+        throws InvalidServiceContractException {
+        if (!contract.isRemotable()) {
+            return;
+        }
+        Map<String, Operation<Type>> operations = contract.getOperations();
+        processInterface(clazz, contract, operations);
+        if (callbackClass != null) {
+            Map<String, Operation<Type>> callbackOperations = contract.getCallbackOperations();
+            processInterface(callbackClass, contract, callbackOperations);
+        }
+    }
+
+    private void processInterface(Class<?> clazz, JavaServiceContract contract, 
+                                  Map<String, Operation<Type>> operations) {
+        // IDLMapping interfaceMapping = clazz.getAnnotation(IDLMapping.class);
+        DataType interfaceDataType = clazz.getAnnotation(DataType.class);
+        if (interfaceDataType != null) {
+            contract.setDataBinding(interfaceDataType.name());
+        }
+        for (Method method : clazz.getMethods()) {
+            Operation<?> operation = operations.get(method.getName());
+            DataType operationDataType = method.getAnnotation(DataType.class);
+            if (operationDataType == null) {
+                operationDataType = interfaceDataType;
+            }
+
+            if (operationDataType != null) {
+                operation.setDataBinding(operationDataType.name());
+                // FIXME: [rfeng] Keep data context as metadata?
+            }
+//            IDLMapping operationMapping = clazz.getAnnotation(IDLMapping.class);
+//            if (operationMapping == null) {
+//                operationMapping = interfaceMapping;
+//            }
+//            
+//            if (operationMapping != null) {
+//                operation.setDataBinding(operationMapping.dataBinding());
+//                operation.setWrapperStyle(operationMapping.wrapperStyle());
+//            }
+            // String dataBinding = operation.getDataBinding();
+
+            Annotation[] annotations = null;
+            if (operationDataType != null) {
+                annotations = new Annotation[] {operationDataType};
+            }
+            // FIXME: We need a better way to identify simple java types
+            for (org.apache.tuscany.spi.model.DataType<?> d : operation.getInputType().getLogical()) {
+                dataBindingRegistry.introspectType(d, annotations);
+            }
+            if (operation.getOutputType() != null) {
+                dataBindingRegistry.introspectType(operation.getOutputType(), annotations);
+            }
+            for (org.apache.tuscany.spi.model.DataType<?> d : operation.getFaultTypes()) {
+                dataBindingRegistry.introspectType(d, annotations);
+            }
+        }
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/DataBindingJavaInterfaceProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/DataBindingJavaInterfaceProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/JavaInterfaceIntrospector.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/JavaInterfaceIntrospector.java?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/JavaInterfaceIntrospector.java (added)
+++ incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/JavaInterfaceIntrospector.java Tue Mar 20 11:26:09 2007
@@ -0,0 +1,152 @@
+/*
+ * 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.core.databinding.processor;
+
+import static org.apache.tuscany.spi.model.Operation.CONVERSATION_END;
+import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.idl.InvalidConversationalOperationException;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.OverloadedOperationException;
+import org.apache.tuscany.spi.idl.java.InterfaceJavaIntrospector;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+import org.osoa.sca.annotations.OneWay;
+import org.osoa.sca.annotations.Remotable;
+
+/**
+ * Default implementation of an InterfaceJavaIntrospector.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JavaInterfaceIntrospector implements InterfaceJavaIntrospector {
+    private static final String UNKNOWN_DATABINDING = null;
+
+    public JavaInterfaceIntrospector() {
+    }
+
+    public <T> JavaServiceContract<T> introspect(Class<T> type) throws InvalidServiceContractException {
+        Class<?> callbackClass = null;
+        Callback callback = type.getAnnotation(Callback.class);
+        if (callback != null && !Void.class.equals(callback.value())) {
+            callbackClass = callback.value();
+        } else if (callback != null && Void.class.equals(callback.value())) {
+            throw new IllegalArgumentException("No callback interface specified on annotation" + type.getName());
+        }
+        return introspect(type, callbackClass);
+    }
+
+    public <I, C> JavaServiceContract<I> introspect(Class<I> type, Class<C> callback)
+        throws InvalidServiceContractException {
+        JavaServiceContract<I> contract = new JavaServiceContract<I>();
+        contract.setInterfaceName(getBaseName(type));
+        contract.setInterfaceClass(type);
+        boolean remotable = type.isAnnotationPresent(Remotable.class);
+        contract.setRemotable(remotable);
+        //Scope interactionScope = type.getAnnotation(Scope.class);
+        boolean conversational = type.isAnnotationPresent(Conversational.class);
+        contract.setConversational(conversational);
+        contract.setOperations(getOperations(type, remotable, conversational));
+
+        if (callback != null) {
+            contract.setCallbackName(getBaseName(callback));
+            contract.setCallbackClass(callback);
+            contract.setCallbackOperations(getOperations(callback, remotable, conversational));
+        }
+        return contract;
+    }
+
+    private <T> Map<String, Operation<Type>> getOperations(Class<T> type, boolean remotable, boolean conversational)
+        throws InvalidServiceContractException {
+        Method[] methods = type.getMethods();
+        Map<String, Operation<Type>> operations = new HashMap<String, Operation<Type>>(methods.length);
+        for (Method method : methods) {
+            String name = method.getName();
+            if (remotable && operations.containsKey(name)) {
+                throw new OverloadedOperationException(method);
+            }
+
+            Type returnType = method.getGenericReturnType();
+            Type[] paramTypes = method.getGenericParameterTypes();
+            Type[] faultTypes = method.getGenericExceptionTypes();
+            boolean nonBlocking = method.isAnnotationPresent(OneWay.class);
+            int conversationSequence = NO_CONVERSATION;
+            if (method.isAnnotationPresent(EndsConversation.class)) {
+                if (!conversational) {
+                    throw new InvalidConversationalOperationException(
+                        "Method is marked as end conversation but contract is not conversational",
+                        method.getDeclaringClass().getName(),
+                        method);
+                }
+                conversationSequence = CONVERSATION_END;
+            } else if (conversational) {
+                conversationSequence = Operation.CONVERSATION_CONTINUE;
+            }
+
+            DataType<Type> returnDataType = new DataType<Type>(UNKNOWN_DATABINDING, returnType, returnType);
+            List<DataType<Type>> paramDataTypes = new ArrayList<DataType<Type>>(paramTypes.length);
+            for (Type paramType : paramTypes) {
+                paramDataTypes.add(new DataType<Type>(UNKNOWN_DATABINDING, paramType, paramType));
+            }
+            List<DataType<Type>> faultDataTypes = new ArrayList<DataType<Type>>(faultTypes.length);
+            for (Type faultType : faultTypes) {
+                faultDataTypes.add(new DataType<Type>(UNKNOWN_DATABINDING, faultType, faultType));
+            }
+
+            DataType<List<DataType<Type>>> inputType =
+                new DataType<List<DataType<Type>>>(DataBinding.IDL_INPUT, Object[].class, paramDataTypes);
+            Operation<Type> operation = new Operation<Type>(name,
+                inputType,
+                returnDataType,
+                faultDataTypes,
+                nonBlocking,
+                UNKNOWN_DATABINDING,
+                conversationSequence);
+            operations.put(name, operation);
+        }
+        return operations;
+    }
+    
+    /**
+     * Returns the simple name of a class - i.e. the class name devoid of its package qualifier
+     *
+     * @param implClass the implmentation class
+     */
+    public static String getBaseName(Class<?> implClass) {
+        String baseName = implClass.getName();
+        int lastDot = baseName.lastIndexOf('.');
+        if (lastDot != -1) {
+            baseName = baseName.substring(lastDot + 1);
+        }
+        return baseName;
+    }    
+
+}

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/JavaInterfaceIntrospector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/processor/JavaInterfaceIntrospector.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Exception2ExceptionTransformer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Exception2ExceptionTransformer.java?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Exception2ExceptionTransformer.java (added)
+++ incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Exception2ExceptionTransformer.java Tue Mar 20 11:26:09 2007
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.core.databinding.transformers;
+
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.ExceptionHandler;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.model.DataType;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This is a special transformer to transform the exception from one IDL to the
+ * other one
+ */
+@Service(Transformer.class)
+public class Exception2ExceptionTransformer extends TransformerExtension<Object[], Object[]> implements
+    PullTransformer<Exception, Exception> {
+
+    protected Mediator mediator;
+
+    public Exception2ExceptionTransformer() {
+        super();
+    }
+
+    @Override
+    public String getSourceDataBinding() {
+        return DataBinding.IDL_FAULT;
+    }
+
+    @Override
+    public String getTargetDataBinding() {
+        return DataBinding.IDL_FAULT;
+    }
+
+    /**
+     * @param mediator the mediator to set
+     */
+    @Reference
+    public void setMediator(Mediator mediator) {
+        this.mediator = mediator;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getSourceType()
+     */
+    @Override
+    protected Class getSourceType() {
+        return Exception.class;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getTargetType()
+     */
+    @Override
+    protected Class getTargetType() {
+        return Exception.class;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.Transformer#getWeight()
+     */
+    public int getWeight() {
+        return 10000;
+    }
+
+    @SuppressWarnings("unchecked")
+    public Exception transform(Exception source, TransformationContext context) {
+        DataType<DataType> sourceType = context.getSourceDataType();
+
+        DataType<DataType> targetType = context.getTargetDataType();
+
+        ExceptionHandler exceptionHandler = getExceptionHandler(sourceType);
+        if (exceptionHandler == null) {
+            return source;
+        }
+
+        Object sourceFaultInfo = exceptionHandler.getFaultInfo(source);
+        Object targetFaultInfo =
+            mediator.mediate(sourceFaultInfo, sourceType.getLogical(), targetType.getLogical(), context.getMetadata());
+
+        ExceptionHandler targetHandler = getExceptionHandler(targetType);
+
+        if (targetHandler != null) {
+            Exception targetException =
+                targetHandler.createException(targetType, source.getMessage(), targetFaultInfo, source.getCause());
+            return targetException;
+        }
+
+        // FIXME
+        return source;
+
+    }
+
+    private ExceptionHandler getExceptionHandler(DataType<DataType> targetType) {
+        DataType targetFaultType = (DataType)targetType.getLogical();
+        DataBinding targetDataBinding =
+            mediator.getDataBindingRegistry().getDataBinding(targetFaultType.getDataBinding());
+        if (targetDataBinding == null) {
+            return null;
+        }
+        ExceptionHandler targetHandler = targetDataBinding.getExceptionHandler();
+        return targetHandler;
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Exception2ExceptionTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Exception2ExceptionTransformer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Input2InputTransformer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Input2InputTransformer.java?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Input2InputTransformer.java (added)
+++ incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Input2InputTransformer.java Tue Mar 20 11:26:09 2007
@@ -0,0 +1,199 @@
+/*
+ * 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.core.databinding.transformers;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.ElementInfo;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.WrapperInfo;
+import org.apache.tuscany.spi.model.XMLType;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This is a special transformer to transform the input from one IDL to the
+ * other one
+ */
+@Service(Transformer.class)
+public class Input2InputTransformer extends TransformerExtension<Object[], Object[]> implements
+    PullTransformer<Object[], Object[]> {
+
+    protected Mediator mediator;
+
+    public Input2InputTransformer() {
+        super();
+    }
+
+    @Override
+    public String getSourceDataBinding() {
+        return DataBinding.IDL_INPUT;
+    }
+
+    @Override
+    public String getTargetDataBinding() {
+        return DataBinding.IDL_INPUT;
+    }
+
+    /**
+     * @param mediator the mediator to set
+     */
+    @Reference
+    public void setMediator(Mediator mediator) {
+        this.mediator = mediator;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getSourceType()
+     */
+    @Override
+    protected Class getSourceType() {
+        return Object[].class;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getTargetType()
+     */
+    @Override
+    protected Class getTargetType() {
+        return Object[].class;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.Transformer#getWeight()
+     */
+    public int getWeight() {
+        return 10000;
+    }
+
+    @SuppressWarnings("unchecked")
+    public Object[] transform(Object[] source, TransformationContext context) {
+        DataType<List<DataType<?>>> sourceType = context.getSourceDataType();
+        Operation<?> sourceOp = (Operation<?>)sourceType.getOperation();
+        boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle();
+
+        WrapperHandler sourceWrapperHandler = null;
+        if (sourceWrapped) {
+            sourceWrapperHandler = getWapperHandler(sourceType.getOperation().getDataBinding(), true);
+        }
+
+        DataType<List<DataType<XMLType>>> targetType = context.getTargetDataType();
+        Operation<?> targetOp = (Operation<?>)targetType.getOperation();
+        boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle();
+        WrapperHandler targetWrapperHandler = null;
+        if (targetWrapped) {
+            targetWrapperHandler = getWapperHandler(targetType.getOperation().getDataBinding(), true);
+        }
+
+        if ((!sourceWrapped) && targetWrapped) {
+            // Unwrapped --> Wrapped
+            WrapperInfo wrapper = targetOp.getWrapper();
+            ElementInfo wrapperElement = wrapper.getInputWrapperElement();
+
+            // If the source can be wrapped, wrapped it first
+            if (sourceWrapperHandler != null) {
+                Object sourceWrapper = sourceWrapperHandler.create(wrapperElement, context);
+                for (int i = 0; i < source.length; i++) {
+                    ElementInfo argElement = wrapper.getInputChildElements().get(i);
+                    sourceWrapperHandler.setChild(sourceWrapper, i, argElement, source[0]);
+                }
+            }
+            Object targetWrapper = targetWrapperHandler.create(wrapperElement, context);
+            if (source == null) {
+                return new Object[] {targetWrapper};
+            }
+            List<DataType<XMLType>> argTypes = wrapper.getUnwrappedInputType().getLogical();
+
+            for (int i = 0; i < source.length; i++) {
+                ElementInfo argElement = wrapper.getInputChildElements().get(i);
+                DataType<XMLType> argType = argTypes.get(i);
+                Object child = source[i];
+                child =
+                    mediator.mediate(source[i], sourceType.getLogical().get(i), argType, context
+                        .getMetadata());
+                targetWrapperHandler.setChild(targetWrapper, i, argElement, child);
+            }
+            return new Object[] {targetWrapper};
+        } else if (sourceWrapped && (!targetWrapped)) {
+            // Wrapped to Unwrapped
+            Object sourceWrapper = source[0];
+            // List<ElementInfo> childElements = sourceOp.getWrapper().getInputChildElements();
+            Object[] target = null;
+
+            targetWrapperHandler = getWapperHandler(targetType.getOperation().getDataBinding(), false);
+            if (targetWrapperHandler != null) {
+                ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement();
+                // Object targetWrapper =
+                // targetWrapperHandler.create(wrapperElement, context);
+                DataType<XMLType> targetWrapperType =
+                    new DataType<XMLType>(targetType.getOperation().getDataBinding(), Object.class,
+                                        new XMLType(wrapperElement));
+                Object targetWrapper =
+                    mediator.mediate(sourceWrapper,
+                                     sourceType.getLogical().get(0),
+                                     targetWrapperType,
+                                     context.getMetadata());
+                target = targetWrapperHandler.getChildren(targetWrapper).toArray();
+            } else {
+                Object[] sourceChildren = sourceWrapperHandler.getChildren(sourceWrapper).toArray();
+                target = new Object[sourceChildren.length];
+                for (int i = 0; i < sourceChildren.length; i++) {
+                    DataType<XMLType> childType =
+                        sourceOp.getWrapper().getUnwrappedInputType().getLogical().get(i);
+                    target[i] =
+                        mediator.mediate(sourceChildren[i], childType, targetType.getLogical().get(i), context
+                            .getMetadata());
+                }
+            }
+            return target;
+        } else {
+            // Assuming wrapper to wrapper conversion can be handled here as
+            // well
+            Object[] newArgs = new Object[source.length];
+            for (int i = 0; i < source.length; i++) {
+                Object child =
+                    mediator.mediate(source[i], sourceType.getLogical().get(i), targetType.getLogical()
+                        .get(i), context.getMetadata());
+                newArgs[i] = child;
+            }
+            return newArgs;
+        }
+    }
+
+    private WrapperHandler getWapperHandler(String dataBindingId, boolean required) {
+        DataBinding dataBinding = mediator.getDataBindingRegistry().getDataBinding(dataBindingId);
+        WrapperHandler wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler();
+        if (wrapperHandler == null && required) {
+            throw new TransformationException(
+                                              "No wrapper handler is provided for databinding: " + dataBindingId);
+        }
+        return wrapperHandler;
+    }
+
+}

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Input2InputTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Input2InputTransformer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Output2OutputTransformer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Output2OutputTransformer.java?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Output2OutputTransformer.java (added)
+++ incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Output2OutputTransformer.java Tue Mar 20 11:26:09 2007
@@ -0,0 +1,186 @@
+/*
+ * 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.core.databinding.transformers;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.databinding.PullTransformer;
+import org.apache.tuscany.spi.databinding.TransformationContext;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.databinding.Transformer;
+import org.apache.tuscany.spi.databinding.WrapperHandler;
+import org.apache.tuscany.spi.databinding.extension.TransformerExtension;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.ElementInfo;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.WrapperInfo;
+import org.apache.tuscany.spi.model.XMLType;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This is a special transformer to transform the output from one IDL to the
+ * other one
+ */
+@Service(Transformer.class)
+public class Output2OutputTransformer extends TransformerExtension<Object, Object> implements
+    PullTransformer<Object, Object> {
+
+    protected Mediator mediator;
+
+    /**
+     * @param wrapperHandler
+     */
+    public Output2OutputTransformer() {
+        super();
+    }
+
+    /**
+     * @param mediator the mediator to set
+     */
+    @Reference
+    public void setMediator(Mediator mediator) {
+        this.mediator = mediator;
+    }
+
+    @Override
+    public String getSourceDataBinding() {
+        return DataBinding.IDL_OUTPUT;
+    }
+
+    @Override
+    public String getTargetDataBinding() {
+        return DataBinding.IDL_OUTPUT;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getSourceType()
+     */
+    @Override
+    protected Class getSourceType() {
+        return Object.class;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.extension.TransformerExtension#getTargetType()
+     */
+    @Override
+    protected Class getTargetType() {
+        return Object.class;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.databinding.Transformer#getWeight()
+     */
+    public int getWeight() {
+        return 10;
+    }
+
+    private WrapperHandler getWapperHandler(Operation<?> operation) {
+        String dataBindingId;
+        dataBindingId = operation.getDataBinding();
+        DataBinding dataBinding = mediator.getDataBindingRegistry().getDataBinding(dataBindingId);
+        WrapperHandler wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler();
+        if (wrapperHandler == null) {
+            throw new TransformationException(
+                                              "No wrapper handler is provided for databinding: " + dataBindingId);
+        }
+        return wrapperHandler;
+    }
+
+    private WrapperHandler getWapperHandler(String dataBindingId) {
+        DataBinding dataBinding = mediator.getDataBindingRegistry().getDataBinding(dataBindingId);
+        return dataBinding == null ? null : dataBinding.getWrapperHandler();
+    }
+
+    @SuppressWarnings("unchecked")
+    public Object transform(Object response, TransformationContext context) {
+        try {
+            DataType<DataType> sourceType = context.getSourceDataType();
+            Operation<?> sourceOp = (Operation<?>)sourceType.getOperation();
+            boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle();
+            WrapperHandler sourceWrapperHandler = null;
+            if (sourceWrapped) {
+                sourceWrapperHandler = getWapperHandler(sourceOp);
+            }
+
+            DataType<DataType> targetType = context.getTargetDataType();
+            Operation<?> targetOp = (Operation<?>)targetType.getOperation();
+            boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle();
+            WrapperHandler targetWrapperHandler = null;
+            if (targetWrapped) {
+                targetWrapperHandler = getWapperHandler(targetOp);
+            }
+
+            if ((!sourceWrapped) && targetWrapped) {
+                // Unwrapped --> Wrapped
+                WrapperInfo wrapper = targetOp.getWrapper();
+                Object targetWrapper =
+                    targetWrapperHandler.create(wrapper.getOutputWrapperElement(), context);
+
+                List<ElementInfo> childElements = wrapper.getOutputChildElements();
+                if (childElements.isEmpty()) {
+                    // void output
+                    return targetWrapper;
+                }
+                ElementInfo argElement = childElements.get(0);
+                DataType<XMLType> argType = wrapper.getUnwrappedOutputType();
+                Object child = response;
+                child = mediator.mediate(response, sourceType.getLogical(), argType, context.getMetadata());
+                targetWrapperHandler.setChild(targetWrapper, 0, argElement, child);
+                return targetWrapper;
+            } else if (sourceWrapped && (!targetWrapped)) {
+                // Wrapped to Unwrapped
+                Object sourceWrapper = response;
+                List<ElementInfo> childElements = sourceOp.getWrapper().getOutputChildElements();
+                if (childElements.isEmpty()) {
+                    // The void output
+                    return null;
+                }
+                targetWrapperHandler = getWapperHandler(targetType.getLogical().getDataBinding());
+                if (targetWrapperHandler != null) {
+                    ElementInfo wrapperElement = sourceOp.getWrapper().getInputWrapperElement();
+                    // Object targetWrapper =
+                    // targetWrapperHandler.create(wrapperElement, context);
+                    DataType<XMLType> targetWrapperType =
+                        new DataType<XMLType>(targetType.getLogical().getDataBinding(), Object.class,
+                                            new XMLType(wrapperElement));
+                    Object targetWrapper =
+                        mediator.mediate(sourceWrapper, sourceType.getLogical(), targetWrapperType, context
+                            .getMetadata());
+                    return targetWrapperHandler.getChildren(targetWrapper).get(0);
+                } else {
+                    Object child = sourceWrapperHandler.getChildren(sourceWrapper).get(0);
+                    DataType<?> childType = sourceOp.getWrapper().getUnwrappedOutputType();
+                    return mediator.mediate(child, childType, targetType.getLogical(), context.getMetadata());
+                }
+            } else {
+                // FIXME: Do we want to handle wrapped to wrapped?
+                return mediator.mediate(response, sourceType.getLogical(), targetType.getLogical(), context
+                    .getMetadata());
+            }
+        } catch (Exception e) {
+            throw new TransformationException(e);
+        }
+    }
+
+}

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Output2OutputTransformer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/transformers/Output2OutputTransformer.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java?view=auto&rev=520509
==============================================================================
--- incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java (added)
+++ incubator/tuscany/java/sca/kernel/databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataBindingInteceptor.java Tue Mar 20 11:26:09 2007
@@ -0,0 +1,254 @@
+/*
+ * 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.core.databinding.wire;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.component.Component;
+import org.apache.tuscany.spi.component.ComponentManager;
+import org.apache.tuscany.spi.databinding.DataBinding;
+import org.apache.tuscany.spi.databinding.ExceptionHandler;
+import org.apache.tuscany.spi.databinding.Mediator;
+import org.apache.tuscany.spi.databinding.TransformationException;
+import org.apache.tuscany.spi.idl.ServiceFaultException;
+import org.apache.tuscany.spi.model.DataType;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.util.UriHelper;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.Wire;
+
+/**
+ * An interceptor to transform data accross databindings on the wire
+ * 
+ * @version $Rev$ $Date$
+ */
+public class DataBindingInteceptor implements Interceptor {
+    private Interceptor next;
+
+    private Component composite;
+
+    private Operation<?> sourceOperation;
+
+    private Operation<?> targetOperation;
+
+    private Mediator mediator;
+
+    public DataBindingInteceptor(ComponentManager componentManager,
+                                 Wire wire,
+                                 Operation<?> sourceOperation,
+                                 Operation<?> targetOperation) {
+        super();
+        this.sourceOperation = sourceOperation;
+        this.targetOperation = targetOperation;
+        URI uri = wire.getSourceUri();
+        URI sourceUri = UriHelper.getDefragmentedName(uri);
+        this.composite = componentManager.getComponent(sourceUri);
+
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.wire.Interceptor#getNext()
+     */
+    public Interceptor getNext() {
+        return next;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.wire.Interceptor#invoke(org.apache.tuscany.spi.wire.Message)
+     */
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.tuscany.spi.wire.Interceptor#invoke(org.apache.tuscany.spi.wire.Message)
+     */
+    public Message invoke(Message msg) {
+        Object input = transform(msg.getBody(), sourceOperation.getInputType(), targetOperation.getInputType());
+        msg.setBody(input);
+        Message resultMsg = next.invoke(msg);
+        Object result = resultMsg.getBody();
+        if (sourceOperation.isNonBlocking()) {
+            // Not to reset the message body
+            return resultMsg;
+        }
+
+        // FIXME: Should we fix the Operation model so that getOutputType
+        // returns DataType<DataType<T>>?
+        DataType<DataType> targetType =
+            new DataType<DataType>(DataBinding.IDL_OUTPUT, Object.class, targetOperation.getOutputType());
+
+        targetType.setOperation(targetOperation.getOutputType().getOperation());
+        DataType<DataType> sourceType =
+            new DataType<DataType>(DataBinding.IDL_OUTPUT, Object.class, sourceOperation.getOutputType());
+        sourceType.setOperation(sourceOperation.getOutputType().getOperation());
+
+        if (resultMsg.isFault()) {
+
+            // FIXME: We need to figure out what fault type it is and then
+            // transform it
+            // back the source fault type
+            // throw new InvocationRuntimeException((Throwable) result);
+
+            if ((result instanceof Exception) && !(result instanceof RuntimeException)) {
+                // FIXME: How to match fault data to a fault type for the
+                // operation?
+
+                // If the result is from an InvocationTargetException look at
+                // the actual cause.
+                if (result instanceof InvocationTargetException) {
+                    result = ((InvocationTargetException)result).getCause();
+                }
+                DataType targetDataType = null;
+                for (DataType exType : targetOperation.getFaultTypes()) {
+                    if (((Class)exType.getPhysical()).isInstance(result)) {
+                        if (result instanceof ServiceFaultException) {
+                            if (((ServiceFaultException)result).isMatchingType(exType.getLogical())) {
+                                targetDataType = exType;
+                                break;
+                            }
+                        } else {
+                            targetDataType = exType;
+                            break;
+                        }
+                    }
+                }
+
+                if (targetDataType == null) {
+                    // Not a business exception
+                    return resultMsg;
+                }
+
+                DataType targetFaultType = getFaultType(targetDataType);
+                if (targetFaultType == null) {
+                    throw new TransformationException("Target fault type cannot be resolved");
+                }
+
+                // FIXME: How to match a source fault type to a target fault
+                // type?
+                DataType sourceDataType = null;
+                DataType sourceFaultType = null;
+                for (DataType exType : sourceOperation.getFaultTypes()) {
+                    DataType faultType = getFaultType(exType);
+                    // Match by the QName (XSD element) of the fault type
+                    if (faultType != null && targetFaultType.getLogical().equals(faultType.getLogical())) {
+                        sourceDataType = exType;
+                        sourceFaultType = faultType;
+                        break;
+                    }
+                }
+
+                if (sourceFaultType == null) {
+                    throw new TransformationException("No matching source fault type is found");
+                }
+
+                Object newResult =
+                    transformException(result, targetDataType, sourceDataType, targetFaultType, sourceFaultType);
+                if (newResult != result) {
+                    resultMsg.setBodyWithFault(newResult);
+                }
+            }
+
+        } else {
+            assert !(result instanceof Throwable) : "Expected messages that are not throwable " + result;
+
+            Object newResult = transform(result, targetType, sourceType);
+            if (newResult != result) {
+                resultMsg.setBody(newResult);
+            }
+        }
+
+        return resultMsg;
+    }
+
+    private Object transform(Object source, DataType sourceType, DataType targetType) {
+        if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) {
+            return source;
+        }
+        Map<Class<?>, Object> metadata = new HashMap<Class<?>, Object>();
+        metadata.put(Component.class, composite);
+        return mediator.mediate(source, sourceType, targetType, metadata);
+    }
+
+    private DataType getFaultType(DataType exceptionType) {
+        // FIXME: We cannot assume the exception will have a databinding set
+        DataBinding targetDataBinding =
+            mediator.getDataBindingRegistry().getDataBinding(exceptionType.getDataBinding());
+        if (targetDataBinding == null) {
+            return null;
+        }
+        ExceptionHandler targetHandler = targetDataBinding.getExceptionHandler();
+        if (targetHandler == null) {
+            return null;
+        }
+        return targetHandler.getFaultType(exceptionType);
+    }
+
+    /**
+     * @param source The source exception
+     * @param sourceExType The data type for the source exception
+     * @param targetExType The data type for the target exception
+     * @param sourceType The fault type for the source
+     * @param targetType The fault type for the target
+     * @return
+     */
+    private Object transformException(Object source,
+                                      DataType sourceExType,
+                                      DataType targetExType,
+                                      DataType sourceType,
+                                      DataType targetType) {
+        if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) {
+            return source;
+        }
+        Map<Class<?>, Object> metadata = new HashMap<Class<?>, Object>();
+        metadata.put(Component.class, composite);
+
+        DataType<DataType<?>> eSourceDataType =
+            new DataType<DataType<?>>("idl:fault", sourceExType.getPhysical(), sourceType);
+        DataType<DataType<?>> eTargetDataType =
+            new DataType<DataType<?>>("idl:fault", targetExType.getPhysical(), targetType);
+
+        return mediator.mediate(source, eSourceDataType, eTargetDataType, metadata);
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.wire.Interceptor#isOptimizable()
+     */
+    public boolean isOptimizable() {
+        return false;
+    }
+
+    /**
+     * @see org.apache.tuscany.spi.wire.Interceptor#setNext(org.apache.tuscany.spi.wire.Interceptor)
+     */
+    public void setNext(Interceptor next) {
+        this.next = next;
+    }
+
+    /**
+     * @param mediator the mediator to set
+     */
+    public void setMediator(Mediator mediator) {
+        this.mediator = mediator;
+    }
+
+}



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