/** * Dynamically loads an instance of a test runner. * * @return A Initialized TestRunner * * @throws IllegalStateException * if multiple TestRunners found in classpath. */ public static TestRunner getTestRunner() { return getTestRunner(SecurityActions.getThreadContextClassLoader()); }
static boolean isClassPresent(String name) { try { loadClass(name); return true; } catch (Exception e) { return false; } }
public ServiceLoader<AutomaticDeployment> find() { return ServiceLoader.load(AutomaticDeployment.class); } };
static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments, final Class<T> expectedType) { @SuppressWarnings("unchecked") Class<T> implClass = (Class<T>) loadClass(className); if (!expectedType.isAssignableFrom(implClass)) { throw new RuntimeException("Loaded class " + className + " is not of expected type " + expectedType); } return newInstance(implClass, argumentTypes, arguments); }
public Set<S> getProviders() { if (providers == null) { reload(); } return Collections.unmodifiableSet(providers); }
static Class<?> loadClass(String className) { try { return Class.forName(className, true, getThreadContextClassLoader()); } catch (ClassNotFoundException e) { try { return Class.forName(className, true, SecurityActions.class.getClassLoader()); } catch (ClassNotFoundException e2) { throw new RuntimeException("Could not load class " + className, e2); } } }
/** * Creates a new service loader for the given service type and class loader. * * @param service * The interface or abstract class representing the service * @param loader * The class loader to be used to load provider-configuration * files and provider classes, or null if the system class loader * (or, failing that, the bootstrap class loader) is to be used * * @return A new service loader */ public static <S> ServiceLoader<S> load(Class<S> service, ClassLoader loader) { if (loader == null) { loader = service.getClassLoader(); } return new ServiceLoader<S>(service, loader); }
static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments, final Class<T> expectedType, ClassLoader classLoader) { Class<?> clazz = null; try { clazz = Class.forName(className, false, classLoader); } catch (Exception e) { throw new RuntimeException("Could not load class " + className, e); } Object obj = newInstance(clazz, argumentTypes, arguments); try { return expectedType.cast(obj); } catch (Exception e) { throw new RuntimeException("Loaded class " + className + " is not of expected type " + expectedType, e); } }
public ServiceLoader<AutomaticDeployment> find() { return ServiceLoader.load(AutomaticDeployment.class); } };
/** * Dynamically loads an instance of a test runner. * * @return A Initialized TestRunner * * @throws IllegalStateException * if multiple TestRunners found in classpath. */ public static TestRunner getTestRunner() { return getTestRunner(SecurityActions.getThreadContextClassLoader()); }
static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments, final Class<T> expectedType) { @SuppressWarnings("unchecked") Class<T> implClass = (Class<T>) loadClass(className); if (!expectedType.isAssignableFrom(implClass)) { throw new RuntimeException("Loaded class " + className + " is not of expected type " + expectedType); } return newInstance(implClass, argumentTypes, arguments); }
static boolean isClassPresent(String name) { try { loadClass(name); return true; } catch (Exception e) { return false; } }
public Set<S> getProviders() { if (providers == null) { reload(); } return Collections.unmodifiableSet(providers); }
static Class<?> loadClass(String className) { try { return Class.forName(className, true, getThreadContextClassLoader()); } catch (ClassNotFoundException e) { try { return Class.forName(className, true, SecurityActions.class.getClassLoader()); } catch (ClassNotFoundException e2) { throw new RuntimeException("Could not load class " + className, e2); } } }
/** * Creates a new service loader for the given service type and class loader. * * @param service * The interface or abstract class representing the service * @param loader * The class loader to be used to load provider-configuration * files and provider classes, or null if the system class loader * (or, failing that, the bootstrap class loader) is to be used * * @return A new service loader */ public static <S> ServiceLoader<S> load(Class<S> service, ClassLoader loader) { if (loader == null) { loader = service.getClassLoader(); } return new ServiceLoader<S>(service, loader); }
static <T> T newInstance(final String className, final Class<?>[] argumentTypes, final Object[] arguments, final Class<T> expectedType, ClassLoader classLoader) { Class<?> clazz = null; try { clazz = Class.forName(className, false, classLoader); } catch (Exception e) { throw new RuntimeException("Could not load class " + className, e); } Object obj = newInstance(clazz, argumentTypes, arguments); try { return expectedType.cast(obj); } catch (Exception e) { throw new RuntimeException("Loaded class " + className + " is not of expected type " + expectedType, e); } }
/** * Creates a new service loader for the given service type, using the current * thread's context class loader. * <p> * An invocation of this convenience method of the form * <p> * {@code ServiceLoader.load(service)</code>} * <p> * is equivalent to * <p> * <code>ServiceLoader.load(service, * Thread.currentThread().getContextClassLoader())</code> * * @param service * The interface or abstract class representing the service * * @return A new service loader */ public static <S> ServiceLoader<S> load(Class<S> service) { return load(service, Thread.currentThread().getContextClassLoader()); }
/** * Creates a new service loader for the given service type, using the current * thread's context class loader. * <p> * An invocation of this convenience method of the form * <p> * {@code ServiceLoader.load(service)</code>} * <p> * is equivalent to * <p> * <code>ServiceLoader.load(service, * Thread.currentThread().getContextClassLoader())</code> * * @param service * The interface or abstract class representing the service * * @return A new service loader */ public static <S> ServiceLoader<S> load(Class<S> service) { return load(service, Thread.currentThread().getContextClassLoader()); }
ArquillianConfig(Set<String> testClasses, String deploymentUnitName) { this.serviceName = getServiceName(deploymentUnitName); this.testClasses.addAll(testClasses); for(ArquillianConfigServiceCustomizer customizer : ServiceLoader.load(ArquillianConfigServiceCustomizer.class)) { serviceCustomizers.add(customizer); } }
ArquillianConfig(Set<String> testClasses, String deploymentUnitName) { this.serviceName = getServiceName(deploymentUnitName); this.testClasses.addAll(testClasses); for(ArquillianConfigServiceCustomizer customizer : ServiceLoader.load(ArquillianConfigServiceCustomizer.class)) { serviceCustomizers.add(customizer); } }