1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.security.oauth.config;
18
19 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
20 import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
21 import org.springframework.beans.factory.xml.ParserContext;
22 import org.springframework.security.oauth.provider.token.InMemoryProviderTokenServices;
23 import org.springframework.util.StringUtils;
24 import org.w3c.dom.Element;
25
26
27
28
29 public class TokenServiceBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
30
31 @Override
32 protected Class getBeanClass(Element element) {
33 return InMemoryProviderTokenServices.class;
34 }
35
36 @Override
37 protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
38 String cleanup = element.getAttribute("cleanupInterval");
39 if (StringUtils.hasText(cleanup)) {
40 try {
41 builder.addPropertyValue("cleanupIntervalSeconds", Integer.parseInt(cleanup));
42 }
43 catch (NumberFormatException e) {
44 parserContext.getReaderContext().error("Invalid value " + cleanup + " for attribute cleanupIntervalSeconds.", element);
45 }
46 }
47 }
48 }