Closed spring-projects-issues closed 15 years ago
["Luke Taylor":https://jira.spring.io/secure/ViewProfile.jspa?name=luke] said:
This class was intended to provide support for property editor based configuration, which is now deprecated, so in future this class will have no purpose within the framework and it would be better if it was removed in the interests of keeping the codebase as clean as possible and minimising maintenance overhead.
What exactly is your requirement? You will of course still be able to make use of the code yourself if it is removed from future versions.
["zhouyanming":https://jira.spring.io/secure/ViewProfile.jspa?name=quaff] said:
I would like to use classic acegi configuration rather than new spring2.0 schema,I can refresh FilterInvocationDefinitionSource at runtime using spring aop.
<bean id="filterInvocationInterceptorObjectDefinitionSource" class="test.RefreshableFilterInvocationDefinitionSource" />
<bean id="filterInvocationInterceptor"
class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
<property name="objectDefinitionSource">
<bean class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="targetSource" ref="filterInvocationInterceptorObjectDefinitionSource" />
</bean>
</property>
</bean>
public class RefreshableFilterInvocationDefinitionSource extends AbstractRefreshableTargetSource implements ResourceLoaderAware, BeanNameAware, InitializingBean {
protected Log logger = LogFactory.getLog(getClass());
private Resource definitionResource;
private String beanName;
private String directory = "/WEB-INF/conf/";
private ResourceLoader resourceLoader;
public String getDirectory() {
return directory.endsWith("/") ? directory : directory + "/";
}
public void setDirectory(String directory) {
this.directory = directory;
}
public void setBeanName(String beanName) {
this.beanName = beanName;
}
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
public void afterPropertiesSet() throws Exception {
Assert.hasLength(directory);
definitionResource = resourceLoader.getResource(getDirectory()
+ beanName + ".conf");
}
public void setDefinitionAsText(String definition) {
try {
FileUtils.writeStringToFile(resourceLoader.getResource(
getDirectory() + beanName + ".conf").getFile(), definition,
"UTF-8");
} catch (IOException e) {
logger.error(e.getMessage(), e);
}
}
public String getDefinitionAsText() {
try {
return FileUtils.readFileToString(definitionResource.getFile(),
"UTF-8");
} catch (IOException e) {
logger.error(e.getMessage(), e);
return "";
}
}
protected Object freshTarget() {
StringBuilder sb = new StringBuilder();
LineIterator it = null;
try {
it = FileUtils.lineIterator(definitionResource.getFile(), "UTF-8");
while (it.hasNext()) {
String line = it.nextLine();
if (!line.startsWith("#"))
sb.append(line + "\n");
}
logger.info("loaded Acegi FilterInvocationDefinition config file["
+ definitionResource.getURL() + "]");
} catch (IOException e) {
} finally {
LineIterator.closeQuietly(it);
}
FilterInvocationDefinitionSourceEditor configEditor = new FilterInvocationDefinitionSourceEditor();
configEditor.setAsText(sb.toString());
return configEditor.getValue();
}
}
["Luke Taylor":https://jira.spring.io/secure/ViewProfile.jspa?name=luke] said:
I'm afraid this class will probably be removed in 2.5, making this issue a "won't fix". We need to refactor the standard FilterInvocationDefinitionSource implementation to accomodate new configuration attributes for expressions. Trying to retain backwards compatibility with the property-editor support is too much of a maintenance headache and will lead to inferior code.
["zhouyanming":https://jira.spring.io/secure/ViewProfile.jspa?name=quaff](Migrated from ["SEC-781":https://jira.spring.io/browse/SEC-781?redirect=false]) said:
some developer need to convert string to FilterInvocationDefinitionSource in java code.