Beispiel #1
0
 /*
  * Facet Methods
  */
 @Override
 public boolean isInstalled() {
   DirectoryResource webRoot = project.getFacet(WebResourceFacet.class).getWebRootDirectory();
   return webRoot.exists()
       && getConfigFile().exists()
       && project.getFacet(DependencyFacet.class).hasDependency(dep);
 }
Beispiel #2
0
  @Override
  public boolean install() {
    if (!isInstalled()) {
      String projectName = project.getFacet(MetadataFacet.class).getProjectName();

      project.getFacet(DependencyFacet.class).addDependency(dep);

      DirectoryResource webRoot = project.getFacet(WebResourceFacet.class).getWebRootDirectory();
      if (!webRoot.exists()) {
        webRoot.mkdirs();
      }

      FileResource<?> descriptor = getConfigFile();
      if (!descriptor.exists()) {
        WebAppDescriptor unit =
            Descriptors.create(WebAppDescriptor.class)
                .displayName(projectName)
                .sessionTimeout(30)
                .welcomeFile("/index.html");

        descriptor.setContents(unit.exportAsString());
      }

      FileResource<?> welcomePage = (FileResource<?>) webRoot.getChild("index.html");
      welcomePage.setContents(
          "<html><head><title>Welcome to Seam Forge</title></head>"
              + "<body>"
              + "<h1> ["
              + projectName
              + "] is Online</h1>"
              + "Powered by <a href=\"http://bit.ly/seamforge\">Seam Forge</a>"
              + "</body>"
              + "</html>");
    }
    return true;
  }