org.jboss.shrinkwrap.api.Filter Java Examples

The following examples show how to use org.jboss.shrinkwrap.api.Filter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArchiveResourceIteratorFactory.java    From tomee with Apache License 2.0 6 votes vote down vote up
private Collection<Resource> findResources(final String path, final String suffix) {
    final ClassLoader loader = Thread.currentThread().getContextClassLoader();
    final Collection<Resource> resources = new ArrayList<Resource>();
    if (SWClassLoader.class.isInstance(loader)) {
        final Collection<Archive<?>> archives = SWClassLoader.class.cast(loader).getArchives();
        final ClassLoader parent = loader.getParent();
        for (final Archive<?> archive : archives) {
            final Map<ArchivePath, Node> content = archive.getContent(new Filter<ArchivePath>() {
                @Override
                public boolean include(final ArchivePath object) {
                    final String currentPath = classloaderPath(object);

                    return !(parent != null && parent.getResource(currentPath) != null)
                            && currentPath.startsWith('/' + path) && currentPath.endsWith(suffix);

                }
            });

            for (final Map.Entry<ArchivePath, Node> entry : content.entrySet()) {
                resources.add(new SWResource(entry.getKey(), entry.getValue()));
            }
        }
    }
    return resources;
}
 
Example #2
Source File: ScanMultiProvider.java    From appengine-tck with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected Filter<ArchivePath> createFilter(WebArchive uber, WebArchive archive) throws Exception {
    if (filterClass != null) {
        return (Filter<ArchivePath>) MultiContext.newInstance(ScanStrategy.class.getClassLoader(), filterClass, new Object[]{uber, archive}, new Class[]{WebArchive.class, WebArchive.class});
    } else {
        return new WarningFilter(uber, archive);
    }
}
 
Example #3
Source File: Mvn.java    From tomee with Apache License 2.0 5 votes vote down vote up
public KnownResourcesFilter(final File base, final String prefix, final Filter<ArchivePath> filter) {
    this.base = base;
    this.delegate = filter;

    if (prefix.startsWith("/")) {
        this.prefix = prefix.substring(1);
    } else {
        this.prefix = prefix;
    }
}
 
Example #4
Source File: BuildCoordinatorDeployments.java    From pnc with Apache License 2.0 4 votes vote down vote up
private static JavaArchive defaultLibs() {
    Filter<ArchivePath> filter = path -> {
        String packageStylePath = path.get().replaceAll("/", ".").replaceAll("\\.class$", "").substring(1);
        log.debug("Checking path: {}.", packageStylePath);
        if (packageStylePath.equals(DefaultBuildExecutor.class.getName())) {
            return false;
        }
        return true;
    };

    JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
            .addClass(Configuration.class)
            .addClass(BuildSetStatusChangedEvent.class)
            .addClass(DefaultBuildSetStatusChangedEvent.class)
            .addClass(BuildEnvironment.Builder.class)
            .addClass(TestEntitiesFactory.class)
            .addClass(BuildCoordinatorFactory.class)
            .addClass(BuildConfigurationAuditedRepositoryMock.class)
            .addPackages(false, filter, BuildResultMapper.class.getPackage())
            .addPackages(
                    true,
                    filter,
                    BuildCoordinator.class.getPackage(),
                    DefaultBuildCoordinator.class.getPackage(),
                    BuildSetStatusNotifications.class.getPackage(),
                    TestProjectConfigurationBuilder.class.getPackage(),
                    ContentIdentityManager.class.getPackage(),
                    BuildConfigSetRecordRepository.class.getPackage(),
                    TestCDIBuildStatusChangedReceiver.class.getPackage(),
                    BuildSetCallBack.class.getPackage(),
                    BuildCallBack.class.getPackage(),
                    BuildCoordinationStatus.class.getPackage(),
                    DefaultBuildStatusChangedEvent.class.getPackage(),
                    BuildExecutorMock.class.getPackage(),
                    DefaultBuildExecutionSession.class.getPackage(),
                    MessageSender.class.getPackage(),
                    SystemConfig.class.getPackage(),
                    ModuleConfigFactory.class.getPackage(),
                    AbstractArtifactMapper.class.getPackage())
            // TODO remove, no need to use default beans.xml
            .addAsManifestResource(
                    new StringAsset(Descriptors.create(BeansDescriptor.class).exportAsString()),
                    "beans.xml")
            .addAsResource("logback-test.xml", "logback.xml");

    log.info("Deployment content: {}", jar.toString(true));
    return jar;
}
 
Example #5
Source File: ScanMultiProvider.java    From appengine-tck with Apache License 2.0 4 votes vote down vote up
protected void merge(MultiContext context, WebArchive war) throws Exception {
    WebArchive uber = context.getWar();
    Filter<ArchivePath> filter = createFilter(uber, war);
    uber.merge(war, filter);
}