Search in sources :

Example 1 with Classpath

use of org.eclipse.jst.server.generic.servertype.definition.Classpath in project webtools.servertools by eclipse.

the class ServerTypeDefinitionUtil method getClasspathEntries.

public static ArrayList getClasspathEntries(String ref, ServerRuntime definition, boolean isLaunch) {
    Classpath cp = definition.getClasspath(ref);
    Iterator archives = cp.getArchive().iterator();
    ArrayList<Object> entryList = new ArrayList<Object>();
    while (archives.hasNext()) {
        ArchiveType archive = (ArchiveType) archives.next();
        String item = definition.getResolver().resolveProperties(archive.getPath());
        if (isLaunch)
            entryList.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(item)));
        else
            entryList.add(JavaCore.newLibraryEntry(new Path(item), null, null));
    }
    Iterator fileSets = cp.getFileset().iterator();
    while (fileSets.hasNext()) {
        FilesetType fileset = (FilesetType) fileSets.next();
        String dir = definition.getResolver().resolveProperties(fileset.getDir());
        Iterator includes = fileset.getInclude().iterator();
        String[] inclstr = new String[fileset.getInclude().size()];
        int i = 0;
        while (includes.hasNext()) {
            IncludeType incl = (IncludeType) includes.next();
            inclstr[i++] = definition.getResolver().resolveProperties(incl.getName());
        }
        Iterator excludes = fileset.getExclude().iterator();
        String[] exclstr = new String[fileset.getExclude().size()];
        i = 0;
        while (excludes.hasNext()) {
            ExcludeType excl = (ExcludeType) excludes.next();
            exclstr[i++] = definition.getResolver().resolveProperties(excl.getName());
        }
        DirectoryScanner scanner = new DirectoryScanner();
        scanner.setBasedir(dir);
        scanner.setIncludes(inclstr);
        scanner.setExcludes(exclstr);
        scanner.scan();
        String[] filesetFiles = scanner.getIncludedFiles();
        for (int j = 0; j < filesetFiles.length; j++) {
            String item = dir + "/" + filesetFiles[j];
            if (isLaunch)
                entryList.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(item)));
            else
                entryList.add(JavaCore.newLibraryEntry(new Path(item), null, null));
        }
    }
    return entryList;
}
Also used : Path(org.eclipse.core.runtime.Path) ArchiveType(org.eclipse.jst.server.generic.servertype.definition.ArchiveType) ArrayList(java.util.ArrayList) ExcludeType(org.eclipse.jst.server.generic.servertype.definition.ExcludeType) FilesetType(org.eclipse.jst.server.generic.servertype.definition.FilesetType) IncludeType(org.eclipse.jst.server.generic.servertype.definition.IncludeType) Classpath(org.eclipse.jst.server.generic.servertype.definition.Classpath) DirectoryScanner(org.eclipse.jst.server.generic.internal.files.DirectoryScanner) Iterator(java.util.Iterator)

Example 2 with Classpath

use of org.eclipse.jst.server.generic.servertype.definition.Classpath in project webtools.servertools by eclipse.

the class ServerRuntimeMergeUtil method containsClasspath.

private static boolean containsClasspath(List properties, String id) {
    boolean found = false;
    Iterator iter = properties.iterator();
    while (iter.hasNext()) {
        Classpath classpath = (Classpath) iter.next();
        if (classpath.getId().equals(id)) {
            found = true;
            break;
        }
    }
    return found;
}
Also used : Classpath(org.eclipse.jst.server.generic.servertype.definition.Classpath) Iterator(java.util.Iterator)

Example 3 with Classpath

use of org.eclipse.jst.server.generic.servertype.definition.Classpath in project webtools.servertools by eclipse.

the class ServerRuntimeUtils method verifyClasspath.

public static void verifyClasspath(List classpaths, String id) {
    boolean found = false;
    int count = 0;
    Iterator iter = classpaths.iterator();
    while (iter.hasNext()) {
        Classpath cp = (Classpath) iter.next();
        if (cp.getId().equals(id)) {
            found = true;
            ++count;
        }
    }
    assertTrue("Classpath not found", found);
    assertEquals("More than one classpath found", 1, count);
}
Also used : Classpath(org.eclipse.jst.server.generic.servertype.definition.Classpath) Iterator(java.util.Iterator)

Example 4 with Classpath

use of org.eclipse.jst.server.generic.servertype.definition.Classpath in project webtools.servertools by eclipse.

the class ServerTypeDefinitionModelTest method testClasspath.

public void testClasspath() {
    Classpath cp = (Classpath) subject.getClasspath().get(0);
    assertTrue(cp.getId() != null && cp.getId().length() > 0);
    assertTrue(cp.getArchive() != null && cp.getArchive().size() > 0);
    ArchiveType archiveType = (ArchiveType) cp.getArchive().get(0);
    assertTrue(archiveType.getPath() != null && archiveType.getPath().length() > 0);
}
Also used : ArchiveType(org.eclipse.jst.server.generic.servertype.definition.ArchiveType) Classpath(org.eclipse.jst.server.generic.servertype.definition.Classpath)

Example 5 with Classpath

use of org.eclipse.jst.server.generic.servertype.definition.Classpath in project webtools.servertools by eclipse.

the class GenericServerRuntime method validateClasspaths.

/**
 * Checks all defined classpaths.
 */
protected IStatus validateClasspaths(ServerRuntime serverTypeDefinition) {
    Iterator cpList = serverTypeDefinition.getClasspath().iterator();
    while (cpList.hasNext()) {
        Classpath cpth = (Classpath) cpList.next();
        if (cpth.getArchive() == null || cpth.getArchive().size() < 1)
            return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, GenericServerCoreMessages.errorNoClasspath, null);
        Iterator archIter = cpth.getArchive().iterator();
        while (archIter.hasNext()) {
            ArchiveType arch = (ArchiveType) archIter.next();
            String arcPath = serverTypeDefinition.getResolver().resolveProperties(arch.getPath());
            File f = new File(arcPath);
            if (f.exists() == false)
                return new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, 0, NLS.bind(GenericServerCoreMessages.errorMissingClasspathEntry, f.getPath()), null);
        }
    }
    // $NON-NLS-1$
    return new Status(IStatus.OK, CorePlugin.PLUGIN_ID, 0, "", null);
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ArchiveType(org.eclipse.jst.server.generic.servertype.definition.ArchiveType) Classpath(org.eclipse.jst.server.generic.servertype.definition.Classpath) Iterator(java.util.Iterator) File(java.io.File)

Aggregations

Classpath (org.eclipse.jst.server.generic.servertype.definition.Classpath)7 Iterator (java.util.Iterator)5 ArchiveType (org.eclipse.jst.server.generic.servertype.definition.ArchiveType)3 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IStatus (org.eclipse.core.runtime.IStatus)1 Path (org.eclipse.core.runtime.Path)1 Status (org.eclipse.core.runtime.Status)1 DirectoryScanner (org.eclipse.jst.server.generic.internal.files.DirectoryScanner)1 ExcludeType (org.eclipse.jst.server.generic.servertype.definition.ExcludeType)1 FilesetType (org.eclipse.jst.server.generic.servertype.definition.FilesetType)1 IncludeType (org.eclipse.jst.server.generic.servertype.definition.IncludeType)1 Module (org.eclipse.jst.server.generic.servertype.definition.Module)1 Property (org.eclipse.jst.server.generic.servertype.definition.Property)1