Package org.jboss.forge.parser.xml

Examples of org.jboss.forge.parser.xml.Node


      assertPropertiesInContext();
      FacesFacet facesFacet = project.getFacet(FacesFacet.class);
      FileResource<?> configFile = facesFacet.getConfigFile();
      String baseBundleName = getBaseBundleName(propertiesFileResource.getName());

      Node facesConfig = XMLParser.parse(configFile.getResourceInputStream());

      Node applicationNode = facesConfig.getOrCreate("application");

      Node resourceBundleNode = applicationNode.getOrCreate("resource-bundle");
      resourceBundleNode.getOrCreate("base-name").text(baseBundleName);
      resourceBundleNode.getOrCreate("var").text(varName);

      configFile.setContents(XMLParser.toXMLInputStream(facesConfig));
      shell.println("Faces config has been updated.");
   }
View Full Code Here


   {
      public static final String FACES_SERVLET_CLASS = "javax.faces.webapp.FacesServlet";

      public InputStream addFacesServletMapping(final InputStream webXmlStream, final String mapping)
      {
         Node root = XMLParser.parse(webXmlStream);
         Node facesServlet = getOrCreateFacesServlet(root);
         boolean mappingCreated = createMappingIfNotExists(root, facesServlet, mapping);
         if (mappingCreated)
         {
            return XMLParser.toXMLInputStream(root);
         }
View Full Code Here

            if (FACES_SERVLET_CLASS.equals(servlet.getSingle("servlet-class").getText()))
            {
               return servlet;
            }
         }
         Node servlet = root.createChild("servlet");
         servlet.createChild("servlet-name").text("Faces Servlet");
         servlet.createChild("servlet-class").text(FACES_SERVLET_CLASS);
         servlet.createChild("load-on-startup").text("1");
         return servlet;
      }
View Full Code Here

      }

      boolean createMappingIfNotExists(final Node root, final Node servlet, final String mapping)
      {
         List<Node> servletMappings = root.get("servlet-mapping");
         Node servletMappingNode = null;
         String servletName = servlet.getSingle("servlet-name").getText();
         for (Node servletMapping : servletMappings)
         {
            if (servletName.equals(servletMapping.getSingle("servlet-name").getText()))
            {
               servletMappingNode = servletMapping;
               List<Node> urlPatterns = servletMapping.get("url-pattern");
               for (Node urlPattern : urlPatterns)
               {
                  if (mapping.equals(urlPattern.getText()))
                  {
                     return false; // mapping already exists; not created
                  }

               }
            }
         }
         // Mapping does not exist, create it and add the url-pattern
         if (servletMappingNode == null)
         {
            servletMappingNode = root.createChild("servlet-mapping");
            servletMappingNode.createChild("servlet-name").text(servletName);
         }
         servletMappingNode.createChild("url-pattern").text(mapping);
         return true;
      }
View Full Code Here

            if (FACES_SERVLET_CLASS.equals(servlet.getSingle("servlet-class").getText()))
            {
               return servlet;
            }
         }
         Node servlet = root.createChild("servlet");
         servlet.createChild("servlet-name").text("Faces Servlet");
         servlet.createChild("servlet-class").text(FACES_SERVLET_CLASS);
         servlet.createChild("load-on-startup").text("1");
         return servlet;
      }
View Full Code Here

      }

      boolean createMappingIfNotExists(final Node root, final Node servlet, final String mapping)
      {
         List<Node> servletMappings = root.get("servlet-mapping");
         Node servletMappingNode = null;
         String servletName = servlet.getSingle("servlet-name").getText();
         for (Node servletMapping : servletMappings)
         {
            if (servletName.equals(servletMapping.getSingle("servlet-name").getText()))
            {
               servletMappingNode = servletMapping;
               List<Node> urlPatterns = servletMapping.get("url-pattern");
               for (Node urlPattern : urlPatterns)
               {
                  if (mapping.equals(urlPattern.getText()))
                  {
                     return false; // mapping already exists; not created
                  }

               }
            }
         }
         // Mapping does not exist, create it and add the url-pattern
         if (servletMappingNode == null)
         {
            servletMappingNode = root.createChild("servlet-mapping");
            servletMappingNode.createChild("servlet-name").text(servletName);
         }
         servletMappingNode.createChild("url-pattern").text(mapping);
         return true;
      }
