com.dyuproject.ioc
Class ClasspathResolver

java.lang.Object
  extended by com.dyuproject.ioc.AbstractResolver
      extended by com.dyuproject.ioc.ClasspathResolver
All Implemented Interfaces:
Resource.Resolver

public final class ClasspathResolver
extends AbstractResolver

A resolver that resolves a resource by loading it from the classpath.

Author:
David Yu
Date created:
Feb 23, 2009

Field Summary
static ClasspathResolver DEFAULT
          The default instance
static String TYPE
          The type of this resolver.
 
Fields inherited from class com.dyuproject.ioc.AbstractResolver
_bufferSize, _encoding, DEFAULT_BUFFER_SIZE, DEFAULT_ENCODING
 
Constructor Summary
ClasspathResolver()
           
 
Method Summary
 Resource createResource(String path)
          Creates a resource from a given path string.
static ClasspathResolver getDefault()
          Gets the default instance.
static URL getResource(String path)
          Loads a URL resource from the classloader.
static URL getResource(String path, Class<?> context)
          Loads a URL resource from the classloader; If not found, the classloader of the context class specified will be used.
 String getType()
          Gets the type (id) of resolver
static boolean isCheckParents()
          Gets the flag whether to lookup the resource from the classloader including its parent.
static Class<?> loadClass(String className)
          Loads a class from the classloader.
static Class<?> loadClass(String className, Class<?> context)
          Loads a class from the classloader; If not found, the classloader of the context class specified will be used.
 void resolve(Resource resource, Context context)
          Resolves a resource by setting the Reader property of the Resource.
static void setCheckParents(boolean checkParents)
          Sets the flag whether to lookup the resource from the classloader including its parent.
 
Methods inherited from class com.dyuproject.ioc.AbstractResolver
generateTypeFromClass, getBufferSize, getEncoding, newReader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE

public static final String TYPE
The type of this resolver. ("classpath")


DEFAULT

public static final ClasspathResolver DEFAULT
The default instance

Constructor Detail

ClasspathResolver

public ClasspathResolver()
Method Detail

getDefault

public static ClasspathResolver getDefault()
Gets the default instance.


isCheckParents

public static boolean isCheckParents()
Gets the flag whether to lookup the resource from the classloader including its parent.


setCheckParents

public static void setCheckParents(boolean checkParents)
Sets the flag whether to lookup the resource from the classloader including its parent.


loadClass

public static Class<?> loadClass(String className,
                                 Class<?> context)
Loads a class from the classloader; If not found, the classloader of the context class specified will be used.


loadClass

public static Class<?> loadClass(String className)
Loads a class from the classloader.

Parameters:
className -
Returns:
the class being loaded

getResource

public static URL getResource(String path,
                              Class<?> context)
Loads a URL resource from the classloader; If not found, the classloader of the context class specified will be used.


getResource

public static URL getResource(String path)
Loads a URL resource from the classloader.


getType

public String getType()
Description copied from interface: Resource.Resolver
Gets the type (id) of resolver


resolve

public void resolve(Resource resource,
                    Context context)
             throws IOException
Description copied from interface: Resource.Resolver
Resolves a resource by setting the Reader property of the Resource. That is done via Resource.resolve(Reader).

Throws:
IOException

createResource

public Resource createResource(String path)
                        throws IOException
Description copied from interface: Resource.Resolver
Creates a resource from a given path string.

Throws:
IOException


Copyright © 2008-2013. All Rights Reserved.