1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.cubby.plugins.spring.spi;
17
18 import org.seasar.cubby.routing.PathResolver;
19 import org.seasar.cubby.spi.PathResolverProvider;
20 import org.seasar.cubby.util.ActionUtils;
21 import org.springframework.beans.factory.BeanFactoryUtils;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.context.ApplicationContext;
24 import org.springframework.context.ApplicationContextAware;
25
26
27
28
29
30
31
32
33 public class SpringPathResolverProvider implements PathResolverProvider,
34 ApplicationContextAware {
35
36 @Autowired
37 private PathResolver pathResolver;
38
39 private ApplicationContext applicationContext;
40
41 private boolean initialized = false;
42
43
44
45
46
47
48
49 public void setApplicationContext(
50 final ApplicationContext applicationContext) {
51 this.applicationContext = applicationContext;
52 }
53
54
55
56
57 public void initialize() {
58 if (initialized) {
59 return;
60 }
61
62 final String[] names = BeanFactoryUtils
63 .beanNamesIncludingAncestors(applicationContext);
64 for (final String beanDefinitionName : names) {
65 final Class<?> type = applicationContext
66 .getType(beanDefinitionName);
67 if (ActionUtils.isActionClass(type)) {
68 pathResolver.add(type);
69 }
70 }
71
72 initialized = true;
73 }
74
75
76
77
78 public PathResolver getPathResolver() {
79 return pathResolver;
80 }
81
82 }