congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ShrinkWrapClassLoader
Code IndexAdd Tabnine to your IDE (free)

How to use
ShrinkWrapClassLoader
in
org.jboss.shrinkwrap.api.classloader

Best Java code snippets using org.jboss.shrinkwrap.api.classloader.ShrinkWrapClassLoader (Showing top 20 results out of 315)

origin: org.jboss.arquillian.container/arquillian-weld-ee-embedded-1.1

private ShrinkWrapClassLoader getClassLoader(Archive<?> archive) {
  return (archive.getName().endsWith(SUFFIX_WEB_ARCHIVE)) ? new WebArchiveClassLoader(archive.getClass().getClassLoader(), archive)
      : new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
}
origin: org.jboss.arquillian.container/arquillian-weld-se-embedded-1.1

  public void disable() 
  {
   Thread.currentThread().setContextClassLoader(contextClassLoader);
   try
   {
     this.shrinkWrapClassLoader.close();
   }
   catch (IOException e)
   {
     throw new RuntimeException("Could not close ShrinkWrapClassLoader", e); 
   }
  }
}
origin: org.jboss.arquillian.container/arquillian-weld-se-embedded-1.1

  public Class<?> classForName(String name)
  {
   try
   {
     return classLoader.loadClass(name);
   } 
   catch (Exception e) 
   {
     throw new ResourceLoadingException(e);
   }
  }
});
origin: org.jboss.arquillian.core/arquillian-core-impl-base

@Test
public void shouldBeAbleToLoadVetoedClasses() throws Exception {
  Archive<JavaArchive> jarWithVetoedServiceImpl = createJarWithVetoedServices();
  ClassLoader emptyParent = null;
  ShrinkWrapClassLoader swClassloader = new ShrinkWrapClassLoader(emptyParent, jarWithVetoedServiceImpl);
  ClassLoader emptyClassLoader = new ClassLoader(null) {
  };
  ClassLoader originalClassLoader = SecurityActions.getThreadContextClassLoader();
  Map<Class<?>, Set<Class<?>>> vetoed = null;
  Class<?> service;
  try {
    Thread.currentThread().setContextClassLoader(emptyClassLoader);
    service = swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.FakeService");
    swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.ShouldBeIncluded");
    swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.ShouldBeExcluded");
    vetoed = new JavaSPIExtensionLoader().loadVetoed(swClassloader);
  } finally {
    Thread.currentThread().setContextClassLoader(originalClassLoader);
  }
  Assert.assertEquals("Unexpected number of vetoed services", 1, vetoed.size());
  Assert.assertEquals("Unexpected number of vetoed services impl", 2, vetoed.get(service).size());
}
origin: org.jboss.arquillian.daemon/arquillian-daemon-server

