com.alogic.redirect.RedirectPath Maven / Gradle / Ivy
package com.alogic.redirect;
import java.util.Map;
import org.w3c.dom.Element;
import com.alogic.load.Loadable;
import com.anysoft.util.Configurable;
import com.anysoft.util.JsonTools;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;
import com.anysoft.util.XMLConfigurable;
import com.anysoft.util.XmlElementProperties;
import com.anysoft.util.XmlTools;
/**
* 重定向路径
*
* @author yyduan
* @since 1.6.11.26
*
* @version 1.6.12.9 [20181127 duanyy]
* - 将redirect框架从alogic-common工程迁移到alogic-auth;
* - 增加事件机制,允许某些跳转可以通过脚本逻辑来定制;
*/
public interface RedirectPath extends Loadable{
/**
* 获取目标路径
* @return 目标路径
*/
public String getTargetPath();
/**
* 是否必须登录
*/
public boolean mustLogin();
/**
* 是否需要携带登录证明
*/
public boolean withCredential();
/**
* 是否作为事件处理
*/
public boolean asEvent();
public static class Default extends Loadable.Abstract implements RedirectPath ,XMLConfigurable,Configurable{
/**
* id
*/
protected String id;
/**
* targetPath
*/
protected String targetPath;
/**
* mustLogin
*/
protected boolean mustLogin = false;
/**
* withCredential
*/
protected boolean withCredential = false;
/**
* 是否作为事件处理
*/
protected boolean asEvent = false;
@Override
public String getId() {
return id;
}
@Override
public void report(Element xml) {
if (xml != null){
XmlTools.setString(xml, "module", getClass().getName());
}
}
@Override
public void report(Map json) {
if (json != null){
JsonTools.setString(json,"module",getClass().getName());
}
}
@Override
public String getTargetPath() {
return targetPath;
}
@Override
public boolean mustLogin() {
return this.mustLogin;
}
@Override
public boolean withCredential() {
return this.withCredential;
}
@Override
public boolean asEvent(){
return this.asEvent;
}
@Override
public void configure(Properties p) {
id = PropertiesConstants.getString(p, "id", id);
targetPath = PropertiesConstants.getRaw(p, "targetPath", targetPath);
mustLogin = PropertiesConstants.getBoolean(p, "mustLogin", mustLogin);
withCredential = PropertiesConstants.getBoolean(p, "withCredential", withCredential);
asEvent = PropertiesConstants.getBoolean(p,"asEvent",asEvent);
}
@Override
public void configure(Element e, Properties p) {
Properties props = new XmlElementProperties(e,p);
configure(props);
}
}
}