?? configuration.java
字號:
// Copyright 2005-2007 onetsoft.com
//
// 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.onetsoft.fastjsp;
import com.onetsoft.fastjsp.request.multipart.UploadConfig;
import com.onetsoft.fastjsp.util.Constants;
import com.onetsoft.fastjsp.util.StringUtils;
import com.onetsoft.fastjsp.valid.DefaultValidationMessageProvider;
import com.onetsoft.fastjsp.valid.ValidationMessageDecorator;
import com.onetsoft.fastjsp.valid.ValidationMessageProvider;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
/**
* 配置FastJsp系統(tǒng)
* 載入當前模塊配置
*
* @author <a href="mailto:hgw@onetsoft.com">hgw</a>
*/
public abstract class Configuration {
/**
* 當前配置模塊名稱
* Just servlet name in web.xml
*/
private String module = null;
public Configuration(String module) {
this.module = module;
}
/**
* 取得當前模塊名稱
*
* @return
*/
public String getModule() {
return module;
}
/**
* 取得驗證消息模板pattern
*
* @return
*/
public ValidationMessageProvider getValidationMessageProvider() {
return new DefaultValidationMessageProvider();
}
/**
* 全局i18n字符串資源
*
* @return
* @see PageModule#getI18nStrings(java.util.Locale)
*/
public MessagesFactory getMessagesFactory() {
return new MessagesFactory() {
public Map getI18nMap(Locale locale) {
return Collections.EMPTY_MAP;
}
};
}
/**
* 取得page service factory
*
* @return
*/
public PageServiceFactory getPageServiceFactory() {
return new PageServiceFactory() {
public PageService createPageService(Servicer servicer) {
return new AbstractPageService(servicer) {
protected AbstractPageCycle createCycle(AbstractPageService pageService) {
return new AbstractPageCycle(pageService) {
};
}
};
}
};
}
/**
* 取得系統(tǒng)缺省locale
*
* @return
*/
public Locale getLocale() {
return Locale.getDefault();
}
/**
* 定義缺省字符集
* 用于 url 解析等,而表單的encoding只能是UTF-8。
*
* @return
*/
public String getEncoding() {
return Constants.UTF_8;
}
public LocaleStateManagerFactory getLocaleStateManagerFactory() {
return new LocaleStateManagerFactory() {
public LocaleStateManager getLocaleStateManager() {
return new LocaleStateManagerImpl();
}
};
}
/**
* 返回的消息修飾
*
* @return
*/
public ValidationMessageDecoratorFactory getValidationMessageDecoratorFactory() {
return new ValidationMessageDecoratorFactory() {
public ValidationMessageDecorator getDecorator() {
return new ValidationMessageDecorator() {
public String decorate(String message) {
if (message == null || message.length() == 0)
return StringUtils.EMPTY;
else
return new StringBuffer("<span style=\"color:red;\">").append(message).append("</span>").toString();
}
};
}
};
}
/**
* 上載配置
*
* @return
*/
public UploadConfig getUploadConfig() {
return new UploadConfig() {
public int getMaxSize() {
return 10000000; //10M
}
public int getThresholdSize() {
return 1024;
}
public String getRepositoryPath() {
return System.getProperty("java.io.tmpdir");
}
};
}
public DataSqueezerFactory getDataSqueezerFactory() {
return new DataSqueezerFactory() {
public DataSqueezer getDataSqueezer() {
return new DefaultDataSqueezer();
}
};
}
/**
* 取得擴展名
*
* @return
*/
public String getUrlExt() {
return ".html";
}
/**
* 取得servicer配置
*
* @return
*/
public abstract ServicerFactory getServicerFactory();
/**
* Action 名稱
* 缺省:action
*
* @return
*/
public abstract String getActionName();
/**
* 定義頁面存放(包)位置,如:"com.mycompony.pages"
*
* @return
* @see PageModule
*/
public abstract String getPagePackageBase();
/**
* 模塊頁面模板Context相對位置:如:template/skin1 若為根路徑,則為 ""
* 每個網站模塊都有自己模板位置,缺省情況下為web context根目錄
* 注:此位置下的文件及目錄組織與{@link this#getPagePackageBase()}下的組織結構相同
*
* @return
* @see PageModule
* @since 1.2
*/
public abstract String getPageTemplateBase();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -