use of org.directwebremoting.extend.AjaxFilterManager in project ma-core-public by infiniteautomation.
the class AnnotationsConfigurator method processGlobalFilter.
/**
* Global Filters apply to all classes
* @param clazz The class to use as a filter
* @param globalFilterAnn The filter annotation
* @param container The IoC container to configure
* @throws InstantiationException In case we can't create the given clazz
* @throws IllegalAccessException In case we can't create the given clazz
*/
private void processGlobalFilter(Class<?> clazz, GlobalFilter globalFilterAnn, Container container) throws InstantiationException, IllegalAccessException {
if (!AjaxFilter.class.isAssignableFrom(clazz)) {
throw new IllegalArgumentException(clazz.getName() + " is not an AjaxFilter implementation");
}
Map<String, String> filterParams = getParamsMap(globalFilterAnn.params());
AjaxFilter filter = (AjaxFilter) clazz.newInstance();
if (filter != null) {
LocalUtil.setParams(filter, filterParams, null);
AjaxFilterManager filterManager = (AjaxFilterManager) container.getBean(AjaxFilterManager.class.getName());
filterManager.addAjaxFilter(filter);
}
}
use of org.directwebremoting.extend.AjaxFilterManager in project ma-core-public by infiniteautomation.
the class AnnotationsConfigurator method processFilter.
/**
* Process the @Filter annotaion
* @param filterAnn The filter annotation
* @param name The Javascript name of the class to filter
* @param container The IoC container to configure
*/
private void processFilter(Filter filterAnn, String name, Container container) {
Map<String, String> filterParams = getParamsMap(filterAnn.params());
AjaxFilter filter = (AjaxFilter) LocalUtil.classNewInstance(name, filterAnn.type().getName(), AjaxFilter.class);
if (filter != null) {
LocalUtil.setParams(filter, filterParams, null);
AjaxFilterManager filterManager = (AjaxFilterManager) container.getBean(AjaxFilterManager.class.getName());
filterManager.addAjaxFilter(filter, name);
}
}
use of org.directwebremoting.extend.AjaxFilterManager in project ma-core-public by infiniteautomation.
the class SpringConfigurator method configure.
/* (non-Javadoc)
* @see org.directwebremoting.Configurator#configure(org.directwebremoting.Container)
*/
public void configure(Container container) {
AccessControl accessControl = (AccessControl) container.getBean(AccessControl.class.getName());
AjaxFilterManager ajaxFilterManager = (AjaxFilterManager) container.getBean(AjaxFilterManager.class.getName());
ConverterManager converterManager = (ConverterManager) container.getBean(ConverterManager.class.getName());
CreatorManager creatorManager = (CreatorManager) container.getBean(CreatorManager.class.getName());
// Configure the creator types
if (creatorTypes != null) {
for (Iterator it = creatorTypes.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry) it.next();
String typeName = (String) entry.getKey();
String className = (String) entry.getValue();
creatorManager.addCreatorType(typeName, className);
}
}
// Configure the converter types
if (converterTypes != null) {
for (Iterator it = converterTypes.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry) it.next();
String typeName = (String) entry.getKey();
String className = (String) entry.getValue();
converterManager.addConverterType(typeName, className);
}
}
// Configure the creators
if (creators != null) {
try {
for (Iterator it = creators.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry) it.next();
String scriptName = (String) entry.getKey();
CreatorConfig creatorConfig = (CreatorConfig) entry.getValue();
if (creatorConfig.getCreator() != null) {
Creator creator = creatorConfig.getCreator();
creatorManager.addCreator(scriptName, creator);
} else {
String creatorName = creatorConfig.getCreatorType();
Map params = creatorConfig.getParams();
creatorManager.addCreator(scriptName, creatorName, params);
}
List excludes = creatorConfig.getExcludes();
for (Iterator eit = excludes.iterator(); eit.hasNext(); ) {
String exclude = (String) eit.next();
accessControl.addExcludeRule(scriptName, exclude);
}
List includes = creatorConfig.getIncludes();
for (Iterator iit = includes.iterator(); iit.hasNext(); ) {
String include = (String) iit.next();
accessControl.addIncludeRule(scriptName, include);
}
Properties auth = creatorConfig.getAuth();
for (Iterator ait = auth.entrySet().iterator(); ait.hasNext(); ) {
Map.Entry aentry = (Map.Entry) ait.next();
String methodName = (String) aentry.getKey();
String role = (String) aentry.getValue();
accessControl.addRoleRestriction(scriptName, methodName, role);
}
List filters = creatorConfig.getFilters();
for (Iterator fit = filters.iterator(); fit.hasNext(); ) {
Object obj = fit.next();
if (obj instanceof String) {
String filterName = (String) obj;
AjaxFilter filter = (AjaxFilter) 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(Messages.getString("SpringConfigurator.InvalidFilter", scriptName, obj));
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
throw new IllegalArgumentException(ex.toString());
}
}
// Configure the converters
if (converters != null) {
try {
for (Iterator it = converters.entrySet().iterator(); it.hasNext(); ) {
Map.Entry entry = (Map.Entry) it.next();
String match = (String) entry.getKey();
ConverterConfig converterConfig = (ConverterConfig) entry.getValue();
Map params = converterConfig.getParams();
if (converterConfig.getIncludes().size() > 0) {
params.put("include", StringUtils.collectionToCommaDelimitedString(converterConfig.getIncludes()));
}
if (converterConfig.getExcludes().size() > 0) {
params.put("exclude", StringUtils.collectionToCommaDelimitedString(converterConfig.getExcludes()));
}
// params.put("force", Boolean.valueOf(converterConfig.isForce()));
if (StringUtils.hasText(converterConfig.getJavascriptClassName())) {
params.put("javascript", converterConfig.getJavascriptClassName());
}
converterManager.addConverter(match, converterConfig.getType(), params);
}
} catch (Exception ex) {
throw new IllegalArgumentException(Messages.getString("SpringConfigurator.ConfigureConverterError"));
}
}
// Configure the signatures
if (StringUtils.hasText(signatures)) {
SignatureParser sigp = new SignatureParser(converterManager, creatorManager);
sigp.parse(signatures);
}
}
use of org.directwebremoting.extend.AjaxFilterManager in project ma-core-public by infiniteautomation.
the class DwrXmlConfigurator method configure.
/* (non-Javadoc)
* @see org.directwebremoting.Configurator#configure(org.directwebremoting.Container)
*/
public void configure(Container container) {
accessControl = (AccessControl) container.getBean(AccessControl.class.getName());
ajaxFilterManager = (AjaxFilterManager) container.getBean(AjaxFilterManager.class.getName());
converterManager = (ConverterManager) container.getBean(ConverterManager.class.getName());
creatorManager = (CreatorManager) container.getBean(CreatorManager.class.getName());
Element root = document.getDocumentElement();
NodeList rootChildren = root.getChildNodes();
for (int i = 0; i < rootChildren.getLength(); i++) {
Node node = rootChildren.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
Element child = (Element) node;
if (child.getNodeName().equals(ELEMENT_INIT)) {
loadInits(child);
} else if (child.getNodeName().equals(ELEMENT_ALLOW)) {
loadAllows(child);
} else if (child.getNodeName().equals(ELEMENT_SIGNATURES)) {
loadSignature(child);
}
}
}
}
use of org.directwebremoting.extend.AjaxFilterManager in project ma-core-public by infiniteautomation.
the class ContainerUtil method debugConfig.
/**
* Create a bunch of debug information about a container
* @param container The container to print debug information about
*/
public static void debugConfig(Container container) {
if (log.isDebugEnabled()) {
// Container level debug
log.debug("Container");
log.debug(" Type: " + container.getClass().getName());
Collection beanNames = container.getBeanNames();
for (Iterator it = beanNames.iterator(); it.hasNext(); ) {
String name = (String) it.next();
Object object = container.getBean(name);
if (object instanceof String) {
log.debug(" Param: " + name + " = " + object + " (" + object.getClass().getName() + ")");
} else {
log.debug(" Bean: " + name + " = " + object + " (" + object.getClass().getName() + ")");
}
}
// AccessControl debugging
AccessControl accessControl = (AccessControl) container.getBean(AccessControl.class.getName());
log.debug("AccessControl");
log.debug(" Type: " + accessControl.getClass().getName());
// AjaxFilterManager debugging
AjaxFilterManager ajaxFilterManager = (AjaxFilterManager) container.getBean(AjaxFilterManager.class.getName());
log.debug("AjaxFilterManager");
log.debug(" Type: " + ajaxFilterManager.getClass().getName());
// ConverterManager debugging
ConverterManager converterManager = (ConverterManager) container.getBean(ConverterManager.class.getName());
log.debug("ConverterManager");
log.debug(" Type: " + converterManager.getClass().getName());
// CreatorManager debugging
CreatorManager creatorManager = (CreatorManager) container.getBean(CreatorManager.class.getName());
log.debug("CreatorManager");
log.debug(" Type: " + creatorManager.getClass().getName());
Collection creatorNames = creatorManager.getCreatorNames();
for (Iterator it = creatorNames.iterator(); it.hasNext(); ) {
String creatorName = (String) it.next();
Creator creator = creatorManager.getCreator(creatorName);
log.debug(" Creator: " + creatorName + " = " + creator + " (" + creator.getClass().getName() + ")");
}
}
}
Aggregations