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

svn commit: r516978 - in /incubator/tuscany/java/sca/extensions/hessian: ./ binding/ binding/src/main/java/org/apache/tuscany/hessian/ binding/src/main/java/org/apache/tuscany/hessian/channel/ binding/src/main/java/org/apache/tuscany/hessian/destinatio...

Author: jmarino
Date: Sun Mar 11 11:14:41 2007
New Revision: 516978

URL: http://svn.apache.org/viewvc?view=rev&rev=516978
Log:
first-cut of Hessian channels and destinations; will need to be refactored to fit with physical wires

Added:
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Channel.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Destination.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/DestinationCreationException.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianException.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianService.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianServiceImpl.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianTargetInvoker.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvalidDestinationException.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvocationException.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/ServletHostNotFoundException.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/TypeNotFoundException.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/HttpChannel.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/LocalChannel.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/AbstractDestination.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/HttpDestination.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/LocalDestination.java   (with props)
    incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/
    incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/channel/
    incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/destination/
    incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/integration/
    incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/integration/HessianLocalSendReceiveTestCase.java   (with props)
Modified:
    incubator/tuscany/java/sca/extensions/hessian/binding/pom.xml
    incubator/tuscany/java/sca/extensions/hessian/pom.xml

Modified: incubator/tuscany/java/sca/extensions/hessian/binding/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/pom.xml?view=diff&rev=516978&r1=516977&r2=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/pom.xml (original)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/pom.xml Sun Mar 11 11:14:41 2007
@@ -32,5 +32,4 @@
     <name>Apache Tuscany Hessian Binding</name>
     <description></description>
     <packaging>jar</packaging>
