1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-24 08:44:01 +02:00

[cleanup] Reinstate copyright from year

This commit is contained in:
Martin Oberhuber 2008-05-02 18:31:40 +00:00
parent a3cc192af8
commit 7807a15c63
2 changed files with 57 additions and 57 deletions

View file

@ -1,15 +1,15 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2008 IBM Corporation. All rights reserved. * Copyright (c) 2006, 2008 IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the terms * This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed * David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed
********************************************************************************/ ********************************************************************************/
@ -27,7 +27,7 @@ import org.eclipse.dstore.core.model.DataStore;
/** /**
* This class loads a class from a remote peer. * This class loads a class from a remote peer.
* This classloader is used just as any other classloader is used. However, * This classloader is used just as any other classloader is used. However,
* when instantiating the RemoteClassLoader, a DataStore is associated with * when instantiating the RemoteClassLoader, a DataStore is associated with
* it. The RemoteClassLoader goes through the following steps when trying to load * it. The RemoteClassLoader goes through the following steps when trying to load
* a class: * a class:
@ -61,25 +61,25 @@ import org.eclipse.dstore.core.model.DataStore;
* class A from the client. Suppose A is loaded on the client using ClassLoaderForA. On the client * class A from the client. Suppose A is loaded on the client using ClassLoaderForA. On the client
* side, ClassLoaderForA must be registered with the "client" DataStore so that when the * side, ClassLoaderForA must be registered with the "client" DataStore so that when the
* class request for A comes in from the server, the client DataStore know how to load class A. * class request for A comes in from the server, the client DataStore know how to load class A.
* *
* Caching: * Caching:
* To set your preference for caching, on either the client or server DataStore, use the following command: * To set your preference for caching, on either the client or server DataStore, use the following command:
* _dataStore.setPreference(RemoteClassLoader.CACHING_PREFERENCE, "true"); * _dataStore.setPreference(RemoteClassLoader.CACHING_PREFERENCE, "true");
* The cache of classes is kept in a jar in the following directory: * The cache of classes is kept in a jar in the following directory:
* $HOME/.eclipse/RSE/rmt_classloader_cache.jar * $HOME/.eclipse/RSE/rmt_classloader_cache.jar
* To clear the cache, you must delete the jar. * To clear the cache, you must delete the jar.
* *
* Threading Issues: * Threading Issues:
* It's safest to use the RemoteClassLoader on a separate thread, and preferably not * It's safest to use the RemoteClassLoader on a separate thread, and preferably not
* from the CommandHandler or UpdateHandler threads. The RemoteClassLoader uses those * from the CommandHandler or UpdateHandler threads. The RemoteClassLoader uses those
* threads to request and send the class. However, DataStore commands can be structured such that * threads to request and send the class. However, DataStore commands can be structured such that
* safe use of the RemoteClassLoader on these threads is possible. See below for an * safe use of the RemoteClassLoader on these threads is possible. See below for an
* example. * example.
* *
* Using the RemoteClassLoader in your subsystem miner: * Using the RemoteClassLoader in your subsystem miner:
* Suppose you want the client to be able to kick off a class request in your host subsystem * Suppose you want the client to be able to kick off a class request in your host subsystem
* miner. In order to accomplish this, you would take the following steps: * miner. In order to accomplish this, you would take the following steps:
* 1) Add a command to your miner in the extendSchema() method. * 1) Add a command to your miner in the extendSchema() method.
* 2) Add logic in the handleCommand() method to route command to another method when handleCommand * 2) Add logic in the handleCommand() method to route command to another method when handleCommand
* receives your new command. * receives your new command.
* 3) In your command handling method, get the name of the class to load from the subject * 3) In your command handling method, get the name of the class to load from the subject
@ -87,32 +87,32 @@ import org.eclipse.dstore.core.model.DataStore;
* 4) Load the class using the RemoteClassLoader. * 4) Load the class using the RemoteClassLoader.
* 5) Make sure the class you are attempting to load exists on the client and that class's * 5) Make sure the class you are attempting to load exists on the client and that class's
* ClassLoader is registered with the DataStore! * ClassLoader is registered with the DataStore!
* *
* @author mjberger * @author mjberger
* *
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class RemoteClassLoader extends ClassLoader public class RemoteClassLoader extends ClassLoader
{ {
public final static String CACHING_PREFERENCE = "Class.Caching"; //$NON-NLS-1$ public final static String CACHING_PREFERENCE = "Class.Caching"; //$NON-NLS-1$
private DataStore _dataStore; private DataStore _dataStore;
private boolean _useCaching = false; private boolean _useCaching = false;
private CacheClassLoader _urlClassLoader; private CacheClassLoader _urlClassLoader;
private class CacheClassLoader extends URLClassLoader private class CacheClassLoader extends URLClassLoader
{ {
public CacheClassLoader(URL[] urls, ClassLoader parent) public CacheClassLoader(URL[] urls, ClassLoader parent)
{ {
super(urls, parent); super(urls, parent);
} }
public Class findCachedClass(String className) throws ClassNotFoundException public Class findCachedClass(String className) throws ClassNotFoundException
{ {
return super.findClass(className); return super.findClass(className);
} }
} }
/** /**
* Constructor * Constructor
* @param dataStore A reference to the datastore to be used by this * @param dataStore A reference to the datastore to be used by this
@ -125,7 +125,7 @@ public class RemoteClassLoader extends ClassLoader
_dataStore = dataStore; _dataStore = dataStore;
useCaching(); useCaching();
} }
public boolean useCaching() public boolean useCaching()
{ {
boolean useCaching = false; boolean useCaching = false;
@ -155,7 +155,7 @@ public class RemoteClassLoader extends ClassLoader
} }
/** /**
* Finds the specified class. If the class cannot be found locally, * Finds the specified class. If the class cannot be found locally,
* a synchronous request for the class is sent to the client, and the calling thread * a synchronous request for the class is sent to the client, and the calling thread
* waits for a response. If the client can find the class, it sends it back to * waits for a response. If the client can find the class, it sends it back to
* the server. The server receives the class in a new thread, defines it, and * the server. The server receives the class in a new thread, defines it, and
@ -165,14 +165,14 @@ public class RemoteClassLoader extends ClassLoader
* @param className the fully qualified classname to find * @param className the fully qualified classname to find
* @return the loaded class * @return the loaded class
* @throws ClassNotFoundException if the class cannot be found on either the client or the server. * @throws ClassNotFoundException if the class cannot be found on either the client or the server.
* *
*/ */
protected Class findClass(String className) throws ClassNotFoundException protected Class findClass(String className) throws ClassNotFoundException
{ {
//System.out.println("finding "+className); //System.out.println("finding "+className);
// first try using the datastore's local classloaders // first try using the datastore's local classloaders
ArrayList localLoaders = _dataStore.getLocalClassLoaders(); ArrayList localLoaders = _dataStore.getLocalClassLoaders();
if (localLoaders != null) if (localLoaders != null)
{ {
@ -189,21 +189,21 @@ public class RemoteClassLoader extends ClassLoader
} }
} }
} }
// next delegate the search to the superclass's find method. // next delegate the search to the superclass's find method.
try try
{ {
Class theClass = super.findClass(className); Class theClass = super.findClass(className);
if (theClass != null) if (theClass != null)
{ {
//System.out.println("Using super's: " + className); //System.out.println("Using super's: " + className);
return theClass; return theClass;
} }
} }
catch (Exception e) catch (Exception e)
{ {
} }
// DKM // DKM
// only do lookup if the classname looks valid // only do lookup if the classname looks valid
// don't want to be requesting rsecomm from client // don't want to be requesting rsecomm from client
@ -211,7 +211,7 @@ public class RemoteClassLoader extends ClassLoader
{ {
throw new ClassNotFoundException(className); throw new ClassNotFoundException(className);
} }
// if it cannot be found: // if it cannot be found:
// search the class request repository to see if the class has been requested // search the class request repository to see if the class has been requested
@ -227,9 +227,9 @@ public class RemoteClassLoader extends ClassLoader
{ {
try try
{ {
Class theClass = _urlClassLoader.findCachedClass(className); Class theClass = _urlClassLoader.findCachedClass(className);
//System.out.println("Using cached: " + className); //System.out.println("Using cached: " + className);
return theClass; return theClass;
} }
@ -249,11 +249,11 @@ public class RemoteClassLoader extends ClassLoader
// the class has been requested before, but it has not yet been received // the class has been requested before, but it has not yet been received
// System.out.println(className + " already requested but not loaded. Waiting for request to load."); // System.out.println(className + " already requested but not loaded. Waiting for request to load.");
request.waitForResponse(); // just wait until the class is received request.waitForResponse(); // just wait until the class is received
// after the class is received, get it from the repository and return it // after the class is received, get it from the repository and return it
// or if the class failed to be received, throw an exception // or if the class failed to be received, throw an exception
if (request.isLoaded()) return request.getLoadedClass(); if (request.isLoaded()) return request.getLoadedClass();
else throw new ClassNotFoundException(className); else throw new ClassNotFoundException(className);
} }
else if (request.isLoaded()) else if (request.isLoaded())
{ {
@ -261,12 +261,12 @@ public class RemoteClassLoader extends ClassLoader
// so just return it. // so just return it.
return request.getLoadedClass(); return request.getLoadedClass();
} }
// if we ever get to this point, the class has not been found, // if we ever get to this point, the class has not been found,
// throw the exception // throw the exception
else throw new ClassNotFoundException(className); else throw new ClassNotFoundException(className);
} }
/** /**
* Receives a class sent by a remote agent and loads it. * Receives a class sent by a remote agent and loads it.
* Notifies all threads waiting for this class to load that the * Notifies all threads waiting for this class to load that the
@ -296,13 +296,13 @@ public class RemoteClassLoader extends ClassLoader
Class receivedClass = null; Class receivedClass = null;
try try
{ {
// System.out.println("defining "+className+"..."); // System.out.println("defining "+className+"...");
// try to define the class. If any dependent classes cannot be // try to define the class. If any dependent classes cannot be
// found the JRE implementation will call findClass to look for them. // found the JRE implementation will call findClass to look for them.
// Thus we could end up with a stack of requests all waiting until the // Thus we could end up with a stack of requests all waiting until the
// classes with no dependent classes load. // classes with no dependent classes load.
receivedClass = defineClass(className, bytes, 0, size); receivedClass = defineClass(className, bytes, 0, size);
// System.out.println("...finished defining "+className); // System.out.println("...finished defining "+className);
} }
catch (NoClassDefFoundError e) catch (NoClassDefFoundError e)
@ -333,7 +333,7 @@ public class RemoteClassLoader extends ClassLoader
err.printStackTrace(); err.printStackTrace();
if (request != null) if (request != null)
request.notifyResponse(); request.notifyResponse();
return; return;
} }
catch (ClassNotFoundException ee) catch (ClassNotFoundException ee)
{ {
@ -342,10 +342,10 @@ public class RemoteClassLoader extends ClassLoader
request.notifyResponse(); request.notifyResponse();
return; return;
} }
// if after trying to define or trying to load the class // if after trying to define or trying to load the class
// we still dont have it, notify the threads and fail. // we still dont have it, notify the threads and fail.
if (receivedClass == null) if (receivedClass == null)
{ {
if (request != null) if (request != null)
request.notifyResponse(); request.notifyResponse();
@ -374,7 +374,7 @@ public class RemoteClassLoader extends ClassLoader
} }
} }
} }
/** /**
* Kicks off a separate thread in which to request the class, * Kicks off a separate thread in which to request the class,
* rather than doing it synchronously. * rather than doing it synchronously.
@ -386,7 +386,7 @@ public class RemoteClassLoader extends ClassLoader
LoadClassThread thread = new LoadClassThread(className); LoadClassThread thread = new LoadClassThread(className);
thread.start(); thread.start();
} }
/** /**
* Requests a class (synchronously) from the client * Requests a class (synchronously) from the client
* @param className The fully qualified name of the class to request. * @param className The fully qualified name of the class to request.
@ -406,10 +406,10 @@ public class RemoteClassLoader extends ClassLoader
request = new ClassRequest(className, true); request = new ClassRequest(className, true);
_dataStore.getClassRequestRepository().put(className, request); _dataStore.getClassRequestRepository().put(className, request);
request.setRequested(true); request.setRequested(true);
// put in the request for the class // put in the request for the class
_dataStore.requestClass(className); _dataStore.requestClass(className);
// wait for a response // wait for a response
// System.out.println("thread to wait: "+Thread.currentThread().getName()); // System.out.println("thread to wait: "+Thread.currentThread().getName());
if (!request.isLoaded()) request.waitForResponse(); if (!request.isLoaded()) request.waitForResponse();
@ -467,7 +467,7 @@ public class RemoteClassLoader extends ClassLoader
return; return;
} }
} }
/** /**
* A new thread for loading classes in. * A new thread for loading classes in.
* @author mjberger * @author mjberger
@ -476,18 +476,18 @@ public class RemoteClassLoader extends ClassLoader
protected class LoadClassThread extends Thread protected class LoadClassThread extends Thread
{ {
private String _className; private String _className;
public LoadClassThread(String className) public LoadClassThread(String className)
{ {
_className = className; _className = className;
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see java.lang.Thread#run() * @see java.lang.Thread#run()
*/ */
public void run() public void run()
{ {
_dataStore.requestClass(_className); _dataStore.requestClass(_className);
} }
} }
} }

View file

@ -1,15 +1,15 @@
/******************************************************************************** /********************************************************************************
* Copyright (c) 2008 IBM Corporation. All rights reserved. * Copyright (c) 2006, 2008 IBM Corporation. All rights reserved.
* This program and the accompanying materials are made available under the terms * This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is * of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html * available at http://www.eclipse.org/legal/epl-v10.html
* *
* Initial Contributors: * Initial Contributors:
* The following IBM employees contributed to the Remote System Explorer * The following IBM employees contributed to the Remote System Explorer
* component that contains this file: David McKnight, Kushal Munir, * component that contains this file: David McKnight, Kushal Munir,
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
* *
* Contributors: * Contributors:
* David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed * David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed
********************************************************************************/ ********************************************************************************/
@ -23,12 +23,12 @@ import java.io.ObjectStreamClass;
/** /**
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
*/ */
public class RemoteObjectInputStream extends ObjectInputStream { public class RemoteObjectInputStream extends ObjectInputStream {
private RemoteClassLoader _loader; private RemoteClassLoader _loader;
public RemoteObjectInputStream(InputStream in, RemoteClassLoader loader) throws IOException public RemoteObjectInputStream(InputStream in, RemoteClassLoader loader) throws IOException
{ {
super(in); super(in);
_loader = loader; _loader = loader;