org.ow2.carol.cmi.smart.client
Class SmartClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.ow2.carol.cmi.smart.client.SmartClassLoader

public class SmartClassLoader
extends java.net.URLClassLoader

ClassLoader that is used and that asks the remote server.

Author:
The new CMI team, Florent Benoit

Constructor Summary
SmartClassLoader(java.lang.String host, int port)
          Creates a new classloader.
 
Method Summary
protected  java.lang.Class<?> findClass(java.lang.String name)
          Finds and loads the class with the specified name from the URL search path.
 java.net.URL findResource(java.lang.String name)
          Finds the resource with the specified name on the URL search path.
 java.util.List<java.lang.String> getProviderURLs(java.lang.String protocol)
          Get the list of available provider urls with the given protocol.
 java.lang.String getWrappedFactoryName(java.lang.String protocol)
          Get the factory name with the given protocol.
 java.nio.ByteBuffer sendRequest(Message message, java.nio.channels.SocketChannel channel)
          Sends the given message on the given channel.
 
Methods inherited from class java.net.URLClassLoader
addURL, definePackage, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmartClassLoader

public SmartClassLoader(java.lang.String host,
                        int port)
Creates a new classloader.

Parameters:
host - The given host.
port - The given port number.
Method Detail

getProviderURLs

public java.util.List<java.lang.String> getProviderURLs(java.lang.String protocol)
Get the list of available provider urls with the given protocol.

Parameters:
protocol - The given protocol used in the client side.
Returns:
The list of provider urls.

getWrappedFactoryName

public java.lang.String getWrappedFactoryName(java.lang.String protocol)
Get the factory name with the given protocol.

Parameters:
protocol - The protocol used in the client side.
Returns:
The factory name.

sendRequest

public java.nio.ByteBuffer sendRequest(Message message,
                                       java.nio.channels.SocketChannel channel)
Sends the given message on the given channel.

Parameters:
message - the message to send
channel - the channel used to send the message.
Returns:
the bytebuffer containing the answer (to analyze)

findClass

protected java.lang.Class<?> findClass(java.lang.String name)
                                throws java.lang.ClassNotFoundException
Finds and loads the class with the specified name from the URL search path.
If the super classloader doesn't find the class, it ask the remote server to download the class

Overrides:
findClass in class java.net.URLClassLoader
Parameters:
name - the name of the class
Returns:
the resulting class
Throws:
java.lang.ClassNotFoundException - if the class could not be found

findResource

public java.net.URL findResource(java.lang.String name)
Finds the resource with the specified name on the URL search path.
If resource is not found locally, search on the remote side.

Overrides:
findResource in class java.net.URLClassLoader
Parameters:
name - the name of the resource
Returns:
a URL for the resource, or null if the resource could not be found.


Copyright © 2008 OW2 Consortium. All Rights Reserved.