Author: marijan
Date: Mon Jul 16 08:37:36 2012
New Revision: 1361936

URL: http://svn.apache.org/viewvc?rev=1361936&view=rev
Log:
RAVE-701 Provide a simple filesystem based url to page definition mapping (xml, 
json)

- output skeleton

Added:
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcResponseHolder.java
   (with props)
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/tags/
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/tags/IncludeComponentTag.java
   (with props)
    rave/sandbox/content-services/rave-web-hmvc/src/main/resources/
    rave/sandbox/content-services/rave-web-hmvc/src/main/resources/META-INF/
    
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/META-INF/hmvc.tld
   (with props)
Modified:
    rave/sandbox/content-services/rave-jcr-config/pom.xml
    rave/sandbox/content-services/rave-jcr-config/src/test/resources/log4j.xml
    rave/sandbox/content-services/rave-web-hmvc/pom.xml
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcDispatcherServlet.java
    
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMapping.java

Modified: rave/sandbox/content-services/rave-jcr-config/pom.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-config/pom.xml?rev=1361936&r1=1361935&r2=1361936&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-config/pom.xml (original)
+++ rave/sandbox/content-services/rave-jcr-config/pom.xml Mon Jul 16 08:37:36 
2012
@@ -20,8 +20,8 @@
   $Id: pom.xml 1303795 2012-03-22 14:19:45Z ate $
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";
->
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";
+  >
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
@@ -38,6 +38,10 @@
   <dependencies>
 
     <dependency>
+      <groupId>org.apache</groupId>
+      <artifactId>jackrabbit-ocm</artifactId>
+    </dependency>
+    <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-core</artifactId>
       <version>${jackson.version}</version>
@@ -106,7 +110,7 @@
             <configuration>
               <target>
                 <copy todir="${project.build.directory}/repository">
-                  <fileset dir="${basedir}/src/test/repository" />
+                  <fileset dir="${basedir}/src/test/repository"/>
                 </copy>
               </target>
             </configuration>

Modified: 
rave/sandbox/content-services/rave-jcr-config/src/test/resources/log4j.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-jcr-config/src/test/resources/log4j.xml?rev=1361936&r1=1361935&r2=1361936&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-jcr-config/src/test/resources/log4j.xml 
(original)
+++ rave/sandbox/content-services/rave-jcr-config/src/test/resources/log4j.xml 
Mon Jul 16 08:37:36 2012
@@ -27,7 +27,7 @@
   <!-- console -->
   <appender name="console" class="org.apache.log4j.ConsoleAppender">
     <layout class="org.apache.log4j.PatternLayout">
-      <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} %-5p 
[%C.%M():%L] %m%n"/>
+      <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} %-5p %m - 
 at %c.%M(%F:%L)%n"/>
     </layout>
   </appender>
 
@@ -39,12 +39,12 @@
     <appender-ref ref="console"/>
   </category>
   <category additivity="false" name="org.apache.rave.jcr">
-    <level value="info"/>
+    <level value="debug"/>
     <appender-ref ref="console"/>
   </category>
 
   <root>
-    <level value="warn"/>
+    <level value="debug"/>
     <appender-ref ref="console"/>
   </root>
 

Modified: rave/sandbox/content-services/rave-web-hmvc/pom.xml
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/pom.xml?rev=1361936&r1=1361935&r2=1361936&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/pom.xml (original)
+++ rave/sandbox/content-services/rave-web-hmvc/pom.xml Mon Jul 16 08:37:36 2012
@@ -20,8 +20,7 @@
   $Id$
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";
->
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
@@ -35,6 +34,11 @@
   <description>Apache Rave Web HMVC</description>
   <packaging>jar</packaging>
 
+  <properties>
+    <javax.servlet.version>2.5</javax.servlet.version>
+    <jsp-api.version>2.1</jsp-api.version>
+    <el-api.version>1.0</el-api.version>
+  </properties>
   <dependencies>
     <dependency>
       <groupId>org.apache.rave</groupId>
