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