Changeset 784

Show
Ignore:
Timestamp:
19/11/08 14:24:52 (2 months ago)
Author:
bruno
Message:

prototype archetype:
- introduce the dbmock component
- introduce a base template layout.xml
- representationbuilder config: allow addressing templates outside of pages (we should only add templates that represent resources to 'pages')
- add it to the archetype catalog

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tools/kauri-archetype/archetype-catalog.xml

    r304 r784  
    99      <repository>http://kauriproject.org/maven/maven2/deploy</repository> 
    1010    </archetype> 
     11   <archetype> 
     12     <groupId>org.kauriproject</groupId> 
     13     <artifactId>kauri-archetype-prototype</artifactId> 
     14     <version>${kauri.version}</version> 
     15     <description>A Kauri project with typical setup to start prototyping</description> 
     16     <repository>http://kauriproject.org/maven/maven2/deploy</repository> 
     17   </archetype> 
    1118  </archetypes> 
    1219</archetype-catalog> 
  • trunk/tools/kauri-archetype/kauri-archetype-prototyping/src/main/resources/archetype-resources/module1/pom.xml

    r689 r784  
    3636      <artifactId>kauri-representationbuilder-api</artifactId> 
    3737    </dependency> 
     38    <dependency> 
     39     <groupId>org.kauriproject</groupId> 
     40     <artifactId>kauri-dbresources-impl</artifactId> 
     41     <version>${version.kauri}</version> 
     42   </dependency> 
    3843  </dependencies> 
    3944 
  • trunk/tools/kauri-archetype/kauri-archetype-prototyping/src/main/resources/archetype-resources/module1/src/main/java/module1/PersonResource.java

    r689 r784  
    2424            // to be build. The mapping between this logical name and the real representation 
    2525            // implementation can be found in representations.groovy 
    26             return new KauriRepresentation("persons/{id}", data); 
     26            return new KauriRepresentation("pages/persons/{id}", data); 
    2727        } else { 
    2828            throw new WebApplicationException(404); 
  • trunk/tools/kauri-archetype/kauri-archetype-prototyping/src/main/resources/archetype-resources/module1/src/main/kauri/pages/index.html.xml

    r748 r784  
    11<?xml version="1.0"?> 
    2 <html> 
    3   <head> 
    4     <title>Home page</title> 
    5   </head> 
     2<html t:inherit="module:/templates/layout.xml" 
     3      xmlns:t="http://kauriproject.org/template"> 
    64 
    7   <body> 
    8     <h1>Welcome</h1> 
     5  <t:block name="title">Home page</t:block> 
     6 
     7  <t:block name="content"> 
     8    <h2>Welcome</h2> 
    99 
    1010    <p>We have created a sample 'person' resource for you:</p> 
     
    1717    --> 
    1818    <p><a href="${publicUri('service:/router/persons/1.html')}">View person</a></p> 
    19   </body
     19  </t:block
    2020</html> 
  • trunk/tools/kauri-archetype/kauri-archetype-prototyping/src/main/resources/archetype-resources/module1/src/main/kauri/pages/persons/{id}.html.xml

    r748 r784  
    11<?xml version="1.0"?> 
    2 <html xmlns:t="http://kauriproject.org/template"> 
    3   <!-- In prototype mode, the template is executed directly, and pulls in 
    4        the data it needs itself. In production mode, the data will be 
    5        supplied from the resource class (PersonResource). 
    6        --> 
    7   <t:variable name="person" src="service:/data/persons/${request.attributes.id}.json" overwrite="false"/> 
     2<html t:inherit="module:/templates/layout.xml" 
     3      xmlns:t="http://kauriproject.org/template"> 
    84 
    9   <head> 
    10     <title>Person data</title> 
    11   </head> 
    12    
    13   <body> 
    14     <h1>Person: ${person.name}</h1> 
     5  <t:block name="title">Person data</t:block> 
     6 
     7  <t:block name="content"> 
     8    <!-- In prototype mode, the template is executed directly, and pulls in 
     9         the data it needs itself. In production mode, the data will be 
     10         supplied from the resource class (PersonResource). 
     11         --> 
     12    <t:variable name="person" src="service:/data/persons/${request.attributes.id}" overwrite="false"/> 
     13 
     14    <h2>Person: ${person.name}</h2> 
    1515 
    1616    <p><b>Hint:</b> If you see as name "Mr. Production" above, try starting Kauri with the 
     
    2020    <p>City: ${person.city}</p> 
    2121    <p>Postal code: ${person.postal_code}</p> 
    22   </body> 
     22  </t:block> 
     23 
    2324</html> 
  • trunk/tools/kauri-archetype/kauri-archetype-prototyping/src/main/resources/archetype-resources/module1/src/main/kauri/representations.groovy

    r748 r784  
    1313builder.representations { 
    1414    select { 
    15         when(name: "{name:**}") { 
     15        when(name: "pages/{name:**}") { 
    1616            template(src: "module:/pages/{name}.html.xml") 
    1717        } 
     18 
     19      when(name: "{name:**}") { 
     20          template(src: "module:/{name}.xml") 
     21      } 
    1822    } 
    1923 
  • trunk/tools/kauri-archetype/kauri-archetype-prototyping/src/main/resources/archetype-resources/module1/src/main/kauri/router.groovy

    r760 r784  
    1111        pages(root: "pages") 
    1212    } 
    13  
    14     /* 
    15      * Custom-implemented resources using Restlet API. 
    16      */ 
    17     //resource(uri: "/person/{id}.html", continueIfNotFound: "true", ofClass: "org.kauriproject.routing.test.testmodules.routing2.PersonResource") 
    1813 
    1914    /* 
  • trunk/tools/kauri-archetype/kauri-archetype-prototyping/src/main/resources/archetype-resources/module1/src/main/kauri/spring/production/module1-production-beans.xml

    r748 r784  
    1717 
    1818  <!-- TODO: for production use, replace the mock data with real data --> 
    19   <bean id="data" class="org.restlet.Directory"> 
     19  <bean id="data" class="org.kauriproject.dbmock.DbMockFinder"> 
    2020    <constructor-arg ref="restletContext"/> 
    21     <constructor-arg value="module:/mockdata/"/> 
     21    <constructor-arg ref="module"/> 
     22    <constructor-arg value="mockdata"/> 
    2223  </bean> 
    2324  <kauri:export-restservice ref="data"/> 
  • trunk/tools/kauri-archetype/kauri-archetype-prototyping/src/main/resources/archetype-resources/module1/src/main/kauri/spring/prototype/module1-prototype-beans.xml

    r748 r784  
    1515  <kauri:module restletContextBeanId="restletContext" classLoaderBeanId="moduleClassLoader" rapiBeanId="module"/> 
    1616 
    17   <bean id="data" class="org.restlet.Directory"> 
     17  <bean id="data" class="org.kauriproject.dbmock.DbMockFinder"> 
    1818    <constructor-arg ref="restletContext"/> 
    19     <constructor-arg value="module:/mockdata/"/> 
     19    <constructor-arg ref="module"/> 
     20    <constructor-arg value="mockdata"/> 
    2021  </bean> 
    2122  <kauri:export-restservice ref="data"/>