Author: david.lloyd(a)jboss.com
Date: 2008-07-18 18:58:52 -0400 (Fri, 18 Jul 2008)
New Revision: 4393
Removed:
remoting3/trunk/api/src/main/java/org/jboss/cx/remoting/service/
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClassLoader.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ClassLoaderResourceListener.java
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ServiceLocatorListener.java
Log:
Remove old service location system
Deleted:
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClassLoader.java
===================================================================
---
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClassLoader.java 2008-07-18
22:31:44 UTC (rev 4392)
+++
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/RemoteClassLoader.java 2008-07-18
22:58:52 UTC (rev 4393)
@@ -1,72 +0,0 @@
-package org.jboss.cx.remoting.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.SecureClassLoader;
-import org.jboss.cx.remoting.Client;
-import org.jboss.cx.remoting.RemoteExecutionException;
-import org.jboss.cx.remoting.RemotingException;
-import org.jboss.cx.remoting.service.ClassLoaderResourceReply;
-import org.jboss.cx.remoting.service.ClassLoaderResourceRequest;
-import org.jboss.cx.remoting.service.RemoteResource;
-import org.jboss.cx.remoting.stream.ObjectSource;
-import org.jboss.xnio.IoUtils;
-
-/**
- *
- */
-public final class RemoteClassLoader extends SecureClassLoader {
- private static final org.jboss.xnio.log.Logger log =
org.jboss.xnio.log.Logger.getLogger(RemoteClassLoader.class);
-
- private final Client<ClassLoaderResourceRequest, ClassLoaderResourceReply>
loaderClient;
-
- public RemoteClassLoader(ClassLoader parent, final
Client<ClassLoaderResourceRequest, ClassLoaderResourceReply> loaderClient) {
- super(parent);
- this.loaderClient = loaderClient;
- }
-
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- try {
- final Class<?> firstClass = super.findClass(name);
- if (firstClass != null) {
- return firstClass;
- }
- } catch (ClassNotFoundException e) {
- // continue on...
- }
- try {
- final ClassLoaderResourceReply reply = loaderClient.invoke(new
ClassLoaderResourceRequest(name + ".class"));
- final ObjectSource<RemoteResource> source = reply.getResources();
- try {
- if (! source.hasNext()) {
- throw new ClassNotFoundException("No resources matched");
- }
- final RemoteResource resource = source.next();
- final InputStream stream = resource.getInputStream();
- try {
- final int size = resource.getSize();
- final byte[] bytes = new byte[size];
- for (int t = 0; t < size; t += stream.read(bytes, t, size - t));
- return defineClass(name, bytes, 0, size);
- } finally {
- IoUtils.safeClose(stream);
- }
- } finally {
- IoUtils.safeClose(source);
- }
- } catch (RemotingException e) {
- throw new ClassNotFoundException("Cannot load class " + name +
" due to an invocation failure", e);
- } catch (RemoteExecutionException e) {
- final Throwable cause = e.getCause();
- if (cause instanceof ClassNotFoundException) {
- throw (ClassNotFoundException)cause;
- }
- throw new ClassNotFoundException("Cannot load class " + name +
" due to a remote invocation failure", cause);
- } catch (IOException e) {
- throw new ClassNotFoundException("Cannot load class " + name +
" due to an I/O error", e);
- }
- }
-
- // todo - support arbitrary resources
- // todo - cache fetched resources locally for forwarding
-}
Deleted:
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ClassLoaderResourceListener.java
===================================================================
---
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ClassLoaderResourceListener.java 2008-07-18
22:31:44 UTC (rev 4392)
+++
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ClassLoaderResourceListener.java 2008-07-18
22:58:52 UTC (rev 4393)
@@ -1,67 +0,0 @@
-package org.jboss.cx.remoting.core.service;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Enumeration;
-import org.jboss.cx.remoting.AbstractRequestListener;
-import org.jboss.cx.remoting.IOExceptionCarrier;
-import org.jboss.cx.remoting.RemoteExecutionException;
-import org.jboss.cx.remoting.RequestContext;
-import org.jboss.cx.remoting.service.ClassLoaderResourceReply;
-import org.jboss.cx.remoting.service.ClassLoaderResourceRequest;
-import org.jboss.cx.remoting.service.RemoteResource;
-import org.jboss.cx.remoting.stream.ObjectSource;
-import org.jboss.cx.remoting.stream.ObjectSourceWrapper;
-import org.jboss.cx.remoting.stream.Streams;
-import org.jboss.cx.remoting.util.CollectionUtil;
-import org.jboss.cx.remoting.util.Translator;
-
-/**
- *
- */
-public final class ClassLoaderResourceListener extends
AbstractRequestListener<ClassLoaderResourceRequest,ClassLoaderResourceReply> {
- private ClassLoader classLoader;
-
- public ClassLoader getClassLoader() {
- return classLoader;
- }
-
- public void setClassLoader(final ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- public void handleRequest(final RequestContext<ClassLoaderResourceReply>
requestContext, final ClassLoaderResourceRequest request) throws RemoteExecutionException
{
- try {
- final Enumeration<URL> urlResources =
classLoader.getResources(request.getName());
- final Enumeration<RemoteResource> actualResources =
CollectionUtil.translate(urlResources, new Translator<URL, RemoteResource>() {
- public RemoteResource translate(final URL input) {
- try {
- final RemoteResource resource = new RemoteResource();
- final URLConnection urlConnection = input.openConnection();
- final int size = urlConnection.getContentLength();
- resource.setInputStream(urlConnection.getInputStream());
- resource.setSize(size);
- return resource;
- } catch (IOException ex) {
- throw new IOExceptionCarrier(ex);
- }
- }
- });
- final ObjectSource<RemoteResource> resourceSequence = new
ObjectSourceWrapper<RemoteResource>(Streams.getEnumerationObjectSource(actualResources))
{
- public RemoteResource next() throws IOException {
- try {
- return super.next();
- } catch (IOExceptionCarrier ex) {
- throw ex.getCause();
- }
- }
- };
- ClassLoaderResourceReply reply = new ClassLoaderResourceReply();
- reply.setResources(resourceSequence);
- requestContext.sendReply(reply);
- } catch (IOException e) {
- throw new RemoteExecutionException("Unable to get resources: " +
e.getMessage(), e);
- }
- }
-}
Deleted:
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ServiceLocatorListener.java
===================================================================
---
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ServiceLocatorListener.java 2008-07-18
22:31:44 UTC (rev 4392)
+++
remoting3/trunk/core/src/main/java/org/jboss/cx/remoting/core/service/ServiceLocatorListener.java 2008-07-18
22:58:52 UTC (rev 4393)
@@ -1,55 +0,0 @@
-package org.jboss.cx.remoting.core.service;
-
-import java.net.URI;
-import java.util.SortedMap;
-import java.util.concurrent.ConcurrentMap;
-import org.jboss.cx.remoting.AbstractRequestListener;
-import org.jboss.cx.remoting.Client;
-import org.jboss.cx.remoting.ClientSource;
-import org.jboss.cx.remoting.RemoteExecutionException;
-import org.jboss.cx.remoting.RequestContext;
-import org.jboss.cx.remoting.service.ServiceReply;
-import org.jboss.cx.remoting.service.ServiceRequest;
-import org.jboss.cx.remoting.util.CollectionUtil;
-import org.jboss.cx.remoting.util.ServiceURI;
-
-/**
- *
- */
-public final class ServiceLocatorListener<I, O> extends
AbstractRequestListener<ServiceRequest<I, O>,ServiceReply<I, O>> {
-
- private interface Service {
- String getGroupName();
-
- String getType();
-
- // todo - add in whatever negotation to the request object (security?)
- <X, Y> Client<Void, ServiceReply<X, Y>> getServiceChannel();
- }
-
- private interface Peer {
- String getName();
-
- int getCost();
-
- <X, Y> Client<ServiceRequest<X, Y>, ServiceReply<X, Y>>
getLocatorClient();
-
- SortedMap<String, Service> getServicesByGroupName();
-
- SortedMap<String, Service> getServicesByType();
- }
-
- private static <K, V> ConcurrentMap<K, V> syncMap() {
- return CollectionUtil.synchronizedMap(CollectionUtil.<K, V>hashMap());
- }
-
- private final ConcurrentMap<String, ConcurrentMap<String, ClientSource<?,
?>>> deployments = syncMap();
-
- public void handleRequest(final RequestContext<ServiceReply<I, O>>
requestContext, final ServiceRequest<I, O> request) throws RemoteExecutionException
{
- final URI uri = request.getUri();
- final ServiceURI serviceURI = new ServiceURI(uri);
- final String endpointName = serviceURI.getEndpointName();
- final String groupName = serviceURI.getGroupName();
- final String serviceType = serviceURI.getServiceType();
- }
-}