Package org.strecks.navigate.spring

Source Code of org.strecks.navigate.spring.SpringViewNavigationReader

/*
* Copyright 2005-2006 the original author or authors.
*
* Licensed 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.strecks.navigate.spring;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import org.springframework.web.servlet.ModelAndView;
import org.strecks.exceptions.ApplicationConfigurationException;
import org.strecks.navigate.NavigationHandlerFactory;
import org.strecks.navigate.factory.IdentityNavigationHandlerFactory;
import org.strecks.navigate.internal.NavigationHandlerInfo;
import org.strecks.navigate.internal.NavigationReader;
import org.strecks.navigate.spring.annotation.SpringView;

/**
* Implementation of the <code>NavigationReader</code> interface, with logic to read the
* @SpringView annotation
* @author Phil Zoio
*/
public class SpringViewNavigationReader implements NavigationReader
{

  public NavigationHandlerInfo getNavigationHandlerFactory(Annotation annotation, Class actionClass,
      Method containingMethod)
  {

    SpringView view = (SpringView) annotation;
    SpringViewNavigationHandler springViewNavigationHandler = new SpringViewNavigationHandler(view.resolver());

    Class<?> returnType = containingMethod.getReturnType();
    if (!ModelAndView.class.isAssignableFrom(returnType))
    {
      throw new ApplicationConfigurationException("Method " + containingMethod.getName() + "() in class "
          + containingMethod.getDeclaringClass().getName() + " must return object of type "
          + ModelAndView.class.getName());
    }

    NavigationHandlerFactory factoryInstance = new IdentityNavigationHandlerFactory(springViewNavigationHandler);
    return new NavigationHandlerInfo(factoryInstance, containingMethod);
  }
}
TOP

Related Classes of org.strecks.navigate.spring.SpringViewNavigationReader

TOP
Copyright © 2018 www.massapi.com. 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.