Package org.jboss.forge.spec.javaee

Examples of org.jboss.forge.spec.javaee.ServletFacet


   }

   @Override
   public List<String> getFaceletsViewMapping()
   {
      ServletFacet facet = project.getFacet(ServletFacet.class);
      WebAppDescriptor webXml = facet.getConfig();
      return webXml.getFaceletsViewMappings();
   }
View Full Code Here


      if (!project.hasFacet(FacesFacet.class))
      {
         throw new RuntimeException("JSF is not installed. Use 'setup faces' to continue.");
      }

      ServletFacet srv = project.getFacet(ServletFacet.class);
      WebAppDescriptor config = srv.getConfig();
      if (stage == null)
      {
         ShellMessages.info(out, "Project stage is currently: " + config.getFacesProjectStage().getStage());
      }
      else
      {
         config.facesProjectStage(stage);
         srv.saveConfig(config);
         ShellMessages.success(out, "Faces PROJECT_STAGE updated to: " + stage.getStage());
      }
   }
View Full Code Here

      return context;
   }

   protected void setupWebXML()
   {
      ServletFacet servlet = this.project.getFacet(ServletFacet.class);

      Node webXML = removeConflictingErrorPages(servlet);
      servlet.getConfigFile().setContents(XMLParser.toXMLInputStream(webXML));

      WebAppDescriptor servletConfig = servlet.getConfig();
      WebResourceFacet web = this.project.getFacet(WebResourceFacet.class);

      // (prefer /faces/error.xhtml)

      String errorLocation = getAccessStrategy().getWebPaths(web.getWebResource("error.xhtml")).get(1);
      servletConfig.errorPage(404, errorLocation);
      servletConfig.errorPage(500, errorLocation);

      servlet.saveConfig(servletConfig);
   }
View Full Code Here

      return context;
   }

   protected void setupWebXML()
   {
      ServletFacet servlet = this.project.getFacet(ServletFacet.class);

      Node webXML = removeConflictingErrorPages(servlet);
      servlet.getConfigFile().setContents(XMLParser.toXMLInputStream(webXML));

      WebAppDescriptor servletConfig = servlet.getConfig();
      WebResourceFacet web = this.project.getFacet(WebResourceFacet.class);

      // (prefer /faces/error.xhtml)

      String errorLocation = getAccessStrategy().getWebPaths(web.getWebResource("error.xhtml")).get(1);
      servletConfig.errorPage(404, errorLocation);
      servletConfig.errorPage(500, errorLocation);
     
      // Use the server timezone since we accept dates in that timezone, and it makes sense to display them in the same
      if (servletConfig.getContextParam("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE") == null)
      {
         servletConfig.contextParam("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE", "true");
      }

      servlet.saveConfig(servletConfig);
   }
View Full Code Here

   }

   @Command("project-stage")
   public void setProjectStage(@Option(name = "set") final FacesProjectStage stage, final PipeOut out)
   {
      ServletFacet srv = project.getFacet(ServletFacet.class);
      WebAppDescriptor config = srv.getConfig();
      if (stage == null)
      {
         ShellMessages.info(out, "Project stage is currently: " + config.getFacesProjectStage().getStage());
      }
      else
      {
         config.facesProjectStage(stage);
         srv.saveConfig(config);
         ShellMessages.success(out, "Faces PROJECT_STAGE updated to: " + stage.getStage());
      }
   }
View Full Code Here

   public boolean install()
   {
      if (!installedInWebXML())
      {
         // TODO this needs to be fixed in desciptors (allow creation of servlet mapping)
         ServletFacet servlet = project.getFacet(ServletFacet.class);
         WebAppDescriptorImpl web = (WebAppDescriptorImpl) servlet.getConfig();
         Node node = web.getRootNode();
         Node servletClass = node.getOrCreate("servlet-mapping/servlet-name=" + JAXRS_SERVLET);
         String urlPattern = prompt.prompt("Serve REST resources under which URL path?", "/rest/*");
         servletClass.getParent().getOrCreate("url-pattern").text(urlPattern);
         servlet.saveConfig(web);
      }
      return super.install();
   }
View Full Code Here

   }

   @Override
   public String getApplicationPath()
   {
      ServletFacet servlet = project.getFacet(ServletFacet.class);
      WebAppDescriptorImpl web = (WebAppDescriptorImpl) servlet.getConfig();

      Node node = web.getRootNode();
      Node servletClass = node.getSingle("servlet-mapping/servlet-name=" + JAXRS_SERVLET);
      if (servletClass != null)
      {
View Full Code Here

   }

   @Override
   public void setApplicationPath(String path)
   {
      ServletFacet servlet = project.getFacet(ServletFacet.class);
      WebAppDescriptorImpl web = (WebAppDescriptorImpl) servlet.getConfig();

      Node node = web.getRootNode();
      Node servletClass = node.getSingle("servlet-mapping/servlet-name=" + JAXRS_SERVLET);

      if (servletClass != null)
      {
         servletClass.getParent().getOrCreate("url-pattern").text(path);
      }

      servlet.saveConfig(web);
   }
View Full Code Here

   public boolean install()
   {
      if (!installedInWebXML())
      {
         // TODO this needs to be fixed in desciptors (allow creation of servlet mapping)
         ServletFacet servlet = project.getFacet(ServletFacet.class);
         WebAppDescriptorImpl web = (WebAppDescriptorImpl) servlet.getConfig();
         Node node = web.getRootNode();
         Node servletClass = node.getSingle("servlet-mapping/servlet-name=" + JAXRS_SERVLET);
         if (servletClass == null)
         {
            Node mapping = node.createChild("servlet-mapping");
            mapping.createChild("servlet-name").text(JAXRS_SERVLET);
            String urlPattern = config.getString(RestFacet.ROOTPATH);
            if (urlPattern.endsWith("/"))
            {
               urlPattern = urlPattern.substring(0, urlPattern.length() - 1);
            }
            mapping.createChild("url-pattern").text(urlPattern + "/*");
         }

         servlet.saveConfig(web);
      }

      return true;
   }
View Full Code Here

   @Override
   public String getServletPath()
   {
      if (project.hasFacet(ServletFacet.class))
      {
         ServletFacet servlet = project.getFacet(ServletFacet.class);
         WebAppDescriptorImpl web = (WebAppDescriptorImpl) servlet.getConfig();

         Node node = web.getRootNode();
         Node servletClass = node.getSingle("servlet-mapping/servlet-name=" + JAXRS_SERVLET);
         if (servletClass != null)
         {
View Full Code Here

TOP

Related Classes of org.jboss.forge.spec.javaee.ServletFacet

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.