tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svkr...@apache.org
Subject svn commit: r532812 - in /incubator/tuscany/java/sca/modules/binding-rmi: ./ src/main/java/org/apache/tuscany/binding/rmi/ src/main/java/org/apache/tuscany/binding/rmi/impl/ src/main/resources/META-INF/sca/ src/main/resources/META-INF/services/ src/tes...
Date Thu, 26 Apr 2007 17:36:18 GMT
Author: svkrish
Date: Thu Apr 26 10:36:16 2007
New Revision: 532812

URL: http://svn.apache.org/viewvc?view=rev&rev=532812
Log:
Reactivated Java RMI Binding

Added:
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingConstants.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingFactory.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIModuleActivator.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/DefaultRMIBindingFactory.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/RMIBindingImpl.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/resources/META-INF/services/
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/RMIBindingTest.composite
      - copied, changed from r532247, incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/default.scdl
Removed:
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingDefinition.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/resources/META-INF/sca/
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingBuilderTestCase.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingLoaderTestCase.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIBindingTestCase.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIInvokerTestCase.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIReferenceTestCase.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/RMIServiceTestCase.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/RemoteMethodHandlerTestCase.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/host/
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/default.scdl
Modified:
    incubator/tuscany/java/sca/modules/binding-rmi/pom.xml
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReferenceBinding.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIServiceBinding.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldImpl.componentType
    incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldRmiImpl.componentType

Modified: incubator/tuscany/java/sca/modules/binding-rmi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/pom.xml?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/pom.xml (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/pom.xml Thu Apr 26 10:36:16 2007
@@ -22,12 +22,45 @@
     <parent>
         <groupId>org.apache.tuscany.sca</groupId>
         <artifactId>tuscany-modules</artifactId>
-        <version>${version}</version>
+        <version>1.0-incubating-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
     <artifactId>tuscany-binding-rmi</artifactId>
     <name>Apache Tuscany Java RMI Binding</name>
 
     <dependencies>
+    	<dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-assembly-xml</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-rmi</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-runtime</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+			<groupId>cglib</groupId>
+			<artifactId>cglib-nodep</artifactId>
+			<version>2.1_3</version>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-host-embedded</artifactId>
+            <version>1.0-incubating-SNAPSHOT</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java Thu Apr 26 10:36:16 2007
@@ -19,7 +19,10 @@
 /**
  * @version $Rev$ $Date$
  */
-public class NoRemoteMethodException extends RMIRuntimeException {
+public class NoRemoteMethodException extends RuntimeException {
+
+    private static final long serialVersionUID = -4706646034473965972L;
+
     public NoRemoteMethodException() { 
     }
 

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java Thu Apr 26 10:36:16 2007
@@ -17,9 +17,10 @@
 package org.apache.tuscany.binding.rmi;
 
 /**
- * @version $Rev$ $Date$
  */
 public class NoRemoteServiceException extends RMIRuntimeException {
+   private static final long serialVersionUID = 4940083022809126473L;
+
     public NoRemoteServiceException() { 
     }
 

Added: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java?view=auto&rev=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java (added)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java Thu Apr 26 10:36:16 2007
@@ -0,0 +1,55 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.tuscany.binding.rmi;
+
+import org.apache.tuscany.assembly.Binding;
+
+/**
+ * Represents a binding to an RMI service.
+ */
+public interface RMIBinding extends Binding {
+    /**
+     * @return the host name of the RMI Service
+     */
+    String getRmiHostName();
+
+    /**
+     * @param rmiHostName the hostname of the RMI Service
+     */
+    void setRmiHostName(String rmiHostName);
+
+    /**
+     * @return the port number for the RMI Service
+     */
+    String getRmiPort();
+
+    /**
+     * @param rmiPort the port number for the RMI Service
+     */
+    void setRmiPort(String rmiPort);
+
+    /**
+     * @return returns the RMI Service Name
+     */
+    String getRmiServiceName();
+
+    /**
+     * Sets the service name for the RMI Server
+     * @param rmiServiceName the name of the RMI service
+     */
+    void setRmiServiceName(String rmiServiceName);
+}

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java Thu Apr 26 10:36:16 2007
@@ -16,67 +16,103 @@
  */
 package org.apache.tuscany.binding.rmi;
 
+import java.net.URI;
 import java.rmi.Remote;
+import java.util.ArrayList;
+import java.util.List;
 
-import org.osoa.sca.annotations.Constructor;
-
-import org.apache.tuscany.spi.annotation.Autowire;
-import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.assembly.CompositeReference;
+import org.apache.tuscany.assembly.CompositeService;
+import org.apache.tuscany.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.spi.builder.BuilderException;
 import org.apache.tuscany.spi.component.ReferenceBinding;
 import org.apache.tuscany.spi.component.ServiceBinding;
 import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.extension.BindingBuilderExtension;
-import org.apache.tuscany.spi.model.BoundReferenceDefinition;
-import org.apache.tuscany.spi.model.BoundServiceDefinition;
-
-import org.apache.tuscany.host.rmi.RMIHost;
 
 /**
  * Builds a Service or Reference for an RMI binding.
  *
- * @version $Rev$ $Date$
  */
 
-public class RMIBindingBuilder extends BindingBuilderExtension<RMIBindingDefinition> {
+public class RMIBindingBuilder extends BindingBuilderExtension<RMIBinding> {
+
+    private RMIHostExtensionPoint rmiHost;
+    
+    //track reference bindings and service bindings so that resources can be released
+    // needed because the stop methods in ReferenceImpl and ServiceImpl aren't being called
+    // TODO: revisit this as part of the lifecycle work
+    private List<ReferenceBinding> referenceBindings = new ArrayList<ReferenceBinding>();
+    private List<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
+    
+    
+    protected Class<RMIBinding> getBindingType() {
+        return RMIBinding.class;
+    }
+
+    @Override
+    public ReferenceBinding build(CompositeReference compositeReference, RMIBinding rmiBindingDefn, DeploymentContext context) throws BuilderException {
+
+        URI name = URI.create(context.getComponentId() + "#" + compositeReference.getName());
+        ReferenceBinding referenceBinding = new RMIReferenceBinding(name,
+                                                                    makeTargetURI(rmiBindingDefn),
+                                                                    rmiBindingDefn, 
+                                                                    rmiHost);
+        referenceBindings.add(referenceBinding); // track binding so that its resources can be released
+        return referenceBinding;
+    }
+
+    @Override
+    public ServiceBinding build(CompositeService compositeService, RMIBinding rmiBindingDefn, DeploymentContext context) throws BuilderException {
+        
+        URI name = URI.create(context.getComponentId() + "#" + compositeService.getName());
+        ServiceBinding serviceBinding = new RMIServiceBinding<Remote>(name,
+                                            rmiBindingDefn, 
+                                            rmiHost, 
+                                            compositeService.getInterfaceContract().getInterface());
+        serviceBindings.add(serviceBinding); // track binding so that its resources can be released
+        return serviceBinding;
+    }
 
-    private RMIHost rmiHost;
+    public RMIHostExtensionPoint getRmiHost() {
+        return rmiHost;
+    }
 
-    @Constructor({"rmiHost"})
-    public RMIBindingBuilder(@Autowire RMIHost rHost) {
-        this.rmiHost = rHost;
-    }
-
-    protected Class<RMIBindingDefinition> getBindingType() {
-        return RMIBindingDefinition.class;
-    }
-
-    @SuppressWarnings({"unchecked"})
-    public ServiceBinding build(CompositeComponent parent,
-                                BoundServiceDefinition boundServiceDefinition,
-                                RMIBindingDefinition bindingDefinition,
-                                DeploymentContext deploymentContext) {
-
-        Class intf = boundServiceDefinition.getServiceContract().getInterfaceClass();
-
-        return new RMIServiceBinding<Remote>(boundServiceDefinition.getName(),
-            parent,
-            wireService,
-            rmiHost,
-            bindingDefinition.getHost(),
-            bindingDefinition.getPort(),
-            bindingDefinition.getServiceName(),
-            intf);
-    }
-
-    public ReferenceBinding build(CompositeComponent parent,
-                                  BoundReferenceDefinition boundReferenceDefinition,
-                                  RMIBindingDefinition bindingDefinition,
-                                  DeploymentContext deploymentContext) {
-        String name = boundReferenceDefinition.getName();
-        String host = bindingDefinition.getHost();
-        String port = bindingDefinition.getPort();
-        String svcName = bindingDefinition.getServiceName();
-        return new RMIReferenceBinding(name, parent, rmiHost, host, port, svcName);
+    public void setRmiHost(RMIHostExtensionPoint rmiHost) {
+        this.rmiHost = rmiHost;
+    }
+    
+    private URI makeTargetURI(RMIBinding rmiBinding) {
+        StringBuffer sb = new StringBuffer();
+        sb.append(RMIBindingConstants.FWD_SLASH);
+        sb.append(RMIBindingConstants.FWD_SLASH);
+        if (rmiBinding.getRmiHostName() != null && rmiBinding.getRmiHostName().length() > 0) {
+            sb.append(rmiBinding.getRmiHostName());
+        } else {
+            sb.append(RMIBindingConstants.LOCAL_HOST);
+        }
+        
+        if (rmiBinding.getRmiPort() != null && rmiBinding.getRmiPort().length() > 0) {
+            sb.append(RMIBindingConstants.COLON);
+            sb.append(rmiBinding.getRmiPort());
+        } 
+        sb.append(RMIBindingConstants.FWD_SLASH);
+        sb.append(rmiBinding.getRmiServiceName());
+        
+        return URI.create(sb.toString());
+    }
+    
+    //  release resources held by bindings
+    // called by stop method of Axis2ModuleActivator
+    // needed because the stop methods in ReferenceImpl and ServiceImpl aren't being called
+    // TODO: revisit this as part of the lifecycle work
+    protected void destroy() {
+       for (ReferenceBinding binding : referenceBindings) {
+          binding.stop();
+       }
+       for (ServiceBinding binding : serviceBindings) {
+          binding.stop();
+       }
     }
 
 }

Added: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingConstants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingConstants.java?view=auto&rev=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingConstants.java (added)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingConstants.java Thu Apr 26 10:36:16 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.binding.rmi;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.assembly.xml.Constants;
+
+public interface RMIBindingConstants {
+
+    String BINDING_RMI = "binding.rmi";
+    QName BINDING_RMI_QNAME = new QName(Constants.SCA10_NS, BINDING_RMI);
+    String RMI_HOST = "host";
+    String RMI_PORT = "port";
+    String RMI_SERVICE = "serviceName";
+    
+    String COLON = ":";
+    String FWD_SLASH = "/";
+    String LOCAL_HOST = "localhost";
+}

Added: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingFactory.java?view=auto&rev=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingFactory.java (added)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingFactory.java Thu Apr 26 10:36:16 2007
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.binding.rmi;
+
+/**
+ * Factory for the RMI binding model.
+ */
+public interface RMIBindingFactory {
+
+    /**
+     * Creates a new RMI binding.
+     * 
+     * @return a new RMI binding
+     */
+    RMIBinding createWebServiceBinding();
+
+}

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java Thu Apr 26 10:36:16 2007
@@ -20,11 +20,11 @@
 import java.lang.reflect.Method;
 import java.rmi.Remote;
 
+import org.apache.tuscany.rmi.RMIHostException;
+import org.apache.tuscany.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.spi.component.WorkContext;
 import org.apache.tuscany.spi.extension.TargetInvokerExtension;
 
-import org.apache.tuscany.host.rmi.RMIHost;
-import org.apache.tuscany.host.rmi.RMIHostException;
-
 /**
  * Invoke an RMI reference.
  *
@@ -35,12 +35,10 @@
     private String host;
     private String port;
     private String svcName;
-    private RMIHost rmiHost;
+    private RMIHostExtensionPoint rmiHost;
     private Remote proxy;
 
-    public RMIInvoker(RMIHost rmiHost, String host, String port, String svcName, Method remoteMethod) {
-        super(null, null, null);
-        // assert remoteMethod.isAccessible();
+    public RMIInvoker(RMIHostExtensionPoint rmiHost, String host, String port, String svcName, Method remoteMethod) {
         this.remoteMethod = remoteMethod;
         this.host = host;
         this.port = port;
@@ -48,18 +46,30 @@
         this.rmiHost = rmiHost;
     }
 
-    public Object invokeTarget(Object payload, final short sequence) throws InvocationTargetException {
+    public Object invokeTarget(final Object payload, 
+                               final short sequence, 
+                               WorkContext workContext) throws InvocationTargetException {
         try {
             if (proxy == null) {
                 proxy = rmiHost.findService(host, port, svcName);
                 // proxy = Naming.lookup(serviceURI);
             }
-            return remoteMethod.invoke(proxy, (Object[]) payload);
+            
+            remoteMethod = proxy.getClass().getMethod(remoteMethod.getName(), remoteMethod.getParameterTypes());
+            
+            if (payload != null && !payload.getClass().isArray()) {
+                return remoteMethod.invoke(proxy, payload);
+            } else {
+                return remoteMethod.invoke(proxy, (Object[])payload);
+                
+            }
         } catch (RMIHostException e) {
             // the method we are passed must be accessible
             throw new AssertionError(e);
         } catch (IllegalAccessException e) {
             // the method we are passed must be accessible
+            throw new AssertionError(e);
+        } catch (NoSuchMethodException e) {
             throw new AssertionError(e);
         }
 

Added: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIModuleActivator.java?view=auto&rev=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIModuleActivator.java (added)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIModuleActivator.java Thu Apr 26 10:36:16 2007
@@ -0,0 +1,66 @@
+/*
+ * 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.binding.rmi;
+
+import java.util.Map;
+
+import org.apache.tuscany.binding.rmi.xml.RMIBindingProcessor;
+import org.apache.tuscany.contribution.processor.StAXArtifactProcessorExtensionPoint;
+import org.apache.tuscany.core.ExtensionPointRegistry;
+import org.apache.tuscany.core.ModuleActivator;
+import org.apache.tuscany.rmi.DefaultRMIHostExtensionPoint;
+import org.apache.tuscany.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+
+public class RMIModuleActivator implements ModuleActivator {
+
+    private RMIBindingBuilder builder;
+
+    public void start(ExtensionPointRegistry extensionPointRegistry) {
+
+        StAXArtifactProcessorExtensionPoint artifactProcessorRegistry = 
+            extensionPointRegistry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+        artifactProcessorRegistry.addExtension(new RMIBindingProcessor());
+
+        RMIHostExtensionPoint rmiHost = 
+            extensionPointRegistry.getExtensionPoint(RMIHostExtensionPoint.class);
+        if (rmiHost == null) {
+            rmiHost = new DefaultRMIHostExtensionPoint();
+        }
+        
+        BuilderRegistry builderRegistry = extensionPointRegistry.getExtensionPoint(BuilderRegistry.class);
+        builder = new RMIBindingBuilder();
+        builder.setBuilderRegistry(builderRegistry);
+        builder.setRmiHost(rmiHost);
+        builder.init();
+    }
+
+    public void stop(ExtensionPointRegistry registry) {
+        // release resources held by bindings
+        // needed because the stop methods in ReferenceImpl and ServiceImpl aren't being called
+        // TODO: revisit this as part of the lifecycle work
+        builder.destroy(); // release connections
+    }
+
+    public Map<Class, Object> getExtensionPoints() {
+        return null;
+    }
+
+}

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReferenceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReferenceBinding.java?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReferenceBinding.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReferenceBinding.java Thu Apr 26 10:36:16 2007
@@ -17,76 +17,55 @@
 package org.apache.tuscany.binding.rmi;
 
 import java.lang.reflect.Method;
+import java.net.URI;
 
 import javax.xml.namespace.QName;
 
-import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.interfacedef.java.JavaInterface;
+import org.apache.tuscany.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
 import org.apache.tuscany.spi.extension.ReferenceBindingExtension;
-import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.ServiceContract;
 import org.apache.tuscany.spi.wire.TargetInvoker;
 
-import org.apache.tuscany.host.rmi.RMIHost;
-
 /**
  * @version $Rev$ $Date$
  */
 public class RMIReferenceBinding extends ReferenceBindingExtension {
-    private static final QName BINDING_RMI = new QName(
-        "http://tuscany.apache.org/xmlns/binding/rmi/1.0-SNAPSHOT", "binding.rmi");
-
-    private final String host;
-
-    private final String port;
-
-    private final String svcName;
-
-    private RMIHost rmiHost;
-
-    public RMIReferenceBinding(String name,
-                               CompositeComponent parent,
-                               RMIHost rmiHost,
-                               String host,
-                               String port,
-                               String svcName) {
-        super(name, parent);
-        this.host = host;
-        this.port = port;
-        this.svcName = svcName;
+    private RMIHostExtensionPoint rmiHost;
+    
+    private RMIBinding rmiBindingDefn;
+    
+    public RMIReferenceBinding(URI name, 
+                               URI targetUri, 
+                               RMIBinding rmiBindingDefn, 
+                               RMIHostExtensionPoint rmiHost) {
+        super(name, targetUri);
+        this.rmiBindingDefn = rmiBindingDefn;
         this.rmiHost = rmiHost;
     }
 
-    public QName getBindingType() {
-        return BINDING_RMI;
-    }
+    public TargetInvoker createTargetInvoker(String targetName, 
+                                             Operation operation, 
+                                             boolean isCallback) throws TargetInvokerCreationException {
 
-    public TargetInvoker createTargetInvoker(ServiceContract contract, Operation operation) {
         try {
-            /*Remote proxy = getProxy();
-             Method remoteMethod = proxy.getClass().getMethod(operation.getName(),
-             (Class[]) operation.getParameterTypes());
-             return new RMIInvoker(proxy, remoteMethod);
-             */
-            Method method = findMethod(operation, contract.getInterfaceClass().getMethods());
-            Method remoteMethod =
-                getInboundWire().getServiceContract().getInterfaceClass().getMethod(operation.getName(), (Class[]) method.getParameterTypes());
-            return new RMIInvoker(rmiHost, host, port, svcName, remoteMethod);
+            Method remoteMethod = 
+                JavaInterfaceUtil.findMethod(((JavaInterface)wire.getTargetContract().getInterface()).getJavaClass(),
+                                                operation);
+            
+            return new RMIInvoker(rmiHost, 
+                                  rmiBindingDefn.getRmiHostName(), 
+                                  rmiBindingDefn.getRmiPort(), 
+                                  rmiBindingDefn.getRmiServiceName(), 
+                                  remoteMethod);
         } catch (NoSuchMethodException e) {
             throw new NoRemoteMethodException(operation.toString(), e);
         }
     }
 
-    /*protected Remote getProxy() {
-    try {
-    // todo do we need to cache this result?
-    return Naming.lookup(uri);
-    } catch (NotBoundException e) {
-    throw new NoRemoteServiceException(uri);
-    } catch (MalformedURLException e) {
-    throw new NoRemoteServiceException(uri);
-    } catch (RemoteException e) {
-    throw new NoRemoteServiceException(uri);
+    public QName getBindingType() {
+        return RMIBindingConstants.BINDING_RMI_QNAME;
     }
-    }*/
 }

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java Thu Apr 26 10:36:16 2007
@@ -16,12 +16,10 @@
  */
 package org.apache.tuscany.binding.rmi;
 
-import org.apache.tuscany.api.TuscanyRuntimeException;
 
 /**
- * @version $Rev$ $Date$
  */
-public abstract class RMIRuntimeException extends TuscanyRuntimeException {
+public abstract class RMIRuntimeException extends RuntimeException {
     protected RMIRuntimeException() {
     }
 

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIServiceBinding.java?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIServiceBinding.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIServiceBinding.java Thu Apr 26 10:36:16 2007
@@ -16,60 +16,64 @@
  */
 package org.apache.tuscany.binding.rmi;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.URI;
 import java.rmi.Remote;
 import java.rmi.server.UnicastRemoteObject;
-import javax.xml.namespace.QName;
 
-import org.apache.tuscany.spi.component.CompositeComponent;
-import org.apache.tuscany.spi.extension.ServiceBindingExtension;
-import org.apache.tuscany.spi.wire.WireService;
+import javax.xml.namespace.QName;
 
 import net.sf.cglib.asm.ClassWriter;
 import net.sf.cglib.asm.Constants;
 import net.sf.cglib.asm.Type;
 import net.sf.cglib.proxy.Enhancer;
-import org.apache.tuscany.host.rmi.RMIHost;
-import org.apache.tuscany.host.rmi.RMIHostException;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import org.apache.tuscany.core.component.SimpleWorkContext;
+import org.apache.tuscany.interfacedef.Interface;
+import org.apache.tuscany.interfacedef.Operation;
+import org.apache.tuscany.interfacedef.java.JavaInterface;
+import org.apache.tuscany.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.rmi.RMIHostException;
+import org.apache.tuscany.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.spi.Scope;
+import org.apache.tuscany.spi.bootstrap.ComponentNames;
+import org.apache.tuscany.spi.component.TargetInvokerCreationException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.component.WorkContextTunnel;
+import org.apache.tuscany.spi.extension.ServiceBindingExtension;
+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;
 
 /**
  * @version $Rev$ $Date$
  */
-public class RMIServiceBinding<T extends Remote> extends ServiceBindingExtension {
-    private static final QName BINDING_RMI = new QName(
-        "http://tuscany.apache.org/xmlns/binding/rmi/1.0-SNAPSHOT", "binding.rmi");
-
-    public static final String URI_PREFIX = "//localhost";
-    public static final String SLASH = "/";
-    public static final String COLON = ":";
-    //private final String host;
-    private final String port;
-    private final String serviceName;
-    private RMIHost rmiHost;
+public class RMIServiceBinding<T extends Remote> extends ServiceBindingExtension implements MethodInterceptor { 
+    private RMIBinding rmiBinding;
+    private RMIHostExtensionPoint rmiHost;
 
     // need this member to morph the service interface to extend from Remote if it does not
     // the base class's member variable interfaze is to be maintained to enable the connection
     // of the service outbound to the component's inbound wire which requires that the service
     // and the component match in their service contracts.
-    private Class serviceInterface;
-    private WireService wireService;
-
-    public RMIServiceBinding(String name,
-                             CompositeComponent parent,
-                             WireService wireService,
-                             RMIHost rHost,
-                             String host,
-                             String port,
-                             String svcName,
-                             Class<T> service) {
-        super(name, parent);
-
-        this.serviceInterface = service;
+    private Interface serviceInterface;
+    
+    public RMIServiceBinding(URI name,
+                             RMIBinding rmiBinding,
+                             RMIHostExtensionPoint rHost,
+                             Interface svcIfc) {
+        super(name);
+        //this.serviceInterface = service;
         this.rmiHost = rHost;
-        //this.host = host;
-        this.port = port;
-        this.serviceName = svcName;
-        this.wireService = wireService;
+        this.rmiBinding = rmiBinding;
+        this.serviceInterface = svcIfc;
+        
+        start(); // TODO: hack while start isn't getting called by runtime
     }
 
     public void start() {
@@ -77,11 +81,9 @@
         Remote rmiProxy = createRmiService();
 
         try {
-            // startRMIRegistry();
-            rmiHost.registerService(serviceName,
-                getPort(port),
-                rmiProxy);
-            // bindRmiService(uri,rmiProxy);
+            rmiHost.registerService(rmiBinding.getRmiServiceName(),
+                                    getPort(rmiBinding.getRmiPort()),
+                                    rmiProxy);
         } catch (RMIHostException e) {
             throw new NoRemoteServiceException(e);
         }
@@ -89,7 +91,8 @@
 
     public void stop() {
         try {
-            rmiHost.unregisterService(serviceName, getPort(port));
+            rmiHost.unregisterService(rmiBinding.getRmiServiceName(), 
+                                      getPort(rmiBinding.getRmiPort()));
         } catch (RMIHostException e) {
             throw new NoRemoteServiceException(e.getMessage());
         }
@@ -99,22 +102,21 @@
     protected Remote createRmiService() {
         Enhancer enhancer = new Enhancer();
         enhancer.setSuperclass(UnicastRemoteObject.class);
-        enhancer.setCallback(new RemoteMethodHandler(wireService.createHandler(serviceInterface, getInboundWire()),
-            serviceInterface));
-
-        if (!Remote.class.isAssignableFrom(serviceInterface)) {
+        enhancer.setCallback(this);
+        Class targetJavaInterface = getTargetJavaClass(serviceInterface);
+        if (!Remote.class.isAssignableFrom(targetJavaInterface)) {
             RMIServiceClassLoader classloader =
                 new RMIServiceClassLoader(getClass().getClassLoader());
-            final byte[] byteCode = generateRemoteInterface(serviceInterface);
-            serviceInterface = classloader.defineClass(byteCode);
+            final byte[] byteCode = generateRemoteInterface(targetJavaInterface);
+            targetJavaInterface = classloader.defineClass(byteCode);
             enhancer.setClassLoader(classloader);
         }
-        enhancer.setInterfaces(new Class[]{serviceInterface});
+        enhancer.setInterfaces(new Class[]{targetJavaInterface});
         return (Remote) enhancer.create();
     }
 
     protected int getPort(String port) {
-        int portNumber = RMIHost.RMI_DEFAULT_PORT;
+        int portNumber = RMIHostExtensionPoint.RMI_DEFAULT_PORT;
         if (port != null && port.length() > 0) {
             portNumber = Integer.decode(port);
         }
@@ -156,7 +158,7 @@
     }
 
     public QName getBindingType() {
-        return BINDING_RMI;
+        return RMIBindingConstants.BINDING_RMI_QNAME;
     }
 
     private class RMIServiceClassLoader extends ClassLoader {
@@ -168,4 +170,76 @@
             return defineClass(null, byteArray, 0, byteArray.length);
         }
     }
+    
+    public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
+        // since incoming method signatures have 'remotemethod invocation' it will not match with the
+        // wired component's method signatures. Hence need to pull in the corresponding method from the
+        // component's service contract interface to make this invocation.
+        
+        
+        return invokeTarget(JavaInterfaceUtil.findOperation(method, serviceInterface.getOperations()), 
+                                                            args);
+    }
+    
+    public Object invokeTarget(Operation op, 
+                               Object[] args) throws InvocationTargetException {
+        InvocationChain chain = null;
+        
+        for (InvocationChain ic : wire.getInvocationChains()) {
+            if (ic.getSourceOperation().equals(op)) {
+                chain = ic;
+            }
+        }
+        if (chain == null) {
+            throw new IllegalStateException("no InvocationChain on wire for operation " + op);
+        }
+        
+        Interceptor headInterceptor = chain.getHeadInterceptor();
+        WorkContext workContext = WorkContextTunnel.getThreadWorkContext();
+        if (workContext == null) {
+            workContext = new SimpleWorkContext();
+            workContext.setIdentifier(Scope.COMPOSITE, ComponentNames.TUSCANY_APPLICATION_ROOT.resolve("default"));
+            WorkContextTunnel.setThreadWorkContext(workContext);
+        }
+        
+        String oldConversationID = (String) workContext.getIdentifier(Scope.CONVERSATION);
+        
+        try {
+            if (headInterceptor == null) {
+                // short-circuit the dispatch and invoke the target directly
+                TargetInvoker targetInvoker = chain.getTargetInvoker();
+                if (targetInvoker == null) {
+                    throw new AssertionError("No target invoker [" + chain.getTargetOperation().getName() + "]");
+                }
+                return targetInvoker.invokeTarget(args, TargetInvoker.NONE, null);
+            } else {
+                Message msg = new MessageImpl();
+                msg.setTargetInvoker(chain.getTargetInvoker());
+                msg.setBody(args);
+                msg.setWorkContext(workContext);
+
+                Message resp;
+                // dispatch the wire down the chain and get the response
+                resp = headInterceptor.invoke(msg);
+                Object body = resp.getBody();
+                if (resp.isFault()) {
+                    throw new InvocationTargetException((Throwable) body);
+                }
+                return body;
+            }
+        } finally {
+        }
+    }
+    
+    private Class<?> getTargetJavaClass(Interface targetInterface) {
+        //TODO: right now assume that the target is always a Java Implementation.  Need to figure out
+        // how to generate Java Interface in cases where the target is not a Java Implementation
+        return ((JavaInterface)targetInterface).getJavaClass();
+    }
+    
+    public TargetInvoker createTargetInvoker(String targetName, Operation operation, boolean isCallback) throws TargetInvokerCreationException {
+        return null;
+    }
+
+
 }

Added: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/DefaultRMIBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/DefaultRMIBindingFactory.java?view=auto&rev=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/DefaultRMIBindingFactory.java (added)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/DefaultRMIBindingFactory.java Thu Apr 26 10:36:16 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.binding.rmi.impl;
+
+import org.apache.tuscany.binding.rmi.RMIBinding;
+import org.apache.tuscany.binding.rmi.RMIBindingFactory;
+
+/**
+ * A factory for the WSDL model.
+ * 
+ * @version $Rev: 526508 $ $Date: 2007-04-08 07:42:42 +0530 (Sun, 08 Apr 2007) $
+ */
+public class DefaultRMIBindingFactory implements RMIBindingFactory {
+
+    public RMIBinding createWebServiceBinding() {
+        return new RMIBindingImpl();
+    }
+
+}

Added: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/RMIBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/RMIBindingImpl.java?view=auto&rev=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/RMIBindingImpl.java (added)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/impl/RMIBindingImpl.java Thu Apr 26 10:36:16 2007
@@ -0,0 +1,91 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  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.
+ */
+package org.apache.tuscany.binding.rmi.impl;
+
+import org.apache.tuscany.assembly.impl.BindingImpl;
+import org.apache.tuscany.binding.rmi.RMIBinding;
+import org.apache.tuscany.binding.rmi.RMIBindingConstants;
+
+/**
+ * Represents a binding to an RMI service.
+ *
+ * @version $Rev: 490475 $ $Date: 2006-12-27 15:53:42 +0530 (Wed, 27 Dec 2006) $
+ */
+public class RMIBindingImpl extends BindingImpl implements RMIBinding, RMIBindingConstants {
+    private String host;
+
+    private String port;
+
+    private String serviceName;
+
+    public String getURI() {
+        return host + COLON + port + serviceName;
+    }
+
+    public String getRmiHostName() {
+        if (host == null) {
+            extractFromUri();
+        }
+        return host;
+    }
+
+    public void setRmiHostName(String host) {
+        this.host = host;
+    }
+
+    public String getRmiPort() {
+        if (port == null) {
+            extractFromUri();
+        }
+        return port;
+    }
+
+    public void setRmiPort(String port) {
+        this.port = port;
+    }
+
+    public String getRmiServiceName() {
+        if (serviceName == null) {
+            extractFromUri();
+        }
+        return serviceName;
+    }
+
+    public void setRmiServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+    
+    private void extractFromUri() {
+        if (getURI() != null && getURI().length() > 0) {
+            int colonIndex = getURI().indexOf(COLON);
+            if (colonIndex != -1) {
+                setRmiHostName(getURI().substring(0, colonIndex));
+                setRmiPort(getURI().substring(colonIndex + 1));
+            } 
+            
+            int slashIndex = getURI().indexOf(FWD_SLASH);
+            if (slashIndex != -1) {
+                if (colonIndex == -1) {
+                    setRmiHostName(getURI().substring(0, slashIndex));
+                }
+                setRmiServiceName(getURI().substring(slashIndex + 1));
+            } else {
+                setRmiServiceName(getURI());
+            }
+        }
+    }
+}

Added: incubator/tuscany/java/sca/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator?view=auto&rev=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator (added)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.core.ModuleActivator Thu Apr 26 10:36:16 2007
@@ -0,0 +1,2 @@
+# Implementation class for the ExtensionActivator
+org.apache.tuscany.binding.rmi.RMIModuleActivator

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/helloworld/HelloWorldImpl.java Thu Apr 26 10:36:16 2007
@@ -20,6 +20,7 @@
 
 import org.osoa.sca.annotations.Service;
 
+
 /**
  * This class implements the HelloWorld service.
  */

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java Thu Apr 26 10:36:16 2007
@@ -18,33 +18,39 @@
  */
 package org.apache.tuscany.binding.rmi;
 
-import junit.framework.TestCase;
+import helloworld.HelloWorldRmiService;
+import junit.framework.Assert;
 
-// TODO: renamed to XXX as it doesn't work for me
-public class BindingTestCase extends TestCase {
-//    private HelloWorldRmiService helloWorldRmiService;
+import org.apache.tuscany.host.embedded.SCARuntime;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class BindingTestCase {
+    private static HelloWorldRmiService helloWorldRmiService;
  
+    @Test
     public void testRmiService() {
-//        System.out.println(helloWorldRmiService.sayRmiHello("Tuscany World!"));
-//        assertEquals("Hello from the RMI Service to - Tuscany World! thro the RMI Reference",
-//                helloWorldRmiService.sayRmiHello("Tuscany World!"));
+        System.out.println(helloWorldRmiService.sayRmiHello("Tuscany World!"));
+        Assert.assertEquals("Hello from the RMI Service to - Tuscany World! thro the RMI Reference",
+                helloWorldRmiService.sayRmiHello("Tuscany World!"));
     }
 
-//    protected void setUp() throws Exception {
-//        addExtension("rmi.binding",
-//                     getClass().getClassLoader().getResource("META-INF/sca/rmi_extension.scdl"));
-//        setApplicationSCDL(getClass().getClassLoader().getResource("META-INF/sca/default.scdl"));
-//
-//        super.setUp();
-//
-//        CompositeContext context = CurrentCompositeContext.getContext();
-//        helloWorldRmiService = context.locateService(HelloWorldRmiService.class,
-//                                                     "HelloWorldRmiServiceComponent");
-//    }
-
 
-//    protected void tearDown() throws Exception {
-//        super.tearDown();
-//    }
+    
+    @BeforeClass
+    public static void init() throws Exception {
+        SCARuntime.start("META-INF/sca/RMIBindingTest.composite");
+        helloWorldRmiService = 
+            CurrentCompositeContext.getContext().locateService(HelloWorldRmiService.class,
+                                                                "HelloWorldRmiServiceComponent");
+       
+    }
+    
+    @AfterClass
+    public static void destroy() throws Exception {
+        SCARuntime.stop();
+    }
 
 }

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldImpl.componentType?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldImpl.componentType (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldImpl.componentType Thu Apr 26 10:36:16 2007
@@ -16,11 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.    
 -->
-
-<?xml version="1.0" encoding="ASCII"?>
-
 <componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
     <service name="HelloWorldService">
         <interface.java interface="helloworld.HelloWorldService"/>
     </service>

Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldRmiImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldRmiImpl.componentType?view=diff&rev=532812&r1=532811&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldRmiImpl.componentType (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/HelloWorldRmiImpl.componentType Thu Apr 26 10:36:16 2007
@@ -16,8 +16,6 @@
  * specific language governing permissions and limitations
  * under the License.    
 -->
-<?xml version="1.0" encoding="ASCII"?>
-
 <componentType xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 
     <service name="HelloWorldRmiService">

Copied: incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/RMIBindingTest.composite (from r532247, incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/default.scdl)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/RMIBindingTest.composite?view=diff&rev=532812&p1=incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/default.scdl&r1=532247&p2=incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/RMIBindingTest.composite&r2=532812
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/default.scdl (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/test/resources/META-INF/sca/RMIBindingTest.composite Thu Apr 26 10:36:16 2007
@@ -21,10 +21,10 @@
            xmlns:rmi="http://tuscany.apache.org/xmlns/binding/rmi/1.0-SNAPSHOT"
            name="HelloWorldRmiComposite">
 
-	<service name="HelloWorldRmiService" target="HelloWorldServiceComponent">
+	<service name="HelloWorldRmiService" promote="HelloWorldServiceComponent">
         <interface.java interface="helloworld.HelloWorldService"/>
-        <rmi:binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService"   />
-        <reference>HelloWorldServiceComponent</reference>
+        <binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService"   />
+        <reference target="HelloWorldServiceComponent">HelloWorldServiceComponent</reference>
     </service>
       
     <component name="HelloWorldServiceComponent">
@@ -33,12 +33,12 @@
   
    <component name="HelloWorldRmiServiceComponent">
         <implementation.java class="helloworld.HelloWorldRmiImpl"/>
-        <reference name="extService" target="HelloWorldRmiReference">HelloWorldRmiReference</reference>
+        <reference name="extService"></reference>
     </component>        
            
-  	<reference name="HelloWorldRmiReference" target="Nothing">
+  	<reference name="HelloWorldRmiReference" promote="HelloWorldRmiServiceComponent/extService">
         <interface.java interface="helloworld.HelloWorldService"/>
-        <rmi:binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService"   />
+        <binding.rmi host="localhost" port="8099" serviceName="HelloWorldRemoteService"   />
     </reference>
 
 </composite>



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


Mime
View raw message