You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by at...@apache.org on 2012/08/09 17:58:00 UTC

svn commit: r1371266 - in /rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc: ./ example/ servlet/

Author: ate
Date: Thu Aug  9 15:58:00 2012
New Revision: 1371266

URL: http://svn.apache.org/viewvc?rev=1371266&view=rev
Log:
RAVE-698: redesigned HMVC annotation logic, now almost completely 'in line' with standard Spring MVC annotations

Added:
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/Hmvc.java
      - copied, changed from r1371123, rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/CCRender.java
Removed:
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/CCRender.java
Modified:
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HController.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethod.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodHandlerAdapter.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodMapping.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyBodyController.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyContentController.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyFooterController.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyHeaderController.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyMenuController.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyPageController.java
    rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/servlet/HmvcDispatcherServlet.java

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HController.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HController.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HController.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HController.java Thu Aug  9 15:58:00 2012
@@ -24,7 +24,7 @@ import java.lang.annotation.Target;
 
 import org.springframework.stereotype.Controller;
 
-@Target({ElementType.TYPE})
+@Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 @Controller

Copied: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/Hmvc.java (from r1371123, rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/CCRender.java)
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/Hmvc.java?p2=rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/Hmvc.java&p1=rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/CCRender.java&r1=1371123&r2=1371266&rev=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/CCRender.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/Hmvc.java Thu Aug  9 15:58:00 2012
@@ -25,5 +25,5 @@ import java.lang.annotation.Target;
 @Target({ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
-public @interface CCRender {
+public @interface Hmvc {
 }

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethod.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethod.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethod.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethod.java Thu Aug  9 15:58:00 2012
@@ -27,7 +27,7 @@ public class HmvcHandlerMethod extends H
 
     public static final String VIEW_RESPONSE_STATE = HmvcHandlerMethod.class.getName()+".ViewResponseState";
     public static final String MODEL_AND_VIEW = HmvcHandlerMethod.class.getName()+".ModelAndView";
-    
+
     protected Map<String, HmvcHandlerMethod> children;
     private BeanFactory beanFactory;
 

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodHandlerAdapter.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodHandlerAdapter.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodHandlerAdapter.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/HmvcHandlerMethodHandlerAdapter.java Thu Aug  9 15:58:00 2012
@@ -28,30 +28,29 @@ import org.springframework.web.servlet.m
 
 public class HmvcHandlerMethodHandlerAdapter extends ForkedRequestMappingHandlerAdapter {
 
-    protected boolean supportsInternal(HandlerMethod handlerMethod) {
-        return handlerMethod instanceof HmvcHandlerMethod;
-    }
-
     @Override
     protected ModelAndView handleInternal(HttpServletRequest request, HttpServletResponse response,
-                                          HandlerMethod handlerMethod) throws Exception {
-        HmvcHandlerMethod hm = (HmvcHandlerMethod) handlerMethod;
+            HandlerMethod handlerMethod) throws Exception {
         ModelAndView mv = super.handleInternal(request, response, handlerMethod);
 
-        Map<String, ModelAndView> cmvMap = new LinkedHashMap<String, ModelAndView>();
-        for (String name : hm.getChildrenNames()) {
-            HmvcHandlerMethod chm = hm.getChild(name);
-            ModelAndView cmv = handleInternal(request, response, chm);
-            if (cmv != null) {
-                cmvMap.put(name, cmv);
+        if (handlerMethod instanceof HmvcHandlerMethod) {
+            HmvcHandlerMethod hm = (HmvcHandlerMethod)handlerMethod;
+
+            Map<String, ModelAndView> cmvMap = new LinkedHashMap<String,ModelAndView>();
+            for (String name : hm.getChildrenNames()) {
+                HmvcHandlerMethod chm = hm.getChild(name);
+                ModelAndView cmv = handleInternal(request, response, chm);
+                if (cmv != null) {
+                    cmvMap.put(name, cmv);
+                }
             }
-        }
 
-        if (mv == null) {
-            mv = new ModelAndView();
-        }
+            if (mv == null) {
+                mv = new ModelAndView();
+            }
 
-        mv.getModelMap().addAttribute(HmvcHandlerMethod.MODEL_AND_VIEW, cmvMap);
+            mv.getModelMap().addAttribute(HmvcHandlerMethod.MODEL_AND_VIEW, cmvMap);
+        }
 
         return mv;
     }

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=1371266&r1=1371265&r2=1371266&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 Thu Aug  9 15:58:00 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.rave.portal.web.hmvc;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -29,6 +30,7 @@ import org.springframework.util.ClassUti
 import org.springframework.util.ObjectUtils;
 import org.springframework.util.ReflectionUtils.MethodFilter;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.method.HandlerMethod;
 import org.springframework.web.method.HandlerMethodSelector;
 import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
@@ -38,15 +40,21 @@ public class HmvcHandlerMethodMapping ex
 
     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());
+    protected Set<Method> getAnnotatedMethods(Class<?> beanType, final Class<? extends Annotation> annotationType) {
+        return HandlerMethodSelector.selectMethods(beanType, new MethodFilter() {
+            public boolean matches(Method method) {
+                return (AnnotationUtils.findAnnotation(method, annotationType)) != null;
+            }
+        });
+    }
+
+    protected boolean isHmvcMethod(Method method) {
+        return AnnotationUtils.findAnnotation(method, Hmvc.class) != null;
     }
 
     @Override
     protected boolean isHandler(Class<?> beanType) {
-        return AnnotationUtils.findAnnotation(beanType, HController.class) != null &&
-                hasTypeRequestMapping(beanType);
+        return super.isHandler(beanType) && !getAnnotatedMethods(beanType, Hmvc.class).isEmpty();
     }
 
     private Class<?> getBeanType(Object handler) {
@@ -56,13 +64,43 @@ public class HmvcHandlerMethodMapping ex
         return ClassUtils.getUserClass(beanType);
     }
 
-    protected Method getCCRenderMethod(Class<?> ccontroller) {
+    protected boolean isEmptyOrRootPathSpecified(RequestMapping requestMapping) {
+        boolean foundRootPath = false;
+        for (String value : requestMapping.value()) {
+            value = value.trim();
+            if (value.isEmpty() == "/".equals(value)) {
+                foundRootPath = true;
+            }
+        }
+        return foundRootPath;
+    }
+
+    protected boolean isDefaultGetRequestMapping(Method method, Class<?> userType) {
+        RequestMappingInfo mapping = getMappingForMethod(method, userType);
+        boolean defaultGetRequestMapping = mapping != null;
+        if (defaultGetRequestMapping && !mapping.getPatternsCondition().getPatterns().isEmpty()) {
+            defaultGetRequestMapping = false;
+            for (String pattern : mapping.getPatternsCondition().getPatterns()) {
+                if ("".equals(pattern) || "/".equals("pattern")) {
+                    defaultGetRequestMapping = true;
+                    break;
+                }
+            }
+        }
+        if (defaultGetRequestMapping && !mapping.getMethodsCondition().getMethods().isEmpty()) {
+            defaultGetRequestMapping = mapping.getMethodsCondition().getMethods().contains(RequestMethod.GET);
+        }
+        // TODO: ensure no other conditions enabled
+        return defaultGetRequestMapping;
+    }
+
+    protected Method getRenderMethod(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;
+                return isDefaultGetRequestMapping(method, userType);
             }
         });
         return methods.isEmpty() ? null : methods.iterator().next();
@@ -70,31 +108,26 @@ public class HmvcHandlerMethodMapping ex
 
     @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.
-        registerHandler(handler, method, mapping);
-        HandlerMethod handlerMethod = super.getHandlerMethods().get(mapping);
-        hmvcHandlerMethods.put(handlerMethod, getHmvcHandlerMethod(handler, method));
+        if (!isHmvcMethod(method)) {
+            registerHandler(handler, method, mapping);
+            HmvcHandlerMethod handlerMethod = getHmvcHandlerMethod(handler, method, true);
+            if (handlerMethod != null) {
+                hmvcHandlerMethods.put(super.getHandlerMethods().get(mapping), handlerMethod);
+            }
+        }
     }
 
     protected void registerHandler(Object handler, Method method, RequestMappingInfo mapping) {
         super.registerHandlerMethod(handler, method, mapping);
     }
 
-    protected HmvcHandlerMethod getHmvcHandlerMethod(Object handler, Method method) {
-        Class<?> handlerType = getBeanType(handler);
-        HController hcontroller = AnnotationUtils.findAnnotation(handlerType, HController.class);
+    protected HmvcHandlerMethod getHmvcHandlerMethod(Object handler, Method method, boolean root) {
         Map<String, HmvcHandlerMethod> ccontrollerMethods = new HashMap<String, HmvcHandlerMethod>();
-        if (!ObjectUtils.isEmpty(hcontroller.controllers())) {
+        HController hcontroller = AnnotationUtils.findAnnotation(method, HController.class);
+        if (hcontroller != null && !ObjectUtils.isEmpty(hcontroller.controllers())) {
             for (CController cc : hcontroller.controllers()) {
-                Method ccrenderMethod = getCCRenderMethod(cc.type());
-                if (ccrenderMethod != null) {
+                Method renderMethod = getRenderMethod(cc.type());
+                if (renderMethod != null) {
                     // should do this better, caching etc.
                     Object ccInstance;
                     try {
@@ -102,21 +135,25 @@ public class HmvcHandlerMethodMapping ex
                     } catch (Exception e) {
                         throw new IllegalStateException("Cannot instantiate found CController");
                     }
-                    ccontrollerMethods.put(cc.name(), getHmvcHandlerMethod(ccInstance, ccrenderMethod));
+                    ccontrollerMethods.put(cc.name(), getHmvcHandlerMethod(ccInstance, renderMethod, false));
                 }
             }
         }
-        Object handlerBean;
-        if (handler instanceof String) {
-            try {
-                handlerBean = handlerType.newInstance();
-            } catch (Exception e) {
-                throw new IllegalStateException("Cannot instantiate Controller " + handlerType.getName());
+        if (!ccontrollerMethods.isEmpty() || !root) {
+            Object handlerBean;
+            if (handler instanceof String) {
+                Class<?> handlerType = getBeanType(handler);
+                try {
+                    handlerBean = handlerType.newInstance();
+                } catch (Exception e) {
+                    throw new IllegalStateException("Cannot instantiate Controller " + handlerType.getName());
+                }
+            } else {
+                handlerBean = handler;
             }
-        } else {
-            handlerBean = handler;
+            return new HmvcHandlerMethod(handlerBean, method, ccontrollerMethods);
         }
-        return new HmvcHandlerMethod(handlerBean, method, ccontrollerMethods);
+        return null;
     }
 
     /**
@@ -139,9 +176,10 @@ public class HmvcHandlerMethodMapping ex
             }
         }
 
-        if (handlerMethod != null) {
-            // return hmvc variant instead
+        if (handlerMethod != null && hmvcHandlerMethods.containsKey(handlerMethod)) {
+            // if available return hmvc variant instead
             handlerMethod = hmvcHandlerMethods.get(handlerMethod);
+            request.setAttribute(getClass().getName(), Boolean.TRUE);
         }
         return (handlerMethod != null) ? handlerMethod.createWithResolvedBean() : null;
     }

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyBodyController.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyBodyController.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyBodyController.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyBodyController.java Thu Aug  9 15:58:00 2012
@@ -16,17 +16,18 @@
  */
 package org.apache.rave.portal.web.hmvc.example;
 
-import org.apache.rave.portal.web.hmvc.CCRender;
 import org.apache.rave.portal.web.hmvc.CController;
 import org.apache.rave.portal.web.hmvc.HController;
+import org.apache.rave.portal.web.hmvc.Hmvc;
+import org.springframework.web.bind.annotation.RequestMapping;
 
-@HController(controllers = {
-        @CController(name = "menu", type = MyMenuController.class),
-        @CController(name = "content", type = MyContentController.class)
-})
 public class MyBodyController {
 
-    @CCRender
+    @Hmvc @RequestMapping
+    @HController(controllers = {
+            @CController(name = "menu", type = MyMenuController.class),
+            @CController(name = "content", type = MyContentController.class)
+    })
     public String render() {
         return "mybody";
     }

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyContentController.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyContentController.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyContentController.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyContentController.java Thu Aug  9 15:58:00 2012
@@ -16,13 +16,12 @@
  */
 package org.apache.rave.portal.web.hmvc.example;
 
-import org.apache.rave.portal.web.hmvc.CCRender;
-import org.apache.rave.portal.web.hmvc.HController;
+import org.apache.rave.portal.web.hmvc.Hmvc;
+import org.springframework.web.bind.annotation.RequestMapping;
 
-@HController
 public class MyContentController {
 
-    @CCRender
+    @Hmvc @RequestMapping
     public String render() {
         return "mycontent";
     }

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyFooterController.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyFooterController.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyFooterController.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyFooterController.java Thu Aug  9 15:58:00 2012
@@ -16,13 +16,12 @@
  */
 package org.apache.rave.portal.web.hmvc.example;
 
-import org.apache.rave.portal.web.hmvc.CCRender;
-import org.apache.rave.portal.web.hmvc.HController;
+import org.apache.rave.portal.web.hmvc.Hmvc;
+import org.springframework.web.bind.annotation.RequestMapping;
 
-@HController
 public class MyFooterController {
 
-    @CCRender
+    @Hmvc @RequestMapping
     public String render() {
         return "myfooter";
     }

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyHeaderController.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyHeaderController.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyHeaderController.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyHeaderController.java Thu Aug  9 15:58:00 2012
@@ -16,13 +16,12 @@
  */
 package org.apache.rave.portal.web.hmvc.example;
 
-import org.apache.rave.portal.web.hmvc.CCRender;
-import org.apache.rave.portal.web.hmvc.HController;
+import org.apache.rave.portal.web.hmvc.Hmvc;
+import org.springframework.web.bind.annotation.RequestMapping;
 
-@HController
 public class MyHeaderController {
 
-    @CCRender
+    @Hmvc @RequestMapping
     public String render() {
         return "myheader";
     }

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyMenuController.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyMenuController.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyMenuController.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyMenuController.java Thu Aug  9 15:58:00 2012
@@ -16,13 +16,12 @@
  */
 package org.apache.rave.portal.web.hmvc.example;
 
-import org.apache.rave.portal.web.hmvc.CCRender;
-import org.apache.rave.portal.web.hmvc.HController;
+import org.apache.rave.portal.web.hmvc.Hmvc;
+import org.springframework.web.bind.annotation.RequestMapping;
 
-@HController
 public class MyMenuController {
 
-    @CCRender
+    @Hmvc @RequestMapping
     public String render() {
         return "mymenu";
     }

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyPageController.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyPageController.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyPageController.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/example/MyPageController.java Thu Aug  9 15:58:00 2012
@@ -18,17 +18,19 @@ package org.apache.rave.portal.web.hmvc.
 
 import org.apache.rave.portal.web.hmvc.CController;
 import org.apache.rave.portal.web.hmvc.HController;
+import org.apache.rave.portal.web.hmvc.Hmvc;
+import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
-@HController(controllers = {
-        @CController(name = "head", type = MyHeaderController.class),
-        @CController(name = "body", type = MyBodyController.class),
-        @CController(name = "footer", type = MyFooterController.class)
-})
-@RequestMapping("/mypage")
+@Controller
 public class MyPageController {
 
-    @RequestMapping
+    @RequestMapping("/mypage")
+    @HController(controllers = {
+            @CController(name = "head", type = MyHeaderController.class),
+            @CController(name = "body", type = MyBodyController.class),
+            @CController(name = "footer", type = MyFooterController.class)
+    })
     public String render() {
         return "mypage";
     }

Modified: rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/servlet/HmvcDispatcherServlet.java
URL: http://svn.apache.org/viewvc/rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/servlet/HmvcDispatcherServlet.java?rev=1371266&r1=1371265&r2=1371266&view=diff
==============================================================================
--- rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/servlet/HmvcDispatcherServlet.java (original)
+++ rave/sandbox/content-services/rave-web-hmvc/src/main/java/org/apache/rave/portal/web/hmvc/servlet/HmvcDispatcherServlet.java Thu Aug  9 15:58:00 2012
@@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.rave.portal.web.hmvc.HmvcHandlerMethod;
+import org.apache.rave.portal.web.hmvc.HmvcHandlerMethodMapping;
 import org.apache.rave.portal.web.hmvc.support.HmvcServletRequest;
 import org.apache.rave.portal.web.hmvc.support.HmvcServletResponse;
 import org.apache.rave.portal.web.hmvc.support.ResponseHolder;
@@ -37,17 +38,26 @@ public class HmvcDispatcherServlet exten
 
     private static final long serialVersionUID = 1L;
 
+    protected boolean isHmvcRendering(HttpServletRequest request) {
+        return request.getAttribute(HmvcHandlerMethodMapping.class.getName()) != null;
+    }
+
     @Override
     protected void render(ModelAndView mv, HttpServletRequest request, HttpServletResponse response) throws Exception {
-        HmvcServletRequest hmvcRequest = new HmvcServletRequest(request);
-        HmvcServletResponse hmvcResponse = new HmvcServletResponse(response);
-        
-        renderChildren(mv, hmvcRequest, hmvcResponse);
-        render(mv, hmvcRequest, hmvcResponse);
-        ResponseHolder responseHolder = hmvcResponse.getResponseHolder();
-        responseHolder.flush();
-        if (responseHolder.getRedirectLocation() != null) {
-            response.sendRedirect(responseHolder.getRedirectLocation());
+        if (isHmvcRendering(request)) {
+            HmvcServletRequest hmvcRequest = new HmvcServletRequest(request);
+            HmvcServletResponse hmvcResponse = new HmvcServletResponse(response);
+
+            renderChildren(mv, hmvcRequest, hmvcResponse);
+            render(mv, hmvcRequest, hmvcResponse);
+            ResponseHolder responseHolder = hmvcResponse.getResponseHolder();
+            responseHolder.flush();
+            if (responseHolder.getRedirectLocation() != null) {
+                response.sendRedirect(responseHolder.getRedirectLocation());
+            }
+        }
+        else {
+            super.render(mv, request, response);
         }
     }
 
@@ -67,7 +77,6 @@ public class HmvcDispatcherServlet exten
     }
     
     protected void render(ModelAndView mv, HmvcServletRequest hmvcRequest, HmvcServletResponse hmvcResponse) throws Exception {
-        
         if (!mv.isReference()) {
             setInternalResourceViewIncludeAlways(mv.getView());
         }
@@ -77,7 +86,9 @@ public class HmvcDispatcherServlet exten
     protected View resolveViewName(String viewName, Map<String, Object> model, Locale locale,
             HttpServletRequest request) throws Exception {
         View view = super.resolveViewName(viewName, model, locale, request);
-        setInternalResourceViewIncludeAlways(view);
+        if (isHmvcRendering(request)) {
+            setInternalResourceViewIncludeAlways(view);
+        }
         return view;
     }