You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2008/10/17 23:49:45 UTC

svn commit: r705766 - in /tuscany/branches/sca-equinox/modules/binding-rmi/src/main: java/org/apache/tuscany/sca/binding/rmi/ java/org/apache/tuscany/sca/binding/rmi/impl/ resources/META-INF/services/

Author: lresende
Date: Fri Oct 17 14:49:44 2008
New Revision: 705766

URL: http://svn.apache.org/viewvc?rev=705766&view=rev
Log:
Updating RMI model to follow interface/factory pattern.

Added:
    tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java   (with props)
    tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/
    tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java   (with props)
    tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java   (with props)
    tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory
Modified:
    tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java
    tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor

Modified: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java?rev=705766&r1=705765&r2=705766&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java (original)
+++ tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java Fri Oct 17 14:49:44 2008
@@ -16,48 +16,48 @@
  * specific language governing permissions and limitations
  * under the License.    
  */
+
 package org.apache.tuscany.sca.binding.rmi;
 
 import org.apache.tuscany.sca.assembly.Binding;
 
 /**
- * Represents a binding to an RMI service.
- *
+ * RMI Binding model
+ * 
  * @version $Rev$ $Date$
  */
-public class RMIBinding implements Binding {
+public interface RMIBinding extends Binding {
 
-    private String uri;
-    private String name;
+    /**
+     * @return the host name of the RMI Service
+     */
+    String getHost();
+
+    /**
+     * @return the port number for the RMI Service
+     */
+    String getPort();
+
+    /**
+     * @return returns the RMI Service Name
+     */
+    String getServiceName();
+
+    /**
+     * @param rmiHostName the hostname of the RMI Service
+     */
+    void setHost(String rmiHostName);
+
+    /**
+     * @param rmiPort the port number for the RMI Service
+     */
+    void setPort(String rmiPort);
+
+    /**
+     * Sets the service name for the RMI Server
+     * 
+     * @param rmiServiceName the name of the RMI service
+     */
+    void setServiceName(String rmiServiceName);
 
-    public String getURI() {
-        return uri;
-    }
-    
-    public void setURI(String uri) {
-        this.uri = uri;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-    
-    public String getName() {
-        return name;
-    }
-
-    public boolean isUnresolved() {
-        // The binding is always resolved
-        return false;
-    }
-
-    public void setUnresolved(boolean unresolved) {
-        // The binding is always resolved
-    }
-
-    @Override
-    public Object clone() throws CloneNotSupportedException {
-        // TODO Auto-generated method stub
-        return super.clone();
-    }
 }

Added: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java?rev=705766&view=auto
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java (added)
+++ tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java Fri Oct 17 14:49:44 2008
@@ -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.sca.binding.rmi;
+
+/**
+ * Factory to create RMIBinding instances
+ * 
+ * @version $Rev$ $Date$
+ */
+public interface RMIBindingFactory {
+    /**
+     * Create RMIBinding model
+     * @return
+     */
+    RMIBinding createRMIBinding();
+}

Propchange: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java?rev=705766&view=auto
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java (added)
+++ tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java Fri Oct 17 14:49:44 2008
@@ -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.sca.binding.rmi.impl;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+import org.apache.tuscany.sca.binding.rmi.RMIBindingFactory;
+
+/**
+ * Factory implementation to create RMI Models
+ * 
+ * @version $Rev$ $Date$
+ */
+public class RMIBindingFactoryImpl implements RMIBindingFactory {
+    public RMIBinding createRMIBinding() {
+        // TODO Auto-generated method stub
+        return new RMIBindingImpl();
+    }
+
+}

Propchange: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java?rev=705766&view=auto
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java (added)
+++ tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java Fri Oct 17 14:49:44 2008
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.binding.rmi.impl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.tuscany.sca.binding.rmi.RMIBinding;
+
+/**
+ * Represents a binding to an RMI service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RMIBindingImpl implements RMIBinding {
+    private String name;
+    private String uri;
+    private String host;
+    private String port;
+    private String serviceName;
+
+    /**
+     * @return the host name of the RMI Service
+     */
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * @param rmiHostName the hostname of the RMI Service
+     */
+    public void setHost(String rmiHostName) {
+        this.host = rmiHostName;
+    }
+
+    /**
+     * @return the port number for the RMI Service
+     */
+    public String getPort() {
+        return port;
+    }
+
+    /**
+     * @param rmiPort the port number for the RMI Service
+     */
+    public void setPort(String rmiPort) {
+        this.port = rmiPort;
+    }
+
+    /**
+     * @return returns the RMI Service Name
+     */
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    /**
+     * Sets the service name for the RMI Server
+     * 
+     * @param rmiServiceName the name of the RMI service
+     */
+    public void setServiceName(String rmiServiceName) {
+        this.serviceName = rmiServiceName;
+    }
+    
+    public String getName() {
+        return name;
+    }
+
+    public String getURI() {
+        compose();
+        return uri;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setURI(String uri) {
+        this.uri = uri;
+        parse(uri);
+    }
+
+    
+    public boolean isUnresolved() {
+        return false;
+    }
+
+    public void setUnresolved(boolean unresolved) {
+        // The sample binding is always resolved
+    }
+
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }     
+    
+    /*
+    rmi://[host][:port][/[object]]
+    rmi:[/][object]
+    */
+    private void parse(String uriStr) {
+        if (uriStr == null) {
+            return;
+        }
+        URI uri = URI.create(uriStr);
+        if (host == null) {
+            this.host = uri.getHost();
+        }
+        if (port == null) {
+            this.port = String.valueOf(uri.getPort());
+        }
+        if (serviceName == null) {
+            String path = uri.getPath();
+            if (path != null && path.charAt(0) == '/') {
+                path = path.substring(1);
+            }
+            this.serviceName = path;
+        }
+    }
+    
+    private void compose() {
+        if (uri == null) {
+            int p = -1;
+            if (port != null && port.length() > 0) {
+                p = Integer.decode(port);
+            }
+            String path = serviceName;
+            if (path != null) {
+                path = "/" + path;
+            }
+            try {
+                uri = new URI("rmi", null, host, p, path, null, null).toString();
+            } catch (URISyntaxException e) {
+                throw new IllegalArgumentException(e);
+            }
+        }
+    }
+
+
+}

Propchange: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory?rev=705766&view=auto
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory (added)
+++ tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory Fri Oct 17 14:49:44 2008
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License. 
+
+# Implementation class for model factory
+org.apache.tuscany.sca.binding.rmi.impl.RMIBindingFactoryImpl

Modified: tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: http://svn.apache.org/viewvc/tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=705766&r1=705765&r2=705766&view=diff
==============================================================================
--- tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (original)
+++ tuscany/branches/sca-equinox/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Fri Oct 17 14:49:44 2008
@@ -16,4 +16,4 @@
 # under the License. 
 
 # Implementation class for the artifact processor extension
-org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.rmi,model=org.apache.tuscany.sca.binding.rmi.RMIBinding
+org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#binding.rmi,model=org.apache.tuscany.sca.binding.rmi.RMIBinding,factory=org.apache.tuscany.sca.binding.rmi.RMIBindingFactory