Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

SEC-781: remove @deprecated on org.springframework.security.intercept.web.FilterInvocationDefinitionSourceEditor #1039

Closed
spring-issuemaster opened this Issue Apr 17, 2008 · 3 comments

Comments

Projects
None yet
1 participant
from SEC-781) said:

some developer need to convert string to FilterInvocationDefinitionSource in java code.

Luke Taylor 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 said:

I would like to use classic acegi configuration rather than new spring2.0 schema,I can refresh FilterInvocationDefinitionSource at runtime using spring aop.

```




```

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 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.

@spring-issuemaster spring-issuemaster added this to the 3.0.0 M1 milestone Feb 5, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment