1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.module.blossom.template;
35
36 import info.magnolia.module.blossom.BlossomModule;
37 import info.magnolia.module.blossom.annotation.Template;
38 import info.magnolia.module.blossom.dispatcher.BlossomDispatcher;
39 import info.magnolia.module.blossom.support.AbstractUrlMappedHandlerPostProcessor;
40 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory;
42
43 import javax.jcr.RepositoryException;
44
45
46
47
48
49
50 public class TemplateExporter extends AbstractUrlMappedHandlerPostProcessor {
51
52 private final Logger logger = LoggerFactory.getLogger(getClass());
53
54 private BlossomDispatcher dispatcher;
55
56 public TemplateExporter(BlossomDispatcher dispatcher) {
57 this.dispatcher = dispatcher;
58 }
59
60 @Override
61 protected void postProcessHandler(Object handler, String handlerPath) {
62 if (handler.getClass().isAnnotationPresent(Template.class)) {
63 try {
64 BlossomModule.getTemplateRegistry().registerTemplate(dispatcher, handler, handlerPath);
65 } catch (RepositoryException e) {
66 logger.error("Unable to register template [" + handler.getClass().getName() + "] with handlerPath [" + handlerPath + "]", e);
67 }
68 try {
69 BlossomModule.getDialogRegistry().registerDialogFactories(handler);
70 } catch (RepositoryException e) {
71 logger.error("Unable to register dialog factories within template [" + handler.getClass().getName() + "] with handlerPath [" + handlerPath + "]", e);
72 }
73 }
74 }
75 }