当前位置: 首页>>代码示例>>Java>>正文


Java ClassPathSupport类代码示例

本文整理汇总了Java中org.netbeans.spi.java.classpath.support.ClassPathSupport的典型用法代码示例。如果您正苦于以下问题:Java ClassPathSupport类的具体用法?Java ClassPathSupport怎么用?Java ClassPathSupport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ClassPathSupport类属于org.netbeans.spi.java.classpath.support包,在下文中一共展示了ClassPathSupport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findClassPath

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
public ClassPath findClassPath(FileObject file, String type) {
    if(ClassPath.SOURCE.equals(type)){
        return this.classPath;
    }
    if (ClassPath.COMPILE.equals(type)){
        try {
            URL eclipselinkJarUrl = Class.forName("javax.persistence.EntityManager").getProtectionDomain().getCodeSource().getLocation();
            URL[] urls = new URL[]{FileUtil.getArchiveRoot(eclipselinkJarUrl)};
            return ClassPathSupport.createClassPath(urls);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    } 
    if (ClassPath.BOOT.equals(type)){
        return JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries();
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ClassPathProviderImpl.java

示例2: getSourceLevel

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
public String getSourceLevel(org.openide.filesystems.FileObject javaFile) {        
    Library ll = this.isLastUsed (javaFile);
    if (ll != null) {
        return getSourceLevel (ll);
    }
    for (LibraryManager mgr : LibraryManager.getOpenManagers()) {
        for (Library lib : mgr.getLibraries()) {
            if (!lib.getType().equals(J2SELibraryTypeProvider.LIBRARY_TYPE)) {
                continue;
            }
            List<URL> sourceRoots = lib.getContent(J2SELibraryTypeProvider.VOLUME_TYPE_SRC);
            if (sourceRoots.isEmpty()) {
                continue;
            }
            ClassPath cp = ClassPathSupport.createClassPath(sourceRoots.toArray(new URL[sourceRoots.size()]));
            FileObject root = cp.findOwnerRoot(javaFile);
            if (root != null) {
                setLastUsedRoot(root, lib);
                return getSourceLevel(lib);
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:J2SELibrarySourceLevelQueryImpl.java

示例3: getStandardLibraries

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
/**
 * This implementation simply reads and parses `java.class.path' property and creates a ClassPath
 * out of it.
 * @return  ClassPath that represents contents of system property java.class.path.
 */
@Override
public ClassPath getStandardLibraries() {
    synchronized (this) {
        ClassPath cp = (standardLibs == null ? null : standardLibs.get());
        if (cp != null)
            return cp;
        final String pathSpec = getSystemProperties().get(SYSPROP_JAVA_CLASS_PATH);
        if (pathSpec == null) {
            cp = ClassPathSupport.createClassPath(new URL[0]);
        }
        else {
            cp = Util.createClassPath (pathSpec);
        }
        standardLibs = new SoftReference<>(cp);
        return cp;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:J2SEPlatformImpl.java

示例4: classToSourceURL

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
private String classToSourceURL (FileObject fo) {
    try {
        ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE);
        FileObject root = cp.findOwnerRoot (fo);
        String resourceName = cp.getResourceName (fo, '/', false);
        if (resourceName == null) {
            getProject().log("Can not find classpath resource for "+fo+", skipping...", Project.MSG_ERR);
            return null;
        }
        int i = resourceName.indexOf ('$');
        if (i > 0)
            resourceName = resourceName.substring (0, i);
        FileObject[] sRoots = SourceForBinaryQuery.findSourceRoots 
            (root.getURL ()).getRoots ();
        ClassPath sourcePath = ClassPathSupport.createClassPath (sRoots);
        FileObject rfo = sourcePath.findResource (resourceName + ".java");
        if (rfo == null) return null;
        return rfo.getURL ().toExternalForm ();
    } catch (FileStateInvalidException ex) {
        ex.printStackTrace ();
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:JPDAReload.java

示例5: createResources

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
@Override
protected List<PathResourceImplementation> createResources() {
    ArrayList<PathResourceImplementation> result = new ArrayList<> ();
            boolean[] includeJDK = { true };
            boolean[] includeFX = { false };
            result.addAll(ecpImpl.getResources(includeJDK, includeFX));
            lastHintValue = project.getAuxProps().get(Constants.HINT_JDK_PLATFORM, true);
            if (includeJDK[0]) {
                JavaPlatform pat = findActivePlatform();
                boolean hasFx = false;
                for (ClassPath.Entry entry : pat.getBootstrapLibraries().entries()) {
                    if (entry.getURL().getPath().endsWith("/jfxrt.jar!/")) {
                        hasFx = true;
                    }
                    result.add(ClassPathSupport.createResource(entry.getURL()));
                }
                if (includeFX[0] && !hasFx) {
                    PathResourceImplementation fxcp = createFxCPImpl(pat);
                    if (fxcp != null) {
                        result.add(fxcp);
                    }
                }
                result.addAll(nbPlatformJavaFxCp(project, pat));
            }
    return result;
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BootClassPathImpl.java

示例6: findOwnerRoot

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
@CheckForNull
private static FileObject findOwnerRoot(
    @NonNull final String className,
    @NonNull final String[] extensions,
    @NonNull final ClassPath... binCps) {
    final String binaryResource = FileObjects.convertPackage2Folder(className);
    final ClassPath merged = ClassPathSupport.createProxyClassPath(binCps);
    for (String ext : extensions) {
        final FileObject res = merged.findResource(String.format(
                "%s.%s",    //NOI18N
                binaryResource,
                ext));
        if (res != null) {
            return merged.findOwnerRoot(res);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ProjectRunnerImpl.java

示例7: createBootClassPath

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
/**
     * Creates boot {@link ClassPath} for platform the test is running on,
     * it uses the sun.boot.class.path property to find out the boot path roots.
     * @return ClassPath
     * @throws java.io.IOException when boot path property contains non valid path
     */
    public static ClassPath createBootClassPath() throws IOException {
        String bootPath = System.getProperty("sun.boot.class.path");
        String[] paths = bootPath.split(File.pathSeparator);
        List<URL> roots = new ArrayList<>(paths.length);
        for (String path : paths) {
            File f = new File(path);
            if (!f.exists()) {
                continue;
            }
            URL url = Utilities.toURI(f).toURL();
            if (FileUtil.isArchiveFile(url)) {
                url = FileUtil.getArchiveRoot(url);
            }
            roots.add(url);
//            System.out.println(url);
        }
//        System.out.println("-----------");
        return ClassPathSupport.createClassPath(roots.toArray(new URL[roots.size()]));
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProjectTestBase.java

示例8: findUnitTestInTestRoot

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
/**
 * Copied from JUnit module implementation in 4.1 and modified
 */
private static FileObject findUnitTestInTestRoot(ClassPath cp, FileObject selectedFO, URL testRoot) {
    ClassPath testClassPath = null;

    if (testRoot == null) { //no tests, use sources instead
        testClassPath = cp;
    } else {
        try {
            List<PathResourceImplementation> cpItems = new ArrayList<PathResourceImplementation>();
            cpItems.add(ClassPathSupport.createResource(testRoot));
            testClassPath = ClassPathSupport.createClassPath(cpItems);
        } catch (IllegalArgumentException ex) {
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
            testClassPath = cp;
        }
    }

    String testName = getTestName(cp, selectedFO);

    return testClassPath.findResource(testName + ".java"); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ProjectUtilities.java

示例9: findClassPath

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
public ClassPath findClassPath(FileObject file, String type) {
    if(ClassPath.SOURCE.equals(type)){
        return this.classPath;
    }
    if (ClassPath.COMPILE.equals(type)){
        try {
            URL eclipselinkJarUrl = Class.forName("javax.persistence.EntityManager").getProtectionDomain().getCodeSource().getLocation();
            return ClassPathSupport.createClassPath(new URL[]{FileUtil.getArchiveRoot(eclipselinkJarUrl)});
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
    if (ClassPath.BOOT.equals(type)){
        return JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries();
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ClassPathProviderImpl.java

示例10: projecRuntimeClassPath

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
public static ClassPath projecRuntimeClassPath(Project project) {
    if (project == null) {
        return null;
    }
    boolean modular = isModularProject(project);
    List<ClassPath> delegates = new ArrayList<>();
    for (SourceGroup sg : org.netbeans.api.project.ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
        if (!isNormalRoot(sg)) {
            continue;
        }
        ClassPath del; 
        if (modular) {
            del = ClassPath.getClassPath(sg.getRootFolder(), JavaClassPathConstants.MODULE_EXECUTE_CLASS_PATH);
        } else {
            del = ClassPath.getClassPath(sg.getRootFolder(), ClassPath.EXECUTE); 
        }
        if (del != null && !del.entries().isEmpty()) {
            delegates.add(del);
        }
    }
    return ClassPathSupport.createProxyClassPath(delegates.toArray(new ClassPath[delegates.size()]));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ShellProjectUtils.java

示例11: findClassPath

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
public ClassPath findClassPath(FileObject file, String type) {
    try {
    if (ClassPath.BOOT == type) {
        // XXX simpler to use JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries()
        return ClassPathSupport.createClassPath(getBootClassPath().toArray(new URL[0]));
    }

    if (ClassPath.SOURCE == type) {
        return sourcePath;
    }

    if (ClassPath.COMPILE == type) {
        return compileClassPath;
    }

    if (ClassPath.EXECUTE == type) {
        return ClassPathSupport.createClassPath(new FileObject[] {
            buildRoot
        });
    }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:HintTest.java

示例12: getJavacApiJarClasspath

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
private static ClassPath getJavacApiJarClasspath() {
    Reference<ClassPath> r = javacApiClasspath;
    ClassPath res = r.get();
    if (res != null) {
        return res;
    }
    if (r == NONE) {
        return null;
    }
    CodeSource codeSource = Modifier.class.getProtectionDomain().getCodeSource();
    URL javacApiJar = codeSource != null ? codeSource.getLocation() : null;
    if (javacApiJar != null) {
        Logger.getLogger(DeclarativeHintsParser.class.getName()).log(Level.FINE, "javacApiJar={0}", javacApiJar);
        File aj = FileUtil.archiveOrDirForURL(javacApiJar);
        if (aj != null) {
            res = ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(aj));
            javacApiClasspath = new WeakReference<>(res);
            return res;
        }
    }
    javacApiClasspath = NONE;
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DeclarativeHintsParser.java

示例13: testNBResLocURL

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
public void testNBResLocURL() throws Exception {
    Map<String, String> files = new HashMap<String, String>();
    files.put("org/test/x.txt", "stuff");
    files.put("org/test/resources/y.txt", "more stuff");
    Layer orig = new Layer("<file name='x' url='nbres:/org/test/x.txt'/><file name='y' url='nbresloc:/org/test/resources/y.txt'/>", files);
    FileObject orgTest = FileUtil.createFolder(new File(orig.folder, "org/test"));
    FileObject lf = orig.f.copy(orgTest, "layer", "xml");
    SavableTreeEditorCookie cookie = LayerUtils.cookieForFile(lf);
    FileSystem fs = new WritableXMLFileSystem(lf.toURL(), cookie,
            ClassPathSupport.createClassPath(new FileObject[] { FileUtil.toFileObject(orig.folder) } ));
    FileObject x = fs.findResource("x");
    assertNotNull(x);
    assertTrue(x.isData());
    assertEquals(5L, x.getSize());
    assertEquals("stuff", x.asText("UTF-8"));

    FileObject y = fs.findResource("y");
    assertNotNull(y);
    assertTrue(y.isData());
    assertEquals(10L, y.getSize());
    assertEquals("more stuff", y.asText("UTF-8"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:WritableXMLFileSystemTest.java

示例14: testBinaryIndexers

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
@RandomlyFails
    public void testBinaryIndexers() throws Exception {
        final TestHandler handler = new TestHandler();
        final Logger logger = Logger.getLogger(RepositoryUpdater.class.getName()+".tests");
        logger.setLevel (Level.FINEST);
        logger.addHandler(handler);

        binIndexerFactory.indexer.setExpectedRoots(bootRoot2.toURL(), bootRoot3.toURL());
//        jarIndexerFactory.indexer.setExpectedRoots(bootRoot3.getURL());
        ClassPath cp = ClassPathSupport.createClassPath(new FileObject[] {bootRoot2, bootRoot3});
        globalPathRegistry_register(PLATFORM,new ClassPath[] {cp});
        assertTrue(handler.await());
        assertEquals(2, handler.getBinaries().size());
//        assertEquals(1, jarIndexerFactory.indexer.getCount());
        assertEquals(2, binIndexerFactory.indexer.getCount());
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:RepositoryUpdaterTest.java

示例15: testDeadLock

import org.netbeans.spi.java.classpath.support.ClassPathSupport; //导入依赖的package包/类
public void testDeadLock() throws Exception{
    List<PathResourceImplementation> resources = Collections.<PathResourceImplementation>emptyList();
    final ReentrantLock lock = new ReentrantLock (false);
    final CountDownLatch signal = new CountDownLatch (1);
    final ClassPath cp = ClassPathFactory.createClassPath(ClassPathSupport.createProxyClassPathImplementation(new ClassPathImplementation[] {new LockClassPathImplementation (resources,lock, signal)}));
    lock.lock();
    final ExecutorService es = Executors.newSingleThreadExecutor();        
    try {
        es.submit(new Runnable () {
            public void run () {
                cp.entries();
            }
        });
        signal.await();
        cp.entries();
    } finally {
        es.shutdownNow();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ProxyClassPathImplementationTest.java


注:本文中的org.netbeans.spi.java.classpath.support.ClassPathSupport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。