Java tutorial
/* * Copyright 2007-2009 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 com.laxser.blitz.web.impl.module; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.springframework.web.context.WebApplicationContext; import com.laxser.blitz.web.ControllerErrorHandler; import com.laxser.blitz.web.InterceptorDelegate; import com.laxser.blitz.web.ParamValidator; import com.laxser.blitz.web.paramresolver.ParamResolver; /** * {@link Module} * * @author laxser Date 2012-4-5 ?3:23:53 @contact [duqifan@gmail.com] @ModuleImpl.java */ public class ModuleImpl implements Module { // private static Log logger = LogFactory.getLog(ModuleImpl.class); // ?? private String mappingPath; // ?? private URL url; // ?controllers?'/''/' private String relativePath; // urlmodule,modulemodule,parent==null private Module parent; // modulespring applicationContextmoduleapplicationContext private WebApplicationContext applicationContext; // module? private List<ControllerRef> controllers = new ArrayList<ControllerRef>(); // module??? private List<ParamResolver> customerResolvers = Collections.emptyList(); // add? private List<InterceptorDelegate> interceptors = Collections.emptyList(); // add? private List<ParamValidator> validators = Collections.emptyList(); // ??(??errorHanlderapplicationContexterrorHandler) private ControllerErrorHandler errorHandler; // "/controller/action"?????? // @Path("")@DefaultController // ?default,index,home,welcome? // private Mapping<Controller> defaultController; // ?nulldefaultControllernull?? // defaultControllerDone==false,?interceptorsdefaultController // private boolean defaultControllerDone; // ??(?applicationContext?multipartResolver) // private MultipartResolver multipartResolver;F public ModuleImpl(Module parent, URL url, String mappingPath, String relativePath, WebApplicationContext context) { this.parent = parent; this.url = url; this.mappingPath = mappingPath; this.relativePath = relativePath; this.applicationContext = context; } @Override public Module getParent() { return parent; } @Override public String getMappingPath() { return mappingPath; } @Override public URL getUrl() { return url; } @Override public String getRelativePath() { return relativePath; } @Override public WebApplicationContext getApplicationContext() { return applicationContext; } // getDefaultController //"", "/default", "/index", "/home", "/welcome", "/hello" @Override public List<ControllerRef> getControllers() { return Collections.unmodifiableList(controllers); } public ModuleImpl addController(String[] mappingPaths, Class<?> controllerClass, String controllerName, Object controllerObject) { ControllerRef controller = new ControllerRef(mappingPaths, controllerName, controllerObject, controllerClass); this.controllers.add(controller); return this; } public void setCustomerResolvers(List<ParamResolver> resolvers) { this.customerResolvers = resolvers; } public List<ParamResolver> getCustomerResolvers() { return Collections.unmodifiableList(customerResolvers); } public void setControllerInterceptors(List<InterceptorDelegate> interceptors) { this.interceptors = interceptors; } @Override public List<InterceptorDelegate> getInterceptors() { return interceptors; } public void setValidators(List<ParamValidator> validators) { this.validators = validators; } @Override public List<ParamValidator> getValidators() { return validators; } @Override public ControllerErrorHandler getErrorHandler() { return errorHandler; } public void setErrorHandler(ControllerErrorHandler errorHandler) { this.errorHandler = errorHandler; } }