final ShrinkWrapClassLoader isolatedArchiveCL = new ShrinkWrapClassLoader((ClassLoader) null, archive);
    testClass = isolatedArchiveCL.loadClass(testClassName);
  } catch (final ClassNotFoundException cnfe) {
    throw new IllegalStateException("Could not load class " + testClassName + " from deployed archive: "
    testRunnersClass = isolatedArchiveCL.loadClass(CLASS_NAME_ARQ_TEST_RUNNERS);
  } catch (final ClassNotFoundException cnfe) {
    throw new IllegalStateException("Could not load class " + CLASS_NAME_ARQ_TEST_RUNNERS
  SecurityActions.setTccl(oldCl);
  try {
    isolatedArchiveCL.close();
  } catch (final IOException ignore) {
origin: org.jboss.shrinkwrap/shrinkwrap-api

/**
 * Constructs a new ShrinkWrapClassLoader for the specified {@link Archive}s using the default delegation parent
 * <code>ClassLoader</code>. The {@link Archive}s will be searched in the order specified for classes and resources
 * after first searching in the parent class loader.
 *
 * @param archives
 *            the {@link Archive}s from which to load classes and resources
 */
public ShrinkWrapClassLoader(final Archive<?>... archives) {
  super(new URL[] {});
  if (archives == null) {
    throw new IllegalArgumentException("Archives must be specified");
  }
  addArchives(archives);
}
origin: org.jboss.shrinkwrap/shrinkwrap-api

private void addArchives(final Archive<?>[] archives) {
  for (final Archive<?> archive : archives) {
    addArchive(archive);
  }
}
origin: org.jboss.shrinkwrap/shrinkwrap-api

private void addArchive(final Archive<?> archive) {
  try {
    addURL(new URL(null, "archive:" + archive.getName() + "/", new URLStreamHandler() {
      @Override
      protected URLConnection openConnection(final URL u) throws IOException {
origin: arquillian/arquillian-core

@Test
public void shouldBeAbleToLoadVetoedClasses() throws Exception {
  Archive<JavaArchive> jarWithVetoedServiceImpl = createJarWithVetoedServices();
  ClassLoader emptyParent = null;
  ShrinkWrapClassLoader swClassloader = new ShrinkWrapClassLoader(emptyParent, jarWithVetoedServiceImpl);
  ClassLoader emptyClassLoader = new ClassLoader(null) {
  };
  ClassLoader originalClassLoader = SecurityActions.getThreadContextClassLoader();
  Map<Class<?>, Set<Class<?>>> vetoed = null;
  Class<?> service;
  try {
    Thread.currentThread().setContextClassLoader(emptyClassLoader);
    service = swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.FakeService");
    swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.ShouldBeIncluded");
    swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.ShouldBeExcluded");
    vetoed = new JavaSPIExtensionLoader().loadVetoed(swClassloader);
  } finally {
    Thread.currentThread().setContextClassLoader(originalClassLoader);
  }
  Assert.assertEquals("Unexpected number of vetoed services", 1, vetoed.size());
  Assert.assertEquals("Unexpected number of vetoed services impl", 2, vetoed.get(service).size());
}
origin: org.jboss.shrinkwrap/shrinkwrap-api

/**
 * Constructs a new ShrinkWrapClassLoader for the given {@link Archive}s. The {@link Archive}s will be searched in
 * the order specified for classes and resources after first searching in the specified parent class loader.
 *
 * @param parent
 *            the parent class loader for delegation
 * @param archives
 *            the {@link Archive}s from which to load classes and resources
 */
public ShrinkWrapClassLoader(final ClassLoader parent, final Archive<?>... archives) {
  super(new URL[] {}, parent);
  if (archives == null) {
    throw new IllegalArgumentException("Archives must be specified");
  }
  addArchives(archives);
}
origin: shrinkwrap/shrinkwrap

private void addArchives(final Archive<?>[] archives) {
  for (final Archive<?> archive : archives) {
    addArchive(archive);
  }
}
origin: shrinkwrap/shrinkwrap

private void addArchive(final Archive<?> archive) {
  try {
    addURL(new URL(null, "archive:" + archive.getName() + "/", new URLStreamHandler() {
      @Override
      protected URLConnection openConnection(final URL u) throws IOException {
origin: org.jboss.arquillian.core/arquillian-core-impl-base

@Test
public void shouldBeAbleToAddSelectedProviderFromClassLoader() throws Exception {
  Archive<JavaArchive> jarWithDefaultServiceImpl = createJarWithDefaultServiceImpl();
  Archive<JavaArchive> jarThatReplaceServiceImpl = createJarThatReplaceServiceImpl();
  ClassLoader emptyParent = null;
  ShrinkWrapClassLoader swClassloader =
    new ShrinkWrapClassLoader(emptyParent, jarThatReplaceServiceImpl, jarWithDefaultServiceImpl);
  ClassLoader emptyClassLoader = new ClassLoader(null) {
  };
  ClassLoader originalClassLoader = SecurityActions.getThreadContextClassLoader();
  Collection<?> providers = null;
  Class<?> expectedImplClass = null;
  try {
    Thread.currentThread().setContextClassLoader(emptyClassLoader);
    Class<?> serviceClass = swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.FakeService");
    expectedImplClass = swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.ShouldBeIncluded");
    providers = new JavaSPIExtensionLoader().all(swClassloader, serviceClass);
  } finally {
    Thread.currentThread().setContextClassLoader(originalClassLoader);
  }
  Assert.assertEquals("Unexpected number of providers loaded", 1, providers.size());
  Assert.assertEquals("Wrong provider loaded", expectedImplClass, providers.iterator().next().getClass());
}
origin: org.jboss.arquillian.extension/arquillian-warp-impl

public static <I, T extends I> I invoke(Class<T> clazz, JavaArchive... classPathArchives) {
  JavaArchive[] copy = new JavaArchive[classPathArchives.length + 1];
  System.arraycopy(classPathArchives, 0, copy, 0, classPathArchives.length);
  copy[copy.length - 1] = ShrinkWrap.create(JavaArchive.class).addClass(SerializationUtils.class);
  ClassLoader separatedClassLoader = new ShrinkWrapClassLoader(ClassLoaderUtils.getBootstrapClassLoader(), copy);
  return invoke(clazz, separatedClassLoader);
}
origin: org.jboss.arquillian.container/arquillian-weld-ee-embedded-1.1

  public void disable() 
  {
   Thread.currentThread().setContextClassLoader(contextClassLoader);
   try
   {
     this.shrinkWrapClassLoader.close();
   }
   catch (IOException e)
   {
     throw new RuntimeException("Could not close ShrinkWrapClassLoader", e); 
   }
  }
}
origin: shrinkwrap/shrinkwrap

/**
 * Constructs a new ShrinkWrapClassLoader for the specified {@link Archive}s using the default delegation parent
 * <code>ClassLoader</code>. The {@link Archive}s will be searched in the order specified for classes and resources
 * after first searching in the parent class loader.  Will assume classes are stored relative to the root of the archive.
 *
 * @param archives
 *            the {@link Archive}s from which to load classes and resources
 */
public ShrinkWrapClassLoader(final Archive<?>... archives) {
  super(new URL[] {});
  if (archives == null) {
    throw new IllegalArgumentException("Archives must be specified");
  }
  addArchives(archives);
  this.classPrefix = ArchivePaths.root();
}
origin: arquillian/arquillian-core

@Test
public void shouldBeAbleToAddSelectedProviderFromClassLoader() throws Exception {
  Archive<JavaArchive> jarWithDefaultServiceImpl = createJarWithDefaultServiceImpl();
  Archive<JavaArchive> jarThatReplaceServiceImpl = createJarThatReplaceServiceImpl();
  ClassLoader emptyParent = null;
  ShrinkWrapClassLoader swClassloader =
    new ShrinkWrapClassLoader(emptyParent, jarThatReplaceServiceImpl, jarWithDefaultServiceImpl);
  ClassLoader emptyClassLoader = new ClassLoader(null) {
  };
  ClassLoader originalClassLoader = SecurityActions.getThreadContextClassLoader();
  Collection<?> providers = null;
  Class<?> expectedImplClass = null;
  try {
    Thread.currentThread().setContextClassLoader(emptyClassLoader);
    Class<?> serviceClass = swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.FakeService");
    expectedImplClass = swClassloader.loadClass("org.jboss.arquillian.core.impl.loadable.util.ShouldBeIncluded");
    providers = new JavaSPIExtensionLoader().all(swClassloader, serviceClass);
  } finally {
    Thread.currentThread().setContextClassLoader(originalClassLoader);
  }
  Assert.assertEquals("Unexpected number of providers loaded", 1, providers.size());
  Assert.assertEquals("Wrong provider loaded", expectedImplClass, providers.iterator().next().getClass());
}
origin: shrinkwrap/shrinkwrap

/**
 * Creates the {@link ShrinkWrapClassLoaderTestCase#shrinkWrapClassLoader} used to load classes from an
 * {@link Archive}. The {@link ClassLoader} will be isolated from the application classpath by specifying a null
 * parent explicitly.
 */
@Before
public void createClassLoader() {
  shrinkWrapClassLoader = new ShrinkWrapClassLoader((ClassLoader)null , archive);
}
origin: shrinkwrap/shrinkwrap

/**
 * Constructs a new ShrinkWrapClassLoader for the given {@link Archive}s. The {@link Archive}s will be searched in
 * the order specified for classes and resources after first searching in the specified parent class loader.
 *
 * @param parent
 *            the parent class loader for delegation
 * @param classPrefix The location under which classes are located in the archive.  For instance,
 * {@link org.jboss.shrinkwrap.api.spec.WebArchive} types store their classes under WEB-INF/classes.  If
 *                    null, assumes the root
 * @param archives
 *            the {@link Archive}s from which to load classes and resources
 */
public ShrinkWrapClassLoader(final ClassLoader parent, final String classPrefix, final Archive<?>... archives) {
  super(new URL[]{}, parent);
  if (archives == null) {
    throw new IllegalArgumentException("Archives must be specified");
  }
  addArchives(archives);
  this.classPrefix = classPrefix == null ? ArchivePaths.root() : ArchivePaths.create(classPrefix);
}
origin: org.jboss.arquillian.container/arquillian-weld-se-embedded-1.1

Validate.notNull(archive, "Archive must be specified");
this.classLoader = new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
org.jboss.shrinkwrap.api.classloaderShrinkWrapClassLoader

Javadoc

Extension that will create a ClassLoader based on a Array of Archives. When done, call ShrinkWrapClassLoader#close() to free resources.

Most used methods

  • <init>
    Constructs a new ShrinkWrapClassLoader for the specified Archives using the default delegation paren
  • close
  • loadClass
  • addArchive
  • addArchives
  • addURL
  • findResource
  • findResources
  • getResource
  • getResources

Popular in Java

  • Reactive rest calls using spring rest template
  • requestLocationUpdates (LocationManager)
  • onCreateOptionsMenu (Activity)
  • getSharedPreferences (Context)
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • BoxLayout (javax.swing)
  • JList (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now