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 public class TemplateExporter extends AbstractUrlMappedHandlerPostProcessor {
49
50 private final Logger logger = LoggerFactory.getLogger(getClass());
51
52 private BlossomDispatcher dispatcher;
53
54 public TemplateExporter(BlossomDispatcher dispatcher) {
55 this.dispatcher = dispatcher;
56 }
57
58 @Override
59 protected void postProcessHandler(Object handler, String handlerPath) {
60 if (handler.getClass().isAnnotationPresent(Template.class)) {
61 try {
62 BlossomModule.getTemplateRegistry().registerTemplate(dispatcher, handler, handlerPath);
63 } catch (RepositoryException e) {
64 logger.error("Unable to register template [" + handler.getClass().getName() + "] with handlerPath [" + handlerPath + "]", e);
65 }
66 try {
67 BlossomModule.getDialogRegistry().registerDialogFactories(handler);
68 } catch (RepositoryException e) {
69 logger.error("Unable to register dialog factories within template [" + handler.getClass().getName() + "] with handlerPath [" + handlerPath + "]", e);
70 }
71 }
72 }
73 }