org.drools.repository
Class ClassUtil

java.lang.Object
  extended by org.drools.repository.ClassUtil

public class ClassUtil
extends Object

Utility methods to aid in class/resource loading.


Constructor Summary
ClassUtil()
           
 
Method Summary
static Class forName(String className, Class caller)
          Load the specified class.
static String getPath(Package packageObj)
          Get a package name and convert it to a path value, so it can be used in calls to methods like getResourceAsStream(java.lang.String, java.lang.Class).
static URL getResource(String resourceName, Class<?> caller)
           
static InputStream getResourceAsStream(String resourceName, Class caller)
          Get the specified resource as a stream.
static List<String> getResourceList(String regex, Class caller)
           
static List<URL> getResources(String resourcePath, Class<?> caller)
           
static Class resolveProxy(String[] interfaces, Class caller)
          Resolve a proxy for the specified interfaces.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtil

public ClassUtil()
Method Detail

forName

public static Class forName(String className,
                            Class caller)
                     throws ClassNotFoundException
Load the specified class.

Parameters:
className - The name of the class to load.
caller - The class of the caller.
Returns:
The specified class.
Throws:
ClassNotFoundException - If the class cannot be found.

resolveProxy

public static Class resolveProxy(String[] interfaces,
                                 Class caller)
                          throws ClassNotFoundException
Resolve a proxy for the specified interfaces.

Parameters:
interfaces - The interfaces associated with the proxy.
caller - The class of the caller.
Returns:
The specified proxy class.
Throws:
ClassNotFoundException - If the class cannot be found.

getResourceAsStream

public static InputStream getResourceAsStream(String resourceName,
                                              Class caller)
Get the specified resource as a stream.

Parameters:
resourceName - The name of the class to load.
caller - The class of the caller.
Returns:
The input stream for the resource or null if not found.

getResource

public static URL getResource(String resourceName,
                              Class<?> caller)

getResources

public static List<URL> getResources(String resourcePath,
                                     Class<?> caller)
                              throws IOException
Throws:
IOException

getPath

public static String getPath(Package packageObj)
Get a package name and convert it to a path value, so it can be used in calls to methods like getResourceAsStream(java.lang.String, java.lang.Class).

Adds a '/' prefix and converts all '." characters to '/'. Doesn't add a trailing slash.

Parameters:
packageObj - The package.
Returns:
The package path.

getResourceList

public static List<String> getResourceList(String regex,
                                           Class caller)


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.