View Full Code Here

   {
      public static final String FACES_SERVLET_CLASS = "javax.faces.webapp.FacesServlet";

      public InputStream addFacesServletMapping(final InputStream webXmlStream, final String mapping)
      {
         Node root = XMLParser.parse(webXmlStream);
         Node facesServlet = getOrCreateFacesServlet(root);
         boolean mappingCreated = createMappingIfNotExists(root, facesServlet, mapping);
         if (mappingCreated)
         {
            return XMLParser.toXMLInputStream(root);
         }
View Full Code Here

               "src/main/resources/META-INF/forge.xml");
      if (forgeXml.exists())
      {
         try
         {
            Node node = XMLParser.parse(forgeXml.getResourceInputStream());
            return node.getSingle("dependencies-as-resource-root") != null;
         }
         catch (ParserException e)
         {
            return false;
         }
View Full Code Here

      moduleXml.delete();
      moduleXml.createNewFile();

      // <resource-root path="maven-dependency.jar" />
      Node module = XMLParser.parse(getClass().getResourceAsStream(MODULE_TEMPLATE_XML));
      module.attribute("name", pluginName);
      module.attribute("slot", pluginSlot);
      Node resources = module.getSingle("resources");

      resources.createChild("resource-root").attribute("path", dep.getArtifactId() + ".jar");

      if (dependenciesAsResourceRoot)
      {
         writeResourceRoots(project, module, moduleDir, resources);
      }

      // Copy the compiled JAR into the module directory
      FileResource<?> jar = moduleDir.getChild(dep.getArtifactId() + ".jar").reify(FileResource.class);
      jar.createNewFile();
      jar.setContents(artifact.getResourceInputStream());

      // <module name="org.jboss.forge:main" />
      Node dependencies = module.getSingle("dependencies");

      if (!dependenciesAsResourceRoot)
      {
         dependencies.createChild("module").attribute("name", pluginName + ".dependencies")
                  .attribute("slot", pluginSlot);
      }

      dependencies.createChild("module").attribute("name", "org.jboss.forge.javaee.api")
               .attribute("services", "import");
      dependencies.createChild("module").attribute("name", "org.jboss.forge.maven.api").attribute("services", "import");
      dependencies.createChild("module").attribute("name", "org.jboss.forge.scaffold.api")
               .attribute("services", "import");
      dependencies.createChild("module").attribute("name", "org.jboss.forge.shell.api").attribute("services", "import");
      dependencies.createChild("module").attribute("name", "org.jboss.seam.render").attribute("services", "import");
      dependencies.createChild("module").attribute("name", "javax.api");

      moduleXml.setContents(XMLParser.toXMLString(module));

      if (!dependenciesAsResourceRoot)
      {
View Full Code Here

      FileResource<?> moduleXml = (FileResource<?>) dependencyDir.getChild("module.xml");
      moduleXml.delete();
      moduleXml.createNewFile();

      // <resource-root path="maven-dependency.jar" />
      Node module = XMLParser.parse(getClass().getResourceAsStream(MODULE_TEMPLATE_XML));
      module.attribute("name", pluginName + ".dependencies");
      module.attribute("slot", pluginSlot);
      Node resources = module.getSingle("resources");

      // <module name="org.jboss.forge:main" />
      Node dependencies = module.getSingle("dependencies");
      dependencies.createChild("module").attribute("name", "javax.api");
      dependencies.createChild("module").attribute("name", "org.jboss.forge.shell.api");

      writeResourceRoots(project, module, dependencyDir, resources);

      // Write out the module XML file.
      moduleXml.setContents(XMLParser.toXMLString(module));
View Full Code Here

TOP

Related Classes of org.jboss.forge.parser.xml.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.