1 package org.appfuse.mojo.exporter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import org.apache.maven.plugin.MojoExecutionException;
20 import org.appfuse.mojo.HibernateExporterMojo;
21 import org.codehaus.mojo.hibernate3.HibernateUtils;
22 import org.hibernate.tool.hbm2x.Exporter;
23 import org.hibernate.tool.hbm2x.GenericExporter;
24
25
26
27
28
29
30
31
32 public class GenericExporterMojo extends HibernateExporterMojo {
33
34
35
36 public GenericExporterMojo() {
37 addDefaultComponent("target/appfuse/generic", "jdbcconfiguration", false);
38 addDefaultComponent("target/appfuse/generic", "jdbcconfiguration", true);
39 }
40
41
42
43
44
45
46
47
48 public String getName() {
49 return "hbmtemplate";
50 }
51
52
53
54
55 protected Exporter configureExporter(Exporter exporter) throws MojoExecutionException {
56 super.configureExporter(exporter);
57
58 if (exporter instanceof GenericExporter) {
59 GenericExporter ge = (GenericExporter) exporter;
60 ge.setFilePattern(getComponentProperty("filepattern"));
61 ge.setTemplateName(getComponentProperty("template"));
62 }
63
64 return exporter;
65 }
66
67
68
69
70
71
72 protected Exporter createExporter() {
73 String exporterClass = getComponentProperty("exporterclass");
74 if (exporterClass != null) {
75 Exporter exporter = (Exporter) HibernateUtils.getClass(exporterClass);
76 if (exporter != null) {
77 getLog().info("Using exporter class " + exporterClass);
78 return exporter;
79 } else {
80 getLog().error("Could not create custom exporter class: " + exporterClass);
81 }
82 }
83 getLog().info("Using exporter class org.hibernate.tool.hbm2x.GenericExporter");
84 return new GenericExporter();
85 }
86 }