@@ -5,11 +5,11 @@ import de.tschuehly.spring.viewcomponent.core.component.ViewComponent
55import org.slf4j.LoggerFactory
66import org.springframework.aop.framework.Advised
77import org.springframework.aop.support.AopUtils
8- import org.springframework.boot.devtools.classpath.ClassPathChangedEvent
98import org.springframework.boot.devtools.filewatch.ChangedFiles
109import org.springframework.boot.devtools.filewatch.FileChangeListener
1110import org.springframework.context.ApplicationContext
1211import org.springframework.context.ApplicationEventPublisher
12+ import org.springframework.context.event.ContextRefreshedEvent
1313
1414
1515class ViewComponentChangeListener (
@@ -39,11 +39,7 @@ class ViewComponentChangeListener(
3939 viewComponentName = javaClass.simpleName.lowercase()
4040 )
4141 parser.parseFile(true )
42- if (srcFile.extension == " kte" || srcFile.extension == " jte" ){
43- applicationEventPublisher.publishEvent(ClassPathChangedEvent (this , changeSet, true ))
44- }else {
45- applicationEventPublisher.publishEvent(ClassPathChangedEvent (this , changeSet, false ))
46- }
42+ applicationEventPublisher.publishEvent(ContextRefreshedEvent (applicationContext))
4743 }
4844 }
4945
@@ -57,29 +53,32 @@ class ViewComponentChangeListener(
5753 }
5854 }
5955
60- private fun getViewActionMethods (javaClass : Class <Any >) =
61- javaClass.declaredMethods.mapNotNull { method ->
62- if (method.getAnnotation(GetViewAction ::class .java) != null ) {
63- val get = (method.getAnnotation(GetViewAction ::class .java) as GetViewAction )
64- return @mapNotNull ViewActionMethod (method.name.toString(), get.path, GetViewAction ::class .java)
65- }
66- if (method.getAnnotation(PostViewAction ::class .java) != null ) {
67- val get = (method.getAnnotation(PostViewAction ::class .java) as PostViewAction )
68- return @mapNotNull ViewActionMethod (method.name.toString(), get.path, PostViewAction ::class .java)
69- }
70- if (method.getAnnotation(PutViewAction ::class .java) != null ) {
71- val get = (method.getAnnotation(PutViewAction ::class .java) as PutViewAction )
72- return @mapNotNull ViewActionMethod (method.name.toString(), get.path, PutViewAction ::class .java)
73- }
74- if (method.getAnnotation(PatchViewAction ::class .java) != null ) {
75- val get = (method.getAnnotation(PatchViewAction ::class .java) as PatchViewAction )
76- return @mapNotNull ViewActionMethod (method.name.toString(), get.path, PatchViewAction ::class .java)
56+ companion object {
57+ fun getViewActionMethods (javaClass : Class <Any >) =
58+ javaClass.declaredMethods.mapNotNull { method ->
59+ if (method.getAnnotation(GetViewAction ::class .java) != null ) {
60+ val get = (method.getAnnotation(GetViewAction ::class .java) as GetViewAction )
61+ return @mapNotNull ViewActionMethod (method.name.toString(), get.path, GetViewAction ::class .java)
62+ }
63+ if (method.getAnnotation(PostViewAction ::class .java) != null ) {
64+ val get = (method.getAnnotation(PostViewAction ::class .java) as PostViewAction )
65+ return @mapNotNull ViewActionMethod (method.name.toString(), get.path, PostViewAction ::class .java)
66+ }
67+ if (method.getAnnotation(PutViewAction ::class .java) != null ) {
68+ val get = (method.getAnnotation(PutViewAction ::class .java) as PutViewAction )
69+ return @mapNotNull ViewActionMethod (method.name.toString(), get.path, PutViewAction ::class .java)
70+ }
71+ if (method.getAnnotation(PatchViewAction ::class .java) != null ) {
72+ val get = (method.getAnnotation(PatchViewAction ::class .java) as PatchViewAction )
73+ return @mapNotNull ViewActionMethod (method.name.toString(), get.path, PatchViewAction ::class .java)
74+ }
75+ if (method.getAnnotation(DeleteViewAction ::class .java) != null ) {
76+ val get = (method.getAnnotation(DeleteViewAction ::class .java) as DeleteViewAction )
77+ return @mapNotNull ViewActionMethod (method.name.toString(), get.path, DeleteViewAction ::class .java)
78+ }
79+ return @mapNotNull null
7780 }
78- if (method.getAnnotation(DeleteViewAction ::class .java) != null ) {
79- val get = (method.getAnnotation(DeleteViewAction ::class .java) as DeleteViewAction )
80- return @mapNotNull ViewActionMethod (method.name.toString(), get.path, DeleteViewAction ::class .java)
81- }
82- return @mapNotNull null
83- }
81+
82+ }
8483
8584}
0 commit comments