-
 </project>

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Channel.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Channel.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Channel.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Channel.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.hessian;
+
+import org.apache.tuscany.spi.wire.Message;
+
+/**
+ * Channels dispatch service invocations over a transport
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Channel {
+
+    /**
+     * Dispatches the service invocation
+     *
+     * @param operation  the service operation to invoke
+     * @param returnType the expected return type or null
+     * @param message    the message containing the invocation payload
+     * @return the response message
+     * @throws InvocationException if an error occurs during the invocation
+     */
+    Message send(String operation, Class<?> returnType, Message message) throws InvocationException;
+
+
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Channel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Channel.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Destination.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Destination.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Destination.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Destination.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,39 @@
+/*
+ * 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.hessian;
+
+import com.caucho.hessian.io.AbstractHessianInput;
+import com.caucho.hessian.io.AbstractHessianOutput;
+
+/**
+ * Responsible for receiving invocations for a service endpoint from a transport
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Destination {
+
+    /**
+     * Dispatches to the service endpoint
+     *
+     * @param in  the input stream containing the invocation payload
+     * @param out the output stream to write the response to
+     * @throws InvocationException if an error occurs invoking the service
+     */
+    void invoke(AbstractHessianInput in, AbstractHessianOutput out) throws InvocationException;
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Destination.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/Destination.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/DestinationCreationException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/DestinationCreationException.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/DestinationCreationException.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/DestinationCreationException.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,49 @@
+/*
+ * 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.hessian;
+
+/**
+ * Thrown when an error creating a destination is encountered
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class DestinationCreationException extends HessianException {
+    public DestinationCreationException() {
+    }
+
+    public DestinationCreationException(String message) {
+        super(message);
+    }
+
+    public DestinationCreationException(String message, String identifier) {
+        super(message, identifier);
+    }
+
+    public DestinationCreationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public DestinationCreationException(String message, String identifier, Throwable cause) {
+        super(message, identifier, cause);
+    }
+
+    public DestinationCreationException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/DestinationCreationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/DestinationCreationException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianException.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianException.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianException.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,51 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*   http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied.  See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+package org.apache.tuscany.hessian;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Base checked exception for the Hessian binding extension
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class HessianException extends TuscanyException {
+    protected HessianException() {
+    }
+
+    protected HessianException(String message) {
+        super(message);
+    }
+
+    protected HessianException(String message, String identifier) {
+        super(message, identifier);
+    }
+
+    protected HessianException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    protected HessianException(String message, String identifier, Throwable cause) {
+        super(message, identifier, cause);
+    }
+
+    protected HessianException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianService.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianService.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianService.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,54 @@
+/*
+ * 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.hessian;
+
+import java.net.URI;
+
+import org.apache.tuscany.spi.wire.Wire;
+
+/**
+ * Creates Channels and Destinations using the Hessian protocol
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HessianService {
+    String LOCAL_SCHEME = "hessianLocal";
+    String HTTP_SCHEME = "http";
+
+    /**
+     * Creates a Channel for the given target URI. The URI scheme will determine the transport protocol
+     *
+     * @param uri the target URI.
+     * @return the
+     * @throws InvalidDestinationException
+     */
+    Channel createChannel(URI uri) throws InvalidDestinationException;
+
+    /**
+     * Creates and registers a destination at the given URI for a service. The URI scheme will determine the transport
+     * protocol
+     *
+     * @param uri    the destination URI
+     * @param wire   the service wire
+     * @param loader  the classloader to use for payload deserializing
+     * @throws DestinationCreationException
+     */
+    void createDestination(URI uri, Wire wire, ClassLoader loader) throws DestinationCreationException;
+
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianService.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianServiceImpl.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianServiceImpl.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianServiceImpl.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,83 @@
+/*
+ * 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.hessian;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osoa.sca.annotations.EagerInit;
+import org.osoa.sca.annotations.Reference;
+
+import org.apache.tuscany.spi.host.ServletHost;
+import org.apache.tuscany.spi.wire.Wire;
+
+import org.apache.tuscany.hessian.channel.HttpChannel;
+import org.apache.tuscany.hessian.channel.LocalChannel;
+import org.apache.tuscany.hessian.destination.HttpDestination;
+import org.apache.tuscany.hessian.destination.LocalDestination;
+
+/**
+ * The default Hessian system service
+ *
+ * @version $Rev$ $Date$
+ */
+@EagerInit
+public class HessianServiceImpl implements HessianService {
+    private ServletHost servletHost;
+    private Map<URI, LocalDestination> destinations;
+
+    public HessianServiceImpl(@Reference ServletHost servletHost) {
+        this.servletHost = servletHost;
+        destinations = new HashMap<URI, LocalDestination>();
+    }
+
+    public Channel createChannel(URI uri) throws InvalidDestinationException {
+        if (LOCAL_SCHEME.equals(uri.getScheme())) {
+            LocalDestination destination = destinations.get(uri);
+            if (destination != null) {
+                throw new InvalidDestinationException("Destination not found", uri.toString());
+            }
+            return new LocalChannel(destination);
+        } else if (HTTP_SCHEME.equals(uri.getScheme())) {
+            try {
+                return new HttpChannel(uri.toURL());
+            } catch (MalformedURLException e) {
+                throw new InvalidDestinationException("URI must be a valid URL ", e);
+            }
+        }
+        throw new UnsupportedOperationException("Unsupported scheme");
+    }
+
+    public void createDestination(URI uri, Wire wire, ClassLoader loader) throws DestinationCreationException {
+        if (LOCAL_SCHEME.equals(uri.getScheme())) {
+            LocalDestination destination = new LocalDestination(wire, loader);
+            destinations.put(uri, destination);
+        } else if (HTTP_SCHEME.equals(uri.getScheme())) {
+            if (servletHost == null) {
+                throw new ServletHostNotFoundException("ServletHost is was not found");
+            }
+            HttpDestination destination = new HttpDestination(wire, loader);
+            // FIXME mapping
+            servletHost.registerMapping(uri.toString(), destination);
+        }
+        throw new UnsupportedOperationException("Unsupported scheme");
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianTargetInvoker.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianTargetInvoker.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianTargetInvoker.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,76 @@
+/*
+ * 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.hessian;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HessianTargetInvoker implements TargetInvoker {
+    private String operation;
+    private Channel channel;
+    protected WorkContext workContext;
+
+    public HessianTargetInvoker(String operation, Channel channel, WorkContext workContext) {
+        this.operation = operation;
+        this.workContext = workContext;
+        this.channel = channel;
+    }
+
+    public boolean isCacheable() {
+        return false;
+    }
+
+    public void setCacheable(boolean cacheable) {
+    }
+
+    public boolean isOptimizable() {
+        return false;
+    }
+
+    public Message invoke(Message msg) throws InvocationRuntimeException {
+        try {
+            return channel.send(operation, null, msg);
+        } catch (InvocationException e) {
+            msg.setBodyWithFault(e);
+            return msg;
+        }
+    }
+
+    public Object clone() throws CloneNotSupportedException {
+        try {
+            return super.clone();
+        } catch (CloneNotSupportedException e) {
+            // TargetInvoker extends Cloneable so this should not have been thrown
+            throw new AssertionError(e);
+        }
+    }
+
+    public Object invokeTarget(final Object payload, final short sequence) throws InvocationTargetException {
+        return new UnsupportedOperationException();
+    }
+
+
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianTargetInvoker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/HessianTargetInvoker.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvalidDestinationException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvalidDestinationException.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvalidDestinationException.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvalidDestinationException.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,14 @@
+package org.apache.tuscany.hessian;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InvalidDestinationException extends HessianException {
+    public InvalidDestinationException(String message, String identifier) {
+        super(message, identifier);
+    }
+
+    public InvalidDestinationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvalidDestinationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvalidDestinationException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvocationException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvocationException.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvocationException.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvocationException.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,45 @@
+/*
+ * 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.hessian;
+
+import org.apache.tuscany.api.TuscanyException;
+
+/**
+ * Raised when an error performing a service invocation is encountered
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvocationException extends TuscanyException {
+
+    public InvocationException(String message, String identifier) {
+        super(message, identifier);
+    }
+
+    public InvocationException(String message, String identifier, Throwable cause) {
+        super(message, identifier, cause);
+    }
+
+    public InvocationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public InvocationException(Throwable cause) {
+        super(cause);
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvocationException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/InvocationException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/ServletHostNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/ServletHostNotFoundException.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/ServletHostNotFoundException.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/ServletHostNotFoundException.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,27 @@
+package org.apache.tuscany.hessian;/*
+ * 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.
+ */
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ServletHostNotFoundException extends DestinationCreationException {
+    public ServletHostNotFoundException(String message) {
+        super(message);
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/ServletHostNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/ServletHostNotFoundException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/TypeNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/TypeNotFoundException.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/TypeNotFoundException.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/TypeNotFoundException.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,31 @@
+/*
+ * 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.hessian;
+
+/**
+ * Denotes a missing or not found type
+ *
+ * @version $Rev$ $Date$
+ */
+public class TypeNotFoundException extends DestinationCreationException {
+
+    public TypeNotFoundException(String message, String identifier, Throwable cause) {
+        super(message, identifier, cause);
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/TypeNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/TypeNotFoundException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/HttpChannel.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/HttpChannel.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/HttpChannel.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/HttpChannel.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,220 @@
+/*
+ * 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.hessian.channel;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+
+import com.caucho.hessian.client.HessianRuntimeException;
+import com.caucho.hessian.io.HessianInput;
+import com.caucho.hessian.io.HessianOutput;
+import org.apache.tuscany.hessian.Channel;
+import org.apache.tuscany.hessian.InvocationException;
+
+/**
+ * A channel implementation that uses HTTP as the transport protocol
+ *
+ * @version $Rev$ $Date$
+ */
+public class HttpChannel implements Channel {
+    private URL destinationUrl;
+    private boolean chunkedPost;
+    private String basicAuth;
+    private String user;
+    private String password;
+    private int readTimeout;
+
+    public HttpChannel(URL url) {
+        this.destinationUrl = url;
+    }
+
+    public Message send(String operation, Class<?> returnType, Message message) throws InvocationException {
+        URLConnection conn;
+        try {
+            conn = openConnection(destinationUrl);
+        } catch (IOException e) {
+            throw new InvocationException(e);
+        }
+        if (chunkedPost && conn instanceof HttpURLConnection) {
+            HttpURLConnection httpConn = (HttpURLConnection) conn;
+            httpConn.setChunkedStreamingMode(8 * 1024);
+        }
+
+        OutputStream os;
+        try {
+            os = conn.getOutputStream();
+        } catch (IOException e) {
+            throw new HessianRuntimeException(e);
+        }
+
+        try {
+            HessianOutput out = new HessianOutput(os);
+            Object[] args;
+            Object payload = message.getBody();
+            if (payload != null && !payload.getClass().isArray()) {
+                args = new Object[]{payload};
+            } else {
+                args = (Object[]) payload;
+            }
+            out.call(operation, args);
+            out.flush();
+
+            InputStream is = null;
+            if (conn instanceof HttpURLConnection) {
+                HttpURLConnection httpConn = (HttpURLConnection) conn;
+                int code = httpConn.getResponseCode();
+                if (code != 200) {
+                    StringBuffer sb = new StringBuffer();
+                    int ch;
+
+                    try {
+                        is = httpConn.getInputStream();
+
+                        if (is != null) {
+                            while ((ch = is.read()) >= 0) {
+                                sb.append((char) ch);
+                            }
+
+                            is.close();
+                        }
+
+                        is = httpConn.getErrorStream();
+                        if (is != null) {
+                            while ((ch = is.read()) >= 0) {
+                                sb.append((char) ch);
+                            }
+                        }
+                    } catch (FileNotFoundException e) {
+                        throw new InvocationException(e);
+                    } catch (IOException e) {
+                        if (is == null) {
+                            throw new InvocationException("Invocation exception", String.valueOf(code), e);
+                        }
+                    }
+
+                    if (is != null) {
+                        is.close();
+                    }
+                    throw new InvocationException("Invocation exception", sb.toString());
+                }
+            }
+            is = conn.getInputStream();
+
+            HessianInput in = new HessianInput(is);
+            // FIXME handle faults
+            Object reply = in.readReply(returnType);
+            Message msg = new MessageImpl();
+            msg.setBody(reply);
+            return msg;
+        } catch (RuntimeException e) {
+            if (conn instanceof HttpURLConnection) {
+                ((HttpURLConnection) conn).disconnect();
+            }
+            throw e;
+        } catch (Throwable e) {
+            if (conn instanceof HttpURLConnection) {
+                ((HttpURLConnection) conn).disconnect();
+            }
+
+            throw new InvocationException(e);
+        }
+    }
+
+    protected URLConnection openConnection(URL url) throws IOException {
+        URLConnection conn = url.openConnection();
+
+        conn.setDoOutput(true);
+
+        if (readTimeout > 0) {
+            conn.setReadTimeout(readTimeout);
+        }
+
+        conn.setRequestProperty("Content-Type", "x-application/hessian");
+
+        if (basicAuth != null)
+            conn.setRequestProperty("Authorization", basicAuth);
+        else if (user != null && password != null) {
+            basicAuth = "Basic " + base64(user + ":" + password);
+            conn.setRequestProperty("Authorization", basicAuth);
+        }
+
+        return conn;
+    }
+
+    private String base64(String value) {
+        StringBuffer cb = new StringBuffer();
+
+        int i = 0;
+        for (i = 0; i + 2 < value.length(); i += 3) {
+            long chunk = (int) value.charAt(i);
+            chunk = (chunk << 8) + (int) value.charAt(i + 1);
+            chunk = (chunk << 8) + (int) value.charAt(i + 2);
+
+            cb.append(encode(chunk >> 18));
+            cb.append(encode(chunk >> 12));
+            cb.append(encode(chunk >> 6));
+            cb.append(encode(chunk));
+        }
+
+        if (i + 1 < value.length()) {
+            long chunk = (int) value.charAt(i);
+            chunk = (chunk << 8) + (int) value.charAt(i + 1);
+            chunk <<= 8;
+
+            cb.append(encode(chunk >> 18));
+            cb.append(encode(chunk >> 12));
+            cb.append(encode(chunk >> 6));
+            cb.append('=');
+        } else if (i < value.length()) {
+            long chunk = (int) value.charAt(i);
+            chunk <<= 16;
+
+            cb.append(encode(chunk >> 18));
+            cb.append(encode(chunk >> 12));
+            cb.append('=');
+            cb.append('=');
+        }
+
+        return cb.toString();
+    }
+
+    public static char encode(long d) {
+        d &= 0x3f;
+        if (d < 26)
+            return (char) (d + 'A');
+        else if (d < 52)
+            return (char) (d + 'a' - 26);
+        else if (d < 62)
+            return (char) (d + '0' - 52);
+        else if (d == 62)
+            return '+';
+        else
+            return '/';
+    }
+
+
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/HttpChannel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/HttpChannel.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/LocalChannel.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/LocalChannel.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/LocalChannel.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/LocalChannel.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,78 @@
+/*
+ * 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.hessian.channel;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+
+import com.caucho.hessian.io.HessianInput;
+import com.caucho.hessian.io.HessianOutput;
+import org.apache.tuscany.hessian.Channel;
+import org.apache.tuscany.hessian.InvocationException;
+import org.apache.tuscany.hessian.destination.LocalDestination;
+
+/**
+ * A channel implementation that uses an in-VM transport
+ *
+ * @version $Rev$ $Date$
+ */
+public class LocalChannel implements Channel {
+    private LocalDestination destination;
+
+    public LocalChannel(LocalDestination destination) {
+        this.destination = destination;
+    }
+
+    public Message send(String operation, Class<?> returnType, Message message) throws InvocationException {
+        Object payload = message.getBody();
+        Object[] args;
+        if (payload != null && !payload.getClass().isArray()) {
+            args = new Object[]{payload};
+        } else {
+            args = (Object[]) payload;
+        }
+        try {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            HessianOutput output = new HessianOutput(baos);
+            output.call(operation, args);
+            output.close();
+            ByteArrayInputStream bas = new ByteArrayInputStream(baos.toByteArray());
+            HessianInput input = new HessianInput(bas);
+
+            ByteArrayOutputStream returnOutputStream = new ByteArrayOutputStream();
+            HessianOutput returnOutput = new HessianOutput(returnOutputStream);
+            destination.invoke(input, returnOutput);
+            ByteArrayInputStream returnStream = new ByteArrayInputStream(returnOutputStream.toByteArray());
+            HessianInput in = new HessianInput(returnStream);
+            // FIXME handle faults
+            Object reply = in.readReply(returnType);
+            Message msg = new MessageImpl();
+            msg.setBody(reply);
+            return msg;
+        } catch (Throwable e) {
+            throw new InvocationException(e);
+        }
+
+
+    }
+
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/LocalChannel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/channel/LocalChannel.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/AbstractDestination.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/AbstractDestination.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/AbstractDestination.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/AbstractDestination.java Sun Mar 11 11:14:41 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.hessian.destination;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.Wire;
+
+import com.caucho.hessian.io.AbstractHessianInput;
+import com.caucho.hessian.io.AbstractHessianOutput;
+import org.apache.tuscany.hessian.Destination;
+import org.apache.tuscany.hessian.InvocationException;
+import org.apache.tuscany.hessian.TypeNotFoundException;
+
+/**
+ * Base implementation of a Destination
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractDestination implements Destination {
+    protected Map<String, ChainHolder> chains;
+    private ClassLoader loader;
+
+    protected AbstractDestination(Wire wire, ClassLoader loader) throws TypeNotFoundException {
+        this.loader = loader;
+        chains = new HashMap<String, ChainHolder>();
+        for (Map.Entry<PhysicalOperationDefinition, InvocationChain> entry : wire.getPhysicalInvocationChains()
+            .entrySet()) {
+            PhysicalOperationDefinition operation = entry.getKey();
+            String operationName = operation.getName();
+            InvocationChain chain = entry.getValue();
+            List<String> params = operation.getParameters();
+            Class<?>[] paramTypes = new Class<?>[params.size()];
+            // load the param types in the target's classloader
+            for (int i = 0; i < params.size(); i++) {
+                String param = params.get(i);
+                try {
+                    paramTypes[i] = loader.loadClass(param);
+                } catch (ClassNotFoundException e) {
+                    throw new TypeNotFoundException("Operation parameter type not found", operationName, e);
+                }
+            }
+            AbstractDestination.ChainHolder holder =
+                new AbstractDestination.ChainHolder(paramTypes, chain);
+            chains.put(operationName, holder);
+        }
+    }
+
+    public void invoke(AbstractHessianInput in, AbstractHessianOutput out) throws InvocationException {
+        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            // ensure serialization is done on the target classloader
+            Thread.currentThread().setContextClassLoader(loader);
+            in.readCall();
+            String m = in.readMethod();
+            AbstractDestination.ChainHolder holder = chains.get(m);
+            if (holder == null) {
+                out.startReply();
+                out.writeFault("OperationNotFound", "The service has no method named: " + m, null);
+                out.completeReply();
+                return;
+            }
+            Class<?>[] paramType = holder.types;
+            Object[] values = new Object[paramType.length];
+            for (int n = 0; n < paramType.length; n++) {
+                values[n] = in.readObject(paramType[n]);
+            }
+            in.completeCall();
+            Message msg = new MessageImpl();
+            InvocationChain chain = holder.chain;
+            msg.setTargetInvoker((TargetInvoker) chain.getTargetInvoker().clone());
+            Message ret = chain.getHeadInterceptor().invoke(msg);
+            out.startReply();
+            Object o = ret.getBody();
+            out.writeObject(o);
+            out.completeReply();
+        } catch (IOException e) {
+            throw new InvocationException(e);
+        } catch (CloneNotSupportedException e) {
+            try {
+                out.startReply();
+                out.writeFault("ServiceException", e.getMessage(), e);
+                out.completeReply();
+            } catch (IOException e1) {
+                throw new InvocationException(e);
+            }
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldLoader);
+        }
+    }
+
+    protected class ChainHolder {
+        Class<?>[] types;
+        InvocationChain chain;
+
+        public ChainHolder(Class<?>[] types, InvocationChain chain) {
+            this.types = types;
+            this.chain = chain;
+        }
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/AbstractDestination.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/AbstractDestination.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/HttpDestination.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/HttpDestination.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/HttpDestination.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/HttpDestination.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.hessian.destination;
+
+import java.io.IOException;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.tuscany.spi.wire.Wire;
+
+import com.caucho.hessian.io.HessianInput;
+import com.caucho.hessian.io.HessianOutput;
+import org.apache.tuscany.hessian.InvocationException;
+import org.apache.tuscany.hessian.TypeNotFoundException;
+
+/**
+ * A Destination implementation which receives requests over HTTP using a servlet engine
+ *
+ * @version $Rev$ $Date$
+ */
+public class HttpDestination extends AbstractDestination implements Servlet {
+
+    public HttpDestination(Wire wire, ClassLoader loader)
+        throws TypeNotFoundException {
+        super(wire, loader);
+    }
+
+    public void service(ServletRequest req, ServletResponse resp)
+        throws ServletException, IOException {
+        try {
+            invoke(new HessianInput(req.getInputStream()), new HessianOutput(resp.getOutputStream()));
+        } catch (InvocationException e) {
+            throw new ServletException(e);
+        }
+    }
+
+    public void init(ServletConfig servletConfig) throws ServletException {
+
+    }
+
+    public ServletConfig getServletConfig() {
+        return null;
+    }
+
+    public String getServletInfo() {
+        return null;
+    }
+
+    public void destroy() {
+
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/HttpDestination.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/HttpDestination.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/LocalDestination.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/LocalDestination.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/LocalDestination.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/LocalDestination.java Sun Mar 11 11:14:41 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.hessian.destination;
+
+import org.apache.tuscany.spi.wire.Wire;
+
+import org.apache.tuscany.hessian.TypeNotFoundException;
+
+/**
+ * A Destination implementation which receives requests over an in-VM transport
+ *
+ * @version $Rev$ $Date$
+ */
+public class LocalDestination extends AbstractDestination {
+
+    public LocalDestination(Wire wire, ClassLoader loader) throws TypeNotFoundException {
+        super(wire, loader);
+    }
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/LocalDestination.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/main/java/org/apache/tuscany/hessian/destination/LocalDestination.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/integration/HessianLocalSendReceiveTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/integration/HessianLocalSendReceiveTestCase.java?view=auto&rev=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/integration/HessianLocalSendReceiveTestCase.java (added)
+++ incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/integration/HessianLocalSendReceiveTestCase.java Sun Mar 11 11:14:41 2007
@@ -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.hessian.integration;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
+import org.apache.tuscany.spi.wire.Interceptor;
+import org.apache.tuscany.spi.wire.InvocationChain;
+import org.apache.tuscany.spi.wire.Message;
+import org.apache.tuscany.spi.wire.MessageImpl;
+import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.spi.wire.Wire;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.hessian.channel.LocalChannel;
+import org.apache.tuscany.hessian.destination.LocalDestination;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class HessianLocalSendReceiveTestCase extends TestCase {
+
+    public void testInvokeVoidReturn() throws Exception {
+        Interceptor interceptor = EasyMock.createMock(Interceptor.class);
+        EasyMock.expect(interceptor.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl());
+        EasyMock.replay(interceptor);
+
+        PhysicalOperationDefinition operation = new PhysicalOperationDefinition();
+        operation.setName("hello");
+
+        TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class);
+        EasyMock.replay(invoker);
+
+        InvocationChain chain = EasyMock.createMock(InvocationChain.class);
+        EasyMock.expect(chain.getTargetInvoker()).andReturn(invoker);
+        EasyMock.expect(chain.getHeadInterceptor()).andReturn(interceptor);
+        EasyMock.replay(chain);
+
+
+        Map<PhysicalOperationDefinition, InvocationChain> chains =
+            new HashMap<PhysicalOperationDefinition, InvocationChain>();
+        chains.put(operation, chain);
+
+        Wire wire = EasyMock.createMock(Wire.class);
+        EasyMock.expect(wire.getPhysicalInvocationChains()).andReturn(chains);
+        EasyMock.replay(wire);
+        ClassLoader loader = getClass().getClassLoader();
+        LocalDestination destination = new LocalDestination(wire, loader);
+        LocalChannel channel = new LocalChannel(destination);
+        channel.send("hello", null, new MessageImpl());
+        EasyMock.verify(interceptor);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/integration/HessianLocalSendReceiveTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/extensions/hessian/binding/src/test/java/org/apache/tuscany/hessian/integration/HessianLocalSendReceiveTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/extensions/hessian/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/extensions/hessian/pom.xml?view=diff&rev=516978&r1=516977&r2=516978
==============================================================================
--- incubator/tuscany/java/sca/extensions/hessian/pom.xml (original)
+++ incubator/tuscany/java/sca/extensions/hessian/pom.xml Sun Mar 11 11:14:41 2007
@@ -60,24 +60,23 @@
                 <enabled>false</enabled>
             </snapshots>
         </repository>
+			<repository>
+				<id>objectstyle</id>
+ 	         <url>http://www.objectstyle.org/maven2/</url>
+			</repository>
     </repositories>
 
     <dependencies>
         <dependency>
             <groupId>org.apache.tuscany.sca.kernel</groupId>
             <artifactId>tuscany-spi</artifactId>
-				<version>1.0-alpha-incubating-SNAPSHOT</version>
+				<version>2.0-alpha2-incubating-SNAPSHOT</version>
         </dependency>
 
         <dependency>
-            <groupId>org.apache.qpid</groupId>
-            <artifactId>qpid-common</artifactId>
-				<version>1.0-incubating-M2-SNAPSHOT</version>
-        </dependency>
-        <dependency>
 				<groupId>com.caucho</groupId>
 				<artifactId>hessian</artifactId>
-				<version>3.0.8</version>
+				<version>3.0.20</version>
 		 </dependency>
 
         <dependency>
@@ -93,6 +92,12 @@
             <version>3.8.1</version>
             <scope>test</scope>
 			</dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.4</version>
+        </dependency>
+
 
     </dependencies>
 



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