OPS4J Pax Swissbox :: OSGi Core 1.3.1

org.ops4j.pax.swissbox.core
Class ContextClassLoaderUtils

java.lang.Object
  extended by org.ops4j.pax.swissbox.core.ContextClassLoaderUtils

public class ContextClassLoaderUtils
extends Object

Utilities for class loading.

Since:
0.1.0, December 29, 2007
Author:
Alin Dreghiciu

Method Summary
static
<V> V
doWithClassLoader(ClassLoader classLoader, Callable<V> callable)
          Executes a piece of code (callable.call) using a specific class loader set as context class loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

doWithClassLoader

public static <V> V doWithClassLoader(ClassLoader classLoader,
                                      Callable<V> callable)
                           throws Exception
Executes a piece of code (callable.call) using a specific class loader set as context class loader. If the curent thread context clas loader is already set, it will be restored after execution.

Parameters:
classLoader - clas loader to be used as context clas loader during call.
callable - piece of code to be executed using the clas loader
Returns:
return from callable
Throws:
Exception - re-thrown from callable

OPS4J Pax Swissbox :: OSGi Core 1.3.1

Copyright © 2006-2011 OPS4J - Open Participation Software for Java. All Rights Reserved.