Package com.buschmais.jqassistant.plugin.java.api.model

Examples of com.buschmais.jqassistant.plugin.java.api.model.ServiceLoaderDescriptor


    @Override
    public Iterable<? extends FileDescriptor> scan(InputStream item, String path, Scope scope, Scanner scanner) throws IOException {
        Matcher matcher = PATTERN.matcher(path);
        if (matcher.matches()) {
            String serviceInterface = matcher.group(2);
            ServiceLoaderDescriptor serviceLoaderDescriptor = getStore().create(ServiceLoaderDescriptor.class);
            TypeDescriptor interfaceTypeDescriptor = getTypeDescriptor(serviceInterface);
            serviceLoaderDescriptor.setType(interfaceTypeDescriptor);
            BufferedReader reader = new BufferedReader(new InputStreamReader(item));
            String serviceImplementation;
            while ((serviceImplementation = reader.readLine()) != null) {
                TypeDescriptor implementationTypeDescriptor = getTypeDescriptor(serviceImplementation);
                serviceLoaderDescriptor.getContains().add(implementationTypeDescriptor);
            }
            serviceLoaderDescriptor.setFileName(path);
            return asList(serviceLoaderDescriptor);
        }
        return emptyList();
    }
View Full Code Here


        scanResource(JavaScope.CLASSPATH, "/META-INF/services/" + Service.class.getName());
        store.beginTransaction();
        List<ServiceLoaderDescriptor> serviceLoaderDescriptors = query("MATCH (sd:ServiceLoader:File) RETURN sd").getColumn("sd");
        assertThat(serviceLoaderDescriptors.size(), equalTo(1));

        ServiceLoaderDescriptor serviceLoaderDescriptor = serviceLoaderDescriptors.get(0);
        assertThat(serviceLoaderDescriptor.getFileName(), endsWith("/META-INF/services/" + Service.class.getName()));
        assertThat(serviceLoaderDescriptor.getType(), typeDescriptor(Service.class));
        assertThat(serviceLoaderDescriptor.getContains(), hasItem(typeDescriptor(ServiceImpl.class)));

        store.commitTransaction();
    }
View Full Code Here

TOP

Related Classes of com.buschmais.jqassistant.plugin.java.api.model.ServiceLoaderDescriptor

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.