Creates an instance of <code>extensionImplClass</code> using <code>archive</code> as the parameter for its
one-argument list constructor.

@param <T>
@param extensionImplClass
@param archive
@return
503972
private <T extends Assignable> T createExtension(Class<T> extensionImplClass, Archive<?> archive) {

        T extension;
        Constructor<T> extensionImplConstructor = findConstructor(extensionImplClass);

        @SuppressWarnings("unchecked")
        Class<T> constructorArg = (Class<T>) extensionImplConstructor.getParameterTypes()[0];
        try {

            if (constructorArg.isInstance(archive)) {
                extension = extensionImplConstructor.newInstance(archive);
            } else {
                extension = extensionImplConstructor.newInstance(load(constructorArg, archive));
            }
        } catch (InstantiationException e) {
            throw new ExtensionLoadingException("Failed to instantiate class of type " + archive.getClass()
                + ". The underlying class can not be abstract.", e);
        } catch (IllegalAccessException e) {
            throw new ExtensionLoadingException("Failed to instantiate class of type " + archive.getClass()
                + ". The underlying constructor is inaccessible.", e);
        } catch (InvocationTargetException e) {
            throw new ExtensionLoadingException("Failed to instantiate class of type " + archive.getClass()
                + ". The underlying constructor threw an exception.", e);
        }

        return extension;
    }
1238909
public static ExtensionInfo load(String className, ClassLoader classLoader) {
        try (InputStream input = classLoader.getResourceAsStream(className.replace('.', '/') + ".class")) {
            ExtensionInfo info = new ExtensionInfo(className);
            new ClassReader(input).accept(new ExtensionVisitor(info), ClassReader.SKIP_DEBUG);

            return info;
        } catch (IOException e) {
            log.error(e.getMessage(), e);
            return null;
        }
    }
189583
public static List<File> listFileWithExtension(final File rootDir, final String extension) {
		return Files.fileTreeTraverser().preOrderTraversal(rootDir).filter(new FileExtensionFilter(extension)).toList();
	}
847019
public static <T> ExtensionLoader<T> getExtensionLoader(Class<T> clazz, ExtensionLoaderListener<T> listener) {
        ExtensionLoader<T> loader = LOADER_MAP.get(clazz);
        if (loader == null) {
            synchronized (ExtensionLoaderFactory.class) {
                loader = LOADER_MAP.get(clazz);
                if (loader == null) {
                    loader = new ExtensionLoader<T>(clazz, listener);
                    LOADER_MAP.put(clazz, loader);
                }
            }
        }
        return loader;
    }
286067
@Override
    public Archive<T> shallowCopy(Filter<ArchivePath> filter) {
        Validate.notNull(filter, "Filter must be specified");

        // Get the actual class type and make a shallow copy of the the underlying archive,
        // using the same underlying configuration
        final Class<T> actualClass = this.getActualClass();
        final Archive<?> underlyingArchive = this.getArchive();
        final Configuration existingConfig = ((Configurable) underlyingArchive).getConfiguration();
        final Domain domain = ShrinkWrap.createDomain(existingConfig);
        final ArchiveFactory factory = domain.getArchiveFactory();
        final Archive<T> newArchive = factory.create(actualClass, this.getName());
        final Map<ArchivePath, Node> contents = underlyingArchive.getContent();
        for (final ArchivePath path : contents.keySet()) {
            Asset asset = contents.get(path).getAsset();
            if (asset != null) {
                if(!filter.include(path)) {
                    continue;
                }
                newArchive.add(asset, path);
            }
        }
        return newArchive;
    }
1038943
JavaArchive createWarpArchive() {
        JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "arquillian-warp.jar");

        // API
        archive.addClass(Inspection.class);
        archive.addClasses(BeforeServlet.class, AfterServlet.class);

        for (String packageName : REQUIRED_WARP_PACKAGES) {
            archive.addPackage(packageName);
        }

        archive.addAsManifestResource(getWebFragmentAsset(), "web-fragment.xml");

        archive.addClasses(REQUIRED_WARP_INNER_CLASSES);

        // register remote extension
        archive.addClass(WarpRemoteExtension.class);
        archive.addAsServiceProvider(RemoteLoadableExtension.class.getName(), WarpRemoteExtension.class.getName(),
            "!org.jboss.arquillian.protocol.servlet.runner.ServletRemoteExtension");
        archive.addAsServiceProvider(LifecycleManagerStore.class, LifecycleManagerStoreImpl.class);

        // register RequestProcessingDelegationService
        archive.addAsServiceProvider(RequestDelegationService.class, CommandBusOnServer.class);

        return archive;
    }
