345 lines
8.5 KiB
Java
345 lines
8.5 KiB
Java
package org.apache.struts.config;
|
|
|
|
import java.io.Serializable;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
|
|
public class ActionConfig implements Serializable {
|
|
protected boolean configured = false;
|
|
|
|
protected HashMap exceptions = new HashMap();
|
|
|
|
protected HashMap forwards = new HashMap();
|
|
|
|
protected ModuleConfig moduleConfig = null;
|
|
|
|
public ModuleConfig getApplicationConfig() {
|
|
return getModuleConfig();
|
|
}
|
|
|
|
public ModuleConfig getModuleConfig() {
|
|
return this.moduleConfig;
|
|
}
|
|
|
|
public void setApplicationConfig(ModuleConfig moduleConfig) {
|
|
setModuleConfig(moduleConfig);
|
|
}
|
|
|
|
public void setModuleConfig(ModuleConfig moduleConfig) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.moduleConfig = moduleConfig;
|
|
}
|
|
|
|
protected String attribute = null;
|
|
|
|
public String getAttribute() {
|
|
if (this.attribute == null)
|
|
return this.name;
|
|
return this.attribute;
|
|
}
|
|
|
|
public void setAttribute(String attribute) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.attribute = attribute;
|
|
}
|
|
|
|
protected String forward = null;
|
|
|
|
public String getForward() {
|
|
return this.forward;
|
|
}
|
|
|
|
public void setForward(String forward) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.forward = forward;
|
|
}
|
|
|
|
protected String include = null;
|
|
|
|
public String getInclude() {
|
|
return this.include;
|
|
}
|
|
|
|
public void setInclude(String include) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.include = include;
|
|
}
|
|
|
|
protected String input = null;
|
|
|
|
public String getInput() {
|
|
return this.input;
|
|
}
|
|
|
|
public void setInput(String input) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.input = input;
|
|
}
|
|
|
|
protected String multipartClass = null;
|
|
|
|
public String getMultipartClass() {
|
|
return this.multipartClass;
|
|
}
|
|
|
|
public void setMultipartClass(String multipartClass) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.multipartClass = multipartClass;
|
|
}
|
|
|
|
protected String name = null;
|
|
|
|
public String getName() {
|
|
return this.name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.name = name;
|
|
}
|
|
|
|
protected String parameter = null;
|
|
|
|
public String getParameter() {
|
|
return this.parameter;
|
|
}
|
|
|
|
public void setParameter(String parameter) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.parameter = parameter;
|
|
}
|
|
|
|
protected String path = null;
|
|
|
|
public String getPath() {
|
|
return this.path;
|
|
}
|
|
|
|
public void setPath(String path) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.path = path;
|
|
}
|
|
|
|
protected String prefix = null;
|
|
|
|
public String getPrefix() {
|
|
return this.prefix;
|
|
}
|
|
|
|
public void setPrefix(String prefix) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.prefix = prefix;
|
|
}
|
|
|
|
protected String roles = null;
|
|
|
|
public String getRoles() {
|
|
return this.roles;
|
|
}
|
|
|
|
public void setRoles(String roles) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.roles = roles;
|
|
if (roles == null) {
|
|
this.roleNames = new String[0];
|
|
return;
|
|
}
|
|
ArrayList list = new ArrayList();
|
|
while (true) {
|
|
int comma = roles.indexOf(',');
|
|
if (comma < 0)
|
|
break;
|
|
list.add(roles.substring(0, comma).trim());
|
|
roles = roles.substring(comma + 1);
|
|
}
|
|
roles = roles.trim();
|
|
if (roles.length() > 0)
|
|
list.add(roles);
|
|
this.roleNames = list.<String>toArray(new String[list.size()]);
|
|
}
|
|
|
|
protected String[] roleNames = new String[0];
|
|
|
|
public String[] getRoleNames() {
|
|
return this.roleNames;
|
|
}
|
|
|
|
protected String scope = "session";
|
|
|
|
public String getScope() {
|
|
return this.scope;
|
|
}
|
|
|
|
public void setScope(String scope) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.scope = scope;
|
|
}
|
|
|
|
protected String suffix = null;
|
|
|
|
public String getSuffix() {
|
|
return this.suffix;
|
|
}
|
|
|
|
public void setSuffix(String suffix) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.suffix = suffix;
|
|
}
|
|
|
|
protected String type = null;
|
|
|
|
public String getType() {
|
|
return this.type;
|
|
}
|
|
|
|
public void setType(String type) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.type = type;
|
|
}
|
|
|
|
protected boolean unknown = false;
|
|
|
|
public boolean getUnknown() {
|
|
return this.unknown;
|
|
}
|
|
|
|
public void setUnknown(boolean unknown) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.unknown = unknown;
|
|
}
|
|
|
|
protected boolean validate = true;
|
|
|
|
public boolean getValidate() {
|
|
return this.validate;
|
|
}
|
|
|
|
public void setValidate(boolean validate) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.validate = validate;
|
|
}
|
|
|
|
public void addExceptionConfig(ExceptionConfig config) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.exceptions.put(config.getType(), config);
|
|
}
|
|
|
|
public void addForwardConfig(ForwardConfig config) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.forwards.put(config.getName(), config);
|
|
}
|
|
|
|
public ExceptionConfig findExceptionConfig(String type) {
|
|
return (ExceptionConfig)this.exceptions.get(type);
|
|
}
|
|
|
|
public ExceptionConfig[] findExceptionConfigs() {
|
|
ExceptionConfig[] results = new ExceptionConfig[this.exceptions.size()];
|
|
return (ExceptionConfig[])this.exceptions.values().toArray((Object[])results);
|
|
}
|
|
|
|
public ForwardConfig findForwardConfig(String name) {
|
|
return (ForwardConfig)this.forwards.get(name);
|
|
}
|
|
|
|
public ForwardConfig[] findForwardConfigs() {
|
|
ForwardConfig[] results = new ForwardConfig[this.forwards.size()];
|
|
return (ForwardConfig[])this.forwards.values().toArray((Object[])results);
|
|
}
|
|
|
|
public void freeze() {
|
|
this.configured = true;
|
|
ExceptionConfig[] econfigs = findExceptionConfigs();
|
|
for (int i = 0; i < econfigs.length; i++)
|
|
econfigs[i].freeze();
|
|
ForwardConfig[] fconfigs = findForwardConfigs();
|
|
for (int j = 0; j < fconfigs.length; j++)
|
|
fconfigs[j].freeze();
|
|
}
|
|
|
|
public void removeExceptionConfig(ExceptionConfig config) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.exceptions.remove(config.getType());
|
|
}
|
|
|
|
public void removeForwardConfig(ForwardConfig config) {
|
|
if (this.configured)
|
|
throw new IllegalStateException("Configuration is frozen");
|
|
this.forwards.remove(config.getName());
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuffer sb = new StringBuffer("ActionConfig[");
|
|
sb.append("path=");
|
|
sb.append(this.path);
|
|
if (this.attribute != null) {
|
|
sb.append(",attribute=");
|
|
sb.append(this.attribute);
|
|
}
|
|
if (this.forward != null) {
|
|
sb.append(",forward=");
|
|
sb.append(this.forward);
|
|
}
|
|
if (this.include != null) {
|
|
sb.append(",include=");
|
|
sb.append(this.include);
|
|
}
|
|
if (this.input != null) {
|
|
sb.append(",input=");
|
|
sb.append(this.input);
|
|
}
|
|
if (this.multipartClass != null) {
|
|
sb.append(",multipartClass=");
|
|
sb.append(this.multipartClass);
|
|
}
|
|
if (this.name != null) {
|
|
sb.append(",name=");
|
|
sb.append(this.name);
|
|
}
|
|
if (this.parameter != null) {
|
|
sb.append(",parameter=");
|
|
sb.append(this.parameter);
|
|
}
|
|
if (this.prefix != null) {
|
|
sb.append(",prefix=");
|
|
sb.append(this.prefix);
|
|
}
|
|
if (this.roles != null) {
|
|
sb.append(",roles=");
|
|
sb.append(this.roles);
|
|
}
|
|
if (this.scope != null) {
|
|
sb.append(",scope=");
|
|
sb.append(this.scope);
|
|
}
|
|
if (this.suffix != null) {
|
|
sb.append(",suffix=");
|
|
sb.append(this.suffix);
|
|
}
|
|
if (this.type != null) {
|
|
sb.append(",type=");
|
|
sb.append(this.type);
|
|
}
|
|
return sb.toString();
|
|
}
|
|
}
|