@@ -53,6 +57,25 @@
     </dependency>
 
     <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+      <version>${javax.servlet.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet.jsp</groupId>
+      <artifactId>jsp-api</artifactId>
+      <version>${jsp-api.version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>javax.el</groupId>
+      <artifactId>el-api</artifactId>
+      <version>${el-api.version}</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>

Modified: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcDispatcherServlet.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcDispatcherServlet.java?rev=1361936&r1=1361935&r2=1361936&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcDispatcherServlet.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcDispatcherServlet.java
 Mon Jul 16 08:37:36 2012
@@ -27,18 +27,21 @@ import org.springframework.web.servlet.M
 
 public class HmvcDispatcherServlet extends DispatcherServlet {
 
+    private static final long serialVersionUID = 1L;
+
     @Override
     protected void render(ModelAndView mv, HttpServletRequest request, 
HttpServletResponse response) throws Exception {
-        Map<String, ModelAndView> ccmvMap = (Map<String, 
ModelAndView>)mv.getModelMap().get(HmvcHandlerMethod.MODEL_AND_VIEW);
+        @SuppressWarnings("unchecked")
+        Map<String, ModelAndView> ccmvMap = (Map<String, ModelAndView>) 
mv.getModelMap().get(HmvcHandlerMethod.MODEL_AND_VIEW);
         if (ccmvMap != null) {
             Map<String, Object> ccvrMap = new LinkedHashMap<String, Object>();
             
mv.getModelMap().addAttribute(HmvcHandlerMethod.VIEW_RESPONSE_STATE, ccvrMap);
-            for (String name : ccmvMap.keySet()) {
+            for (Map.Entry<String, ModelAndView> entry : ccmvMap.entrySet()) {
                 // TODO: wrap response to buffer and capture its view render 
state
-                render(ccmvMap.get(name), request, response);
+                render(entry.getValue(), request, response);
                 Object viewResponseState = null;
                 // TODO: retrieve viewResponseState from wrapped response
-                ccvrMap.put(name, viewResponseState);
+                ccvrMap.put(entry.getKey(), viewResponseState);
             }
         }
         super.render(mv, request, response);

Modified: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMapping.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMapping.java?rev=1361936&r1=1361935&r2=1361936&view=diff
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMapping.java
 (original)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMapping.java
 Mon Jul 16 08:37:36 2012
@@ -36,30 +36,30 @@ import org.springframework.web.servlet.m
 
 public class HmvcHandlerMethodMapping extends RequestMappingHandlerMapping {
 
-    private Map<HandlerMethod,HmvcHandlerMethod> hmvcHandlerMethods = new 
LinkedHashMap<HandlerMethod,HmvcHandlerMethod>();
+    private Map<HandlerMethod, HmvcHandlerMethod> hmvcHandlerMethods = new 
LinkedHashMap<HandlerMethod, HmvcHandlerMethod>();
 
     protected boolean hasTypeRequestMapping(Class<?> beanType) {
         RequestMapping requestMapping = 
AnnotationUtils.findAnnotation(beanType, RequestMapping.class);
         return requestMapping != null && 
!ObjectUtils.isEmpty(requestMapping.value());
     }
-    
+
     @Override
     protected boolean isHandler(Class<?> beanType) {
         return AnnotationUtils.findAnnotation(beanType, HController.class) != 
null &&
                 hasTypeRequestMapping(beanType);
     }
-    
+
     private Class<?> getBeanType(Object handler) {
-        Class<?> beanType = (handler instanceof String) ? 
+        Class<?> beanType = (handler instanceof String) ?
                 getApplicationContext().getType((String) handler) : 
handler.getClass();
 
         return ClassUtils.getUserClass(beanType);
     }
-    
+
     protected Method getCCRenderMethod(Class<?> ccontroller) {
 
         final Class<?> userType = ClassUtils.getUserClass(ccontroller);
-                
+
         Set<Method> methods = HandlerMethodSelector.selectMethods(userType, 
new MethodFilter() {
             public boolean matches(Method method) {
                 return (AnnotationUtils.findAnnotation(method, 
CCRender.class)) != null;
@@ -67,14 +67,14 @@ public class HmvcHandlerMethodMapping ex
         });
         return methods.isEmpty() ? null : methods.iterator().next();
     }
-    
+
     @Override
     protected void registerHandlerMethod(Object handler, Method method, 
RequestMappingInfo mapping) {
         RequestMapping requestMapping = AnnotationUtils.findAnnotation(method, 
RequestMapping.class);
         if (!ObjectUtils.isEmpty(requestMapping.value())) {
             // enforce empty or no pattern value specified on the 
@RequestMapping at method level
             throw new IllegalStateException("HController class may only have a 
RequestMapping pattern specified on type level");
-        }        
+        }
         // assuming for now this to be the only/single @RequestMapping 
HandlerMethod for a @HController type
         // if more than one is defined it might/should cause a conflict on url 
pattern already,
         // if we ignore the other differentiators like method parameters etc.
@@ -82,7 +82,7 @@ public class HmvcHandlerMethodMapping ex
         HandlerMethod handlerMethod = super.getHandlerMethods().get(mapping);
         hmvcHandlerMethods.put(handlerMethod, getHmvcHandlerMethod(handler, 
method));
     }
-    
+
     protected HmvcHandlerMethod getHmvcHandlerMethod(Object handler, Method 
method) {
         Class<?> handlerType = getBeanType(handler);
         HController hcontroller = AnnotationUtils.findAnnotation(handlerType, 
HController.class);
@@ -95,8 +95,7 @@ public class HmvcHandlerMethodMapping ex
                     Object ccInstance;
                     try {
                         ccInstance = cc.type().newInstance();
-                    } 
-                    catch (Exception e) {
+                    } catch (Exception e) {
                         throw new IllegalStateException("Cannot instantiate 
found CController");
                     }
                     ccontrollerMethods.put(cc.name(), 
getHmvcHandlerMethod(ccInstance, ccrenderMethod));
@@ -108,10 +107,9 @@ public class HmvcHandlerMethodMapping ex
             try {
                 handlerBean = handlerType.newInstance();
             } catch (Exception e) {
-                throw new IllegalStateException("Cannot instantiate Controller 
"+handlerType.getName());
+                throw new IllegalStateException("Cannot instantiate Controller 
" + handlerType.getName());
             }
-        }
-        else {
+        } else {
             handlerBean = handler;
         }
         return new HmvcHandlerMethod(handlerBean, method, ccontrollerMethods);
@@ -131,10 +129,9 @@ public class HmvcHandlerMethodMapping ex
 
         if (logger.isDebugEnabled()) {
             if (handlerMethod != null) {
-                logger.debug("Returning handler method [" + handlerMethod + 
"]");
-            }
-            else {
-                logger.debug("Did not find handler method for [" + lookupPath 
+ "]");
+                logger.debug("Returning handler method [" + handlerMethod + 
']');
+            } else {
+                logger.debug("Did not find handler method for [" + lookupPath 
+ ']');
             }
         }
 

Added: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcResponseHolder.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcResponseHolder.java?rev=1361936&view=auto
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcResponseHolder.java
 (added)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcResponseHolder.java
 Mon Jul 16 08:37:36 2012
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.rave.portal.web.hmvc;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Wraps HttpRequest, so we can capture sub-components output.
+ *
+ * @version "$Id$"
+ */
+public class HmvcResponseHolder {
+
+    private static Logger log = 
LoggerFactory.getLogger(HmvcResponseHolder.class);
+
+    private boolean flushed;
+}

Propchange: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcResponseHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcResponseHolder.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/tags/IncludeComponentTag.java
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/tags/IncludeComponentTag.java?rev=1361936&view=auto
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/tags/IncludeComponentTag.java
 (added)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/tags/IncludeComponentTag.java
 Mon Jul 16 08:37:36 2012
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.rave.portal.web.hmvc.tags;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.TagSupport;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @version "$Id$"
+ */
+public class IncludeComponentTag extends TagSupport {
+
+    private static Logger log = 
LoggerFactory.getLogger(IncludeComponentTag.class);
+
+    private static final long serialVersionUID = 1L;
+
+    protected String ref = null;
+
+    @Override
+    public int doStartTag() throws JspException {
+        return EVAL_BODY_INCLUDE;
+    }
+
+    @Override
+    public int doEndTag() throws JspException {
+
+        HttpServletRequest request = (HttpServletRequest) 
pageContext.getRequest();
+        HttpServletResponse response = (HttpServletResponse) 
pageContext.getResponse();
+
+
+        try {
+            JspWriter writer = pageContext.getOut();
+            writer.flush();
+
+        } catch (IOException e) {
+        }
+
+        ref = null;
+        return EVAL_PAGE;
+    }
+
+    /**
+     * Returns the referenced name of the child window content to include
+     */
+    public String getRef() {
+        return this.ref;
+    }
+
+    /**
+     * Sets the ref property.
+     *
+     * @param ref The referenced name of the child window content to include
+     */
+    public void setRef(String ref) {
+        this.ref = ref;
+    }
+}
\ No newline at end of file

Propchange: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/tags/IncludeComponentTag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/tags/IncludeComponentTag.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: 
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/META-INF/hmvc.tld
URL: 
http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/resources/META-INF/hmvc.tld?rev=1361936&view=auto
==============================================================================
--- 
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/META-INF/hmvc.tld
 (added)
+++ 
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/META-INF/hmvc.tld
 Mon Jul 16 08:37:36 2012
@@ -0,0 +1,50 @@
+<?xml version="1.0" ?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<taglib xmlns="http://java.sun.com/xml/ns/javaee"; version="2.1"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  >
+
+  <tlib-version>1.0</tlib-version>
+  <jsp-version>1.2</jsp-version>
+  <short-name>hmvc-tags</short-name>
+  <uri>http://www.apache-rave.org/jsp/core</uri>
+  <description>Rave Core Tag Library</description>
+
+  <tag>
+    <name>include</name>
+    
<tag-class>org.apache.rave.portal.controller.tags.IncludeComponentTag</tag-class>
+    <body-content>empty</body-content>
+    <description>Include component output</description>
+    <attribute>
+      <name>ref</name>
+      <required>true</required>
+      <rtexprvalue>true</rtexprvalue>
+      <type>java.lang.String</type>
+      <description>The name of the component</description>
+    </attribute>
+    <example><![CDATA[
+
+                TODO
+                ]]></example>
+  </tag>
+
+
+</taglib>
\ No newline at end of file

Propchange: 
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/META-INF/hmvc.tld
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
rave/sandbox/content-services/rave-web-hmvc/src/main/resources/META-INF/hmvc.tld
------------------------------------------------------------------------------
    svn:keywords = Id


Reply via email to