1 2 Previous Next 20 Replies Latest reply: Aug 28, 2010 1:51 AM by Andrew Rubinger Go to original post RSS
      • 15. Re: DSL for XML descriptors
        Dan Allen Master

        Just to make you wet yourself:

         

        WebApp webApp = new WebAppDef()
           .moduleName("test")
           .description("A description of my webapp")
           .displayName("Sample")
           .distributable()
           .contextParam("com.sun.faces.validateXml", true)
           // we can do more like this :)
           .facesDevelopmentMode()
           .facesStateSavingMethod(StateManager.STATE_SAVING_METHOD_CLIENT)
           .listener("org.jboss.seam.servlet.SeamListener")
           .filter("org.tuckey.web.filters.urlrewrite.UrlRewriteFilter", "/*")
              .initParam("confReloadCheckInterval", 60)
           .servlet("javax.faces.webapp.FacesServlet", "*.jsf")
           .welcomeFile("/index.jsf")
           .sessionTimeout(60)
           .sessionTrackingModes(TrackingModeType.URL)
           .errorPage(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "/500.jsp")
           .errorPage(IOException.class, "/outputError.jsp")
           .loginConfig(AuthMethodType.BASIC, "Cool App")
           .formLoginConfig("/login.jsp", "/invalidLogin.jsp")
           .securityConstraint()
              .webResourceCollection("All Access")
                 .urlPatterns("/public/*")
                 .httpMethods(HttpMethodType.DELETE, HttpMethodType.PUT, HttpMethodType.HEAD, HttpMethodType.OPTIONS,
                    HttpMethodType.TRACE, HttpMethodType.GET, HttpMethodType.POST)
              .userDataConstraint(TransportGuaranteeType.NONE)
           .securityConstraint("Restricted GET To Employees")
              .webResourceCollection("Restricted Access - Get Only", "/restricted/employee/*", HttpMethodType.GET)
              .authConstraint("Employee")
              .userDataConstraint(TransportGuaranteeType.NONE)
           .securityConstraint("Restrict access to Facelets templates (XHTML files)")
              .webResourceCollection("Facelets templates").urlPatterns("*.xhtml").httpMethods(true, HttpMethodType.HEAD)
              .authConstraint()
              .userDataConstraint(TransportGuaranteeType.NONE)
           .securityRole("Employee", "Employees of the company")
           .absoluteOrdering("one", "two", "three")
           .descriptor();
        

         

        produces...

         

         

        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
        <web-app version="3.0"
            xmlns="http://java.sun.com/xml/ns/javaee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
            <module-name>test</module-name>
            <description>A description of my webapp</description>
            <display-name>Sample</display-name>
            <distributable/>
            <context-param>
                <param-name>com.sun.faces.validateXml</param-name>
                <param-value>true</param-value>
            </context-param>
            <context-param>
                <param-name>javax.faces.PROJECT_STAGE</param-name>
                <param-value>Development</param-value>
            </context-param>
            <context-param>
                <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                <param-value>client</param-value>
            </context-param>
            <listener>
                <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
            </listener>
            <filter>
                <filter-name>UrlRewriteFilter</filter-name>
                <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
                <init-param>
                    <param-name>confReloadCheckInterval</param-name>
                    <param-value>60</param-value>
                </init-param>
            </filter>
            <filter-mapping>
                <url-pattern>/*</url-pattern>
                <filter-name>UrlRewriteFilter</filter-name>
            </filter-mapping>
            <servlet>
                <servlet-name>FacesServlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            </servlet>
            <servlet-mapping>
                <servlet-name>FacesServlet</servlet-name>
                <url-pattern>*.jsf</url-pattern>
            </servlet-mapping>
            <session-config>
                <session-timeout>60</session-timeout>
                <tracking-mode>URL</tracking-mode>
            </session-config>
            <welcome-file-list>
                <welcome-file>/index.jsf</welcome-file>
            </welcome-file-list>
            <error-page>
                <error-code>500</error-code>
                <location>/500.jsp</location>
            </error-page>
            <error-page>
                <exception-type>java.io.IOException</exception-type>
                <location>/outputError.jsp</location>
            </error-page>
            <security-constraint>
                <web-resource-collection>
                    <web-resource-name>All Access</web-resource-name>
                    <url-pattern>/public/*</url-pattern>
                    <http-method>DELETE</http-method>
                    <http-method>PUT</http-method>
                    <http-method>HEAD</http-method>
                    <http-method>OPTIONS</http-method>
                    <http-method>TRACE</http-method>
                    <http-method>GET</http-method>
                    <http-method>POST</http-method>
                </web-resource-collection>
                <user-data-constraint>
                    <transport-guarantee>NONE</transport-guarantee>
                </user-data-constraint>
            </security-constraint>
            <security-constraint>
                <display-name>Restricted GET To Employees</display-name>
                <web-resource-collection>
                    <web-resource-name>Restricted Access - Get Only</web-resource-name>
                    <url-pattern>/restricted/employee/*</url-pattern>
                    <http-method>GET</http-method>
                </web-resource-collection>
                <auth-constraint>
                    <role-name>Employee</role-name>
                </auth-constraint>
                <user-data-constraint>
                    <transport-guarantee>NONE</transport-guarantee>
                </user-data-constraint>
            </security-constraint>
            <security-constraint>
                <display-name>Restrict access to Facelets templates (XHTML files)</display-name>
                <web-resource-collection>
                    <web-resource-name>Facelets templates</web-resource-name>
                    <url-pattern>*.xhtml</url-pattern>
                    <http-method-omission>HEAD</http-method-omission>
                </web-resource-collection>
                <auth-constraint/>
                <user-data-constraint>
                    <transport-guarantee>NONE</transport-guarantee>
                </user-data-constraint>
            </security-constraint>
            <login-config>
                <auth-method>BASIC</auth-method>
                <realm-name>Cool App</realm-name>
            </login-config>
            <login-config>
                <auth-method>FORM</auth-method>
                <form-login-config>
                    <form-login-page>/login.jsp</form-login-page>
                    <form-error-page>/invalidLogin.jsp</form-error-page>
                </form-login-config>
            </login-config>
            <security-role>
                <description>Employees of the company</description>
                <role-name>Employee</role-name>
            </security-role>
            <absolute-ordering>
                <name>one</name>
                <name>two</name>
                <name>three</name>
            </absolute-ordering>
        </web-app>
        

         

         

        Holy XM-hell Batman

        • 16. Re: DSL for XML descriptors
          Lincoln Baxter III Master

          Dan, this is awesome!!

           

          I think there may be value in also allowing typesafe declaration of servlet and filter classes:

           

           

           .servlet(FacesServlet.class, new String[] { "*.jsf" }) 

           

           

          WDYT?

          • 17. Re: DSL for XML descriptors
            Dan Allen Master

            Lincoln Baxter III wrote:

             

            Dan, this is awesome!!

             

            I think there may be value in also allowing typesafe declaration of servlet and filter classes:

             

             

             .servlet(FacesServlet.class, new String[] { "*.jsf" }) 

             

             

            WDYT?

             

            Already implemented. That was just a copy-paste from one of the tests, where I was testing the string version. You can do:

             

            .servlet(FacesServlet.class, "*.jsf", "/faces/*")

             

            In fact, the definition enforces a servlet class:

             

            public WebAppDef servlet(Class<? extends javax.servlet.Servlet> clazz, String... urlPatterns)
            {
               return servlet(clazz.getSimpleName(), clazz.getName(), urlPatterns);
            }
            

             

            And now you can even do:

             

            .facesServlet()

             

             

            • 18. Re: DSL for XML descriptors
              Andrew Rubinger Master

              Created an umbrella task:

               

              https://jira.jboss.org/browse/SHRINKWRAP-213

               

              Also the project now lives:

               

              http://github.com/shrinkwrap/descriptors

               

              ...as was ported in by Dan.  I've updated to latest ShrinkWrap dependencies.

               

              I think the next steps:

               

              1. Make models for API, impl
              2. Remove the dependency upon ShrinkWrap
              3. Make ShrinkWrap extension-descriptors to pull in the descriptors project and represent them as Assets

               

              WDYT?

               

              S,

              ALR

              • 19. Re: DSL for XML descriptors
                Andrew Rubinger Master

                Circling back on the current state of affairs.

                 

                We've each had some cracks at:

                 

                http://github.com/shrinkwrap/descriptors

                 

                I started moving packages around to denote what's API, what's not.  The tests in place should be pretty indicative of what the end goal should look like.

                 

                Need to now break up the API/impl stuff into modules.  Then get some clearcut tasks with which contributors may hack away and flesh out full test coverage for all properties of the descriptors we'll support.

                 

                S,

                ALR

                • 20. Re: DSL for XML descriptors
                  Andrew Rubinger Master

                  Also, issues for this project go:

                   

                  https://jira.jboss.org/browse/SHRINKDESC

                   

                  S,

                  ALR

                  1 2 Previous Next