本文整理匯總了Java中org.jboss.forge.furnace.util.ClassLoaders.containsClass方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassLoaders.containsClass方法的具體用法?Java ClassLoaders.containsClass怎麽用?Java ClassLoaders.containsClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jboss.forge.furnace.util.ClassLoaders
的用法示例。
在下文中一共展示了ClassLoaders.containsClass方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getServiceRegistry
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@Override
public ServiceRegistry getServiceRegistry(Addon addon) throws Exception
{
URL resource = addon.getClassLoader().getResource("/META-INF/services/" + SERVICE_REGISTRATION_FILE_NAME);
Set<Class<?>> serviceTypes = new HashSet<Class<?>>();
if (resource != null)
{
InputStream stream = resource.openStream();
String services = Streams.toString(stream);
for (String serviceType : services.split("\n"))
{
if (ClassLoaders.containsClass(addon.getClassLoader(), serviceType))
{
Class<?> type = ClassLoaders.loadClass(addon.getClassLoader(), serviceType);
serviceTypes.add(type);
}
}
}
return new ReflectionServiceRegistry(furnace, addon, serviceTypes);
}
示例2: exceptionNeedsEnhancement
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private boolean exceptionNeedsEnhancement(Exception exception)
{
final Class<? extends Exception> exceptionType = exception.getClass();
final Class<? extends Exception> unwrappedExceptionType = (Class<? extends Exception>) Proxies.unwrap(exception)
.getClass();
if (Proxies.isPassthroughType(unwrappedExceptionType))
{
return false;
}
if (unwrappedExceptionType.getClassLoader() != null
&& !exceptionType.getClassLoader().equals(getCallingLoader()))
{
if (ClassLoaders.containsClass(getCallingLoader(), exceptionType))
{
return false;
}
}
return true;
}
示例3: exceptionNeedsEnhancement
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private boolean exceptionNeedsEnhancement(Exception exception)
{
Class<? extends Exception> exceptionType = exception.getClass();
Class<? extends Exception> unwrappedExceptionType =
(Class<? extends Exception>) Proxies.unwrap(exception).getClass();
if (Proxies.isPassthroughType(unwrappedExceptionType))
{
return false;
}
if (unwrappedExceptionType.getClassLoader() != null
&& !exceptionType.getClassLoader().equals(getCallingLoader()))
{
if (ClassLoaders.containsClass(getCallingLoader(), exceptionType))
{
return false;
}
}
return true;
}
示例4: returnTypeNeedsEnhancement
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
private boolean returnTypeNeedsEnhancement(Class<?> methodReturnType, Object returnValue,
Class<?> unwrappedReturnValueType)
{
if (Proxies.isPassthroughType(unwrappedReturnValueType))
{
return false;
}
else if (!Object.class.equals(methodReturnType) && Proxies.isPassthroughType(methodReturnType))
{
return false;
}
if (unwrappedReturnValueType.getClassLoader() != null
&& !unwrappedReturnValueType.getClassLoader().equals(getCallingLoader()))
{
if (ClassLoaders.containsClass(getCallingLoader(), unwrappedReturnValueType)
&& ClassLoaders.containsClass(getCallingLoader(), methodReturnType))
{
return false;
}
}
return true;
}
示例5: getExportedInstances
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public <T> Set<ExportedInstance<T>> getExportedInstances(String typeName)
{
Set<ExportedInstance<T>> result = new HashSet<ExportedInstance<T>>();
if (ClassLoaders.containsClass(addon.getClassLoader(), typeName))
{
Class<T> type = (Class<T>) ClassLoaders.loadClass(addon.getClassLoader(), typeName);
result.addAll(getExportedInstances(type));
}
return result;
}
示例6: getExportedInstance
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public <T> ExportedInstance<T> getExportedInstance(String type)
{
if (ClassLoaders.containsClass(addon.getClassLoader(), type))
{
Class<T> clazz = (Class<T>) ClassLoaders.loadClass(addon.getClassLoader(), type);
return getExportedInstance(clazz);
}
return null;
}
示例7: hasService
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@Override
public boolean hasService(String clazz)
{
if (ClassLoaders.containsClass(addon.getClassLoader(), clazz))
return hasService(ClassLoaders.loadClass(addon.getClassLoader(), clazz));
return false;
}
示例8: returnTypeNeedsEnhancement
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
private boolean returnTypeNeedsEnhancement(Method method, Class<?> methodReturnType,
Class<?> unwrappedReturnValueType)
{
String key = getReturnTypeNeedsEnhancementCacheKey(methodReturnType, unwrappedReturnValueType);
Boolean result = returnTypeNeedsEnhancementCache.get(key);
if (result == null)
{
result = true;
if (Proxies.isPassthroughType(unwrappedReturnValueType))
{
result = false;
}
else if (!Object.class.equals(methodReturnType) && Proxies.isPassthroughType(methodReturnType))
{
result = false;
}
else if (unwrappedReturnValueType.getClassLoader() != null
&& !unwrappedReturnValueType.getClassLoader().equals(getCallingLoader()))
{
if (ClassLoaders.containsClass(getCallingLoader(), unwrappedReturnValueType)
&& ClassLoaders.containsClass(getCallingLoader(), methodReturnType))
{
result = false;
}
}
returnTypeNeedsEnhancementCache.put(key, result);
}
return result;
}
示例9: getCompatibleClassHierarchy
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
public static Class<?>[] getCompatibleClassHierarchy(ClassLoader loader, Class<?> origin)
{
Set<Class<?>> hierarchy = new LinkedHashSet<Class<?>>();
Class<?> baseClass = origin;
while (baseClass != null && Modifier.isFinal(baseClass.getModifiers()))
{
baseClass = baseClass.getSuperclass();
}
while (baseClass != null
&& !baseClass.isInterface()
&& baseClass.getSuperclass() != null
&& !baseClass.getSuperclass().equals(Object.class)
&& !Proxies.isInstantiable(baseClass))
{
baseClass = baseClass.getSuperclass();
}
if (baseClass != null && ClassLoaders.containsClass(loader, baseClass.getName())
&& !Object.class.equals(baseClass)
&& (Proxies.isInstantiable(baseClass) || baseClass.isInterface()))
{
hierarchy.add(ClassLoaders.loadClass(loader, baseClass));
}
baseClass = origin;
while (baseClass != null)
{
for (Class<?> type : baseClass.getInterfaces())
{
if (ClassLoaders.containsClass(loader, type.getName()))
hierarchy.add(ClassLoaders.loadClass(loader, type));
else
hierarchy.addAll(java.util.Arrays.asList(getCompatibleClassHierarchy(loader, type)));
}
baseClass = baseClass.getSuperclass();
}
return hierarchy.toArray(new Class<?>[hierarchy.size()]);
}
示例10: enhanceException
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
private Exception enhanceException(final Method method, final Exception exception)
{
Exception result = exception;
try
{
if (exception != null)
{
final Class<?> unwrappedExceptionType = Proxies.unwrap(exception).getClass();
ClassLoader exceptionLoader = delegateLoader;
if (!ClassLoaders.containsClass(delegateLoader, unwrappedExceptionType))
{
exceptionLoader = Proxies.unwrapProxyTypes(unwrappedExceptionType, getCallingLoader(), delegateLoader,
unwrappedExceptionType.getClassLoader()).getClassLoader();
if (exceptionLoader == null)
{
exceptionLoader = getClass().getClassLoader();
}
}
if (exceptionNeedsEnhancement(exception))
{
final Class<?>[] exceptionHierarchy = ProxyTypeInspector.getCompatibleClassHierarchy(getCallingLoader(),
Proxies.unwrapProxyTypes(exception.getClass(), getCallingLoader(), delegateLoader,
exceptionLoader));
if (!Modifier.isFinal(unwrappedExceptionType.getModifiers()))
{
result = enhance(whitelist, getCallingLoader(), exceptionLoader, method, exception,
exceptionHierarchy);
}
}
}
}
catch (final Exception e)
{
log.log(Level.WARNING,
"Could not enhance exception for passing through ClassLoader boundary. Exception type ["
+ exception.getClass().getName() + "], Caller [" + getCallingLoader() + "], Delegate ["
+ delegateLoader + "]");
return exception;
}
return result;
}
示例11: enhanceException
import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
private Exception enhanceException(final Method method, final Exception exception)
{
Exception result = exception;
try
{
if (exception != null)
{
Class<?> unwrappedExceptionType = Proxies.unwrap(exception).getClass();
ClassLoader exceptionLoader = delegateLoader;
if (!ClassLoaders.containsClass(delegateLoader, unwrappedExceptionType))
{
exceptionLoader = Proxies.unwrapProxyTypes(unwrappedExceptionType, getCallingLoader(), delegateLoader,
unwrappedExceptionType.getClassLoader()).getClassLoader();
if (exceptionLoader == null)
{
exceptionLoader = getClass().getClassLoader();
}
}
if (exceptionNeedsEnhancement(exception))
{
Class<?>[] exceptionHierarchy = ProxyTypeInspector.getCompatibleClassHierarchy(getCallingLoader(),
Proxies.unwrapProxyTypes(exception.getClass(), getCallingLoader(), delegateLoader,
exceptionLoader));
if (!Modifier.isFinal(unwrappedExceptionType.getModifiers()))
{
result = enhance(whitelist, getCallingLoader(), exceptionLoader, method, exception,
exceptionHierarchy);
result.initCause(exception);
result.setStackTrace(exception.getStackTrace());
}
}
}
}
catch (Exception e)
{
log.log(Level.WARNING,
"Could not enhance exception for passing through ClassLoader boundary. Exception type ["
+ exception.getClass().getName() + "], Caller [" + getCallingLoader() + "], Delegate ["
+ delegateLoader + "]");
return exception;
}
return result;
}