You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2008/12/29 17:31:48 UTC

svn commit: r729931 - in /tuscany/branches/sca-java-1.x/modules/binding-hessian: ./ 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/apa...

Author: antelder
Date: Mon Dec 29 08:31:47 2008
New Revision: 729931

URL: http://svn.apache.org/viewvc?rev=729931&view=rev
Log:
TUSCANY-2748: Apply patch from zlwyzzx for contibution of a new hessian binding. Thanks for the code zlwyzzx!

Added:
    tuscany/branches/sca-java-1.x/modules/binding-hessian/   (with props)
    tuscany/branches/sca-java-1.x/modules/binding-hessian/LICENSE
    tuscany/branches/sca-java-1.x/modules/binding-hessian/NOTICE
    tuscany/branches/sca-java-1.x/modules/binding-hessian/pom.xml
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBinding.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingException.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingProcessor.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingInvoker.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingProviderFactory.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianReferenceBindingProvider.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceBindingProvider.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceListenerServlet.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/binding-hessian.xsd
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstImpl.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstTestCase.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/IFirst.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/ISecond.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondImpl.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondTestCase.java
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/first_hessian.composite
    tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/second_hessian.composite

Propchange: tuscany/branches/sca-java-1.x/modules/binding-hessian/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Dec 29 08:31:47 2008
@@ -0,0 +1,20 @@
+target
+work
+dojo
+*.iws
+*.ipr
+*.iml
+derby.log
+maven.log
+maven-eclipse.xml
+build.xml
+build-dependency.xml
+velocity.log*
+junit*.properties
+surefire*.properties
+.project
+.classpath
+.settings
+.deployables
+.wtpmodules
+.externalToolBuilders

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/LICENSE
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/LICENSE?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/LICENSE (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/LICENSE Mon Dec 29 08:31:47 2008
@@ -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.
+
+
+

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/NOTICE
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/NOTICE?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/NOTICE (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/NOTICE Mon Dec 29 08:31:47 2008
@@ -0,0 +1,6 @@
+${pom.name}
+Copyright (c) 2005 - 2008 The Apache Software Foundation
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
+

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/pom.xml?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/pom.xml (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/pom.xml Mon Dec 29 08:31:47 2008
@@ -0,0 +1,107 @@
+<?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 pehessianssions and limitations
+ * under the License.
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>1.5-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>tuscany-binding-hessian</artifactId>
+    <name>Apache Tuscany SCA Hessian Binding Extension</name>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core-spi</artifactId>
+            <version>1.5-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.caucho</groupId>
+            <artifactId>hessian</artifactId>
+            <version>3.1.5</version>
+        </dependency>
+       <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-http</artifactId>
+            <version>1.5-SNAPSHOT</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-jetty</artifactId>
+            <version>1.5-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>        
+        
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>  
+            <scope>provided</scope>
+        </dependency>        
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.5</version>
+            <scope>test</scope>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-node-impl</artifactId>
+            <version>1.5-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.5-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+
+                <configuration>
+                    <instructions>
+                        <Bundle-Version>${tuscany.version}</Bundle-Version>
+                        <Bundle-SymbolicName>org.apache.tuscany.sca.binding.hessian</Bundle-SymbolicName>
+                        <Bundle-Description>${pom.name}</Bundle-Description>
+                        <Export-Package>org.apache.tuscany.sca.binding.hessian*</Export-Package>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBinding.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBinding.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBinding.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBinding.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,94 @@
+/*
+ * 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.binding.hessian.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+
+public class HessianBinding implements Binding {
+
+    // properties required to implement the Tuscany
+    // binding extension SPI
+    private String uri = null;
+    private String name = null;
+    private boolean unresolved = false;
+    private List<Object> extensions = new ArrayList<Object>();
+
+    public HessianBinding() {
+        super();
+    }
+
+    /**
+     * Returns the binding URI.
+     * 
+     * @return the binding URI
+     */
+    public String getURI() {
+        return this.uri;
+    }
+
+    /**
+     * Sets the binding URI.
+     * 
+     * @param uri the binding URI
+     */
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    /**
+     * Returns the binding name.
+     * 
+     * @return the binding name
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    /**
+     * Sets the binding name.
+     * 
+     * @param name the binding name
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public boolean isUnresolved() {
+        return this.unresolved;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+        this.unresolved = unresolved;
+    }
+
+    public List<Object> getExtensions() {
+        return extensions;
+    }
+
+    /**
+     * Clone the binding
+     */
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingException.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingException.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingException.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingException.java Mon Dec 29 08:31:47 2008
@@ -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.binding.hessian.impl;
+
+public class HessianBindingException extends RuntimeException {
+    private static final long serialVersionUID = 1L;
+
+    public HessianBindingException() {
+        super();
+    }
+
+    public HessianBindingException(String arg0, Throwable arg1) {
+        super(arg0, arg1);
+    }
+
+    public HessianBindingException(String arg0) {
+        super(arg0);
+    }
+
+    public HessianBindingException(Throwable arg0) {
+        super(arg0);
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingProcessor.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingProcessor.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/impl/HessianBindingProcessor.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,135 @@
+/*
+ * 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.binding.hessian.impl;
+
+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.builder.impl.ProblemImpl;
+import org.apache.tuscany.sca.assembly.xml.PolicyAttachPointProcessor;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
+import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+
+public class HessianBindingProcessor implements StAXArtifactProcessor<HessianBinding> {
+
+    private QName BINDING_HESSIAN = new QName("http://hessian", "binding.hessian");
+
+    private PolicyFactory policyFactory;
+    private PolicyAttachPointProcessor policyProcessor;
+    private Monitor monitor;
+
+    public HessianBindingProcessor(ModelFactoryExtensionPoint modelFactories, Monitor monitor) {
+        this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+        this.policyProcessor = new PolicyAttachPointProcessor(policyFactory);
+        this.monitor = monitor;
+    }
+
+    /**
+     * Report a error.
+     * 
+     * @param problems
+     * @param message
+     * @param model
+     */
+    private void warning(String message, Object model, Object... messageParameters) {
+        if (monitor != null) {
+            Problem problem =
+                new ProblemImpl(this.getClass().getName(), "binding-hessian-validation-messages", Severity.WARNING,
+                                model, message, (Object[])messageParameters);
+            monitor.problem(problem);
+        }
+    }
+
+    /**
+     * Report a error.
+     * 
+     * @param problems
+     * @param message
+     * @param model
+     */
+    private void error(String message, Object model, Object... messageParameters) {
+        if (monitor != null) {
+            Problem problem =
+                new ProblemImpl(this.getClass().getName(), "binding-hessian-validation-messages", Severity.ERROR,
+                                model, message, (Object[])messageParameters);
+            monitor.problem(problem);
+        }
+    }
+
+    public QName getArtifactType() {
+        return BINDING_HESSIAN;
+    }
+
+    public Class<HessianBinding> getModelType() {
+        return HessianBinding.class;
+    }
+
+    public HessianBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {
+        HessianBinding hessianBinding = new HessianBinding();
+
+        // Read policies
+        policyProcessor.readPolicies(hessianBinding, reader);
+
+        // Read binding name
+        String name = reader.getAttributeValue(null, "name");
+        if (name != null) {
+            hessianBinding.setName(name);
+        }
+
+        // Read binding URI
+        String uri = reader.getAttributeValue(null, "uri");
+        if (uri != null) {
+            hessianBinding.setURI(uri);
+        }
+
+        return hessianBinding;
+    }
+
+    public void resolve(HessianBinding model, ModelResolver resolver) throws ContributionResolveException {
+    }
+
+    public void write(HessianBinding hessianBinding, XMLStreamWriter writer) throws ContributionWriteException,
+        XMLStreamException {
+        policyProcessor.writePolicyPrefixes(hessianBinding, writer);
+        writer.writeStartElement(BINDING_HESSIAN.getNamespaceURI(), BINDING_HESSIAN.getLocalPart());
+        policyProcessor.writePolicyAttributes(hessianBinding, writer);
+
+        if (hessianBinding.getName() != null) {
+            writer.writeAttribute("name", hessianBinding.getName());
+        }
+
+        if (hessianBinding.getURI() != null) {
+            writer.writeAttribute("uri", hessianBinding.getURI());
+        }
+
+        writer.writeEndElement();
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingInvoker.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingInvoker.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingInvoker.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,73 @@
+/*
+ * 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.binding.hessian.provider;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.binding.hessian.impl.HessianBinding;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+import com.caucho.hessian.client.HessianProxyFactory;
+
+public class HessianBindingInvoker implements Invoker {
+
+    private String serviceURL;
+    private Interface homeImpl;
+
+    HessianBindingInvoker(Interface homeImpl, HessianBinding binding) {
+        this.serviceURL = binding.getURI();
+        this.homeImpl = homeImpl;
+    }
+
+    public Message invoke(Message msg) {
+        try {
+            Method method = ((JavaOperation)msg.getOperation()).getJavaMethod();
+            Object[] args = msg.getBody();
+
+            HessianProxyFactory proxyFactory = new HessianProxyFactory();
+            Object service = proxyFactory.create(loadClass(homeImpl.toString()), serviceURL);
+            Object result = null;
+            result = method.invoke(service, args);
+            msg.setBody(result);
+        } catch (Throwable e) {
+            e.printStackTrace();
+            if (e instanceof InvocationTargetException)
+                e = ((InvocationTargetException)e).getTargetException();
+            msg.setFaultBody(e);
+        }
+        return msg;
+    }
+
+    private Class loadClass(String className) {
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        try {
+            if (loader != null)
+                return Class.forName(className, false, loader);
+            else
+                return Class.forName(className);
+        } catch (Exception e) {
+
+        }
+        return null;
+    }
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingProviderFactory.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingProviderFactory.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingProviderFactory.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianBindingProviderFactory.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,67 @@
+/*
+ * 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.binding.hessian.provider;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.binding.hessian.impl.HessianBinding;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+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 class HessianBindingProviderFactory implements BindingProviderFactory<HessianBinding> {
+
+    private MessageFactory messageFactory;
+    private ServletHost servletHost;
+
+    public HessianBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+        ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+        List<ServletHost> hosts = servletHosts.getServletHosts();
+        if (!hosts.isEmpty()) {
+            this.servletHost = hosts.get(0);
+        }
+        ModelFactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class);
+        messageFactory = modelFactories.getFactory(MessageFactory.class);
+    }
+
+    public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
+                                                                   RuntimeComponentReference reference,
+                                                                   HessianBinding binding) {
+        return new HessianReferenceBindingProvider(component, reference, binding);
+    }
+
+    public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
+                                                               RuntimeComponentService service,
+                                                               HessianBinding binding) {
+        return new HessianServiceBindingProvider(component, service, binding, messageFactory, servletHost);
+    }
+
+    public Class<HessianBinding> getModelType() {
+        return HessianBinding.class;
+    }
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianReferenceBindingProvider.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianReferenceBindingProvider.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianReferenceBindingProvider.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,62 @@
+/*
+ * 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.binding.hessian.provider;
+
+import org.apache.tuscany.sca.binding.hessian.impl.HessianBinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+public class HessianReferenceBindingProvider implements ReferenceBindingProvider {
+
+    private RuntimeComponentReference reference;
+    private HessianBinding hessianBinding;
+
+    public HessianReferenceBindingProvider(RuntimeComponent component,
+                                           RuntimeComponentReference reference,
+                                           HessianBinding binding) {
+        this.reference = reference;
+        this.hessianBinding = binding;
+    }
+
+    public Invoker createInvoker(Operation operation) {
+        return new HessianBindingInvoker(getBindingInterfaceContract().getInterface(), hessianBinding);
+    }
+
+    public boolean supportsOneWayInvocation() {
+        return true;
+    }
+
+    public InterfaceContract getBindingInterfaceContract() {
+        return reference.getInterfaceContract();
+    }
+
+    public void start() {
+
+    }
+
+    public void stop() {
+
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceBindingProvider.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceBindingProvider.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceBindingProvider.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.binding.hessian.provider;
+
+import java.util.logging.Logger;
+
+import javax.servlet.Servlet;
+
+import org.apache.tuscany.sca.binding.hessian.impl.HessianBinding;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+public class HessianServiceBindingProvider implements ServiceBindingProvider {
+    private static final Logger logger = Logger.getLogger(HessianServiceBindingProvider.class.getName());
+
+    private RuntimeComponent component;
+    private RuntimeComponentService service;
+    private HessianBinding hessianBinding;
+    private MessageFactory messageFactory;
+    private ServletHost servletHost;
+    private String servletMapping;
+
+    public HessianServiceBindingProvider(RuntimeComponent component,
+                                         RuntimeComponentService service,
+                                         HessianBinding binding,
+                                         MessageFactory messageFactory,
+                                         ServletHost servletHost) {
+        this.component = component;
+        this.service = service;
+        this.hessianBinding = binding;
+        this.messageFactory = messageFactory;
+        this.servletHost = servletHost;
+    }
+
+    public InterfaceContract getBindingInterfaceContract() {
+        return service.getInterfaceContract();
+    }
+
+    public boolean supportsOneWayInvocation() {
+        return true;
+    }
+
+    public void start() {
+        Servlet servlet = null;
+        Interface homeImpl = service.getInterfaceContract().getInterface();
+        RuntimeWire wire = service.getRuntimeWire(hessianBinding);
+        servlet = new HessianServiceListenerServlet(homeImpl, wire, messageFactory);
+
+        if (servlet == null) {
+            throw new IllegalStateException("No get or service method found on the service");
+        }
+
+        servletMapping = hessianBinding.getURI();
+        servletHost.addServletMapping(servletMapping, servlet);
+
+        // Save the actual binding URI in the binding
+        hessianBinding.setURI(servletHost.getURLMapping(hessianBinding.getURI()).toString());
+    }
+
+    public void stop() {
+        servletHost.removeServletMapping(servletMapping);
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceListenerServlet.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceListenerServlet.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceListenerServlet.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/java/org/apache/tuscany/sca/binding/hessian/provider/HessianServiceListenerServlet.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,335 @@
+/*
+ * Copyright (c) 2001-2008 Caucho Technology, Inc.  All rights reserved.
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ *    any, must include the following acknowlegement:
+ *       "This product includes software developed by the
+ *        Caucho Technology (http://www.caucho.com/)."
+ *    Alternately, this acknowlegement may appear in the software itself,
+ *    if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "Hessian", "Resin", and "Caucho" must not be used to
+ *    endorse or promote products derived from this software without prior
+ *    written permission. For written permission, please contact
+ *    info@caucho.com.
+ *
+ * 5. Products derived from this software may not be called "Resin"
+ *    nor may "Resin" appear in their names without prior written
+ *    permission of Caucho Technology.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL CAUCHO TECHNOLOGY OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @author Scott Ferguson
+ */
+
+package org.apache.tuscany.sca.binding.hessian.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.servlet.GenericServlet;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+import com.caucho.hessian.io.AbstractHessianInput;
+import com.caucho.hessian.io.AbstractHessianOutput;
+import com.caucho.hessian.io.Hessian2Input;
+import com.caucho.hessian.io.Hessian2Output;
+import com.caucho.hessian.io.HessianOutput;
+import com.caucho.hessian.io.SerializerFactory;
+import com.caucho.services.server.ServiceContext;
+
+/**
+ * Servlet for serving Hessian services.
+ */
+public class HessianServiceListenerServlet extends GenericServlet {
+
+    private static final Logger logger = Logger.getLogger(HessianServiceListenerServlet.class.getName());
+
+    private Interface homeImpl;
+    private RuntimeWire wire;
+    private MessageFactory messageFactory;
+
+    private SerializerFactory _serializerFactory;
+
+    private Map<String, JavaOperation> _operationMap = new Hashtable<String, JavaOperation>();
+
+    public HessianServiceListenerServlet(Interface homeImpl, RuntimeWire wire, MessageFactory messageFactory) {
+        this.homeImpl = homeImpl;
+        this.wire = wire;
+        this.messageFactory = messageFactory;
+
+        List<Operation> operations = homeImpl.getOperations();
+        for (int i = 0; i < operations.size(); i++) {
+            JavaOperation op = (JavaOperation)operations.get(i);
+            Method method = op.getJavaMethod();
+            if (_operationMap.get(method.getName()) == null)
+                _operationMap.put(method.getName(), op);
+
+            Class[] param = method.getParameterTypes();
+            String mangledName = method.getName() + "__" + param.length;
+            _operationMap.put(mangledName, op);
+            _operationMap.put(mangleName(method, false), op);
+        }
+    }
+
+    public String getServletInfo() {
+        return "Tuscany Binding Hessian Servlet";
+    }
+
+    /**
+     * Sets the serializer factory.
+     */
+    public void setSerializerFactory(SerializerFactory factory) {
+        _serializerFactory = factory;
+    }
+
+    /**
+     * Gets the serializer factory.
+     */
+    public SerializerFactory getSerializerFactory() {
+        if (_serializerFactory == null)
+            _serializerFactory = new SerializerFactory();
+
+        return _serializerFactory;
+    }
+
+    /**
+     * Sets the serializer send collection java type.
+     */
+    public void setSendCollectionType(boolean sendType) {
+        getSerializerFactory().setSendCollectionType(sendType);
+    }
+
+    /**
+     * Execute a request. The path-info of the request selects the bean. Once
+     * the bean's selected, it will be applied.
+     */
+    public void service(ServletRequest request, ServletResponse response) throws IOException, ServletException {
+        HttpServletRequest req = (HttpServletRequest)request;
+        HttpServletResponse res = (HttpServletResponse)response;
+
+        if (!req.getMethod().equals("POST")) {
+            res.setStatus(500, "Hessian Requires POST");
+            PrintWriter out = res.getWriter();
+            res.setContentType("text/html");
+            out.println("<h1>Hessian Requires POST</h1>");
+            return;
+        }
+
+        String serviceId = req.getPathInfo();
+        String objectId = req.getParameter("id");
+        if (objectId == null)
+            objectId = req.getParameter("ejbid");
+
+        ServiceContext.begin(req, serviceId, objectId);
+
+        try {
+            InputStream is = request.getInputStream();
+            OutputStream os = response.getOutputStream();
+
+            Hessian2Input in = new Hessian2Input(is);
+            AbstractHessianOutput out;
+
+            SerializerFactory serializerFactory = getSerializerFactory();
+
+            in.setSerializerFactory(serializerFactory);
+
+            int code = in.read();
+
+            if (code != 'c') {
+                // XXX: deflate
+                throw new IOException("expected 'c' in hessian input at " + code);
+            }
+
+            int major = in.read();
+            int minor = in.read();
+
+            if (major >= 2)
+                out = new Hessian2Output(os);
+            else
+                out = new HessianOutput(os);
+
+            out.setSerializerFactory(serializerFactory);
+
+            invoke(in, out);
+
+            out.close();
+        } catch (RuntimeException e) {
+            throw e;
+        } catch (ServletException e) {
+            throw e;
+        } catch (Throwable e) {
+            throw new ServletException(e);
+        } finally {
+            ServiceContext.end();
+        }
+    }
+
+    private String mangleName(Method method, boolean isFull) {
+        StringBuffer sb = new StringBuffer();
+        sb.append(method.getName());
+        Class[] params = method.getParameterTypes();
+        for (int i = 0; i < params.length; i++) {
+            sb.append('_');
+            sb.append(mangleClass(params[i], isFull));
+        }
+        return sb.toString();
+    }
+
+    private String mangleClass(Class cl, boolean isFull) {
+        String name = cl.getName();
+        if (name.equals("boolean") || name.equals("java.lang.Boolean"))
+            return "boolean";
+        else if (name.equals("int") || name.equals("java.lang.Integer")
+            || name.equals("short")
+            || name.equals("java.lang.Short")
+            || name.equals("byte")
+            || name.equals("java.lang.Byte"))
+            return "int";
+        else if (name.equals("long") || name.equals("java.lang.Long"))
+            return "long";
+        else if (name.equals("float") || name.equals("java.lang.Float")
+            || name.equals("double")
+            || name.equals("java.lang.Double"))
+            return "double";
+        else if (name.equals("java.lang.String") || name.equals("com.caucho.util.CharBuffer")
+            || name.equals("char")
+            || name.equals("java.lang.Character")
+            || name.equals("java.io.Reader"))
+            return "string";
+        else if (name.equals("java.util.Date") || name.equals("com.caucho.util.QDate"))
+            return "date";
+        else if (InputStream.class.isAssignableFrom(cl) || name.equals("[B"))
+            return "binary";
+        else if (cl.isArray()) {
+            return "[" + mangleClass(cl.getComponentType(), isFull);
+        } else if (name.equals("org.w3c.dom.Node") || name.equals("org.w3c.dom.Element")
+            || name.equals("org.w3c.dom.Document"))
+            return "xml";
+        else if (isFull)
+            return name;
+        else {
+            int p = name.lastIndexOf('.');
+            if (p > 0)
+                return name.substring(p + 1);
+            else
+                return name;
+        }
+    }
+
+    public void invoke(AbstractHessianInput in, AbstractHessianOutput out) throws Exception {
+        ServiceContext context = ServiceContext.getContext();
+
+        // backward compatibility for some frameworks that don't read
+        // the call type first
+        in.skipOptionalCall();
+
+        String header;
+        while ((header = in.readHeader()) != null) {
+            Object value = in.readObject();
+            context.addHeader(header, value);
+        }
+
+        String methodName = in.readMethod();
+        Method method = null;
+        JavaOperation operation = _operationMap.get(methodName);
+        if (operation != null)
+            method = operation.getJavaMethod();
+
+        if (method != null) {
+        } else if ("_hessian_getAttribute".equals(methodName)) {
+            String attrName = in.readString();
+            in.completeCall();
+            String value = null;
+            if ("java.api.class".equals(attrName))
+                value = homeImpl.toString();
+            else if ("java.home.class".equals(attrName))
+                value = homeImpl.toString();
+            else if ("java.object.class".equals(attrName))
+                value = homeImpl.toString();
+            out.startReply();
+            out.writeObject(value);
+            out.completeReply();
+            return;
+        } else if (method == null) {
+            out.startReply();
+            out.writeFault("NoSuchMethodException", "The service has no method named: " + in.getMethod(), null);
+            out.completeReply();
+            return;
+        }
+
+        Class[] args = method.getParameterTypes();
+        Object[] values = new Object[args.length];
+
+        for (int i = 0; i < args.length; i++) {
+            values[i] = in.readObject(args[i]);
+        }
+
+        Object result = null;
+        try {
+            Message msg = messageFactory.createMessage();
+            msg.setOperation(operation);
+            msg.setBody(values);
+            result = wire.invoke(operation, msg);
+        } catch (Throwable e) {
+            while (e instanceof InvocationTargetException)
+                e = ((InvocationTargetException)e).getTargetException();
+            out.startReply();
+            out.writeFault("ServiceException", e.getMessage(), e);
+            out.completeReply();
+            return;
+        }
+
+        // The complete call needs to be after the invoke to handle a
+        // trailing InputStream
+        in.completeCall();
+        out.startReply();
+        out.writeObject(result);
+        out.completeReply();
+        out.close();
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Mon Dec 29 08:31:47 2008
@@ -0,0 +1,19 @@
+# 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. 
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.binding.hessian.impl.HessianBindingProcessor;qname=http://hessian#binding.hessian,model=org.apache.tuscany.sca.binding.hessian.impl.HessianBinding

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema Mon Dec 29 08:31:47 2008
@@ -0,0 +1,19 @@
+# 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. 
+
+# URI of the XML schema to be used for validation
+binding-hessian.xsd

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory Mon Dec 29 08:31:47 2008
@@ -0,0 +1,19 @@
+# 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. 
+
+# Implementation class for the binding extension
+org.apache.tuscany.sca.binding.hessian.provider.HessianBindingProviderFactory;model=org.apache.tuscany.sca.binding.hessian.impl.HessianBinding

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/binding-hessian.xsd
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/binding-hessian.xsd?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/binding-hessian.xsd (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/main/resources/binding-hessian.xsd Mon Dec 29 08:31:47 2008
@@ -0,0 +1,36 @@
+<?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.    
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema" 
+    targetNamespace="http://hessian" 
+    xmlns:sca="http://www.osoa.org/xmlns/sca/1.0"
+    xmlns:e="http://hessian" 
+    elementFormDefault="qualified">
+
+    <import namespace="http://www.osoa.org/xmlns/sca/1.0"/>
+
+    <element name="binding.hessian" type="e:HessianBinding"/>
+    
+    <complexType name="HessianBinding">
+        <complexContent>
+            <extension base="sca:Binding">
+            </extension>
+        </complexContent>
+    </complexType>
+</schema>

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstImpl.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstImpl.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstImpl.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,19 @@
+package org.zhulei.test.hessian.first;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class FirstImpl implements IFirst {
+
+    public String getString(String str) {
+        return str + "_first";
+    }
+
+    public List<String> getData(String str1, String str2) {
+        List<String> list = new ArrayList<String>();
+        list.add(str1 + "_first");
+        list.add(str2 + "_first");
+        return list;
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstTestCase.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstTestCase.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/FirstTestCase.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.zhulei.test.hessian.first;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.caucho.hessian.client.HessianProxyFactory;
+
+/**
+ * 
+ */
+public class FirstTestCase {
+    private static SCANode node;
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        node = SCANodeFactory.newInstance().createSCANodeFromClassLoader("first_hessian.composite", null);
+        node.start();
+    }
+    
+    @Test
+    public void testServer() throws IOException {
+        try {
+            HessianProxyFactory proxyFactory = new HessianProxyFactory();
+            IFirst service = (IFirst)proxyFactory.create(IFirst.class, "http://localhost:8085/hessian1");
+            List<String> datas = service.getData("123", "ABC");
+            for (int i = 0; i < datas.size(); i++) {
+                System.out.println(datas.get(i));
+            }
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+        }
+    }
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+        node.stop();
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/IFirst.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/IFirst.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/IFirst.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/first/IFirst.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,11 @@
+package org.zhulei.test.hessian.first;
+
+import java.util.List;
+
+public interface IFirst {
+
+    public String getString(String str);
+
+    public List<String> getData(String str1, String str2);
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/ISecond.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/ISecond.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/ISecond.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/ISecond.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,7 @@
+package org.zhulei.test.hessian.second;
+
+public interface ISecond {
+
+    public String getString(String str);
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondImpl.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondImpl.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondImpl.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,19 @@
+package org.zhulei.test.hessian.second;
+
+import org.osoa.sca.annotations.Reference;
+import org.zhulei.test.hessian.first.IFirst;
+
+public class SecondImpl implements ISecond {
+
+    private IFirst first;
+
+    public String getString(String str) {
+        return first.getString(str) + "_second";
+    }
+
+    @Reference
+    public void setFirst(IFirst first) {
+        this.first = first;
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondTestCase.java?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondTestCase.java (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/java/org/zhulei/test/hessian/second/SecondTestCase.java Mon Dec 29 08:31:47 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.zhulei.test.hessian.second;
+
+import java.io.IOException;
+
+import org.apache.tuscany.sca.node.SCANode;
+import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.caucho.hessian.client.HessianProxyFactory;
+
+/**
+ * 
+ */
+public class SecondTestCase {
+    private static SCANode node1;
+    private static SCANode node2;
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        node1 = SCANodeFactory.newInstance().createSCANodeFromClassLoader("second_hessian.composite", null);
+        node1.start();
+        
+        node2 = SCANodeFactory.newInstance().createSCANodeFromClassLoader("first_hessian.composite", null);
+        node2.start();
+    }
+    
+    @Test
+    public void testServer() throws IOException {
+        try {
+            HessianProxyFactory proxyFactory = new HessianProxyFactory();
+            ISecond service = (ISecond)proxyFactory.create(ISecond.class, "http://localhost:8085/hessian2");
+            String str = service.getString("XYZ");
+            System.out.println(str);
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+        }
+    }
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+        node1.stop();
+        node2.stop();
+    }
+
+}

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/first_hessian.composite
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/first_hessian.composite?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/first_hessian.composite (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/first_hessian.composite Mon Dec 29 08:31:47 2008
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+	xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+	xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0"
+	xmlns:e="http://hessian"
+	targetNamespace="http://FirstHessianSCA"
+	name="FirstHessianSCA">
+
+	<component name="FirstHessianComponent">
+		<implementation.java
+			class="org.zhulei.test.hessian.first.FirstImpl" />
+	</component>
+ 	
+	<service name="Hessian"
+		promote="FirstHessianComponent">
+		<interface.java
+			interface="org.zhulei.test.hessian.first.IFirst" />
+		<e:binding.hessian uri="/hessian1" />
+	</service>
+
+</composite>

Added: tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/second_hessian.composite
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/second_hessian.composite?rev=729931&view=auto
==============================================================================
--- tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/second_hessian.composite (added)
+++ tuscany/branches/sca-java-1.x/modules/binding-hessian/src/test/resources/second_hessian.composite Mon Dec 29 08:31:47 2008
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+	xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+	xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0"
+	xmlns:e="http://hessian"
+	targetNamespace="http://FirstHessianSCA"
+	name="FirstHessianSCA">
+
+	<component name="SecondHessianComponent">
+		<implementation.java
+			class="org.zhulei.test.hessian.second.SecondImpl" />
+		<reference name="first">
+			<interface.java
+				interface="org.zhulei.test.hessian.first.IFirst" />
+			<e:binding.hessian
+				uri="http://localhost:8085/hessian1" />
+		</reference>
+	</component>
+ 	
+	<service name="Hessian"
+		promote="SecondHessianComponent">
+		<interface.java
+			interface="org.zhulei.test.hessian.second.ISecond" />
+		<e:binding.hessian uri="/hessian2" />
+	</service>
+
+</composite>