461245
@SuppressWarnings("unchecked")
    public static <S, I, O> ExtensionResult<S, I, O> empty() {
        return (ExtensionResult<S, I, O>) EMPTY;
    }
1008221
@Override
    public IterableResult<Extension> search(ExtensionQuery query) throws SearchException
    {
        return RepositoryUtils.search(query, this.repositories);
    }
227075
@Override
    public Set<String> getExtensionClasses() {

        Set<String> serviceClazzes = new HashSet<>();

        if (getType() == ArchiveType.WEB_MODULE) {
            Resource webInfClassesMetaInfServicesEntry = getResource(CDIUtils.WEB_INF_CLASSES_META_INF_SERVICES_CDI_EXTENSION);
            serviceClazzes.addAll(CDIUtils.parseServiceSPIExtensionFile(webInfClassesMetaInfServicesEntry));
        }

        Resource metaInfServicesEntry = getResource(CDIUtils.META_INF_SERVICES_CDI_EXTENSION);
        serviceClazzes.addAll(CDIUtils.parseServiceSPIExtensionFile(metaInfServicesEntry));
        return serviceClazzes;
    }
495601
@Override
    public <X extends Archive<X>> X getAsType(Class<X> type, String path) {
        Validate.notNull(path, "Path must be specified");
        return getAsType(type, ArchivePaths.create(path));
    }
70009
@Override
    public T add(final Archive<?> archive, final String path, final Class<? extends StreamExporter> exporter) {
        this.getArchive().add(archive, path, exporter);
        return covarientReturn();
    }
591946
public static List<File> getFilesByExtension(File dir, String[] extensions)
    {
        if (!dir.isDirectory() || extensions == null)
            return Collections.emptyList();
        List<File> files = new ArrayList<File>();
        addFilesByExtension(files, dir, extensions);
        return files;
    }
1308827
public static URI getRootUri(final Archive<?> archive) throws IllegalArgumentException {
        if (archive == null) {
            throw new IllegalArgumentException("Archive must be specified");
        }
        final StringBuilder sb = new StringBuilder();
        sb.append(PROTOCOL);
        sb.append(URI_PROTOCOL_SUFFIX);
        sb.append(archive.getId());
        sb.append('/');
        final URI uri = URI.create(sb.toString());
        return uri;
    }
1004360
@Override
    public <X extends Archive<X>> Collection<X> getAsType(Class<X> type, Filter<ArchivePath> filter) {
        return this.getArchive().getAsType(type, filter);
    }
1242650
@Override
    public Extension resolve(ExtensionId extensionId) throws ResolveException
    {
        ResolveException lastException = null;

        for ( repository : this.repositories) {
            try {
                return repository.resolve(extensionId);
            } catch (ExtensionNotFoundException e1) {
                this.logger.debug("Could not find extension [{}] in repository [{}]", extensionId,
                    repository.getDescriptor(), e1);
            } catch (ResolveException e2) {
                this.logger.error("Unexpected error when trying to find extension [{}] in repository [{}]", extensionId,
                    repository.getDescriptor(), e2);

                lastException = e2;
            }
        }

        if (lastException != null) {
            throw new ResolveException(MessageFormat.format("Failed to resolve extension [{0}]", extensionId),
                lastException);
        } else {
            throw new ExtensionNotFoundException(MessageFormat.format("Could not find extension [{0}]", extensionId));
        }
    }
40502
public static TypeAnnotationPosition
        classExtends(final List<TypePathEntry> location,
                     final JCLambda onLambda,
                     final int type_index,
                     final int pos) {
        return new TypeAnnotationPosition(TargetType.CLASS_EXTENDS, pos,
                                          Integer.MIN_VALUE, onLambda,
                                          type_index, Integer.MIN_VALUE,
                                          location);
    }
701842
public <T> T getLocalExtension(Class<T> extensionType) {
        Object obj = extensions.get(extensionType);
        if (null != obj) {
            return extensionType.cast(obj);
        }
        return null;
    }