Package org.jboss.shrinkwrap.api.classloader

Examples of org.jboss.shrinkwrap.api.classloader.ShrinkWrapClassLoader


   public ShrinkwrapBeanDeploymentArchiveImpl(Archive<?> archive)
   {
      Validate.notNull(archive, "Archive must be specified");
      this.archive = archive;
     
      this.classLoader = new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
   }
View Full Code Here


    @Before
    public void setUp() {

        threadClassLoader = Thread.currentThread().getContextClassLoader();

        shrinkWrapClassLoader = new ShrinkWrapClassLoader(ShrinkWrap.create(JavaArchive.class));
        instance = new ContextClassLoaderManager(shrinkWrapClassLoader);
    }
View Full Code Here

     */
    @Override
    public ProtocolMetaData deploy(Archive archive) throws DeploymentException {

        // creates the class loader based on the passed archive
        ShrinkWrapClassLoader classLoader = getClassLoader(archive);

        // instantiates the class loader manager
        ContextClassLoaderManager classLoaderManager = new ContextClassLoaderManager(classLoader);
        contextClassLoaderManager.set(classLoaderManager);

View Full Code Here

     * @param archive the shrinkwrap archive
     *
     * @return the created class loader
     */
    private ShrinkWrapClassLoader getClassLoader(Archive<?> archive) {
        return new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
    }
View Full Code Here

        if (archive == null) {
            throw new IllegalStateException("Archive with ID " + archiveId + " is not deployed");
        }

        // Use a ClassLoader with explicitly null parent to achieve isolation from --classpath
        final ShrinkWrapClassLoader isolatedArchiveCL = new ShrinkWrapClassLoader((ClassLoader) null, archive);

        final ClassLoader oldCl = SecurityActions.getTccl();
        ObjectOutputStream objectOutstream = null;
        try {
            // We have to set the TCCL here due to ARQ-1181; if that's resolved we can remove all TCCL mucking
            SecurityActions.setTccl(isolatedArchiveCL);
            /*
             * All reflection in this section is to avoid CCE when we load these classes from the isolated ClassLoader,
             * we can't have them assignable to the ClassLoader which loaded this class.
             */
            final Class<?> testClass;
            try {
                testClass = isolatedArchiveCL.loadClass(testClassName);
            } catch (final ClassNotFoundException cnfe) {
                throw new IllegalStateException("Could not load class " + testClassName + " from deployed archive: "
                    + archive.toString());
            }
            final Class<?> testRunnersClass;
            try {
                testRunnersClass = isolatedArchiveCL.loadClass(CLASS_NAME_ARQ_TEST_RUNNERS);
            } catch (final ClassNotFoundException cnfe) {
                throw new IllegalStateException("Could not load class " + CLASS_NAME_ARQ_TEST_RUNNERS
                    + " from deployed archive: " + archive.toString());
            }
            final Method getTestRunnerMethod = testRunnersClass.getMethod(METHOD_NAME_GET_TEST_RUNNER,
                ClassLoader.class);
            final Object testRunner = getTestRunnerMethod.invoke(null, isolatedArchiveCL);
            final Class<?> testRunnerClass = testRunner.getClass();
            final Method executeMethod = testRunnerClass.getMethod(METHOD_NAME_EXECUTE, Class.class, String.class);
            final Serializable testResult = (Serializable) executeMethod.invoke(testRunner, testClass, methodName);
            return testResult;
        } catch (final IllegalAccessException iae) {
            throw new RuntimeException(iae);
        } catch (final InvocationTargetException ite) {
            throw new RuntimeException(ite);
        } catch (final NoSuchMethodException nsme) {
            throw new RuntimeException(nsme);
        } finally {
            SecurityActions.setTccl(oldCl);
            try {
                isolatedArchiveCL.close();
            } catch (final IOException ignore) {
            }
            if (objectOutstream != null) {
                try {
                    objectOutstream.close();
View Full Code Here

   public ShrinkwrapBeanDeploymentArchiveImpl(Archive<?> archive)
   {
      super(archive);
      Validate.notNull(archive, "Archive must be specified");
     
      this.classLoader = new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
     
      serviceRegistry.add(ResourceLoader.class, new ResourceLoader()
      {
         public void cleanup() { }
        
View Full Code Here

   public ShrinkwrapBeanDeploymentArchiveImpl(Archive<?> archive)
   {
      super(archive);
      Validate.notNull(archive, "Archive must be specified");
     
      this.classLoader = new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
     
      serviceRegistry.add(ResourceLoader.class, new ResourceLoader()
      {
         public void cleanup() { }
        
View Full Code Here

   {
   }

   public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException
  
      ShrinkWrapClassLoader classLoader = new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
      ContextClassLoaderManager classLoaderManager = new ContextClassLoaderManager(classLoader);
      classLoaderManager.enable();
     
      TestContainer container = new TestContainer(findArchiveId(archive), findBeansXml(archive), findBeanClasses(archive, classLoader));
      Bootstrap bootstrap = container.getBootstrap();
View Full Code Here

   public ShrinkwrapBeanDeploymentArchiveImpl(Archive<?> archive)
   {
      super(archive);
      Validate.notNull(archive, "Archive must be specified");
     
      this.classLoader = new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
     
      serviceRegistry.add(ResourceLoader.class, new ResourceLoader()
      {
         public void cleanup() { }
        
View Full Code Here

   {
      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
      {
View Full Code Here

TOP

Related Classes of org.jboss.shrinkwrap.api.classloader.ShrinkWrapClassLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.