You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2006/08/25 13:08:51 UTC
svn commit: r436755 [1/2] - in
/incubator/tuscany/java/sca/bindings/binding.rmi: ./
src/main/java/org/apache/tuscany/binding/rmi/
src/main/resources/META-INF/sca/ src/test/ src/test/java/
src/test/java/helloworld/ src/test/java/org/ src/test/java/org/a...
Author: antelder
Date: Fri Aug 25 04:08:48 2006
New Revision: 436755
URL: http://svn.apache.org/viewvc?rev=436755&view=rev
Log:
TUSCANY-611, Venkats latest fixes to the RMI binding
Added:
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIHostImpl.java (with props)
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java (with props)
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java (with props)
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java (with props)
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java (with props)
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java (with props)
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/META-INF/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/META-INF/LICENSE.txt (with props)
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/META-INF/NOTICE
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/META-INF/sca/
incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/META-INF/sca/default.scdl (with props)
Modified:
incubator/tuscany/java/sca/bindings/binding.rmi/pom.xml
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl
incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/pom.xml?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/pom.xml (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/pom.xml Fri Aug 25 04:08:48 2006
@@ -1,22 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
+ * Copyright (c) 2005-2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
@@ -44,6 +41,18 @@
<artifactId>spi</artifactId>
<version>${sca.version}</version>
<scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>api</artifactId>
+ <version>${sca.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany</groupId>
+ <artifactId>test</artifactId>
+ <version>${sca.version}</version>
+ <scope>test</scope>
</dependency>
</dependencies>
</project>
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteMethodException.java Fri Aug 25 04:08:48 2006
@@ -1,20 +1,18 @@
-/*
- * 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.
+/**
+ *
+ * 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;
@@ -22,7 +20,7 @@
* @version $Rev$ $Date$
*/
public class NoRemoteMethodException extends RMIRuntimeException {
- public NoRemoteMethodException() {
+ public NoRemoteMethodException() {
}
public NoRemoteMethodException(String message) {
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/NoRemoteServiceException.java Fri Aug 25 04:08:48 2006
@@ -1,20 +1,18 @@
-/*
- * 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.
+/**
+ *
+ * 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;
@@ -22,7 +20,7 @@
* @version $Rev$ $Date$
*/
public class NoRemoteServiceException extends RMIRuntimeException {
- public NoRemoteServiceException() {
+ public NoRemoteServiceException() {
}
public NoRemoteServiceException(String message) {
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBinding.java Fri Aug 25 04:08:48 2006
@@ -1,20 +1,18 @@
-/*
- * 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.
+/**
+ *
+ * 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;
@@ -26,13 +24,34 @@
* @version $Rev$ $Date$
*/
public class RMIBinding extends Binding {
- private String uri;
+ private String host;
+
+ private String port;
+
+ private String serviceName;
+
+ public String getHost() {
+ return host;
+ }
- public String getURI() {
- return uri;
+ public void setHost(String host) {
+ this.host = host;
}
- public void setURI(String uri) {
- this.uri = uri;
+ public String getPort() {
+ return port;
}
+
+ public void setPort(String port) {
+ this.port = port;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
}
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingBuilder.java Fri Aug 25 04:08:48 2006
@@ -1,74 +1,81 @@
-/*
- * 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.
+/**
+ *
+ * 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 java.rmi.Remote;
-import org.apache.tuscany.spi.builder.InvalidServiceInterfaceException;
+import org.apache.tuscany.spi.annotation.Autowire;
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.component.SCAObject;
import org.apache.tuscany.spi.deployer.DeploymentContext;
import org.apache.tuscany.spi.extension.BindingBuilderExtension;
+import org.apache.tuscany.spi.host.RMIHost;
import org.apache.tuscany.spi.model.BoundReferenceDefinition;
import org.apache.tuscany.spi.model.BoundServiceDefinition;
+import org.osoa.sca.annotations.Constructor;
/**
* Builds a Service or Reference for an RMI binding.
- *
+ *
* @version $Rev$ $Date$
*/
+
public class RMIBindingBuilder extends BindingBuilderExtension<RMIBinding> {
+
+ private RMIHost rmiHost;
+
+ @Constructor({"rmiHost"})
+ public RMIBindingBuilder(@Autowire RMIHost rHost) {
+ this.rmiHost = rHost;
+ }
+
protected Class<RMIBinding> getBindingType() {
return RMIBinding.class;
}
+ @SuppressWarnings({"unchecked"})
public SCAObject build(CompositeComponent parent,
BoundServiceDefinition<RMIBinding> boundServiceDefinition,
DeploymentContext deploymentContext) {
+
String name = boundServiceDefinition.getName();
- Class<Remote> service = getServiceInterface(boundServiceDefinition);
- String uri = boundServiceDefinition.getBinding().getURI();
+ Class intf = boundServiceDefinition.getServiceContract().getInterfaceClass();
+ String host = boundServiceDefinition.getBinding().getHost();
- RMIService rmiService = new RMIService<Remote>(name, parent, wireService, uri, service);
+ RMIService rmiService = new RMIService<Remote>(boundServiceDefinition.getName(), parent, wireService, rmiHost,
+ boundServiceDefinition.getBinding().getHost(), boundServiceDefinition.getBinding().getPort(),
+ boundServiceDefinition.getBinding().getServiceName(), intf);
return rmiService;
}
@SuppressWarnings({"unchecked"})
- protected Class<Remote> getServiceInterface(BoundServiceDefinition<RMIBinding> boundServiceDefinition) {
- Class<?> intf = boundServiceDefinition.getServiceContract().getInterfaceClass();
- if (!Remote.class.isAssignableFrom(intf)) {
- throw new InvalidServiceInterfaceException("RMI requires interface extend Remote", intf);
- }
- return (Class<Remote>) intf;
- }
-
- @SuppressWarnings({"unchecked"})
public RMIReference build(CompositeComponent parent,
BoundReferenceDefinition<RMIBinding> boundReferenceDefinition,
DeploymentContext deploymentContext) {
String name = boundReferenceDefinition.getName();
- String uri = boundReferenceDefinition.getBinding().getURI();
- Class<?> interfaze = boundReferenceDefinition.getServiceContract().getInterfaceClass();
- RMIReference rmiReference = new RMIReference(name, parent, wireService, uri, boundReferenceDefinition
- .getServiceContract().getInterfaceClass());
+ String host = boundReferenceDefinition.getBinding().getHost();
+ String port = boundReferenceDefinition.getBinding().getPort();
+ String svcName = boundReferenceDefinition.getBinding().getServiceName();
+ // Class<?> interfaze = boundReferenceDefinition.getServiceContract().getInterfaceClass();
+ RMIReference rmiReference = new RMIReference(name, parent, wireService, rmiHost, host, port, svcName,
+ boundReferenceDefinition.getServiceContract().getInterfaceClass());
return rmiReference;
}
+
}
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingLoader.java Fri Aug 25 04:08:48 2006
@@ -1,20 +1,18 @@
-/*
- * 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.
+/**
+ *
+ * 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;
@@ -38,11 +36,11 @@
*/
@Scope("MODULE")
public class RMIBindingLoader extends LoaderExtension<RMIBinding> {
- public static final QName BINDING_RMI =
- new QName("http://tuscany.apache.org/xmlns/binding/rmi/1.0-SNAPSHOT",
- "binding.rmi");
+ public static final QName BINDING_RMI = new QName(
+ "http://tuscany.apache.org/xmlns/binding/rmi/1.0-SNAPSHOT", "binding.rmi");
- public RMIBindingLoader(@Autowire LoaderRegistry registry) {
+ public RMIBindingLoader(@Autowire
+ LoaderRegistry registry) {
super(registry);
}
@@ -50,16 +48,23 @@
return BINDING_RMI;
}
- public RMIBinding load(CompositeComponent parent,
- XMLStreamReader reader,
+ public RMIBinding load(CompositeComponent parent,
+ XMLStreamReader reader,
DeploymentContext deploymentContext) throws XMLStreamException,
- LoaderException {
- String uri = reader.getAttributeValue(null,
- "uri");
+ LoaderException {
+ String host = reader.getAttributeValue(null,
+ "host");
+ String port = reader.getAttributeValue(null,
+ "port");
+ String svcName = reader.getAttributeValue(null,
+ "serviceName");
+
LoaderUtil.skipToEndElement(reader);
RMIBinding binding = new RMIBinding();
- binding.setURI(uri);
+ binding.setHost(host);
+ binding.setPort(port);
+ binding.setServiceName(svcName);
return binding;
}
}
Added: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIHostImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIHostImpl.java?rev=436755&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIHostImpl.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIHostImpl.java Fri Aug 25 04:08:48 2006
@@ -0,0 +1,120 @@
+/**
+ *
+ * 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 java.rmi.AlreadyBoundException;
+import java.rmi.RMISecurityManager;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Hashtable;
+
+import org.apache.tuscany.spi.host.RMIHost;
+import org.apache.tuscany.spi.host.RemoteServiceException;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * This class provides an implementation for the RMI Host SPIs
+ */
+@Scope("MODULE")
+public class RMIHostImpl implements RMIHost {
+
+ // map of RMI registries started and running
+ private Hashtable<String, Registry> rmiRegistries;
+
+ public RMIHostImpl() {
+ rmiRegistries = new Hashtable<String, Registry>();
+ /*if (System.getSecurityManager() == null) {
+ System.setSecurityManager(new RMISecurityManager());
+ }*/
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+ public void registerService(String serviceName, int port, Remote serviceObject) throws RemoteServiceException {
+ Registry registry = null;
+
+ try {
+ if ((registry = rmiRegistries.get(Integer.toString(port))) == null) {
+ registry = LocateRegistry.createRegistry(port);
+ rmiRegistries.put(Integer.toString(port),
+ registry);
+ }
+ registry.bind(serviceName,
+ serviceObject);
+ } catch (AlreadyBoundException e) {
+ throw new RemoteServiceException(e);
+ } catch (RemoteException e) {
+ throw new RemoteServiceException(e);
+ }
+
+ }
+
+ public void registerService(String serviceName, Remote serviceObject) throws RemoteServiceException {
+ registerService(serviceName,
+ RMI_DEFAULT_PORT,
+ serviceObject);
+ }
+
+ public void unregisterService(String serviceName, int port) throws RemoteServiceException {
+ Registry registry = null;
+
+ try {
+ if ((registry = rmiRegistries.get(Integer.toString(port))) == null) {
+ registry = LocateRegistry.createRegistry(port);
+ rmiRegistries.put(Integer.toString(port),
+ registry);
+ }
+ registry.unbind(serviceName);
+ } catch (Exception e) {
+ throw new RemoteServiceException(e);
+ }
+
+ }
+
+ public void unregisterService(String serviceName) throws RemoteServiceException {
+ unregisterService(serviceName,
+ RMI_DEFAULT_PORT);
+
+ }
+
+ public Remote findService(String host, String port, String svcName) throws RemoteServiceException {
+ Registry registry = null;
+ Remote remoteService = null;
+ host = (host == null || host.length() <= 0) ? "localhost" : host;
+ int portNumber = (port == null || port.length() <= 0) ? RMI_DEFAULT_PORT : Integer.decode(port).intValue();
+
+ try {
+
+ registry = LocateRegistry.getRegistry(host,
+ portNumber);
+
+ if (registry != null) {
+ remoteService = registry.lookup(svcName);
+ }
+ } catch (Exception e) {
+ throw new RemoteServiceException(e);
+ }
+
+ return remoteService;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIHostImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIHostImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIInvoker.java Fri Aug 25 04:08:48 2006
@@ -1,20 +1,18 @@
-/*
- * 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.
+/**
+ *
+ * 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;
@@ -22,6 +20,8 @@
import java.lang.reflect.Method;
import java.rmi.Remote;
+import org.apache.tuscany.spi.host.RMIHost;
+import org.apache.tuscany.spi.host.RemoteServiceException;
import org.apache.tuscany.spi.wire.InvocationRuntimeException;
import org.apache.tuscany.spi.wire.Message;
import org.apache.tuscany.spi.wire.TargetInvoker;
@@ -32,14 +32,40 @@
* @version $Rev$ $Date$
*/
public class RMIInvoker implements TargetInvoker {
- private final Method remoteMethod;
+ private Method remoteMethod;
+
+ private String host;
+
+ private String port;
- private final Remote proxy;
+ private String svcName;
- public RMIInvoker(Remote proxy, Method remoteMethod) {
- assert remoteMethod.isAccessible();
+ private RMIHost rmiHost;
+
+ private Remote proxy;
+
+ /*@Constructor({"rmiHost", "host", "port", "svnName", "remoteMethod"})
+ public RMIInvoker(@Autowire
+ RMIHost rmiHost, @Autowire
+ String host, @Autowire
+ String port, @Autowire
+ String svcName, @Autowire
+ Method remoteMethod) {
+ // assert remoteMethod.isAccessible();
+ this.remoteMethod = remoteMethod;
+ this.host = host;
+ this.port = port;
+ this.svcName = svcName;
+ this.rmiHost = rmiHost;
+ }*/
+
+ public RMIInvoker(RMIHost rmiHost, String host, String port, String svcName, Method remoteMethod) {
+ // assert remoteMethod.isAccessible();
this.remoteMethod = remoteMethod;
- this.proxy = proxy;
+ this.host = host;
+ this.port = port;
+ this.svcName = svcName;
+ this.rmiHost = rmiHost;
}
public Message invoke(Message msg) throws InvocationRuntimeException {
@@ -54,12 +80,22 @@
public Object invokeTarget(Object payload) throws InvocationTargetException {
try {
+ if (proxy == null) {
+ proxy = rmiHost.findService(host,
+ port,
+ svcName);
+ // proxy = Naming.lookup(serviceURI);
+ }
return remoteMethod.invoke(proxy,
(Object[]) payload);
+ } catch (RemoteServiceException 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);
}
+
}
public Object clone() throws CloneNotSupportedException {
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIReference.java Fri Aug 25 04:08:48 2006
@@ -1,32 +1,26 @@
-/*
- * 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.
+/**
+ *
+ * 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 java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.rmi.Naming;
-import java.rmi.NotBoundException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.extension.ReferenceExtension;
+import org.apache.tuscany.spi.host.RMIHost;
import org.apache.tuscany.spi.wire.TargetInvoker;
import org.apache.tuscany.spi.wire.WireService;
@@ -34,39 +28,55 @@
* @version $Rev$ $Date$
*/
public class RMIReference<T> extends ReferenceExtension<T> {
- private final String uri;
+ private final String host;
+
+ private final String port;
+
+ private final String svcName;
+
+ private RMIHost rmiHost;
- public RMIReference(String name,
- CompositeComponent<?> parent,
- WireService wireService,
- String uri,
+ public RMIReference(String name,
+ CompositeComponent<?> parent,
+ WireService wireService,
+ RMIHost rmiHost,
+ String host,
+ String port,
+ String svcName,
Class<T> service) {
super(name, service, parent, wireService);
setInterface(service);
- this.uri = uri;
+ this.host = host;
+ this.port = port;
+ this.svcName = svcName;
+ this.rmiHost = rmiHost;
}
public TargetInvoker createTargetInvoker(Method operation) {
try {
- Remote proxy = getProxy();
- Method remoteMethod = proxy.getClass().getMethod(operation.getName(),
- operation.getParameterTypes());
- return new RMIInvoker(proxy, remoteMethod);
+ /*Remote proxy = getProxy();
+ Method remoteMethod = proxy.getClass().getMethod(operation.getName(),
+ (Class[]) operation.getParameterTypes());
+ return new RMIInvoker(proxy, remoteMethod);
+ */
+ Method remoteMethod = getInterface().getMethod(operation.getName(),
+ (Class[]) operation.getParameterTypes());
+ return new RMIInvoker(rmiHost, host, port, svcName, 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);
- }
- }
+ 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);
+ }
+ }*/
}
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIRuntimeException.java Fri Aug 25 04:08:48 2006
@@ -1,20 +1,18 @@
-/*
- * 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.
+/**
+ *
+ * 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;
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIService.java Fri Aug 25 04:08:48 2006
@@ -1,37 +1,34 @@
-/*
- * 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.
+/**
+ *
+ * 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 java.net.MalformedURLException;
-import java.rmi.AlreadyBoundException;
-import java.rmi.Naming;
-import java.rmi.NotBoundException;
+import java.lang.reflect.Method;
import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
+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.spi.component.CompositeComponent;
import org.apache.tuscany.spi.extension.ServiceExtension;
+import org.apache.tuscany.spi.host.RMIHost;
+import org.apache.tuscany.spi.host.RemoteServiceException;
import org.apache.tuscany.spi.wire.WireService;
/**
@@ -41,52 +38,60 @@
public static final String URI_PREFIX = "//localhost";
public static final String SLASH = "/";
-
+
public static final String COLON = ":";
- private final String uri;
+ private final String host;
+
+ private final String port;
- private Class service;
+ private final String serviceName;
- private int rmiPort = 1099;
+ private RMIHost rmiHost;
- public RMIService(String name,
- CompositeComponent parent,
- WireService wireService,
- String uri,
+ // 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;
+
+ public RMIService(String name,
+ CompositeComponent parent,
+ WireService wireService,
+ RMIHost rHost,
+ String host,
+ String port,
+ String svcName,
Class<T> service) {
super(name, service, parent, wireService);
- this.uri = uri;
- this.service = service;
+
+ this.serviceInterface = service;
+ this.rmiHost = rHost;
+ this.host = host;
+ this.port = port;
+ this.serviceName = svcName;
}
public void start() {
super.start();
- Remote rmiProxy = createProxy();//createRmiService();
+ Remote rmiProxy = createRmiService();
try {
- startRMIRegistry();
- bindRmiService(uri,
- rmiProxy);
-
- } catch (AlreadyBoundException e) {
+ // startRMIRegistry();
+ rmiHost.registerService(serviceName,
+ getPort(port),
+ rmiProxy);
+ // bindRmiService(uri,rmiProxy);
+ } catch (RemoteServiceException e) {
throw new NoRemoteServiceException(e);
- } catch (RemoteException e) {
- throw new NoRemoteServiceException(e);
- } catch (MalformedURLException e) {
- throw new AssertionError(e);
}
}
public void stop() {
try {
- Naming.unbind(uri);
- } catch (NotBoundException e) {
- // ignore
- } catch (RemoteException e) {
+ rmiHost.unregisterService(serviceName);
+ } catch (RemoteServiceException e) {
throw new NoRemoteServiceException(e.getMessage());
- } catch (MalformedURLException e) {
- throw new AssertionError(e);
}
super.stop();
}
@@ -94,62 +99,75 @@
private Remote createRmiService() {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(UnicastRemoteObject.class);
- //Class remoteIfc = RemoteInterfaceGenerator.generateRemoteInterface(serviceInterface, cl);
- enhancer.setInterfaces(new Class[]{service});
- enhancer.setCallback(new RemoteMethodHandler(getHandler()));
+ enhancer.setCallback(new RemoteMethodHandler(getHandler(), interfaze));
+ if (!Remote.class.isAssignableFrom(serviceInterface)) {
+ RMIServiceClassLoader classloader = new RMIServiceClassLoader();
+ final byte[] byteCode = generateRemoteInterface(serviceInterface);
+ serviceInterface = classloader.defineClass(byteCode);
+ enhancer.setClassLoader(classloader);
+ }
+ enhancer.setInterfaces(new Class[]{serviceInterface});
return (Remote) enhancer.create();
}
- private void bindRmiService(String uri, Remote rmiService) throws MalformedURLException,
- RemoteException,
- AlreadyBoundException {
- StringBuffer serverUri = new StringBuffer(URI_PREFIX);
-
- serverUri.append(COLON);
- serverUri.append(rmiPort);
- serverUri.append(SLASH);
- serverUri.append(uri);
-
- Naming.bind(uri.toString(),
- rmiService);
- System.out.println("RMI srevice started - " + uri.toString());
-
- }
-
- //how will you stop the registry... no APIs for that...
- private void startRMIRegistry() throws RemoteException {
- try {
- Registry registry = LocateRegistry.createRegistry(rmiPort);
- } catch (Exception e) {
- LocateRegistry.getRegistry(rmiPort);
+ private int getPort(String port) {
+ int portNumber = RMIHost.RMI_DEFAULT_PORT;
+ if (port != null && port.length() > 0) {
+ portNumber = Integer.decode(port).intValue();
}
- }
- protected T createProxy() {
- //InvocationHandler handler = new RMIInvocationHandler(getHandler());
- return interfaze.cast(createRmiService());
+ return portNumber;
}
- /*protected Remote createProxy()
- {
- =======
- protected T createProxy() {
- >>>>>>> .r429120
- InvocationHandler handler = new RMIInvocationHandler(getHandler());
- return interfaze.cast(Proxy.newProxyInstance(interfaze.getClassLoader(), new Class[]{interfaze}, handler));
- }
+ // if the interface of the component whose services must be exposed as RMI Service, does not
+ // implement java.rmi.Remote, then generate such an interface. This method will stop with
+ // just generating the bytecode. Defining the class from the byte code must tbe the responsibility
+ // of the caller of this method, since it requires a classloader to be created to define and load
+ // this interface.
+ private byte[] generateRemoteInterface(Class serviceInterface) {
+ String interfazeName = serviceInterface.getCanonicalName();
+ ClassWriter cw = new ClassWriter(false);
+
+ cw.visit(Constants.V1_5,
+ Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT + Constants.ACC_INTERFACE,
+ interfazeName.replace('.',
+ '/'),
+ "java/lang/Object",
+ new String[]{"java/rmi/Remote"},
+ serviceInterface.getSimpleName() + ".java");
+
+ StringBuffer argsAndReturn = new StringBuffer("(");
+ Method[] methods = serviceInterface.getMethods();
+ for (int count = 0; count < methods.length; ++count) {
+ Class[] paramTypes = methods[count].getParameterTypes();
+ Class returnType = methods[count].getReturnType();
+
+ for (int paramCount = 0; paramCount < paramTypes.length; ++paramCount) {
+ argsAndReturn.append(Type.getType(paramTypes[paramCount]));
+ }
+ argsAndReturn.append(")");
+ argsAndReturn.append(Type.getType(returnType));
+
+ cw.visitMethod(Constants.ACC_PUBLIC + Constants.ACC_ABSTRACT,
+ methods[count].getName(),
+ argsAndReturn.toString(),
+ new String[]{"java/rmi/RemoteException"},
+ null);
+ }
- private static class RMIInvocationHandler implements InvocationHandler {
- private final WireInvocationHandler wireHandler;
+ cw.visitEnd();
- public RMIInvocationHandler(WireInvocationHandler wireHandler) {
- this.wireHandler = wireHandler;
- }
+ return cw.toByteArray();
+ }
- public Object invoke(Object object, Method method, Object[] objects) throws Throwable {
- return wireHandler.invoke(method, objects);
- }
- }*/
+ private class RMIServiceClassLoader extends ClassLoader {
+ public Class defineClass(byte[] byteArray) {
+ return defineClass(null,
+ byteArray,
+ 0,
+ byteArray.length);
+ }
+ }
}
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/java/org/apache/tuscany/binding/rmi/RemoteMethodHandler.java Fri Aug 25 04:08:48 2006
@@ -1,20 +1,18 @@
-/*
- * 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.
+/**
+ *
+ * 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;
@@ -30,19 +28,20 @@
private WireInvocationHandler wireHandler;
- public RemoteMethodHandler(WireInvocationHandler handler) {
+ private Class compSvcIntf;
+
+ public RemoteMethodHandler(WireInvocationHandler handler, Class intf) {
this.wireHandler = handler;
+ compSvcIntf = intf;
}
public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
- // TO BE FIXED: don't know why it hangs for the finalize method... so blocking it for now
- if (!method.getName().equals(FINALIZE_METHOD)) {
- return wireHandler.invoke(method,
- args);
- }
- return methodProxy.invoke(object,
+ // 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 wireHandler.invoke(compSvcIntf.getMethod(method.getName(),
+ (Class[]) method.getParameterTypes()),
args);
- //return null;
}
}
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/default.scdl Fri Aug 25 04:08:48 2006
@@ -1,22 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
+ * Copyright (c) 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
<!--
Default system configuration for the launcher environment.
@@ -34,7 +31,14 @@
<system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingBuilder"/>
</component>
- <component name="binding.rmi.bindingInvoker">
+ <!-- <component name="binding.rmi.bindingInvoker">
<system:implementation.system class="org.apache.tuscany.binding.rmi.RMIInvoker"/>
</component>
-</composite>
+ -->
+
+ <!-- RMI Host service -->
+ <component name="rmiHost">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIHostImpl"/>
+ </component>
+
+</composite>
\ No newline at end of file
Modified: incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl?rev=436755&r1=436754&r2=436755&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl (original)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/main/resources/META-INF/sca/rmi_extension.scdl Fri Aug 25 04:08:48 2006
@@ -1,22 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
+ * Copyright (c) 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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.
+ -->
<!--
Default system configuration for the launcher environment.
@@ -34,7 +31,14 @@
<system:implementation.system class="org.apache.tuscany.binding.rmi.RMIBindingBuilder"/>
</component>
- <component name="binding.rmi.bindingInvoker">
+ <!-- <component name="binding.rmi.bindingInvoker">
<system:implementation.system class="org.apache.tuscany.binding.rmi.RMIInvoker"/>
</component>
+ -->
+
+ <!-- RMI Host service -->
+ <component name="rmiHost">
+ <system:implementation.system class="org.apache.tuscany.binding.rmi.RMIHostImpl"/>
+ </component>
+
</composite>
Added: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java?rev=436755&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java Fri Aug 25 04:08:48 2006
@@ -0,0 +1,30 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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 helloworld;
+
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldService.class)
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "Hello from the RMI Service to - " + name;
+ }
+}
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java?rev=436755&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java Fri Aug 25 04:08:48 2006
@@ -0,0 +1,43 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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 helloworld;
+
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(HelloWorldRmiService.class)
+public class HelloWorldRmiImpl implements HelloWorldRmiService {
+ @Reference
+ private HelloWorldService extService;
+
+ public HelloWorldService getExtService() {
+ return extService;
+ }
+
+ @Reference
+ public void setExtService(HelloWorldService extService) {
+ this.extService = extService;
+ }
+
+ public String sayRmiHello(String name) {
+ return extService.sayHello(name) + " thro the RMI Reference";
+ }
+
+}
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java?rev=436755&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java Fri Aug 25 04:08:48 2006
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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 helloworld;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+public interface HelloWorldRmiService {
+
+ String sayRmiHello(String name);
+
+}
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldRmiService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java?rev=436755&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java Fri Aug 25 04:08:48 2006
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * 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 helloworld;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+public interface HelloWorldService {
+
+ String sayHello(String name);
+
+}
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/helloworld/HelloWorldService.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java?rev=436755&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java (added)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java Fri Aug 25 04:08:48 2006
@@ -0,0 +1,37 @@
+package org.apache.tuscany.binding.rmi;
+
+import helloworld.HelloWorldRmiService;
+import helloworld.HelloWorldService;
+
+import org.apache.tuscany.test.SCATestCase;
+import org.osoa.sca.CompositeContext;
+import org.osoa.sca.CurrentCompositeContext;
+
+public class BindingTestCase extends SCATestCase {
+ HelloWorldService helloWorldService;
+
+ HelloWorldRmiService helloWorldRmiService;
+
+ protected void setUp() throws Exception {
+ //addExtension("rmi.binding",
+ // getClass().getClassLoader().getResource("META-INF/sca/rmi_extension.scdl"));
+
+ //super.setUp();
+ //System.out.println("Hit Enter");
+ //System.in.read();
+
+ //CompositeContext context = CurrentCompositeContext.getContext();
+ //helloWorldRmiService = context.locateService(HelloWorldRmiService.class,
+ // "HelloWorldRmiServiceComponent");
+
+ }
+
+ public void testRmiService() {
+ // System.out.println(helloWorldRmiService.sayRmiHello("Tuscany World!"));
+ }
+
+ protected void tearDown() throws Exception {
+ //super.tearDown();
+ }
+
+}
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/java/org/apache/tuscany/binding/rmi/BindingTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType?rev=436755&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType (added)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldImpl.componentType Fri Aug 25 04:08:48 2006
@@ -0,0 +1,8 @@
+<?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>
+</componentType>
Added: incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType?rev=436755&view=auto
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType (added)
+++ incubator/tuscany/java/sca/bindings/binding.rmi/src/test/resources/HelloWorldRmiImpl.componentType Fri Aug 25 04:08:48 2006
@@ -0,0 +1,11 @@
+<?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">
+ <interface.java interface="helloworld.HelloWorldRmiService"/>
+ </service>
+ <reference name="extService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </reference>
+</componentType>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org