*/
public void configure(Container container)
{
AccessControl accessControl = container.getBean(AccessControl.class);
AjaxFilterManager ajaxFilterManager = container.getBean(AjaxFilterManager.class);
ConverterManager converterManager = container.getBean(ConverterManager.class);
CreatorManager creatorManager = container.getBean(CreatorManager.class);
// Configure the global filters
if (null != filters)
{
for (AjaxFilter filter : filters)
{
ajaxFilterManager.addAjaxFilter(filter);
}
}
// Configure the creator types
if (creatorTypes != null)
{
for (Entry<String, String> entry : creatorTypes.entrySet())
{
String typeName = entry.getKey();
String className = entry.getValue();
creatorManager.addCreatorType(typeName, className);
}
}
// Configure the converter types
if (converterTypes != null)
{
for (Entry<String, String> entry : converterTypes.entrySet())
{
String typeName = entry.getKey();
String className = entry.getValue();
converterManager.addConverterType(typeName, className);
}
}
// Configure the creators
if (creators != null)
{
try
{
for (Entry<String, CreatorConfig> entry : creators.entrySet())
{
String scriptName = entry.getKey();
CreatorConfig creatorConfig = entry.getValue();
if (creatorConfig.getCreator() != null)
{
Creator creator = creatorConfig.getCreator();
creatorManager.addCreator(creator);
}
else
{
String creatorName = creatorConfig.getCreatorType();
Map<String, String> params = creatorConfig.getParams();
creatorManager.addCreator(creatorName, params);
}
for (String exclude : creatorConfig.getExcludes())
{
accessControl.addExcludeRule(scriptName, exclude);
}
for (String include : creatorConfig.getIncludes())
{
accessControl.addIncludeRule(scriptName, include);
}
Map<String, List<String>> auth = creatorConfig.getAuth();
for (Entry<String, List<String>> constraint : auth.entrySet())
{
for (String role : constraint.getValue())
{
accessControl.addRoleRestriction(scriptName, constraint.getKey(), role);
}
}
for (Object obj : creatorConfig.getFilters())
{
if (obj instanceof String)
{
String filterName = (String) obj;
AjaxFilter filter = LocalUtil.classNewInstance(filterName, filterName, AjaxFilter.class);
if (filter != null)
{
ajaxFilterManager.addAjaxFilter(filter, scriptName);
}
}
else if (obj instanceof AjaxFilter)
{
AjaxFilter filter = (AjaxFilter) obj;
ajaxFilterManager.addAjaxFilter(filter, scriptName);
}
else
{
throw new IllegalArgumentException("An invalid filter is added for script '" + scriptName + "'. It should either be the class name of the filter or an instantiated AjaxFilter, but was: '" + obj + "'.");
}
}
}
}
catch (Exception ex)
{
throw new IllegalArgumentException(ex);
}
}
// Configure the converters
if (converters != null)
{
try
{
for (Entry<String, ConverterConfig> entry : converters.entrySet())
{
String match = entry.getKey();
ConverterConfig converterConfig = entry.getValue();
Map<String, String> params = converterConfig.getParams();
if (!converterConfig.getIncludes().isEmpty())
{
params.put("include", StringUtils.collectionToCommaDelimitedString(converterConfig.getIncludes()));
}
if (!converterConfig.getExcludes().isEmpty())
{
params.put("exclude", StringUtils.collectionToCommaDelimitedString(converterConfig.getExcludes()));
}
if (StringUtils.hasText(converterConfig.getJavascriptClassName()))
{
params.put("javascript", converterConfig.getJavascriptClassName());
}
if (converterConfig.isForce())
{
params.put("force", String.valueOf(converterConfig.isForce()));
}
String type = converterConfig.getType();
if(type.startsWith("preconfigured"))
{
converterManager.addConverter(match, (Converter) container.getBean(type.substring(14)));
}
else
{
converterManager.addConverter(match, type, params);
}
}
}
catch (Exception ex)
{