示例#1
0
 @Test
 public void testCreateTopLevelPackage() throws Exception {
   initializeJavaProject();
   DirectoryResource root = getProject().getProjectRoot();
   Resource<?> srcMainJavaDirectory = root.getChild("/src/main/java");
   assertNotNull(srcMainJavaDirectory.reify(DirectoryResource.class));
   Resource<?> testDirectory = srcMainJavaDirectory.getChild("com/test");
   assertNotNull(testDirectory.reify(DirectoryResource.class));
 }
示例#2
0
  @Override
  public FileResource<?> getConfigFile() {
    DirectoryResource webRoot = project.getFacet(WebResourceFacet.class).getWebRootDirectory();
    FileResource<?> child =
        (FileResource<?>) webRoot.getChild("WEB-INF" + File.separator + "faces-config.xml");

    if (!child.exists()) {
      return new UnknownFileResource(
          child.getResourceFactory(), child.getUnderlyingResourceObject()) {
        @Override
        public InputStream getResourceInputStream() {
          if (!exists()) {
            String projectName = project.getFacet(MetadataFacet.class).getProjectName();
            WebAppDescriptor unit =
                Descriptors.create(WebAppDescriptor.class)
                    .displayName(projectName)
                    .sessionTimeout(30);
            return Streams.fromString(unit.exportAsString());
          } else {
            return super.getResourceInputStream();
          }
        }

        @Override
        public UnknownFileResource setContents(InputStream data) {
          if (!exists()) {
            createNewFile();
          }
          return super.setContents(data);
        }

        @Override
        public UnknownFileResource setContents(char[] data) {
          if (!exists()) {
            createNewFile();
          }
          return super.setContents(data);
        }

        @Override
        public UnknownFileResource setContents(String data) {
          if (!exists()) {
            createNewFile();
          }
          return super.setContents(data);
        }
      };
    }

    return (FileResource<?>) child;
  }
示例#3
0
 @Override
 public FileResource<?> getConfigFile() {
   DirectoryResource webRoot = project.getFacet(WebResourceFacet.class).getWebRootDirectory();
   return (FileResource<?>) webRoot.getChild("WEB-INF" + File.separator + "faces-config.xml");
 }