You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/05/07 01:43:14 UTC
svn commit: r535682 - in /incubator/tuscany/java/sca/modules:
binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/
host-rmi/src/main/java/org/apache/tuscany/rmi/
host-rmi/src/main/java/org/apache/tuscany/rmi/module/
host-rmi/src/test/java/org/apac...
Author: jsdelfino
Date: Sun May 6 16:43:13 2007
New Revision: 535682
URL: http://svn.apache.org/viewvc?view=rev&rev=535682
Log:
Renamed RMIHostExtensionPoint to RMIHost as it's not an extension point.
Added:
incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/DefaultRMIHost.java (with props)
incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/RMIHost.java (with props)
Removed:
incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/DefaultRMIHostExtensionPoint.java
incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/RMIHostExtensionPoint.java
Modified:
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/DefaultRMIBindingFactory.java
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInterceptor.java
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIModuleActivator.java
incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/module/RMIRuntimeModuleActivator.java
incubator/tuscany/java/sca/modules/host-rmi/src/test/java/org/apache/tuscany/rmi/RMIHostImplTestCase.java
Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/DefaultRMIBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/DefaultRMIBindingFactory.java?view=diff&rev=535682&r1=535681&r2=535682
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/DefaultRMIBindingFactory.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/DefaultRMIBindingFactory.java Sun May 6 16:43:13 2007
@@ -18,7 +18,7 @@
*/
package org.apache.tuscany.binding.rmi;
-import org.apache.tuscany.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.rmi.RMIHost;
/**
* A factory for the WSDL model.
@@ -26,9 +26,9 @@
* @version $Rev: 526508 $ $Date: 2007-04-08 07:42:42 +0530 (Sun, 08 Apr 2007) $
*/
public class DefaultRMIBindingFactory implements RMIBindingFactory {
- private RMIHostExtensionPoint rmiHost = null;
+ private RMIHost rmiHost = null;
- public DefaultRMIBindingFactory(RMIHostExtensionPoint rmiHost) {
+ public DefaultRMIBindingFactory(RMIHost rmiHost) {
this.rmiHost = rmiHost;
}
Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInterceptor.java?view=diff&rev=535682&r1=535681&r2=535682
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInterceptor.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInterceptor.java Sun May 6 16:43:13 2007
@@ -23,11 +23,11 @@
import org.apache.tuscany.invocation.InvocationRuntimeException;
import org.apache.tuscany.invocation.Message;
import org.apache.tuscany.rmi.RMIHostException;
-import org.apache.tuscany.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.rmi.RMIHost;
import org.apache.tuscany.spi.component.WorkContext;
public class RMIBindingInterceptor implements Interceptor {
- private RMIHostExtensionPoint rmiHost;
+ private RMIHost rmiHost;
private String host;
private String port;
private String svcName;
@@ -36,7 +36,7 @@
private Interceptor next;
- public RMIBindingInterceptor(RMIHostExtensionPoint rmiHost, String host, String port, String svcName, Method remoteMethod) {
+ public RMIBindingInterceptor(RMIHost rmiHost, String host, String port, String svcName, Method remoteMethod) {
this.rmiHost = rmiHost;
this.remoteMethod = remoteMethod;
this.host = host;
Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java?view=diff&rev=535682&r1=535681&r2=535682
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java Sun May 6 16:43:13 2007
@@ -49,7 +49,7 @@
import org.apache.tuscany.invocation.MessageImpl;
import org.apache.tuscany.invocation.TargetInvoker;
import org.apache.tuscany.rmi.RMIHostException;
-import org.apache.tuscany.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.rmi.RMIHost;
import org.apache.tuscany.scope.Scope;
import org.apache.tuscany.spi.component.WorkContext;
import org.apache.tuscany.spi.component.WorkContextTunnel;
@@ -61,7 +61,7 @@
public class RMIBindingProvider extends RMIBindingImpl implements ReferenceBindingActivator,
ReferenceBindingProvider, ServiceBindingActivator, ServiceBindingProvider, MethodInterceptor {
- private RMIHostExtensionPoint rmiHost;
+ private RMIHost rmiHost;
private RuntimeWire wire;
//need this member to morph the service interface to extend from Remote if it does not
@@ -70,7 +70,7 @@
// and the component match in their service contracts.
private Interface serviceInterface;
- public RMIBindingProvider(RMIHostExtensionPoint rmiHost) {
+ public RMIBindingProvider(RMIHost rmiHost) {
this.rmiHost = rmiHost;
}
@@ -238,7 +238,7 @@
}
protected int getPort(String port) {
- int portNumber = RMIHostExtensionPoint.RMI_DEFAULT_PORT;
+ int portNumber = RMIHost.RMI_DEFAULT_PORT;
if (port != null && port.length() > 0) {
portNumber = Integer.decode(port);
}
Modified: 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=diff&rev=535682&r1=535681&r2=535682
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIModuleActivator.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIModuleActivator.java Sun May 6 16:43:13 2007
@@ -29,7 +29,7 @@
import org.apache.tuscany.core.ModuleActivator;
import org.apache.tuscany.policy.DefaultPolicyFactory;
import org.apache.tuscany.policy.PolicyFactory;
-import org.apache.tuscany.rmi.RMIHostExtensionPoint;
+import org.apache.tuscany.rmi.RMIHost;
public class RMIModuleActivator implements ModuleActivator {
@@ -40,7 +40,7 @@
AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
PolicyFactory policyFactory = new DefaultPolicyFactory();
- RMIHostExtensionPoint rmiHost = registry.getExtensionPoint(RMIHostExtensionPoint.class);
+ RMIHost rmiHost = registry.getExtensionPoint(RMIHost.class);
RMIBindingFactory rmiFactory = new DefaultRMIBindingFactory(rmiHost);
processors.addArtifactProcessor(new RMIBindingProcessor(assemblyFactory, policyFactory, rmiFactory));
}
Added: incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/DefaultRMIHost.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/DefaultRMIHost.java?view=auto&rev=535682
==============================================================================
--- incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/DefaultRMIHost.java (added)
+++ incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/DefaultRMIHost.java Sun May 6 16:43:13 2007
@@ -0,0 +1,129 @@
+/*
+ * 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.rmi;
+
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Default implementation of a rmi host extension point.
+ *
+ */
+public class DefaultRMIHost implements RMIHost {
+
+ //map of RMI registries started and running
+ private Map<String, Registry> rmiRegistries;
+
+ public DefaultRMIHost() {
+ rmiRegistries = new ConcurrentHashMap<String, Registry>();
+ /*
+ * if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); }
+ */
+ }
+
+ public void registerService(String serviceName, int port, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException {
+ Registry registry;
+ try {
+ registry = rmiRegistries.get(Integer.toString(port));
+ if (registry == null) {
+ registry = LocateRegistry.createRegistry(port);
+ rmiRegistries.put(Integer.toString(port),
+ registry);
+ }
+ registry.bind(serviceName,
+ serviceObject);
+ } catch (AlreadyBoundException e) {
+ throw new RMIHostException(e);
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ }
+
+ }
+
+ public void registerService(String serviceName, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException {
+ registerService(serviceName,
+ RMI_DEFAULT_PORT,
+ serviceObject);
+ }
+
+ public void unregisterService(String serviceName, int port) throws RMIHostException,
+ RMIHostRuntimeException {
+ Registry registry;
+
+ try {
+ registry = rmiRegistries.get(Integer.toString(port));
+ if (registry == null) {
+ registry = LocateRegistry.createRegistry(port);
+ rmiRegistries.put(Integer.toString(port),
+ registry);
+ }
+ registry.unbind(serviceName);
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ } catch (NotBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ }
+ }
+
+ public void unregisterService(String serviceName) throws RMIHostException,
+ RMIHostRuntimeException {
+ unregisterService(serviceName,
+ RMI_DEFAULT_PORT);
+
+ }
+
+ public Remote findService(String host, String port, String svcName) throws RMIHostException,
+ RMIHostRuntimeException {
+ Registry registry;
+ Remote remoteService = null;
+ host = (host == null || host.length() <= 0) ? "localhost" : host;
+ int portNumber = (port == null || port.length() <= 0) ? RMI_DEFAULT_PORT : Integer
+ .decode(port);
+
+ try {
+ registry = LocateRegistry.getRegistry(host,
+ portNumber);
+
+ if (registry != null) {
+ remoteService = registry.lookup(svcName);
+ }
+ } catch (RemoteException e) {
+ RMIHostRuntimeException rmiExec = new RMIHostRuntimeException(e.getMessage());
+ rmiExec.setStackTrace(e.getStackTrace());
+ throw rmiExec;
+ } catch (NotBoundException e) {
+ throw new RMIHostException(e.getMessage());
+ }
+ return remoteService;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/DefaultRMIHost.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/DefaultRMIHost.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/RMIHost.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/RMIHost.java?view=auto&rev=535682
==============================================================================
--- incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/RMIHost.java (added)
+++ incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/RMIHost.java Sun May 6 16:43:13 2007
@@ -0,0 +1,88 @@
+/*
+ * 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.rmi;
+
+import java.rmi.Remote;
+
+/**
+ * RMI Service hosting interface to be implemented by host environments that allows SCA Components
+ * to register RMI Services to handle inbound service requests over RMI to SCA Components
+ */
+public interface RMIHost {
+ int RMI_DEFAULT_PORT = 1099;
+
+ /**
+ * Register an RMI service with the given name and port
+ *
+ * @param serviceName against which the server is to be registered
+ * @param port the port against which the server is to be registered
+ * @param serviceObject the server object to be registered
+ * @throws RMIHostException
+ * @throws RMIHostRuntimeException
+ */
+ void registerService(String serviceName, int port, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ /**
+ * Register an RMI service with the given name and default port (1099)
+ *
+ * @param serviceName serviceName against which the server is to be registered
+ * @param serviceObject the server object to be registered
+ * @throws RMIHostException
+ * @throws RMIHostRuntimeException
+ */
+ void registerService(String serviceName, Remote serviceObject) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ /**
+ * Unregister a service registered under the given service name and port number
+ *
+ * @param serviceName serviceName against which the server is to be registered
+ * @param port the port against which the server is to be registered
+ * @throws RMIHostException
+ * @throws RMIHostRuntimeException
+ */
+ void unregisterService(String serviceName, int port) throws RMIHostException,
+ RMIHostRuntimeException;
+
+ /**
+ * Unregister a service registered under the given service name and defalut port number (1099)
+ *
+ * @param serviceName the name of the service that has to be unregistered
+ * @throws RMIHostException
+ * @throws RMIHostRuntimeException
+ */
+ void unregisterService(String serviceName) throws RMIHostException,
+ RMIHostRuntimeException;
+
+
+ /**
+ * find a remote service hosted on the given host, port and service name
+ *
+ * @param host the name of the host on which the rmi service to be unregistered is running
+ * @param port the port against which the server is to be unregistered is running
+ * @param svcName serviceName against which the server is to be unregistered is running
+ * @return the RMI server object
+ * @throws RMIHostException
+ * @throws RMIHostRuntimeException
+ */
+ Remote findService(String host, String port, String svcName) throws RMIHostException,
+ RMIHostRuntimeException;
+
+}
Propchange: incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/RMIHost.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/RMIHost.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/module/RMIRuntimeModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/module/RMIRuntimeModuleActivator.java?view=diff&rev=535682&r1=535681&r2=535682
==============================================================================
--- incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/module/RMIRuntimeModuleActivator.java (original)
+++ incubator/tuscany/java/sca/modules/host-rmi/src/main/java/org/apache/tuscany/rmi/module/RMIRuntimeModuleActivator.java Sun May 6 16:43:13 2007
@@ -24,8 +24,8 @@
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.rmi.DefaultRMIHost;
+import org.apache.tuscany.rmi.RMIHost;
/**
* @version $Rev: 529327 $ $Date: 2007-04-16 22:40:43 +0530 (Mon, 16 Apr 2007) $
@@ -34,7 +34,7 @@
public Map<Class, Object> getExtensionPoints() {
Map<Class, Object> map = new HashMap<Class, Object>();
- map.put(RMIHostExtensionPoint.class, new DefaultRMIHostExtensionPoint());
+ map.put(RMIHost.class, new DefaultRMIHost());
return map;
}
Modified: incubator/tuscany/java/sca/modules/host-rmi/src/test/java/org/apache/tuscany/rmi/RMIHostImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-rmi/src/test/java/org/apache/tuscany/rmi/RMIHostImplTestCase.java?view=diff&rev=535682&r1=535681&r2=535682
==============================================================================
--- incubator/tuscany/java/sca/modules/host-rmi/src/test/java/org/apache/tuscany/rmi/RMIHostImplTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/host-rmi/src/test/java/org/apache/tuscany/rmi/RMIHostImplTestCase.java Sun May 6 16:43:13 2007
@@ -23,12 +23,12 @@
public class RMIHostImplTestCase extends TestCase {
public void testInit() {
- new DefaultRMIHostExtensionPoint();
+ new DefaultRMIHost();
}
public void testFindServiceBadHost() throws RMIHostRuntimeException, RMIHostException {
try {
- new DefaultRMIHostExtensionPoint().findService(null, "0", null);
+ new DefaultRMIHost().findService(null, "0", null);
fail();
} catch (RMIHostRuntimeException e) {
// expected
@@ -36,19 +36,19 @@
}
public void testRegisterService1() throws RMIHostRuntimeException, RMIHostException {
- DefaultRMIHostExtensionPoint host = new DefaultRMIHostExtensionPoint();
+ DefaultRMIHost host = new DefaultRMIHost();
host.registerService("foo1", new MockRemote());
host.unregisterService("foo1");
}
public void testRegisterService2() throws RMIHostRuntimeException, RMIHostException {
- DefaultRMIHostExtensionPoint host = new DefaultRMIHostExtensionPoint();
+ DefaultRMIHost host = new DefaultRMIHost();
host.registerService("bar1", 9999, new MockRemote());
host.unregisterService("bar1", 9999);
}
public void testRegisterServiceAlreadyBound() throws RMIHostRuntimeException, RMIHostException {
- DefaultRMIHostExtensionPoint host = new DefaultRMIHostExtensionPoint();
+ DefaultRMIHost host = new DefaultRMIHost();
host.registerService("bar2", 9997, new MockRemote());
try {
host.registerService("bar2", 9997, new MockRemote());
@@ -59,7 +59,7 @@
}
public void testUnRegisterService() throws RMIHostRuntimeException, RMIHostException {
- DefaultRMIHostExtensionPoint host = new DefaultRMIHostExtensionPoint();
+ DefaultRMIHost host = new DefaultRMIHost();
try {
host.unregisterService("bar3", 9998);
fail();
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org