Search in sources :

Example 6 with Classpath

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

the class ServerRuntimeMergeUtil method combine.

/**
 * Combines a runtime definition and a server definition
 * into a single logical <code>ServerRuntime</code>.
 *
 * @param serverdef
 * @param runtimedef
 * @return serverdef
 */
public static ServerRuntime combine(ServerRuntime serverdef, ServerRuntime runtimedef) {
    /**
     * Add properties from runtimedef to serverdef if not already present,
     * this ensures that:
     *
     * (1) while we are affecting the cached copy of serverdef, it is always
     *     required to be combined with its runtimedef (if there is one), and
     *     we check that the property has not already been added
     *
     * (2) serverdef properties can override runtimedef properties
     */
    List properties = runtimedef.getProperty();
    if (properties != null) {
        Iterator iter = properties.iterator();
        while (iter.hasNext()) {
            Property prop = (Property) iter.next();
            addPropertyIfNotPresent(serverdef.getProperty(), prop);
        }
    }
    /**
     * Add classpaths from runtimedef to serverdef if not already present,
     * this ensures that:
     *
     * (1) while we are affecting the cached copy of serverdef, it is always
     *     required to be combined with its runtimedef (if there is one), and
     *     we check that the classpath has not already been added (by id)
     *
     * (2) serverdef classpath can override runtimedef classpath by id
     */
    List classpaths = runtimedef.getClasspath();
    if (classpaths != null) {
        Iterator iter = classpaths.iterator();
        while (iter.hasNext()) {
            Classpath classpath = (Classpath) iter.next();
            addClasspathIfNotPresent(serverdef.getClasspath(), classpath);
        }
    }
    return serverdef;
}
Also used : Classpath(org.eclipse.jst.server.generic.servertype.definition.Classpath) Iterator(java.util.Iterator) List(java.util.List) Property(org.eclipse.jst.server.generic.servertype.definition.Property)

Example 7 with Classpath

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

the class ServerTypeDefinitionModelTest method testServerRuntime.

public void testServerRuntime() {
    assertTrue(subject.getClasspath() != null && subject.getClasspath().size() > 0);
    assertTrue(subject.getConfigurationElementNamespace() != null && subject.getConfigurationElementNamespace().length() > 0);
    assertTrue(subject.getName() != null && subject.getName().length() > 0);
    assertTrue(subject.getVersion() != null && subject.getVersion().length() > 0);
    assertTrue(subject.getProperty() != null && subject.getProperty().size() > 0);
    assertTrue(subject.getPort() != null && subject.getPort().size() > 0);
    assertTrue(subject.getModule() != null && subject.getModule().size() > 0);
    assertNotNull(subject.getProject());
    assertNotNull(subject.getStop());
    assertNotNull(subject.getStart());
    assertTrue(subject.getId() != null && subject.getId().length() > 0);
    assertTrue(subject.getFilename() != null && subject.getFilename().length() > 0);
    Classpath cp = (Classpath) subject.getClasspath().get(0);
    assertEquals(cp, subject.getClasspath(cp.getId()));
    Module module = (Module) subject.getModule().get(0);
    assertEquals(module, subject.getModule(module.getType()));
    assertNotNull(subject.getPublisher("org.eclipse.jst.server.generic.antpublisher"));
}
Also used : Classpath(org.eclipse.jst.server.generic.servertype.definition.Classpath) Module(org.eclipse.jst.server.generic.servertype.definition.Module)

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