1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3 <head><meta http-equiv="content-type" content="text/html; charset=UTF-8" />
4 <title>Hbm2DdlMojo xref</title>
5 <link type="text/css" rel="stylesheet" href="../../../../stylesheet.css" />
8 <div id="overview"><a href="../../../../../apidocs/de/juplo/plugins/hibernate4/Hbm2DdlMojo.html">View Javadoc</a></div><pre>
9 <a class="jxr_linenumber" name="L1" href="#L1">1</a> <strong class="jxr_keyword">package</strong> de.juplo.plugins.hibernate4;
10 <a class="jxr_linenumber" name="L2" href="#L2">2</a>
11 <a class="jxr_linenumber" name="L3" href="#L3">3</a> <em class="jxr_comment">/*</em>
12 <a class="jxr_linenumber" name="L4" href="#L4">4</a> <em class="jxr_comment"> * Copyright 2001-2005 The Apache Software Foundation.</em>
13 <a class="jxr_linenumber" name="L5" href="#L5">5</a> <em class="jxr_comment"> *</em>
14 <a class="jxr_linenumber" name="L6" href="#L6">6</a> <em class="jxr_comment"> * Licensed under the Apache License, Version 2.0 (the "License");</em>
15 <a class="jxr_linenumber" name="L7" href="#L7">7</a> <em class="jxr_comment"> * you may not use this file except in compliance with the License.</em>
16 <a class="jxr_linenumber" name="L8" href="#L8">8</a> <em class="jxr_comment"> * You may obtain a copy of the License at</em>
17 <a class="jxr_linenumber" name="L9" href="#L9">9</a> <em class="jxr_comment"> *</em>
18 <a class="jxr_linenumber" name="L10" href="#L10">10</a> <em class="jxr_comment"> * <a href="http://www.apache.org/licenses/LICENSE-2." target="alexandria_uri">http://www.apache.org/licenses/LICENSE-2.</a>0</em>
19 <a class="jxr_linenumber" name="L11" href="#L11">11</a> <em class="jxr_comment"> *</em>
20 <a class="jxr_linenumber" name="L12" href="#L12">12</a> <em class="jxr_comment"> * Unless required by applicable law or agreed to in writing, software</em>
21 <a class="jxr_linenumber" name="L13" href="#L13">13</a> <em class="jxr_comment"> * distributed under the License is distributed on an "AS IS" BASIS,</em>
22 <a class="jxr_linenumber" name="L14" href="#L14">14</a> <em class="jxr_comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</em>
23 <a class="jxr_linenumber" name="L15" href="#L15">15</a> <em class="jxr_comment"> * See the License for the specific language governing permissions and</em>
24 <a class="jxr_linenumber" name="L16" href="#L16">16</a> <em class="jxr_comment"> * limitations under the License.</em>
25 <a class="jxr_linenumber" name="L17" href="#L17">17</a> <em class="jxr_comment"> */</em>
26 <a class="jxr_linenumber" name="L18" href="#L18">18</a>
27 <a class="jxr_linenumber" name="L19" href="#L19">19</a> <strong class="jxr_keyword">import</strong> com.pyx4j.log4j.MavenLogAppender;
28 <a class="jxr_linenumber" name="L20" href="#L20">20</a> <strong class="jxr_keyword">import</strong> java.io.File;
29 <a class="jxr_linenumber" name="L21" href="#L21">21</a> <strong class="jxr_keyword">import</strong> java.io.FileInputStream;
30 <a class="jxr_linenumber" name="L22" href="#L22">22</a> <strong class="jxr_keyword">import</strong> java.io.FileNotFoundException;
31 <a class="jxr_linenumber" name="L23" href="#L23">23</a> <strong class="jxr_keyword">import</strong> java.io.FileOutputStream;
32 <a class="jxr_linenumber" name="L24" href="#L24">24</a> <strong class="jxr_keyword">import</strong> java.io.IOException;
33 <a class="jxr_linenumber" name="L25" href="#L25">25</a> <strong class="jxr_keyword">import</strong> java.io.InputStream;
34 <a class="jxr_linenumber" name="L26" href="#L26">26</a> <strong class="jxr_keyword">import</strong> java.io.ObjectInputStream;
35 <a class="jxr_linenumber" name="L27" href="#L27">27</a> <strong class="jxr_keyword">import</strong> java.io.ObjectOutputStream;
36 <a class="jxr_linenumber" name="L28" href="#L28">28</a> <strong class="jxr_keyword">import</strong> java.math.BigInteger;
37 <a class="jxr_linenumber" name="L29" href="#L29">29</a> <strong class="jxr_keyword">import</strong> java.net.URL;
38 <a class="jxr_linenumber" name="L30" href="#L30">30</a> <strong class="jxr_keyword">import</strong> java.net.URLClassLoader;
39 <a class="jxr_linenumber" name="L31" href="#L31">31</a> <strong class="jxr_keyword">import</strong> java.security.MessageDigest;
40 <a class="jxr_linenumber" name="L32" href="#L32">32</a> <strong class="jxr_keyword">import</strong> java.security.NoSuchAlgorithmException;
41 <a class="jxr_linenumber" name="L33" href="#L33">33</a> <strong class="jxr_keyword">import</strong> java.sql.Driver;
42 <a class="jxr_linenumber" name="L34" href="#L34">34</a> <strong class="jxr_keyword">import</strong> java.sql.DriverPropertyInfo;
43 <a class="jxr_linenumber" name="L35" href="#L35">35</a> <strong class="jxr_keyword">import</strong> java.sql.SQLException;
44 <a class="jxr_linenumber" name="L36" href="#L36">36</a> <strong class="jxr_keyword">import</strong> java.sql.SQLFeatureNotSupportedException;
45 <a class="jxr_linenumber" name="L37" href="#L37">37</a> <strong class="jxr_keyword">import</strong> java.util.Collections;
46 <a class="jxr_linenumber" name="L38" href="#L38">38</a> <strong class="jxr_keyword">import</strong> java.util.Comparator;
47 <a class="jxr_linenumber" name="L39" href="#L39">39</a> <strong class="jxr_keyword">import</strong> java.util.HashMap;
48 <a class="jxr_linenumber" name="L40" href="#L40">40</a> <strong class="jxr_keyword">import</strong> java.util.HashSet;
49 <a class="jxr_linenumber" name="L41" href="#L41">41</a> <strong class="jxr_keyword">import</strong> java.util.LinkedHashSet;
50 <a class="jxr_linenumber" name="L42" href="#L42">42</a> <strong class="jxr_keyword">import</strong> java.util.LinkedList;
51 <a class="jxr_linenumber" name="L43" href="#L43">43</a> <strong class="jxr_keyword">import</strong> java.util.List;
52 <a class="jxr_linenumber" name="L44" href="#L44">44</a> <strong class="jxr_keyword">import</strong> java.util.Map;
53 <a class="jxr_linenumber" name="L45" href="#L45">45</a> <strong class="jxr_keyword">import</strong> java.util.Map.Entry;
54 <a class="jxr_linenumber" name="L46" href="#L46">46</a> <strong class="jxr_keyword">import</strong> java.util.Properties;
55 <a class="jxr_linenumber" name="L47" href="#L47">47</a> <strong class="jxr_keyword">import</strong> java.util.Set;
56 <a class="jxr_linenumber" name="L48" href="#L48">48</a> <strong class="jxr_keyword">import</strong> java.util.TreeSet;
57 <a class="jxr_linenumber" name="L49" href="#L49">49</a> <strong class="jxr_keyword">import</strong> java.util.logging.Logger;
58 <a class="jxr_linenumber" name="L50" href="#L50">50</a> <strong class="jxr_keyword">import</strong> java.util.regex.Matcher;
59 <a class="jxr_linenumber" name="L51" href="#L51">51</a> <strong class="jxr_keyword">import</strong> java.util.regex.Pattern;
60 <a class="jxr_linenumber" name="L52" href="#L52">52</a> <strong class="jxr_keyword">import</strong> javax.persistence.Embeddable;
61 <a class="jxr_linenumber" name="L53" href="#L53">53</a> <strong class="jxr_keyword">import</strong> javax.persistence.Entity;
62 <a class="jxr_linenumber" name="L54" href="#L54">54</a> <strong class="jxr_keyword">import</strong> javax.persistence.MappedSuperclass;
63 <a class="jxr_linenumber" name="L55" href="#L55">55</a> <strong class="jxr_keyword">import</strong> javax.persistence.spi.PersistenceUnitTransactionType;
64 <a class="jxr_linenumber" name="L56" href="#L56">56</a> <strong class="jxr_keyword">import</strong> org.apache.maven.artifact.Artifact;
65 <a class="jxr_linenumber" name="L57" href="#L57">57</a> <strong class="jxr_keyword">import</strong> org.apache.maven.model.Resource;
66 <a class="jxr_linenumber" name="L58" href="#L58">58</a> <strong class="jxr_keyword">import</strong> org.apache.maven.plugin.AbstractMojo;
67 <a class="jxr_linenumber" name="L59" href="#L59">59</a> <strong class="jxr_keyword">import</strong> org.apache.maven.plugin.MojoExecutionException;
68 <a class="jxr_linenumber" name="L60" href="#L60">60</a> <strong class="jxr_keyword">import</strong> org.apache.maven.plugin.MojoFailureException;
69 <a class="jxr_linenumber" name="L61" href="#L61">61</a> <strong class="jxr_keyword">import</strong> org.apache.maven.project.MavenProject;
70 <a class="jxr_linenumber" name="L62" href="#L62">62</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.StandardServiceRegistryBuilder;
71 <a class="jxr_linenumber" name="L63" href="#L63">63</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
72 <a class="jxr_linenumber" name="L64" href="#L64">64</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
73 <a class="jxr_linenumber" name="L65" href="#L65">65</a> <strong class="jxr_keyword">import</strong> org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
74 <a class="jxr_linenumber" name="L66" href="#L66">66</a> <strong class="jxr_keyword">import</strong> org.hibernate.cfg.Environment;
75 <a class="jxr_linenumber" name="L67" href="#L67">67</a> <strong class="jxr_keyword">import</strong> org.hibernate.cfg.NamingStrategy;
76 <a class="jxr_linenumber" name="L68" href="#L68">68</a> <strong class="jxr_keyword">import</strong> org.hibernate.envers.configuration.spi.AuditConfiguration;
77 <a class="jxr_linenumber" name="L69" href="#L69">69</a> <strong class="jxr_keyword">import</strong> org.hibernate.internal.util.config.ConfigurationHelper;
78 <a class="jxr_linenumber" name="L70" href="#L70">70</a> <strong class="jxr_keyword">import</strong> org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
79 <a class="jxr_linenumber" name="L71" href="#L71">71</a> <strong class="jxr_keyword">import</strong> org.hibernate.jpa.boot.internal.PersistenceXmlParser;
80 <a class="jxr_linenumber" name="L72" href="#L72">72</a> <strong class="jxr_keyword">import</strong> org.hibernate.jpa.boot.spi.ProviderChecker;
81 <a class="jxr_linenumber" name="L73" href="#L73">73</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.hbm2ddl.SchemaExport;
82 <a class="jxr_linenumber" name="L74" href="#L74">74</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.hbm2ddl.SchemaExport.Type;
83 <a class="jxr_linenumber" name="L75" href="#L75">75</a> <strong class="jxr_keyword">import</strong> org.hibernate.tool.hbm2ddl.Target;
84 <a class="jxr_linenumber" name="L76" href="#L76">76</a> <strong class="jxr_keyword">import</strong> org.scannotation.AnnotationDB;
85 <a class="jxr_linenumber" name="L77" href="#L77">77</a>
86 <a class="jxr_linenumber" name="L78" href="#L78">78</a>
87 <a class="jxr_linenumber" name="L79" href="#L79">79</a> <em class="jxr_javadoccomment">/**</em>
88 <a class="jxr_linenumber" name="L80" href="#L80">80</a> <em class="jxr_javadoccomment"> * Goal which extracts the hibernate-mapping-configuration and</em>
89 <a class="jxr_linenumber" name="L81" href="#L81">81</a> <em class="jxr_javadoccomment"> * exports an according SQL-database-schema.</em>
90 <a class="jxr_linenumber" name="L82" href="#L82">82</a> <em class="jxr_javadoccomment"> *</em>
91 <a class="jxr_linenumber" name="L83" href="#L83">83</a> <em class="jxr_javadoccomment"> * @goal export</em>
92 <a class="jxr_linenumber" name="L84" href="#L84">84</a> <em class="jxr_javadoccomment"> * @phase process-classes</em>
93 <a class="jxr_linenumber" name="L85" href="#L85">85</a> <em class="jxr_javadoccomment"> * @threadSafe</em>
94 <a class="jxr_linenumber" name="L86" href="#L86">86</a> <em class="jxr_javadoccomment"> * @requiresDependencyResolution runtime</em>
95 <a class="jxr_linenumber" name="L87" href="#L87">87</a> <em class="jxr_javadoccomment"> */</em>
96 <a class="jxr_linenumber" name="L88" href="#L88">88</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../de/juplo/plugins/hibernate4/Hbm2DdlMojo.html">Hbm2DdlMojo</a> <strong class="jxr_keyword">extends</strong> AbstractMojo
97 <a class="jxr_linenumber" name="L89" href="#L89">89</a> {
98 <a class="jxr_linenumber" name="L90" href="#L90">90</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String EXPORT_SKIPPED_PROPERTY = <span class="jxr_string">"hibernate.export.skipped"</span>;
99 <a class="jxr_linenumber" name="L91" href="#L91">91</a>
100 <a class="jxr_linenumber" name="L92" href="#L92">92</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String DRIVER_CLASS = <span class="jxr_string">"hibernate.connection.driver_class"</span>;
101 <a class="jxr_linenumber" name="L93" href="#L93">93</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String URL = <span class="jxr_string">"hibernate.connection.url"</span>;
102 <a class="jxr_linenumber" name="L94" href="#L94">94</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String USERNAME = <span class="jxr_string">"hibernate.connection.username"</span>;
103 <a class="jxr_linenumber" name="L95" href="#L95">95</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String PASSWORD = <span class="jxr_string">"hibernate.connection.password"</span>;
104 <a class="jxr_linenumber" name="L96" href="#L96">96</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String DIALECT = <span class="jxr_string">"hibernate.dialect"</span>;
105 <a class="jxr_linenumber" name="L97" href="#L97">97</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String NAMING_STRATEGY=<span class="jxr_string">"hibernate.ejb.naming_strategy"</span>;
106 <a class="jxr_linenumber" name="L98" href="#L98">98</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String ENVERS = <span class="jxr_string">"hibernate.export.envers"</span>;
107 <a class="jxr_linenumber" name="L99" href="#L99">99</a>
108 <a class="jxr_linenumber" name="L100" href="#L100">100</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String JPA_DRIVER = <span class="jxr_string">"javax.persistence.jdbc.driver"</span>;
109 <a class="jxr_linenumber" name="L101" href="#L101">101</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String JPA_URL = <span class="jxr_string">"javax.persistence.jdbc.url"</span>;
110 <a class="jxr_linenumber" name="L102" href="#L102">102</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String JPA_USERNAME = <span class="jxr_string">"javax.persistence.jdbc.user"</span>;
111 <a class="jxr_linenumber" name="L103" href="#L103">103</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String JPA_PASSWORD = <span class="jxr_string">"javax.persistence.jdbc.password"</span>;
112 <a class="jxr_linenumber" name="L104" href="#L104">104</a>
113 <a class="jxr_linenumber" name="L105" href="#L105">105</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> String MD5S = <span class="jxr_string">"hibernate4-generatedschema.md5s"</span>;
114 <a class="jxr_linenumber" name="L106" href="#L106">106</a>
115 <a class="jxr_linenumber" name="L107" href="#L107">107</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">static</strong> Pattern split = Pattern.compile(<span class="jxr_string">"[^,\\s]+"</span>);
116 <a class="jxr_linenumber" name="L108" href="#L108">108</a>
117 <a class="jxr_linenumber" name="L109" href="#L109">109</a>
118 <a class="jxr_linenumber" name="L110" href="#L110">110</a> <em class="jxr_javadoccomment">/**</em>
119 <a class="jxr_linenumber" name="L111" href="#L111">111</a> <em class="jxr_javadoccomment"> * The maven project.</em>
120 <a class="jxr_linenumber" name="L112" href="#L112">112</a> <em class="jxr_javadoccomment"> * <p></em>
121 <a class="jxr_linenumber" name="L113" href="#L113">113</a> <em class="jxr_javadoccomment"> * Only needed internally.</em>
122 <a class="jxr_linenumber" name="L114" href="#L114">114</a> <em class="jxr_javadoccomment"> *</em>
123 <a class="jxr_linenumber" name="L115" href="#L115">115</a> <em class="jxr_javadoccomment"> * @parameter property="project"</em>
124 <a class="jxr_linenumber" name="L116" href="#L116">116</a> <em class="jxr_javadoccomment"> * @required</em>
125 <a class="jxr_linenumber" name="L117" href="#L117">117</a> <em class="jxr_javadoccomment"> * @readonly</em>
126 <a class="jxr_linenumber" name="L118" href="#L118">118</a> <em class="jxr_javadoccomment"> */</em>
127 <a class="jxr_linenumber" name="L119" href="#L119">119</a> <strong class="jxr_keyword">private</strong> MavenProject project;
128 <a class="jxr_linenumber" name="L120" href="#L120">120</a>
129 <a class="jxr_linenumber" name="L121" href="#L121">121</a> <em class="jxr_javadoccomment">/**</em>
130 <a class="jxr_linenumber" name="L122" href="#L122">122</a> <em class="jxr_javadoccomment"> * Build-directory.</em>
131 <a class="jxr_linenumber" name="L123" href="#L123">123</a> <em class="jxr_javadoccomment"> * <p></em>
132 <a class="jxr_linenumber" name="L124" href="#L124">124</a> <em class="jxr_javadoccomment"> * Only needed internally.</em>
133 <a class="jxr_linenumber" name="L125" href="#L125">125</a> <em class="jxr_javadoccomment"> *</em>
134 <a class="jxr_linenumber" name="L126" href="#L126">126</a> <em class="jxr_javadoccomment"> * @parameter property="project.build.directory"</em>
135 <a class="jxr_linenumber" name="L127" href="#L127">127</a> <em class="jxr_javadoccomment"> * @required</em>
136 <a class="jxr_linenumber" name="L128" href="#L128">128</a> <em class="jxr_javadoccomment"> * @readonly</em>
137 <a class="jxr_linenumber" name="L129" href="#L129">129</a> <em class="jxr_javadoccomment"> */</em>
138 <a class="jxr_linenumber" name="L130" href="#L130">130</a> <strong class="jxr_keyword">private</strong> String buildDirectory;
139 <a class="jxr_linenumber" name="L131" href="#L131">131</a>
140 <a class="jxr_linenumber" name="L132" href="#L132">132</a> <em class="jxr_javadoccomment">/**</em>
141 <a class="jxr_linenumber" name="L133" href="#L133">133</a> <em class="jxr_javadoccomment"> * Classes-Directory to scan.</em>
142 <a class="jxr_linenumber" name="L134" href="#L134">134</a> <em class="jxr_javadoccomment"> * <p></em>
143 <a class="jxr_linenumber" name="L135" href="#L135">135</a> <em class="jxr_javadoccomment"> * This parameter defaults to the maven build-output-directory for classes.</em>
144 <a class="jxr_linenumber" name="L136" href="#L136">136</a> <em class="jxr_javadoccomment"> * Additionally, all dependencies are scanned for annotated classes.</em>
145 <a class="jxr_linenumber" name="L137" href="#L137">137</a> <em class="jxr_javadoccomment"> *</em>
146 <a class="jxr_linenumber" name="L138" href="#L138">138</a> <em class="jxr_javadoccomment"> * @parameter property="project.build.outputDirectory"</em>
147 <a class="jxr_linenumber" name="L139" href="#L139">139</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
148 <a class="jxr_linenumber" name="L140" href="#L140">140</a> <em class="jxr_javadoccomment"> */</em>
149 <a class="jxr_linenumber" name="L141" href="#L141">141</a> <strong class="jxr_keyword">private</strong> String outputDirectory;
150 <a class="jxr_linenumber" name="L142" href="#L142">142</a>
151 <a class="jxr_linenumber" name="L143" href="#L143">143</a> <em class="jxr_javadoccomment">/**</em>
152 <a class="jxr_linenumber" name="L144" href="#L144">144</a> <em class="jxr_javadoccomment"> * Whether to scan test-classes too, or not.</em>
153 <a class="jxr_linenumber" name="L145" href="#L145">145</a> <em class="jxr_javadoccomment"> * <p></em>
154 <a class="jxr_linenumber" name="L146" href="#L146">146</a> <em class="jxr_javadoccomment"> * If this parameter is set to <code>true</code> the test-classes of the</em>
155 <a class="jxr_linenumber" name="L147" href="#L147">147</a> <em class="jxr_javadoccomment"> * artifact will be scanned for hibernate-annotated classes additionally.</em>
156 <a class="jxr_linenumber" name="L148" href="#L148">148</a> <em class="jxr_javadoccomment"> *</em>
157 <a class="jxr_linenumber" name="L149" href="#L149">149</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.export.scan_testclasses" default-value="false"</em>
158 <a class="jxr_linenumber" name="L150" href="#L150">150</a> <em class="jxr_javadoccomment"> * @since 1.0.1</em>
159 <a class="jxr_linenumber" name="L151" href="#L151">151</a> <em class="jxr_javadoccomment"> */</em>
160 <a class="jxr_linenumber" name="L152" href="#L152">152</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> scanTestClasses;
161 <a class="jxr_linenumber" name="L153" href="#L153">153</a>
162 <a class="jxr_linenumber" name="L154" href="#L154">154</a> <em class="jxr_javadoccomment">/**</em>
163 <a class="jxr_linenumber" name="L155" href="#L155">155</a> <em class="jxr_javadoccomment"> * Dependency-Scopes, that should be scanned for annotated classes.</em>
164 <a class="jxr_linenumber" name="L156" href="#L156">156</a> <em class="jxr_javadoccomment"> * <p></em>
165 <a class="jxr_linenumber" name="L157" href="#L157">157</a> <em class="jxr_javadoccomment"> * By default, only dependencies in the scope <code>compile</code> are</em>
166 <a class="jxr_linenumber" name="L158" href="#L158">158</a> <em class="jxr_javadoccomment"> * scanned for annotated classes. Multiple scopes can be seperated by</em>
167 <a class="jxr_linenumber" name="L159" href="#L159">159</a> <em class="jxr_javadoccomment"> * white space or commas.</em>
168 <a class="jxr_linenumber" name="L160" href="#L160">160</a> <em class="jxr_javadoccomment"> * <p></em>
169 <a class="jxr_linenumber" name="L161" href="#L161">161</a> <em class="jxr_javadoccomment"> * If you do not want any dependencies to be scanned for annotated</em>
170 <a class="jxr_linenumber" name="L162" href="#L162">162</a> <em class="jxr_javadoccomment"> * classes, set this parameter to <code>none</code>.</em>
171 <a class="jxr_linenumber" name="L163" href="#L163">163</a> <em class="jxr_javadoccomment"> * <p></em>
172 <a class="jxr_linenumber" name="L164" href="#L164">164</a> <em class="jxr_javadoccomment"> * The plugin does not scan for annotated classes in transitive</em>
173 <a class="jxr_linenumber" name="L165" href="#L165">165</a> <em class="jxr_javadoccomment"> * dependencies. If some of your annotated classes are hidden in a</em>
174 <a class="jxr_linenumber" name="L166" href="#L166">166</a> <em class="jxr_javadoccomment"> * transitive dependency, you can simply add that dependency explicitly.</em>
175 <a class="jxr_linenumber" name="L167" href="#L167">167</a> <em class="jxr_javadoccomment"> *</em>
176 <a class="jxr_linenumber" name="L168" href="#L168">168</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.export.scan_dependencies" default-value="compile"</em>
177 <a class="jxr_linenumber" name="L169" href="#L169">169</a> <em class="jxr_javadoccomment"> * @since 1.0.3</em>
178 <a class="jxr_linenumber" name="L170" href="#L170">170</a> <em class="jxr_javadoccomment"> */</em>
179 <a class="jxr_linenumber" name="L171" href="#L171">171</a> <strong class="jxr_keyword">private</strong> String scanDependencies;
180 <a class="jxr_linenumber" name="L172" href="#L172">172</a>
181 <a class="jxr_linenumber" name="L173" href="#L173">173</a> <em class="jxr_javadoccomment">/**</em>
182 <a class="jxr_linenumber" name="L174" href="#L174">174</a> <em class="jxr_javadoccomment"> * Test-Classes-Directory to scan.</em>
183 <a class="jxr_linenumber" name="L175" href="#L175">175</a> <em class="jxr_javadoccomment"> * <p></em>
184 <a class="jxr_linenumber" name="L176" href="#L176">176</a> <em class="jxr_javadoccomment"> * This parameter defaults to the maven build-output-directory for</em>
185 <a class="jxr_linenumber" name="L177" href="#L177">177</a> <em class="jxr_javadoccomment"> * test-classes.</em>
186 <a class="jxr_linenumber" name="L178" href="#L178">178</a> <em class="jxr_javadoccomment"> * <p></em>
187 <a class="jxr_linenumber" name="L179" href="#L179">179</a> <em class="jxr_javadoccomment"> * This parameter is only used, when <code>scanTestClasses</code> is set</em>
188 <a class="jxr_linenumber" name="L180" href="#L180">180</a> <em class="jxr_javadoccomment"> * to <code>true</code>!</em>
189 <a class="jxr_linenumber" name="L181" href="#L181">181</a> <em class="jxr_javadoccomment"> *</em>
190 <a class="jxr_linenumber" name="L182" href="#L182">182</a> <em class="jxr_javadoccomment"> * @parameter property="project.build.testOutputDirectory"</em>
191 <a class="jxr_linenumber" name="L183" href="#L183">183</a> <em class="jxr_javadoccomment"> * @since 1.0.2</em>
192 <a class="jxr_linenumber" name="L184" href="#L184">184</a> <em class="jxr_javadoccomment"> */</em>
193 <a class="jxr_linenumber" name="L185" href="#L185">185</a> <strong class="jxr_keyword">private</strong> String testOutputDirectory;
194 <a class="jxr_linenumber" name="L186" href="#L186">186</a>
195 <a class="jxr_linenumber" name="L187" href="#L187">187</a> <em class="jxr_javadoccomment">/**</em>
196 <a class="jxr_linenumber" name="L188" href="#L188">188</a> <em class="jxr_javadoccomment"> * Skip execution</em>
197 <a class="jxr_linenumber" name="L189" href="#L189">189</a> <em class="jxr_javadoccomment"> * <p></em>
198 <a class="jxr_linenumber" name="L190" href="#L190">190</a> <em class="jxr_javadoccomment"> * If set to <code>true</code>, the execution is skipped.</em>
199 <a class="jxr_linenumber" name="L191" href="#L191">191</a> <em class="jxr_javadoccomment"> * <p></em>
200 <a class="jxr_linenumber" name="L192" href="#L192">192</a> <em class="jxr_javadoccomment"> * A skipped execution is signaled via the maven-property</em>
201 <a class="jxr_linenumber" name="L193" href="#L193">193</a> <em class="jxr_javadoccomment"> * <code>${hibernate.export.skipped}</code>.</em>
202 <a class="jxr_linenumber" name="L194" href="#L194">194</a> <em class="jxr_javadoccomment"> * <p></em>
203 <a class="jxr_linenumber" name="L195" href="#L195">195</a> <em class="jxr_javadoccomment"> * The execution is skipped automatically, if no modified or newly added</em>
204 <a class="jxr_linenumber" name="L196" href="#L196">196</a> <em class="jxr_javadoccomment"> * annotated classes are found and the dialect was not changed.</em>
205 <a class="jxr_linenumber" name="L197" href="#L197">197</a> <em class="jxr_javadoccomment"> *</em>
206 <a class="jxr_linenumber" name="L198" href="#L198">198</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.skip" default-value="${maven.test.skip}"</em>
207 <a class="jxr_linenumber" name="L199" href="#L199">199</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
208 <a class="jxr_linenumber" name="L200" href="#L200">200</a> <em class="jxr_javadoccomment"> */</em>
209 <a class="jxr_linenumber" name="L201" href="#L201">201</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> skip;
210 <a class="jxr_linenumber" name="L202" href="#L202">202</a>
211 <a class="jxr_linenumber" name="L203" href="#L203">203</a> <em class="jxr_javadoccomment">/**</em>
212 <a class="jxr_linenumber" name="L204" href="#L204">204</a> <em class="jxr_javadoccomment"> * Force execution</em>
213 <a class="jxr_linenumber" name="L205" href="#L205">205</a> <em class="jxr_javadoccomment"> * <p></em>
214 <a class="jxr_linenumber" name="L206" href="#L206">206</a> <em class="jxr_javadoccomment"> * Force execution, even if no modified or newly added annotated classes</em>
215 <a class="jxr_linenumber" name="L207" href="#L207">207</a> <em class="jxr_javadoccomment"> * where found and the dialect was not changed.</em>
216 <a class="jxr_linenumber" name="L208" href="#L208">208</a> <em class="jxr_javadoccomment"> * <p></em>
217 <a class="jxr_linenumber" name="L209" href="#L209">209</a> <em class="jxr_javadoccomment"> * <code>skip</code> takes precedence over <code>force</code>.</em>
218 <a class="jxr_linenumber" name="L210" href="#L210">210</a> <em class="jxr_javadoccomment"> *</em>
219 <a class="jxr_linenumber" name="L211" href="#L211">211</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.export.force" default-value="false"</em>
220 <a class="jxr_linenumber" name="L212" href="#L212">212</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
221 <a class="jxr_linenumber" name="L213" href="#L213">213</a> <em class="jxr_javadoccomment"> */</em>
222 <a class="jxr_linenumber" name="L214" href="#L214">214</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> force;
223 <a class="jxr_linenumber" name="L215" href="#L215">215</a>
224 <a class="jxr_linenumber" name="L216" href="#L216">216</a> <em class="jxr_javadoccomment">/**</em>
225 <a class="jxr_linenumber" name="L217" href="#L217">217</a> <em class="jxr_javadoccomment"> * SQL-Driver name.</em>
226 <a class="jxr_linenumber" name="L218" href="#L218">218</a> <em class="jxr_javadoccomment"> *</em>
227 <a class="jxr_linenumber" name="L219" href="#L219">219</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.connection.driver_class"</em>
228 <a class="jxr_linenumber" name="L220" href="#L220">220</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
229 <a class="jxr_linenumber" name="L221" href="#L221">221</a> <em class="jxr_javadoccomment"> */</em>
230 <a class="jxr_linenumber" name="L222" href="#L222">222</a> <strong class="jxr_keyword">private</strong> String driverClassName;
231 <a class="jxr_linenumber" name="L223" href="#L223">223</a>
232 <a class="jxr_linenumber" name="L224" href="#L224">224</a> <em class="jxr_javadoccomment">/**</em>
233 <a class="jxr_linenumber" name="L225" href="#L225">225</a> <em class="jxr_javadoccomment"> * Database URL.</em>
234 <a class="jxr_linenumber" name="L226" href="#L226">226</a> <em class="jxr_javadoccomment"> *</em>
235 <a class="jxr_linenumber" name="L227" href="#L227">227</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.connection.url"</em>
236 <a class="jxr_linenumber" name="L228" href="#L228">228</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
237 <a class="jxr_linenumber" name="L229" href="#L229">229</a> <em class="jxr_javadoccomment"> */</em>
238 <a class="jxr_linenumber" name="L230" href="#L230">230</a> <strong class="jxr_keyword">private</strong> String url;
239 <a class="jxr_linenumber" name="L231" href="#L231">231</a>
240 <a class="jxr_linenumber" name="L232" href="#L232">232</a> <em class="jxr_javadoccomment">/**</em>
241 <a class="jxr_linenumber" name="L233" href="#L233">233</a> <em class="jxr_javadoccomment"> * Database username</em>
242 <a class="jxr_linenumber" name="L234" href="#L234">234</a> <em class="jxr_javadoccomment"> *</em>
243 <a class="jxr_linenumber" name="L235" href="#L235">235</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.connection.username"</em>
244 <a class="jxr_linenumber" name="L236" href="#L236">236</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
245 <a class="jxr_linenumber" name="L237" href="#L237">237</a> <em class="jxr_javadoccomment"> */</em>
246 <a class="jxr_linenumber" name="L238" href="#L238">238</a> <strong class="jxr_keyword">private</strong> String username;
247 <a class="jxr_linenumber" name="L239" href="#L239">239</a>
248 <a class="jxr_linenumber" name="L240" href="#L240">240</a> <em class="jxr_javadoccomment">/**</em>
249 <a class="jxr_linenumber" name="L241" href="#L241">241</a> <em class="jxr_javadoccomment"> * Database password</em>
250 <a class="jxr_linenumber" name="L242" href="#L242">242</a> <em class="jxr_javadoccomment"> *</em>
251 <a class="jxr_linenumber" name="L243" href="#L243">243</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.connection.password"</em>
252 <a class="jxr_linenumber" name="L244" href="#L244">244</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
253 <a class="jxr_linenumber" name="L245" href="#L245">245</a> <em class="jxr_javadoccomment"> */</em>
254 <a class="jxr_linenumber" name="L246" href="#L246">246</a> <strong class="jxr_keyword">private</strong> String password;
255 <a class="jxr_linenumber" name="L247" href="#L247">247</a>
256 <a class="jxr_linenumber" name="L248" href="#L248">248</a> <em class="jxr_javadoccomment">/**</em>
257 <a class="jxr_linenumber" name="L249" href="#L249">249</a> <em class="jxr_javadoccomment"> * Hibernate dialect.</em>
258 <a class="jxr_linenumber" name="L250" href="#L250">250</a> <em class="jxr_javadoccomment"> *</em>
259 <a class="jxr_linenumber" name="L251" href="#L251">251</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.dialect"</em>
260 <a class="jxr_linenumber" name="L252" href="#L252">252</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
261 <a class="jxr_linenumber" name="L253" href="#L253">253</a> <em class="jxr_javadoccomment"> */</em>
262 <a class="jxr_linenumber" name="L254" href="#L254">254</a> <strong class="jxr_keyword">private</strong> String hibernateDialect;
263 <a class="jxr_linenumber" name="L255" href="#L255">255</a>
264 <a class="jxr_linenumber" name="L256" href="#L256">256</a> <em class="jxr_javadoccomment">/**</em>
265 <a class="jxr_linenumber" name="L257" href="#L257">257</a> <em class="jxr_javadoccomment"> * Hibernate Naming Strategy</em>
266 <a class="jxr_linenumber" name="L258" href="#L258">258</a> <em class="jxr_javadoccomment"> *</em>
267 <a class="jxr_linenumber" name="L259" href="#L259">259</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.ejb.naming_strategy"</em>
268 <a class="jxr_linenumber" name="L260" href="#L260">260</a> <em class="jxr_javadoccomment"> * @since 1.0.2</em>
269 <a class="jxr_linenumber" name="L261" href="#L261">261</a> <em class="jxr_javadoccomment"> */</em>
270 <a class="jxr_linenumber" name="L262" href="#L262">262</a> <strong class="jxr_keyword">private</strong> String hibernateNamingStrategy;
271 <a class="jxr_linenumber" name="L263" href="#L263">263</a>
272 <a class="jxr_linenumber" name="L264" href="#L264">264</a> <em class="jxr_javadoccomment">/**</em>
273 <a class="jxr_linenumber" name="L265" href="#L265">265</a> <em class="jxr_javadoccomment"> * Path to Hibernate properties file.</em>
274 <a class="jxr_linenumber" name="L266" href="#L266">266</a> <em class="jxr_javadoccomment"> * If this parameter is not set the plugin will try to load the configuration</em>
275 <a class="jxr_linenumber" name="L267" href="#L267">267</a> <em class="jxr_javadoccomment"> * from a file <code>hibernate.properties</code> on the classpath. The</em>
276 <a class="jxr_linenumber" name="L268" href="#L268">268</a> <em class="jxr_javadoccomment"> * test-classpath takes precedence.</em>
277 <a class="jxr_linenumber" name="L269" href="#L269">269</a> <em class="jxr_javadoccomment"> *</em>
278 <a class="jxr_linenumber" name="L270" href="#L270">270</a> <em class="jxr_javadoccomment"> * @parameter</em>
279 <a class="jxr_linenumber" name="L271" href="#L271">271</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
280 <a class="jxr_linenumber" name="L272" href="#L272">272</a> <em class="jxr_javadoccomment"> */</em>
281 <a class="jxr_linenumber" name="L273" href="#L273">273</a> <strong class="jxr_keyword">private</strong> String hibernateProperties;
282 <a class="jxr_linenumber" name="L274" href="#L274">274</a>
283 <a class="jxr_linenumber" name="L275" href="#L275">275</a> <em class="jxr_javadoccomment">/**</em>
284 <a class="jxr_linenumber" name="L276" href="#L276">276</a> <em class="jxr_javadoccomment"> * Path to Hibernate configuration file (.cfg.xml).</em>
285 <a class="jxr_linenumber" name="L277" href="#L277">277</a> <em class="jxr_javadoccomment"> * Settings in this file will overwrite settings in the properties file.</em>
286 <a class="jxr_linenumber" name="L278" href="#L278">278</a> <em class="jxr_javadoccomment"> * If this parameter is not set the plugin will try to load the configuration</em>
287 <a class="jxr_linenumber" name="L279" href="#L279">279</a> <em class="jxr_javadoccomment"> * from a file <code>hibernate.cfg.xml</code> on the classpath. The</em>
288 <a class="jxr_linenumber" name="L280" href="#L280">280</a> <em class="jxr_javadoccomment"> * test-classpath takes precedence.</em>
289 <a class="jxr_linenumber" name="L281" href="#L281">281</a> <em class="jxr_javadoccomment"> *</em>
290 <a class="jxr_linenumber" name="L282" href="#L282">282</a> <em class="jxr_javadoccomment"> * @parameter</em>
291 <a class="jxr_linenumber" name="L283" href="#L283">283</a> <em class="jxr_javadoccomment"> * @since 1.1.0</em>
292 <a class="jxr_linenumber" name="L284" href="#L284">284</a> <em class="jxr_javadoccomment"> */</em>
293 <a class="jxr_linenumber" name="L285" href="#L285">285</a> <strong class="jxr_keyword">private</strong> String hibernateConfig;
294 <a class="jxr_linenumber" name="L286" href="#L286">286</a>
295 <a class="jxr_linenumber" name="L287" href="#L287">287</a> <em class="jxr_javadoccomment">/**</em>
296 <a class="jxr_linenumber" name="L288" href="#L288">288</a> <em class="jxr_javadoccomment"> * Name of the persistence-unit.</em>
297 <a class="jxr_linenumber" name="L289" href="#L289">289</a> <em class="jxr_javadoccomment"> * If there is only one persistence-unit available, that unit will be used</em>
298 <a class="jxr_linenumber" name="L290" href="#L290">290</a> <em class="jxr_javadoccomment"> * automatically.</em>
299 <a class="jxr_linenumber" name="L291" href="#L291">291</a> <em class="jxr_javadoccomment"> * Settings in this file will overwrite settings in the properties or the</em>
300 <a class="jxr_linenumber" name="L292" href="#L292">292</a> <em class="jxr_javadoccomment"> * configuration file.</em>
301 <a class="jxr_linenumber" name="L293" href="#L293">293</a> <em class="jxr_javadoccomment"> *</em>
302 <a class="jxr_linenumber" name="L294" href="#L294">294</a> <em class="jxr_javadoccomment"> * @parameter</em>
303 <a class="jxr_linenumber" name="L295" href="#L295">295</a> <em class="jxr_javadoccomment"> * @since 1.1.0</em>
304 <a class="jxr_linenumber" name="L296" href="#L296">296</a> <em class="jxr_javadoccomment"> */</em>
305 <a class="jxr_linenumber" name="L297" href="#L297">297</a> <strong class="jxr_keyword">private</strong> String persistenceUnit;
306 <a class="jxr_linenumber" name="L298" href="#L298">298</a>
307 <a class="jxr_linenumber" name="L299" href="#L299">299</a> <em class="jxr_javadoccomment">/**</em>
308 <a class="jxr_linenumber" name="L300" href="#L300">300</a> <em class="jxr_javadoccomment"> * List of Hibernate-Mapping-Files (XML).</em>
309 <a class="jxr_linenumber" name="L301" href="#L301">301</a> <em class="jxr_javadoccomment"> * Multiple files can be separated with white-spaces and/or commas.</em>
310 <a class="jxr_linenumber" name="L302" href="#L302">302</a> <em class="jxr_javadoccomment"> *</em>
311 <a class="jxr_linenumber" name="L303" href="#L303">303</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.mapping"</em>
312 <a class="jxr_linenumber" name="L304" href="#L304">304</a> <em class="jxr_javadoccomment"> * @since 1.0.2</em>
313 <a class="jxr_linenumber" name="L305" href="#L305">305</a> <em class="jxr_javadoccomment"> */</em>
314 <a class="jxr_linenumber" name="L306" href="#L306">306</a> <strong class="jxr_keyword">private</strong> String hibernateMapping;
315 <a class="jxr_linenumber" name="L307" href="#L307">307</a>
316 <a class="jxr_linenumber" name="L308" href="#L308">308</a> <em class="jxr_javadoccomment">/**</em>
317 <a class="jxr_linenumber" name="L309" href="#L309">309</a> <em class="jxr_javadoccomment"> * Target of execution:</em>
318 <a class="jxr_linenumber" name="L310" href="#L310">310</a> <em class="jxr_javadoccomment"> * <ul></em>
319 <a class="jxr_linenumber" name="L311" href="#L311">311</a> <em class="jxr_javadoccomment"> * <li><strong>NONE</strong> only export schema to SQL-script (forces execution, signals skip)</li></em>
320 <a class="jxr_linenumber" name="L312" href="#L312">312</a> <em class="jxr_javadoccomment"> * <li><strong>EXPORT</strong> create database (<strong>DEFAULT!</strong>). forces execution, signals skip)</li></em>
321 <a class="jxr_linenumber" name="L313" href="#L313">313</a> <em class="jxr_javadoccomment"> * <li><strong>SCRIPT</strong> export schema to SQL-script and print it to STDOUT</li></em>
322 <a class="jxr_linenumber" name="L314" href="#L314">314</a> <em class="jxr_javadoccomment"> * <li><strong>BOTH</strong></li></em>
323 <a class="jxr_linenumber" name="L315" href="#L315">315</a> <em class="jxr_javadoccomment"> * </ul></em>
324 <a class="jxr_linenumber" name="L316" href="#L316">316</a> <em class="jxr_javadoccomment"> *</em>
325 <a class="jxr_linenumber" name="L317" href="#L317">317</a> <em class="jxr_javadoccomment"> * A database connection is only needed for EXPORT and BOTH, but a</em>
326 <a class="jxr_linenumber" name="L318" href="#L318">318</a> <em class="jxr_javadoccomment"> * Hibernate-Dialect must always be chosen.</em>
327 <a class="jxr_linenumber" name="L319" href="#L319">319</a> <em class="jxr_javadoccomment"> *</em>
328 <a class="jxr_linenumber" name="L320" href="#L320">320</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.export.target" default-value="EXPORT"</em>
329 <a class="jxr_linenumber" name="L321" href="#L321">321</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
330 <a class="jxr_linenumber" name="L322" href="#L322">322</a> <em class="jxr_javadoccomment"> */</em>
331 <a class="jxr_linenumber" name="L323" href="#L323">323</a> <strong class="jxr_keyword">private</strong> String target;
332 <a class="jxr_linenumber" name="L324" href="#L324">324</a>
333 <a class="jxr_linenumber" name="L325" href="#L325">325</a> <em class="jxr_javadoccomment">/**</em>
334 <a class="jxr_linenumber" name="L326" href="#L326">326</a> <em class="jxr_javadoccomment"> * Type of execution.</em>
335 <a class="jxr_linenumber" name="L327" href="#L327">327</a> <em class="jxr_javadoccomment"> * <ul></em>
336 <a class="jxr_linenumber" name="L328" href="#L328">328</a> <em class="jxr_javadoccomment"> * <li><strong>NONE</strong> do nothing - just validate the configuration</li></em>
337 <a class="jxr_linenumber" name="L329" href="#L329">329</a> <em class="jxr_javadoccomment"> * <li><strong>CREATE</strong> create database-schema</li></em>
338 <a class="jxr_linenumber" name="L330" href="#L330">330</a> <em class="jxr_javadoccomment"> * <li><strong>DROP</strong> drop database-schema</li></em>
339 <a class="jxr_linenumber" name="L331" href="#L331">331</a> <em class="jxr_javadoccomment"> * <li><strong>BOTH</strong> (<strong>DEFAULT!</strong>)</li></em>
340 <a class="jxr_linenumber" name="L332" href="#L332">332</a> <em class="jxr_javadoccomment"> * </ul></em>
341 <a class="jxr_linenumber" name="L333" href="#L333">333</a> <em class="jxr_javadoccomment"> *</em>
342 <a class="jxr_linenumber" name="L334" href="#L334">334</a> <em class="jxr_javadoccomment"> * If NONE is choosen, no databaseconnection is needed.</em>
343 <a class="jxr_linenumber" name="L335" href="#L335">335</a> <em class="jxr_javadoccomment"> *</em>
344 <a class="jxr_linenumber" name="L336" href="#L336">336</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.export.type" default-value="BOTH"</em>
345 <a class="jxr_linenumber" name="L337" href="#L337">337</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
346 <a class="jxr_linenumber" name="L338" href="#L338">338</a> <em class="jxr_javadoccomment"> */</em>
347 <a class="jxr_linenumber" name="L339" href="#L339">339</a> <strong class="jxr_keyword">private</strong> String type;
348 <a class="jxr_linenumber" name="L340" href="#L340">340</a>
349 <a class="jxr_linenumber" name="L341" href="#L341">341</a> <em class="jxr_javadoccomment">/**</em>
350 <a class="jxr_linenumber" name="L342" href="#L342">342</a> <em class="jxr_javadoccomment"> * Output file.</em>
351 <a class="jxr_linenumber" name="L343" href="#L343">343</a> <em class="jxr_javadoccomment"> *</em>
352 <a class="jxr_linenumber" name="L344" href="#L344">344</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.export.schema.filename" default-value="${project.build.directory}/schema.sql"</em>
353 <a class="jxr_linenumber" name="L345" href="#L345">345</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
354 <a class="jxr_linenumber" name="L346" href="#L346">346</a> <em class="jxr_javadoccomment"> */</em>
355 <a class="jxr_linenumber" name="L347" href="#L347">347</a> <strong class="jxr_keyword">private</strong> String outputFile;
356 <a class="jxr_linenumber" name="L348" href="#L348">348</a>
357 <a class="jxr_linenumber" name="L349" href="#L349">349</a> <em class="jxr_javadoccomment">/**</em>
358 <a class="jxr_linenumber" name="L350" href="#L350">350</a> <em class="jxr_javadoccomment"> * Delimiter in output-file.</em>
359 <a class="jxr_linenumber" name="L351" href="#L351">351</a> <em class="jxr_javadoccomment"> *</em>
360 <a class="jxr_linenumber" name="L352" href="#L352">352</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.export.schema.delimiter" default-value=";"</em>
361 <a class="jxr_linenumber" name="L353" href="#L353">353</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
362 <a class="jxr_linenumber" name="L354" href="#L354">354</a> <em class="jxr_javadoccomment"> */</em>
363 <a class="jxr_linenumber" name="L355" href="#L355">355</a> <strong class="jxr_keyword">private</strong> String delimiter;
364 <a class="jxr_linenumber" name="L356" href="#L356">356</a>
365 <a class="jxr_linenumber" name="L357" href="#L357">357</a> <em class="jxr_javadoccomment">/**</em>
366 <a class="jxr_linenumber" name="L358" href="#L358">358</a> <em class="jxr_javadoccomment"> * Format output-file.</em>
367 <a class="jxr_linenumber" name="L359" href="#L359">359</a> <em class="jxr_javadoccomment"> *</em>
368 <a class="jxr_linenumber" name="L360" href="#L360">360</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.export.schema.format" default-value="true"</em>
369 <a class="jxr_linenumber" name="L361" href="#L361">361</a> <em class="jxr_javadoccomment"> * @since 1.0</em>
370 <a class="jxr_linenumber" name="L362" href="#L362">362</a> <em class="jxr_javadoccomment"> */</em>
371 <a class="jxr_linenumber" name="L363" href="#L363">363</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> format;
372 <a class="jxr_linenumber" name="L364" href="#L364">364</a>
373 <a class="jxr_linenumber" name="L365" href="#L365">365</a> <em class="jxr_javadoccomment">/**</em>
374 <a class="jxr_linenumber" name="L366" href="#L366">366</a> <em class="jxr_javadoccomment"> * Generate envers schema for auditing tables.</em>
375 <a class="jxr_linenumber" name="L367" href="#L367">367</a> <em class="jxr_javadoccomment"> *</em>
376 <a class="jxr_linenumber" name="L368" href="#L368">368</a> <em class="jxr_javadoccomment"> * @parameter property="hibernate.export.envers" default-value="true"</em>
377 <a class="jxr_linenumber" name="L369" href="#L369">369</a> <em class="jxr_javadoccomment"> * @since 1.0.3</em>
378 <a class="jxr_linenumber" name="L370" href="#L370">370</a> <em class="jxr_javadoccomment"> */</em>
379 <a class="jxr_linenumber" name="L371" href="#L371">371</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> envers;
380 <a class="jxr_linenumber" name="L372" href="#L372">372</a>
381 <a class="jxr_linenumber" name="L373" href="#L373">373</a>
382 <a class="jxr_linenumber" name="L374" href="#L374">374</a> @Override
383 <a class="jxr_linenumber" name="L375" href="#L375">375</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> execute()
384 <a class="jxr_linenumber" name="L376" href="#L376">376</a> <strong class="jxr_keyword">throws</strong>
385 <a class="jxr_linenumber" name="L377" href="#L377">377</a> MojoFailureException,
386 <a class="jxr_linenumber" name="L378" href="#L378">378</a> MojoExecutionException
387 <a class="jxr_linenumber" name="L379" href="#L379">379</a> {
388 <a class="jxr_linenumber" name="L380" href="#L380">380</a> <strong class="jxr_keyword">if</strong> (skip)
389 <a class="jxr_linenumber" name="L381" href="#L381">381</a> {
390 <a class="jxr_linenumber" name="L382" href="#L382">382</a> getLog().info(<span class="jxr_string">"Execution of hibernate4-maven-plugin:export was skipped!"</span>);
391 <a class="jxr_linenumber" name="L383" href="#L383">383</a> project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, <span class="jxr_string">"true"</span>);
392 <a class="jxr_linenumber" name="L384" href="#L384">384</a> <strong class="jxr_keyword">return</strong>;
393 <a class="jxr_linenumber" name="L385" href="#L385">385</a> }
394 <a class="jxr_linenumber" name="L386" href="#L386">386</a>
395 <a class="jxr_linenumber" name="L387" href="#L387">387</a> Map<String,String> md5s;
396 <a class="jxr_linenumber" name="L388" href="#L388">388</a> <strong class="jxr_keyword">boolean</strong> modified = false;
397 <a class="jxr_linenumber" name="L389" href="#L389">389</a> File saved = <strong class="jxr_keyword">new</strong> File(buildDirectory + File.separator + MD5S);
398 <a class="jxr_linenumber" name="L390" href="#L390">390</a>
399 <a class="jxr_linenumber" name="L391" href="#L391">391</a> <strong class="jxr_keyword">if</strong> (saved.isFile() && saved.length() > 0)
400 <a class="jxr_linenumber" name="L392" href="#L392">392</a> {
401 <a class="jxr_linenumber" name="L393" href="#L393">393</a> <strong class="jxr_keyword">try</strong>
402 <a class="jxr_linenumber" name="L394" href="#L394">394</a> {
403 <a class="jxr_linenumber" name="L395" href="#L395">395</a> FileInputStream fis = <strong class="jxr_keyword">new</strong> FileInputStream(saved);
404 <a class="jxr_linenumber" name="L396" href="#L396">396</a> ObjectInputStream ois = <strong class="jxr_keyword">new</strong> ObjectInputStream(fis);
405 <a class="jxr_linenumber" name="L397" href="#L397">397</a> md5s = (HashMap<String,String>)ois.readObject();
406 <a class="jxr_linenumber" name="L398" href="#L398">398</a> ois.close();
407 <a class="jxr_linenumber" name="L399" href="#L399">399</a> }
408 <a class="jxr_linenumber" name="L400" href="#L400">400</a> <strong class="jxr_keyword">catch</strong> (Exception e)
409 <a class="jxr_linenumber" name="L401" href="#L401">401</a> {
410 <a class="jxr_linenumber" name="L402" href="#L402">402</a> md5s = <strong class="jxr_keyword">new</strong> HashMap<String,String>();
411 <a class="jxr_linenumber" name="L403" href="#L403">403</a> getLog().warn(<span class="jxr_string">"Cannot read timestamps from saved: "</span> + e);
412 <a class="jxr_linenumber" name="L404" href="#L404">404</a> }
413 <a class="jxr_linenumber" name="L405" href="#L405">405</a> }
414 <a class="jxr_linenumber" name="L406" href="#L406">406</a> <strong class="jxr_keyword">else</strong>
415 <a class="jxr_linenumber" name="L407" href="#L407">407</a> {
416 <a class="jxr_linenumber" name="L408" href="#L408">408</a> md5s = <strong class="jxr_keyword">new</strong> HashMap<String,String>();
417 <a class="jxr_linenumber" name="L409" href="#L409">409</a> <strong class="jxr_keyword">try</strong>
418 <a class="jxr_linenumber" name="L410" href="#L410">410</a> {
419 <a class="jxr_linenumber" name="L411" href="#L411">411</a> saved.createNewFile();
420 <a class="jxr_linenumber" name="L412" href="#L412">412</a> }
421 <a class="jxr_linenumber" name="L413" href="#L413">413</a> <strong class="jxr_keyword">catch</strong> (IOException e)
422 <a class="jxr_linenumber" name="L414" href="#L414">414</a> {
423 <a class="jxr_linenumber" name="L415" href="#L415">415</a> getLog().debug(<span class="jxr_string">"Cannot create file \""</span> + saved.getPath() + <span class="jxr_string">"\" for timestamps: "</span> + e);
424 <a class="jxr_linenumber" name="L416" href="#L416">416</a> }
425 <a class="jxr_linenumber" name="L417" href="#L417">417</a> }
426 <a class="jxr_linenumber" name="L418" href="#L418">418</a>
427 <a class="jxr_linenumber" name="L419" href="#L419">419</a> URLClassLoader classLoader = <strong class="jxr_keyword">null</strong>;
428 <a class="jxr_linenumber" name="L420" href="#L420">420</a> <strong class="jxr_keyword">try</strong>
429 <a class="jxr_linenumber" name="L421" href="#L421">421</a> {
430 <a class="jxr_linenumber" name="L422" href="#L422">422</a> getLog().debug(<span class="jxr_string">"Creating ClassLoader for project-dependencies..."</span>);
431 <a class="jxr_linenumber" name="L423" href="#L423">423</a> List<String> classpathFiles = project.getCompileClasspathElements();
432 <a class="jxr_linenumber" name="L424" href="#L424">424</a> <strong class="jxr_keyword">if</strong> (scanTestClasses)
433 <a class="jxr_linenumber" name="L425" href="#L425">425</a> classpathFiles.addAll(project.getTestClasspathElements());
434 <a class="jxr_linenumber" name="L426" href="#L426">426</a> List<URL> urls = <strong class="jxr_keyword">new</strong> LinkedList<URL>();
435 <a class="jxr_linenumber" name="L427" href="#L427">427</a> File file;
436 <a class="jxr_linenumber" name="L428" href="#L428">428</a> file = <strong class="jxr_keyword">new</strong> File(testOutputDirectory);
437 <a class="jxr_linenumber" name="L429" href="#L429">429</a> <strong class="jxr_keyword">if</strong> (!file.exists())
438 <a class="jxr_linenumber" name="L430" href="#L430">430</a> {
439 <a class="jxr_linenumber" name="L431" href="#L431">431</a> getLog().info(<span class="jxr_string">"creating test-output-directory: "</span> + testOutputDirectory);
440 <a class="jxr_linenumber" name="L432" href="#L432">432</a> file.mkdirs();
441 <a class="jxr_linenumber" name="L433" href="#L433">433</a> }
442 <a class="jxr_linenumber" name="L434" href="#L434">434</a> urls.add(file.toURI().toURL());
443 <a class="jxr_linenumber" name="L435" href="#L435">435</a> file = <strong class="jxr_keyword">new</strong> File(outputDirectory);
444 <a class="jxr_linenumber" name="L436" href="#L436">436</a> <strong class="jxr_keyword">if</strong> (!file.exists())
445 <a class="jxr_linenumber" name="L437" href="#L437">437</a> {
446 <a class="jxr_linenumber" name="L438" href="#L438">438</a> getLog().info(<span class="jxr_string">"creating output-directory: "</span> + outputDirectory);
447 <a class="jxr_linenumber" name="L439" href="#L439">439</a> file.mkdirs();
448 <a class="jxr_linenumber" name="L440" href="#L440">440</a> }
449 <a class="jxr_linenumber" name="L441" href="#L441">441</a> urls.add(file.toURI().toURL());
450 <a class="jxr_linenumber" name="L442" href="#L442">442</a> <strong class="jxr_keyword">for</strong> (String pathElement : classpathFiles)
451 <a class="jxr_linenumber" name="L443" href="#L443">443</a> {
452 <a class="jxr_linenumber" name="L444" href="#L444">444</a> getLog().debug(<span class="jxr_string">"Dependency: "</span> + pathElement);
453 <a class="jxr_linenumber" name="L445" href="#L445">445</a> urls.add(<strong class="jxr_keyword">new</strong> File(pathElement).toURI().toURL());
454 <a class="jxr_linenumber" name="L446" href="#L446">446</a> }
455 <a class="jxr_linenumber" name="L447" href="#L447">447</a> classLoader =
456 <a class="jxr_linenumber" name="L448" href="#L448">448</a> <strong class="jxr_keyword">new</strong> URLClassLoader(
457 <a class="jxr_linenumber" name="L449" href="#L449">449</a> urls.toArray(<strong class="jxr_keyword">new</strong> URL[urls.size()]),
458 <a class="jxr_linenumber" name="L450" href="#L450">450</a> getClass().getClassLoader()
459 <a class="jxr_linenumber" name="L451" href="#L451">451</a> );
460 <a class="jxr_linenumber" name="L452" href="#L452">452</a> }
461 <a class="jxr_linenumber" name="L453" href="#L453">453</a> <strong class="jxr_keyword">catch</strong> (Exception e)
462 <a class="jxr_linenumber" name="L454" href="#L454">454</a> {
463 <a class="jxr_linenumber" name="L455" href="#L455">455</a> getLog().error(<span class="jxr_string">"Error while creating ClassLoader!"</span>, e);
464 <a class="jxr_linenumber" name="L456" href="#L456">456</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(e.getMessage());
465 <a class="jxr_linenumber" name="L457" href="#L457">457</a> }
466 <a class="jxr_linenumber" name="L458" href="#L458">458</a>
467 <a class="jxr_linenumber" name="L459" href="#L459">459</a> Set<Class<?>> classes =
468 <a class="jxr_linenumber" name="L460" href="#L460">460</a> <strong class="jxr_keyword">new</strong> TreeSet<Class<?>>(
469 <a class="jxr_linenumber" name="L461" href="#L461">461</a> <strong class="jxr_keyword">new</strong> Comparator<Class<?>>() {
470 <a class="jxr_linenumber" name="L462" href="#L462">462</a> @Override
471 <a class="jxr_linenumber" name="L463" href="#L463">463</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> compare(Class<?> a, Class<?> b)
472 <a class="jxr_linenumber" name="L464" href="#L464">464</a> {
473 <a class="jxr_linenumber" name="L465" href="#L465">465</a> <strong class="jxr_keyword">return</strong> a.getName().compareTo(b.getName());
474 <a class="jxr_linenumber" name="L466" href="#L466">466</a> }
475 <a class="jxr_linenumber" name="L467" href="#L467">467</a> }
476 <a class="jxr_linenumber" name="L468" href="#L468">468</a> );
477 <a class="jxr_linenumber" name="L469" href="#L469">469</a>
478 <a class="jxr_linenumber" name="L470" href="#L470">470</a> <strong class="jxr_keyword">try</strong>
479 <a class="jxr_linenumber" name="L471" href="#L471">471</a> {
480 <a class="jxr_linenumber" name="L472" href="#L472">472</a> AnnotationDB db = <strong class="jxr_keyword">new</strong> AnnotationDB();
481 <a class="jxr_linenumber" name="L473" href="#L473">473</a> File dir = <strong class="jxr_keyword">new</strong> File(outputDirectory);
482 <a class="jxr_linenumber" name="L474" href="#L474">474</a> <strong class="jxr_keyword">if</strong> (dir.exists())
483 <a class="jxr_linenumber" name="L475" href="#L475">475</a> {
484 <a class="jxr_linenumber" name="L476" href="#L476">476</a> getLog().info(<span class="jxr_string">"Scanning directory "</span> + outputDirectory + <span class="jxr_string">" for annotated classes..."</span>);
485 <a class="jxr_linenumber" name="L477" href="#L477">477</a> URL dirUrl = dir.toURI().toURL();
486 <a class="jxr_linenumber" name="L478" href="#L478">478</a> db.scanArchives(dirUrl);
487 <a class="jxr_linenumber" name="L479" href="#L479">479</a> }
488 <a class="jxr_linenumber" name="L480" href="#L480">480</a> <strong class="jxr_keyword">if</strong> (scanTestClasses)
489 <a class="jxr_linenumber" name="L481" href="#L481">481</a> {
490 <a class="jxr_linenumber" name="L482" href="#L482">482</a> dir = <strong class="jxr_keyword">new</strong> File(testOutputDirectory);
491 <a class="jxr_linenumber" name="L483" href="#L483">483</a> <strong class="jxr_keyword">if</strong> (dir.exists())
492 <a class="jxr_linenumber" name="L484" href="#L484">484</a> {
493 <a class="jxr_linenumber" name="L485" href="#L485">485</a> getLog().info(<span class="jxr_string">"Scanning directory "</span> + testOutputDirectory + <span class="jxr_string">" for annotated classes..."</span>);
494 <a class="jxr_linenumber" name="L486" href="#L486">486</a> URL dirUrl = dir.toURI().toURL();
495 <a class="jxr_linenumber" name="L487" href="#L487">487</a> db.scanArchives(dirUrl);
496 <a class="jxr_linenumber" name="L488" href="#L488">488</a> }
497 <a class="jxr_linenumber" name="L489" href="#L489">489</a> }
498 <a class="jxr_linenumber" name="L490" href="#L490">490</a> <strong class="jxr_keyword">if</strong> (scanDependencies != <strong class="jxr_keyword">null</strong>)
499 <a class="jxr_linenumber" name="L491" href="#L491">491</a> {
500 <a class="jxr_linenumber" name="L492" href="#L492">492</a> Matcher matcher = split.matcher(scanDependencies);
501 <a class="jxr_linenumber" name="L493" href="#L493">493</a> <strong class="jxr_keyword">while</strong> (matcher.find())
502 <a class="jxr_linenumber" name="L494" href="#L494">494</a> {
503 <a class="jxr_linenumber" name="L495" href="#L495">495</a> getLog().info(<span class="jxr_string">"Scanning dependencies for scope "</span> + matcher.group());
504 <a class="jxr_linenumber" name="L496" href="#L496">496</a> <strong class="jxr_keyword">for</strong> (Artifact artifact : project.getDependencyArtifacts())
505 <a class="jxr_linenumber" name="L497" href="#L497">497</a> {
506 <a class="jxr_linenumber" name="L498" href="#L498">498</a> <strong class="jxr_keyword">if</strong> (!artifact.getScope().equalsIgnoreCase(matcher.group()))
507 <a class="jxr_linenumber" name="L499" href="#L499">499</a> <strong class="jxr_keyword">continue</strong>;
508 <a class="jxr_linenumber" name="L500" href="#L500">500</a> <strong class="jxr_keyword">if</strong> (artifact.getFile() == <strong class="jxr_keyword">null</strong>)
509 <a class="jxr_linenumber" name="L501" href="#L501">501</a> {
510 <a class="jxr_linenumber" name="L502" href="#L502">502</a> getLog().warn(
511 <a class="jxr_linenumber" name="L503" href="#L503">503</a> <span class="jxr_string">"Cannot scan dependency "</span> +
512 <a class="jxr_linenumber" name="L504" href="#L504">504</a> artifact.getId() +
513 <a class="jxr_linenumber" name="L505" href="#L505">505</a> <span class="jxr_string">": no JAR-file available!"</span>
514 <a class="jxr_linenumber" name="L506" href="#L506">506</a> );
515 <a class="jxr_linenumber" name="L507" href="#L507">507</a> <strong class="jxr_keyword">continue</strong>;
516 <a class="jxr_linenumber" name="L508" href="#L508">508</a> }
517 <a class="jxr_linenumber" name="L509" href="#L509">509</a> getLog().info(
518 <a class="jxr_linenumber" name="L510" href="#L510">510</a> <span class="jxr_string">"Scanning dependency "</span> +
519 <a class="jxr_linenumber" name="L511" href="#L511">511</a> artifact.getId() +
520 <a class="jxr_linenumber" name="L512" href="#L512">512</a> <span class="jxr_string">" for annotated classes..."</span>
521 <a class="jxr_linenumber" name="L513" href="#L513">513</a> );
522 <a class="jxr_linenumber" name="L514" href="#L514">514</a> db.scanArchives(artifact.getFile().toURI().toURL());
523 <a class="jxr_linenumber" name="L515" href="#L515">515</a> }
524 <a class="jxr_linenumber" name="L516" href="#L516">516</a> }
525 <a class="jxr_linenumber" name="L517" href="#L517">517</a> }
526 <a class="jxr_linenumber" name="L518" href="#L518">518</a>
527 <a class="jxr_linenumber" name="L519" href="#L519">519</a> Set<String> classNames = <strong class="jxr_keyword">new</strong> HashSet<String>();
528 <a class="jxr_linenumber" name="L520" href="#L520">520</a> <strong class="jxr_keyword">if</strong> (db.getAnnotationIndex().containsKey(Entity.<strong class="jxr_keyword">class</strong>.getName()))
529 <a class="jxr_linenumber" name="L521" href="#L521">521</a> classNames.addAll(db.getAnnotationIndex().get(Entity.<strong class="jxr_keyword">class</strong>.getName()));
530 <a class="jxr_linenumber" name="L522" href="#L522">522</a> <strong class="jxr_keyword">if</strong> (db.getAnnotationIndex().containsKey(MappedSuperclass.<strong class="jxr_keyword">class</strong>.getName()))
531 <a class="jxr_linenumber" name="L523" href="#L523">523</a> classNames.addAll(db.getAnnotationIndex().get(MappedSuperclass.<strong class="jxr_keyword">class</strong>.getName()));
532 <a class="jxr_linenumber" name="L524" href="#L524">524</a> <strong class="jxr_keyword">if</strong> (db.getAnnotationIndex().containsKey(Embeddable.<strong class="jxr_keyword">class</strong>.getName()))
533 <a class="jxr_linenumber" name="L525" href="#L525">525</a> classNames.addAll(db.getAnnotationIndex().get(Embeddable.<strong class="jxr_keyword">class</strong>.getName()));
534 <a class="jxr_linenumber" name="L526" href="#L526">526</a>
535 <a class="jxr_linenumber" name="L527" href="#L527">527</a> MessageDigest digest = java.security.MessageDigest.getInstance(<span class="jxr_string">"MD5"</span>);
536 <a class="jxr_linenumber" name="L528" href="#L528">528</a> <strong class="jxr_keyword">for</strong> (String name : classNames)
537 <a class="jxr_linenumber" name="L529" href="#L529">529</a> {
538 <a class="jxr_linenumber" name="L530" href="#L530">530</a> Class<?> annotatedClass = classLoader.loadClass(name);
539 <a class="jxr_linenumber" name="L531" href="#L531">531</a> classes.add(annotatedClass);
540 <a class="jxr_linenumber" name="L532" href="#L532">532</a> String resourceName = annotatedClass.getName();
541 <a class="jxr_linenumber" name="L533" href="#L533">533</a> resourceName = resourceName.substring(resourceName.lastIndexOf(<span class="jxr_string">"."</span>) + 1, resourceName.length()) + <span class="jxr_string">".class"</span>;
542 <a class="jxr_linenumber" name="L534" href="#L534">534</a> InputStream is =
543 <a class="jxr_linenumber" name="L535" href="#L535">535</a> annotatedClass
544 <a class="jxr_linenumber" name="L536" href="#L536">536</a> .getResourceAsStream(resourceName);
545 <a class="jxr_linenumber" name="L537" href="#L537">537</a> byte[] buffer = <strong class="jxr_keyword">new</strong> byte[1024*4]; <em class="jxr_comment">// copy data in 4MB-chunks</em>
546 <a class="jxr_linenumber" name="L538" href="#L538">538</a> <strong class="jxr_keyword">int</strong> i;
547 <a class="jxr_linenumber" name="L539" href="#L539">539</a> <strong class="jxr_keyword">while</strong>((i = is.read(buffer)) > -1)
548 <a class="jxr_linenumber" name="L540" href="#L540">540</a> digest.update(buffer, 0, i);
549 <a class="jxr_linenumber" name="L541" href="#L541">541</a> is.close();
550 <a class="jxr_linenumber" name="L542" href="#L542">542</a> byte[] bytes = digest.digest();
551 <a class="jxr_linenumber" name="L543" href="#L543">543</a> BigInteger bi = <strong class="jxr_keyword">new</strong> BigInteger(1, bytes);
552 <a class="jxr_linenumber" name="L544" href="#L544">544</a> String newMd5 = String.format(<span class="jxr_string">"%0"</span> + (bytes.length << 1) + <span class="jxr_string">"x"</span>, bi);
553 <a class="jxr_linenumber" name="L545" href="#L545">545</a> String oldMd5 = !md5s.containsKey(name) ? <span class="jxr_string">""</span> : md5s.get(name);
554 <a class="jxr_linenumber" name="L546" href="#L546">546</a> <strong class="jxr_keyword">if</strong> (!newMd5.equals(oldMd5))
555 <a class="jxr_linenumber" name="L547" href="#L547">547</a> {
556 <a class="jxr_linenumber" name="L548" href="#L548">548</a> getLog().debug(<span class="jxr_string">"Found new or modified annotated class: "</span> + name);
557 <a class="jxr_linenumber" name="L549" href="#L549">549</a> modified = <strong class="jxr_keyword">true</strong>;
558 <a class="jxr_linenumber" name="L550" href="#L550">550</a> md5s.put(name, newMd5);
559 <a class="jxr_linenumber" name="L551" href="#L551">551</a> }
560 <a class="jxr_linenumber" name="L552" href="#L552">552</a> <strong class="jxr_keyword">else</strong>
561 <a class="jxr_linenumber" name="L553" href="#L553">553</a> {
562 <a class="jxr_linenumber" name="L554" href="#L554">554</a> getLog().debug(oldMd5 + <span class="jxr_string">" -> class unchanged: "</span> + name);
563 <a class="jxr_linenumber" name="L555" href="#L555">555</a> }
564 <a class="jxr_linenumber" name="L556" href="#L556">556</a> }
565 <a class="jxr_linenumber" name="L557" href="#L557">557</a> }
566 <a class="jxr_linenumber" name="L558" href="#L558">558</a> <strong class="jxr_keyword">catch</strong> (ClassNotFoundException e)
567 <a class="jxr_linenumber" name="L559" href="#L559">559</a> {
568 <a class="jxr_linenumber" name="L560" href="#L560">560</a> getLog().error(<span class="jxr_string">"Error while adding annotated classes!"</span>, e);
569 <a class="jxr_linenumber" name="L561" href="#L561">561</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(e.getMessage());
570 <a class="jxr_linenumber" name="L562" href="#L562">562</a> }
571 <a class="jxr_linenumber" name="L563" href="#L563">563</a> <strong class="jxr_keyword">catch</strong> (Exception e)
572 <a class="jxr_linenumber" name="L564" href="#L564">564</a> {
573 <a class="jxr_linenumber" name="L565" href="#L565">565</a> getLog().error(<span class="jxr_string">"Error while scanning!"</span>, e);
574 <a class="jxr_linenumber" name="L566" href="#L566">566</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(e.getMessage());
575 <a class="jxr_linenumber" name="L567" href="#L567">567</a> }
576 <a class="jxr_linenumber" name="L568" href="#L568">568</a>
577 <a class="jxr_linenumber" name="L569" href="#L569">569</a>
578 <a class="jxr_linenumber" name="L570" href="#L570">570</a> <a href="../../../../de/juplo/plugins/hibernate4/ValidationConfiguration.html">ValidationConfiguration</a> config = <strong class="jxr_keyword">new</strong> <a href="../../../../de/juplo/plugins/hibernate4/ValidationConfiguration.html">ValidationConfiguration</a>();
579 <a class="jxr_linenumber" name="L571" href="#L571">571</a> <em class="jxr_comment">// Clear unused system-properties</em>
580 <a class="jxr_linenumber" name="L572" href="#L572">572</a> config.setProperties(<strong class="jxr_keyword">new</strong> Properties());
581 <a class="jxr_linenumber" name="L573" href="#L573">573</a>
582 <a class="jxr_linenumber" name="L574" href="#L574">574</a>
583 <a class="jxr_linenumber" name="L575" href="#L575">575</a> ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
584 <a class="jxr_linenumber" name="L576" href="#L576">576</a> StandardServiceRegistryImpl registry = <strong class="jxr_keyword">null</strong>;
585 <a class="jxr_linenumber" name="L577" href="#L577">577</a> MavenLogAppender.startPluginLog(<strong class="jxr_keyword">this</strong>);
586 <a class="jxr_linenumber" name="L578" href="#L578">578</a>
587 <a class="jxr_linenumber" name="L579" href="#L579">579</a> <strong class="jxr_keyword">try</strong>
588 <a class="jxr_linenumber" name="L580" href="#L580">580</a> {
589 <a class="jxr_linenumber" name="L581" href="#L581">581</a> <em class="jxr_javadoccomment">/**</em>
590 <a class="jxr_linenumber" name="L582" href="#L582">582</a> <em class="jxr_javadoccomment"> * Change class-loader of current thread, so that hibernate can</em>
591 <a class="jxr_linenumber" name="L583" href="#L583">583</a> <em class="jxr_javadoccomment"> * see all dependencies!</em>
592 <a class="jxr_linenumber" name="L584" href="#L584">584</a> <em class="jxr_javadoccomment"> */</em>
593 <a class="jxr_linenumber" name="L585" href="#L585">585</a> Thread.currentThread().setContextClassLoader(classLoader);
594 <a class="jxr_linenumber" name="L586" href="#L586">586</a>
595 <a class="jxr_linenumber" name="L587" href="#L587">587</a>
596 <a class="jxr_linenumber" name="L588" href="#L588">588</a> <em class="jxr_javadoccomment">/** Try to read configuration from properties-file */</em>
597 <a class="jxr_linenumber" name="L589" href="#L589">589</a> <strong class="jxr_keyword">try</strong>
598 <a class="jxr_linenumber" name="L590" href="#L590">590</a> {
599 <a class="jxr_linenumber" name="L591" href="#L591">591</a> <strong class="jxr_keyword">if</strong> (hibernateProperties == <strong class="jxr_keyword">null</strong>)
600 <a class="jxr_linenumber" name="L592" href="#L592">592</a> {
601 <a class="jxr_linenumber" name="L593" href="#L593">593</a> URL url = classLoader.findResource(<span class="jxr_string">"hibernate.properties"</span>);
602 <a class="jxr_linenumber" name="L594" href="#L594">594</a> <strong class="jxr_keyword">if</strong> (url == <strong class="jxr_keyword">null</strong>)
603 <a class="jxr_linenumber" name="L595" href="#L595">595</a> {
604 <a class="jxr_linenumber" name="L596" href="#L596">596</a> getLog().info(<span class="jxr_string">"No hibernate.properties on the classpath!"</span>);
605 <a class="jxr_linenumber" name="L597" href="#L597">597</a> }
606 <a class="jxr_linenumber" name="L598" href="#L598">598</a> <strong class="jxr_keyword">else</strong>
607 <a class="jxr_linenumber" name="L599" href="#L599">599</a> {
608 <a class="jxr_linenumber" name="L600" href="#L600">600</a> getLog().info(<span class="jxr_string">"Reading settings from hibernate.properties on the classpath."</span>);
609 <a class="jxr_linenumber" name="L601" href="#L601">601</a> Properties properties = <strong class="jxr_keyword">new</strong> Properties();
610 <a class="jxr_linenumber" name="L602" href="#L602">602</a> properties.load(url.openStream());
611 <a class="jxr_linenumber" name="L603" href="#L603">603</a> config.setProperties(properties);
612 <a class="jxr_linenumber" name="L604" href="#L604">604</a> }
613 <a class="jxr_linenumber" name="L605" href="#L605">605</a> }
614 <a class="jxr_linenumber" name="L606" href="#L606">606</a> <strong class="jxr_keyword">else</strong>
615 <a class="jxr_linenumber" name="L607" href="#L607">607</a> {
616 <a class="jxr_linenumber" name="L608" href="#L608">608</a> File file = <strong class="jxr_keyword">new</strong> File(hibernateProperties);
617 <a class="jxr_linenumber" name="L609" href="#L609">609</a> <strong class="jxr_keyword">if</strong> (file.exists())
618 <a class="jxr_linenumber" name="L610" href="#L610">610</a> {
619 <a class="jxr_linenumber" name="L611" href="#L611">611</a> getLog().info(<span class="jxr_string">"Reading settings from file "</span> + hibernateProperties + <span class="jxr_string">"..."</span>);
620 <a class="jxr_linenumber" name="L612" href="#L612">612</a> Properties properties = <strong class="jxr_keyword">new</strong> Properties();
621 <a class="jxr_linenumber" name="L613" href="#L613">613</a> properties.load(<strong class="jxr_keyword">new</strong> FileInputStream(file));
622 <a class="jxr_linenumber" name="L614" href="#L614">614</a> config.setProperties(properties);
623 <a class="jxr_linenumber" name="L615" href="#L615">615</a> }
624 <a class="jxr_linenumber" name="L616" href="#L616">616</a> <strong class="jxr_keyword">else</strong>
625 <a class="jxr_linenumber" name="L617" href="#L617">617</a> getLog().info(<span class="jxr_string">"No hibernate-properties-file found! (Checked path: "</span> + hibernateProperties + <span class="jxr_string">")"</span>);
626 <a class="jxr_linenumber" name="L618" href="#L618">618</a> }
627 <a class="jxr_linenumber" name="L619" href="#L619">619</a> }
628 <a class="jxr_linenumber" name="L620" href="#L620">620</a> <strong class="jxr_keyword">catch</strong> (IOException e)
629 <a class="jxr_linenumber" name="L621" href="#L621">621</a> {
630 <a class="jxr_linenumber" name="L622" href="#L622">622</a> getLog().error(<span class="jxr_string">"Error while reading properties!"</span>, e);
631 <a class="jxr_linenumber" name="L623" href="#L623">623</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(e.getMessage());
632 <a class="jxr_linenumber" name="L624" href="#L624">624</a> }
633 <a class="jxr_linenumber" name="L625" href="#L625">625</a>
634 <a class="jxr_linenumber" name="L626" href="#L626">626</a> <em class="jxr_javadoccomment">/** Try to read configuration from configuration-file */</em>
635 <a class="jxr_linenumber" name="L627" href="#L627">627</a> <strong class="jxr_keyword">try</strong>
636 <a class="jxr_linenumber" name="L628" href="#L628">628</a> {
637 <a class="jxr_linenumber" name="L629" href="#L629">629</a> <strong class="jxr_keyword">if</strong> (hibernateConfig == <strong class="jxr_keyword">null</strong>)
638 <a class="jxr_linenumber" name="L630" href="#L630">630</a> {
639 <a class="jxr_linenumber" name="L631" href="#L631">631</a> URL url = classLoader.findResource(<span class="jxr_string">"hibernate.cfg.xml"</span>);
640 <a class="jxr_linenumber" name="L632" href="#L632">632</a> <strong class="jxr_keyword">if</strong> (url == <strong class="jxr_keyword">null</strong>)
641 <a class="jxr_linenumber" name="L633" href="#L633">633</a> {
642 <a class="jxr_linenumber" name="L634" href="#L634">634</a> getLog().info(<span class="jxr_string">"No hibernate.cfg.xml on the classpath!"</span>);
643 <a class="jxr_linenumber" name="L635" href="#L635">635</a> }
644 <a class="jxr_linenumber" name="L636" href="#L636">636</a> <strong class="jxr_keyword">else</strong>
645 <a class="jxr_linenumber" name="L637" href="#L637">637</a> {
646 <a class="jxr_linenumber" name="L638" href="#L638">638</a> getLog().info(<span class="jxr_string">"Reading settings from hibernate.cfg.xml on the classpath."</span>);
647 <a class="jxr_linenumber" name="L639" href="#L639">639</a> config.configure(url);
648 <a class="jxr_linenumber" name="L640" href="#L640">640</a> }
649 <a class="jxr_linenumber" name="L641" href="#L641">641</a> }
650 <a class="jxr_linenumber" name="L642" href="#L642">642</a> <strong class="jxr_keyword">else</strong>
651 <a class="jxr_linenumber" name="L643" href="#L643">643</a> {
652 <a class="jxr_linenumber" name="L644" href="#L644">644</a> File file = <strong class="jxr_keyword">new</strong> File(hibernateConfig);
653 <a class="jxr_linenumber" name="L645" href="#L645">645</a> <strong class="jxr_keyword">if</strong> (file.exists())
654 <a class="jxr_linenumber" name="L646" href="#L646">646</a> {
655 <a class="jxr_linenumber" name="L647" href="#L647">647</a> getLog().info(<span class="jxr_string">"Reading configuration from file "</span> + hibernateConfig + <span class="jxr_string">"..."</span>);
656 <a class="jxr_linenumber" name="L648" href="#L648">648</a> config.configure(file);
657 <a class="jxr_linenumber" name="L649" href="#L649">649</a> }
658 <a class="jxr_linenumber" name="L650" href="#L650">650</a> <strong class="jxr_keyword">else</strong>
659 <a class="jxr_linenumber" name="L651" href="#L651">651</a> getLog().info(<span class="jxr_string">"No hibernate-configuration-file found! (Checked path: "</span> + hibernateConfig + <span class="jxr_string">")"</span>);
660 <a class="jxr_linenumber" name="L652" href="#L652">652</a> }
661 <a class="jxr_linenumber" name="L653" href="#L653">653</a> }
662 <a class="jxr_linenumber" name="L654" href="#L654">654</a> <strong class="jxr_keyword">catch</strong> (Exception e)
663 <a class="jxr_linenumber" name="L655" href="#L655">655</a> {
664 <a class="jxr_linenumber" name="L656" href="#L656">656</a> getLog().error(<span class="jxr_string">"Error while reading configuration!"</span>, e);
665 <a class="jxr_linenumber" name="L657" href="#L657">657</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(e.getMessage());
666 <a class="jxr_linenumber" name="L658" href="#L658">658</a> }
667 <a class="jxr_linenumber" name="L659" href="#L659">659</a>
668 <a class="jxr_linenumber" name="L660" href="#L660">660</a> ParsedPersistenceXmlDescriptor persistenceUnitDescriptor =
669 <a class="jxr_linenumber" name="L661" href="#L661">661</a> getPersistenceUnitDescriptor(
670 <a class="jxr_linenumber" name="L662" href="#L662">662</a> persistenceUnit,
671 <a class="jxr_linenumber" name="L663" href="#L663">663</a> config.getProperties(),
672 <a class="jxr_linenumber" name="L664" href="#L664">664</a> <strong class="jxr_keyword">new</strong> <a href="../../../../de/juplo/plugins/hibernate4/Hbm2DdlMojo.html">MavenProjectClassLoaderService</a>(classLoader)
673 <a class="jxr_linenumber" name="L665" href="#L665">665</a> );
674 <a class="jxr_linenumber" name="L666" href="#L666">666</a> <strong class="jxr_keyword">if</strong> (persistenceUnitDescriptor != <strong class="jxr_keyword">null</strong>)
675 <a class="jxr_linenumber" name="L667" href="#L667">667</a> config.setProperties(persistenceUnitDescriptor.getProperties());
676 <a class="jxr_linenumber" name="L668" href="#L668">668</a>
677 <a class="jxr_linenumber" name="L669" href="#L669">669</a>
678 <a class="jxr_linenumber" name="L670" href="#L670">670</a> <em class="jxr_javadoccomment">/** Overwrite values from properties-file or set, if given */</em>
679 <a class="jxr_linenumber" name="L671" href="#L671">671</a>
680 <a class="jxr_linenumber" name="L672" href="#L672">672</a> <strong class="jxr_keyword">if</strong> (driverClassName != <strong class="jxr_keyword">null</strong>)
681 <a class="jxr_linenumber" name="L673" href="#L673">673</a> {
682 <a class="jxr_linenumber" name="L674" href="#L674">674</a> <strong class="jxr_keyword">if</strong> (config.getProperties().containsKey(DRIVER_CLASS))
683 <a class="jxr_linenumber" name="L675" href="#L675">675</a> getLog().debug(
684 <a class="jxr_linenumber" name="L676" href="#L676">676</a> <span class="jxr_string">"Overwriting property "</span> +
685 <a class="jxr_linenumber" name="L677" href="#L677">677</a> DRIVER_CLASS + <span class="jxr_string">"="</span> + config.getProperty(DRIVER_CLASS) +
686 <a class="jxr_linenumber" name="L678" href="#L678">678</a> <span class="jxr_string">" with the value "</span> + driverClassName
687 <a class="jxr_linenumber" name="L679" href="#L679">679</a> );
688 <a class="jxr_linenumber" name="L680" href="#L680">680</a> <strong class="jxr_keyword">else</strong>
689 <a class="jxr_linenumber" name="L681" href="#L681">681</a> getLog().debug(<span class="jxr_string">"Using the value "</span> + driverClassName);
690 <a class="jxr_linenumber" name="L682" href="#L682">682</a> config.setProperty(DRIVER_CLASS, driverClassName);
691 <a class="jxr_linenumber" name="L683" href="#L683">683</a> }
692 <a class="jxr_linenumber" name="L684" href="#L684">684</a> <strong class="jxr_keyword">if</strong> (config.getProperty(DRIVER_CLASS) == <strong class="jxr_keyword">null</strong>)
693 <a class="jxr_linenumber" name="L685" href="#L685">685</a> {
694 <a class="jxr_linenumber" name="L686" href="#L686">686</a> String driver = config.getProperty(JPA_DRIVER);
695 <a class="jxr_linenumber" name="L687" href="#L687">687</a> <strong class="jxr_keyword">if</strong> (driver != <strong class="jxr_keyword">null</strong>)
696 <a class="jxr_linenumber" name="L688" href="#L688">688</a> {
697 <a class="jxr_linenumber" name="L689" href="#L689">689</a> getLog().info(
698 <a class="jxr_linenumber" name="L690" href="#L690">690</a> DRIVER_CLASS +
699 <a class="jxr_linenumber" name="L691" href="#L691">691</a> <span class="jxr_string">" is not set. Borrow setting from "</span> +
700 <a class="jxr_linenumber" name="L692" href="#L692">692</a> JPA_DRIVER +
701 <a class="jxr_linenumber" name="L693" href="#L693">693</a> <span class="jxr_string">": "</span> +
702 <a class="jxr_linenumber" name="L694" href="#L694">694</a> driver);
703 <a class="jxr_linenumber" name="L695" href="#L695">695</a> config.setProperty(DRIVER_CLASS, driver);
704 <a class="jxr_linenumber" name="L696" href="#L696">696</a> }
705 <a class="jxr_linenumber" name="L697" href="#L697">697</a> }
706 <a class="jxr_linenumber" name="L698" href="#L698">698</a>
707 <a class="jxr_linenumber" name="L699" href="#L699">699</a> <strong class="jxr_keyword">if</strong> (url != <strong class="jxr_keyword">null</strong>)
708 <a class="jxr_linenumber" name="L700" href="#L700">700</a> {
709 <a class="jxr_linenumber" name="L701" href="#L701">701</a> <strong class="jxr_keyword">if</strong> (config.getProperties().containsKey(URL))
710 <a class="jxr_linenumber" name="L702" href="#L702">702</a> getLog().debug(
711 <a class="jxr_linenumber" name="L703" href="#L703">703</a> <span class="jxr_string">"Overwriting property "</span> +
712 <a class="jxr_linenumber" name="L704" href="#L704">704</a> URL + <span class="jxr_string">"="</span> + config.getProperty(URL) +
713 <a class="jxr_linenumber" name="L705" href="#L705">705</a> <span class="jxr_string">" with the value "</span> + url
714 <a class="jxr_linenumber" name="L706" href="#L706">706</a> );
715 <a class="jxr_linenumber" name="L707" href="#L707">707</a> <strong class="jxr_keyword">else</strong>
716 <a class="jxr_linenumber" name="L708" href="#L708">708</a> getLog().debug(<span class="jxr_string">"Using the value "</span> + url);
717 <a class="jxr_linenumber" name="L709" href="#L709">709</a> config.setProperty(URL, url);
718 <a class="jxr_linenumber" name="L710" href="#L710">710</a> }
719 <a class="jxr_linenumber" name="L711" href="#L711">711</a> <strong class="jxr_keyword">if</strong> (config.getProperty(URL) == <strong class="jxr_keyword">null</strong>)
720 <a class="jxr_linenumber" name="L712" href="#L712">712</a> {
721 <a class="jxr_linenumber" name="L713" href="#L713">713</a> String url = config.getProperty(JPA_URL);
722 <a class="jxr_linenumber" name="L714" href="#L714">714</a> <strong class="jxr_keyword">if</strong> (url != <strong class="jxr_keyword">null</strong>)
723 <a class="jxr_linenumber" name="L715" href="#L715">715</a> {
724 <a class="jxr_linenumber" name="L716" href="#L716">716</a> getLog().info(
725 <a class="jxr_linenumber" name="L717" href="#L717">717</a> URL +
726 <a class="jxr_linenumber" name="L718" href="#L718">718</a> <span class="jxr_string">" is not set. Borrow setting from "</span> +
727 <a class="jxr_linenumber" name="L719" href="#L719">719</a> JPA_URL +
728 <a class="jxr_linenumber" name="L720" href="#L720">720</a> <span class="jxr_string">": "</span> +
729 <a class="jxr_linenumber" name="L721" href="#L721">721</a> url);
730 <a class="jxr_linenumber" name="L722" href="#L722">722</a> config.setProperty(URL, url);
731 <a class="jxr_linenumber" name="L723" href="#L723">723</a> }
732 <a class="jxr_linenumber" name="L724" href="#L724">724</a> }
733 <a class="jxr_linenumber" name="L725" href="#L725">725</a>
734 <a class="jxr_linenumber" name="L726" href="#L726">726</a> <strong class="jxr_keyword">if</strong> (username != <strong class="jxr_keyword">null</strong>)
735 <a class="jxr_linenumber" name="L727" href="#L727">727</a> {
736 <a class="jxr_linenumber" name="L728" href="#L728">728</a> <strong class="jxr_keyword">if</strong> (config.getProperties().containsKey(USERNAME))
737 <a class="jxr_linenumber" name="L729" href="#L729">729</a> getLog().debug(
738 <a class="jxr_linenumber" name="L730" href="#L730">730</a> <span class="jxr_string">"Overwriting property "</span> +
739 <a class="jxr_linenumber" name="L731" href="#L731">731</a> USERNAME + <span class="jxr_string">"="</span> + config.getProperty(USERNAME) +
740 <a class="jxr_linenumber" name="L732" href="#L732">732</a> <span class="jxr_string">" with the value "</span> + username
741 <a class="jxr_linenumber" name="L733" href="#L733">733</a> );
742 <a class="jxr_linenumber" name="L734" href="#L734">734</a> <strong class="jxr_keyword">else</strong>
743 <a class="jxr_linenumber" name="L735" href="#L735">735</a> getLog().debug(<span class="jxr_string">"Using the value "</span> + username);
744 <a class="jxr_linenumber" name="L736" href="#L736">736</a> config.setProperty(USERNAME, username);
745 <a class="jxr_linenumber" name="L737" href="#L737">737</a> }
746 <a class="jxr_linenumber" name="L738" href="#L738">738</a> <strong class="jxr_keyword">if</strong> (config.getProperty(USERNAME) == <strong class="jxr_keyword">null</strong>)
747 <a class="jxr_linenumber" name="L739" href="#L739">739</a> {
748 <a class="jxr_linenumber" name="L740" href="#L740">740</a> String username = config.getProperty(JPA_USERNAME);
749 <a class="jxr_linenumber" name="L741" href="#L741">741</a> <strong class="jxr_keyword">if</strong> (username != <strong class="jxr_keyword">null</strong>)
750 <a class="jxr_linenumber" name="L742" href="#L742">742</a> {
751 <a class="jxr_linenumber" name="L743" href="#L743">743</a> getLog().info(
752 <a class="jxr_linenumber" name="L744" href="#L744">744</a> USERNAME +
753 <a class="jxr_linenumber" name="L745" href="#L745">745</a> <span class="jxr_string">" is not set. Borrow setting from "</span> +
754 <a class="jxr_linenumber" name="L746" href="#L746">746</a> JPA_USERNAME +
755 <a class="jxr_linenumber" name="L747" href="#L747">747</a> <span class="jxr_string">": "</span> +
756 <a class="jxr_linenumber" name="L748" href="#L748">748</a> username);
757 <a class="jxr_linenumber" name="L749" href="#L749">749</a> config.setProperty(USERNAME, username);
758 <a class="jxr_linenumber" name="L750" href="#L750">750</a> }
759 <a class="jxr_linenumber" name="L751" href="#L751">751</a> }
760 <a class="jxr_linenumber" name="L752" href="#L752">752</a>
761 <a class="jxr_linenumber" name="L753" href="#L753">753</a> <strong class="jxr_keyword">if</strong> (password != <strong class="jxr_keyword">null</strong>)
762 <a class="jxr_linenumber" name="L754" href="#L754">754</a> {
763 <a class="jxr_linenumber" name="L755" href="#L755">755</a> <strong class="jxr_keyword">if</strong> (config.getProperties().containsKey(PASSWORD))
764 <a class="jxr_linenumber" name="L756" href="#L756">756</a> getLog().debug(
765 <a class="jxr_linenumber" name="L757" href="#L757">757</a> <span class="jxr_string">"Overwriting property "</span> +
766 <a class="jxr_linenumber" name="L758" href="#L758">758</a> PASSWORD + <span class="jxr_string">"="</span> + config.getProperty(PASSWORD) +
767 <a class="jxr_linenumber" name="L759" href="#L759">759</a> <span class="jxr_string">" with value "</span> + password
768 <a class="jxr_linenumber" name="L760" href="#L760">760</a> );
769 <a class="jxr_linenumber" name="L761" href="#L761">761</a> <strong class="jxr_keyword">else</strong>
770 <a class="jxr_linenumber" name="L762" href="#L762">762</a> getLog().debug(<span class="jxr_string">"Using value "</span> + password + <span class="jxr_string">" for property "</span> + PASSWORD);
771 <a class="jxr_linenumber" name="L763" href="#L763">763</a> config.setProperty(PASSWORD, password);
772 <a class="jxr_linenumber" name="L764" href="#L764">764</a> }
773 <a class="jxr_linenumber" name="L765" href="#L765">765</a> <strong class="jxr_keyword">if</strong> (config.getProperty(PASSWORD) == <strong class="jxr_keyword">null</strong>)
774 <a class="jxr_linenumber" name="L766" href="#L766">766</a> {
775 <a class="jxr_linenumber" name="L767" href="#L767">767</a> String password = config.getProperty(JPA_PASSWORD);
776 <a class="jxr_linenumber" name="L768" href="#L768">768</a> <strong class="jxr_keyword">if</strong> (password != <strong class="jxr_keyword">null</strong>)
777 <a class="jxr_linenumber" name="L769" href="#L769">769</a> {
778 <a class="jxr_linenumber" name="L770" href="#L770">770</a> getLog().info(
779 <a class="jxr_linenumber" name="L771" href="#L771">771</a> PASSWORD +
780 <a class="jxr_linenumber" name="L772" href="#L772">772</a> <span class="jxr_string">" is not set. Borrow setting from "</span> +
781 <a class="jxr_linenumber" name="L773" href="#L773">773</a> JPA_PASSWORD +
782 <a class="jxr_linenumber" name="L774" href="#L774">774</a> <span class="jxr_string">": "</span> +
783 <a class="jxr_linenumber" name="L775" href="#L775">775</a> password);
784 <a class="jxr_linenumber" name="L776" href="#L776">776</a> config.setProperty(PASSWORD, password);
785 <a class="jxr_linenumber" name="L777" href="#L777">777</a> }
786 <a class="jxr_linenumber" name="L778" href="#L778">778</a> }
787 <a class="jxr_linenumber" name="L779" href="#L779">779</a>
788 <a class="jxr_linenumber" name="L780" href="#L780">780</a> <strong class="jxr_keyword">if</strong> (hibernateDialect != <strong class="jxr_keyword">null</strong>)
789 <a class="jxr_linenumber" name="L781" href="#L781">781</a> {
790 <a class="jxr_linenumber" name="L782" href="#L782">782</a> <strong class="jxr_keyword">if</strong> (config.getProperties().containsKey(DIALECT))
791 <a class="jxr_linenumber" name="L783" href="#L783">783</a> getLog().debug(
792 <a class="jxr_linenumber" name="L784" href="#L784">784</a> <span class="jxr_string">"Overwriting property "</span> +
793 <a class="jxr_linenumber" name="L785" href="#L785">785</a> DIALECT + <span class="jxr_string">"="</span> + config.getProperty(DIALECT) +
794 <a class="jxr_linenumber" name="L786" href="#L786">786</a> <span class="jxr_string">" with value "</span> + hibernateDialect
795 <a class="jxr_linenumber" name="L787" href="#L787">787</a> );
796 <a class="jxr_linenumber" name="L788" href="#L788">788</a> <strong class="jxr_keyword">else</strong>
797 <a class="jxr_linenumber" name="L789" href="#L789">789</a> getLog().debug(
798 <a class="jxr_linenumber" name="L790" href="#L790">790</a> <span class="jxr_string">"Using value "</span> + hibernateDialect + <span class="jxr_string">" for property "</span> + DIALECT
799 <a class="jxr_linenumber" name="L791" href="#L791">791</a> );
800 <a class="jxr_linenumber" name="L792" href="#L792">792</a> config.setProperty(DIALECT, hibernateDialect);
801 <a class="jxr_linenumber" name="L793" href="#L793">793</a> }
802 <a class="jxr_linenumber" name="L794" href="#L794">794</a>
803 <a class="jxr_linenumber" name="L795" href="#L795">795</a> <strong class="jxr_keyword">if</strong> ( hibernateNamingStrategy != <strong class="jxr_keyword">null</strong> )
804 <a class="jxr_linenumber" name="L796" href="#L796">796</a> {
805 <a class="jxr_linenumber" name="L797" href="#L797">797</a> <strong class="jxr_keyword">if</strong> ( config.getProperties().contains(NAMING_STRATEGY))
806 <a class="jxr_linenumber" name="L798" href="#L798">798</a> getLog().debug(
807 <a class="jxr_linenumber" name="L799" href="#L799">799</a> <span class="jxr_string">"Overwriting property "</span> +
808 <a class="jxr_linenumber" name="L800" href="#L800">800</a> NAMING_STRATEGY + <span class="jxr_string">"="</span> + config.getProperty(NAMING_STRATEGY) +
809 <a class="jxr_linenumber" name="L801" href="#L801">801</a> <span class="jxr_string">" with value "</span> + hibernateNamingStrategy
810 <a class="jxr_linenumber" name="L802" href="#L802">802</a> );
811 <a class="jxr_linenumber" name="L803" href="#L803">803</a> <strong class="jxr_keyword">else</strong>
812 <a class="jxr_linenumber" name="L804" href="#L804">804</a> getLog().debug(
813 <a class="jxr_linenumber" name="L805" href="#L805">805</a> <span class="jxr_string">"Using value "</span> + hibernateNamingStrategy + <span class="jxr_string">" for property "</span> +
814 <a class="jxr_linenumber" name="L806" href="#L806">806</a> NAMING_STRATEGY
815 <a class="jxr_linenumber" name="L807" href="#L807">807</a> );
816 <a class="jxr_linenumber" name="L808" href="#L808">808</a> config.setProperty(NAMING_STRATEGY, hibernateNamingStrategy);
817 <a class="jxr_linenumber" name="L809" href="#L809">809</a> }
818 <a class="jxr_linenumber" name="L810" href="#L810">810</a>
819 <a class="jxr_linenumber" name="L811" href="#L811">811</a> <em class="jxr_javadoccomment">/** The generated SQL varies with the dialect! */</em>
820 <a class="jxr_linenumber" name="L812" href="#L812">812</a> <strong class="jxr_keyword">if</strong> (md5s.containsKey(DIALECT))
821 <a class="jxr_linenumber" name="L813" href="#L813">813</a> {
822 <a class="jxr_linenumber" name="L814" href="#L814">814</a> String dialect = config.getProperty(DIALECT);
823 <a class="jxr_linenumber" name="L815" href="#L815">815</a> <strong class="jxr_keyword">if</strong> (md5s.get(DIALECT).equals(dialect))
824 <a class="jxr_linenumber" name="L816" href="#L816">816</a> getLog().debug(<span class="jxr_string">"SQL-dialect unchanged."</span>);
825 <a class="jxr_linenumber" name="L817" href="#L817">817</a> <strong class="jxr_keyword">else</strong>
826 <a class="jxr_linenumber" name="L818" href="#L818">818</a> {
827 <a class="jxr_linenumber" name="L819" href="#L819">819</a> modified = <strong class="jxr_keyword">true</strong>;
828 <a class="jxr_linenumber" name="L820" href="#L820">820</a> <strong class="jxr_keyword">if</strong> (dialect == <strong class="jxr_keyword">null</strong>)
829 <a class="jxr_linenumber" name="L821" href="#L821">821</a> {
830 <a class="jxr_linenumber" name="L822" href="#L822">822</a> getLog().debug(<span class="jxr_string">"SQL-dialect was unset."</span>);
831 <a class="jxr_linenumber" name="L823" href="#L823">823</a> md5s.remove(DIALECT);
832 <a class="jxr_linenumber" name="L824" href="#L824">824</a> }
833 <a class="jxr_linenumber" name="L825" href="#L825">825</a> <strong class="jxr_keyword">else</strong>
834 <a class="jxr_linenumber" name="L826" href="#L826">826</a> {
835 <a class="jxr_linenumber" name="L827" href="#L827">827</a> getLog().debug(<span class="jxr_string">"SQL-dialect changed: "</span> + dialect);
836 <a class="jxr_linenumber" name="L828" href="#L828">828</a> md5s.put(DIALECT, dialect);
837 <a class="jxr_linenumber" name="L829" href="#L829">829</a> }
838 <a class="jxr_linenumber" name="L830" href="#L830">830</a> }
839 <a class="jxr_linenumber" name="L831" href="#L831">831</a> }
840 <a class="jxr_linenumber" name="L832" href="#L832">832</a> <strong class="jxr_keyword">else</strong>
841 <a class="jxr_linenumber" name="L833" href="#L833">833</a> {
842 <a class="jxr_linenumber" name="L834" href="#L834">834</a> String dialect = config.getProperty(DIALECT);
843 <a class="jxr_linenumber" name="L835" href="#L835">835</a> <strong class="jxr_keyword">if</strong> (dialect != <strong class="jxr_keyword">null</strong>)
844 <a class="jxr_linenumber" name="L836" href="#L836">836</a> {
845 <a class="jxr_linenumber" name="L837" href="#L837">837</a> modified = <strong class="jxr_keyword">true</strong>;
846 <a class="jxr_linenumber" name="L838" href="#L838">838</a> md5s.put(DIALECT, config.getProperty(DIALECT));
847 <a class="jxr_linenumber" name="L839" href="#L839">839</a> }
848 <a class="jxr_linenumber" name="L840" href="#L840">840</a> }
849 <a class="jxr_linenumber" name="L841" href="#L841">841</a>
850 <a class="jxr_linenumber" name="L842" href="#L842">842</a> <em class="jxr_javadoccomment">/** The generated SQL varies with the envers-configuration */</em>
851 <a class="jxr_linenumber" name="L843" href="#L843">843</a> <strong class="jxr_keyword">if</strong> (md5s.get(ENVERS) != <strong class="jxr_keyword">null</strong>)
852 <a class="jxr_linenumber" name="L844" href="#L844">844</a> {
853 <a class="jxr_linenumber" name="L845" href="#L845">845</a> <strong class="jxr_keyword">if</strong> (md5s.get(ENVERS).equals(Boolean.toString(envers)))
854 <a class="jxr_linenumber" name="L846" href="#L846">846</a> getLog().debug(<span class="jxr_string">"Envers-Configuration unchanged. Enabled: "</span> + envers);
855 <a class="jxr_linenumber" name="L847" href="#L847">847</a> <strong class="jxr_keyword">else</strong>
856 <a class="jxr_linenumber" name="L848" href="#L848">848</a> {
857 <a class="jxr_linenumber" name="L849" href="#L849">849</a> getLog().debug(<span class="jxr_string">"Envers-Configuration changed. Enabled: "</span> + envers);
858 <a class="jxr_linenumber" name="L850" href="#L850">850</a> modified = <strong class="jxr_keyword">true</strong>;
859 <a class="jxr_linenumber" name="L851" href="#L851">851</a> md5s.put(ENVERS, Boolean.toString(envers));
860 <a class="jxr_linenumber" name="L852" href="#L852">852</a> }
861 <a class="jxr_linenumber" name="L853" href="#L853">853</a> }
862 <a class="jxr_linenumber" name="L854" href="#L854">854</a> <strong class="jxr_keyword">else</strong>
863 <a class="jxr_linenumber" name="L855" href="#L855">855</a> {
864 <a class="jxr_linenumber" name="L856" href="#L856">856</a> modified = <strong class="jxr_keyword">true</strong>;
865 <a class="jxr_linenumber" name="L857" href="#L857">857</a> md5s.put(ENVERS, Boolean.toString(envers));
866 <a class="jxr_linenumber" name="L858" href="#L858">858</a> }
867 <a class="jxr_linenumber" name="L859" href="#L859">859</a>
868 <a class="jxr_linenumber" name="L860" href="#L860">860</a> <strong class="jxr_keyword">if</strong> (config.getProperties().isEmpty())
869 <a class="jxr_linenumber" name="L861" href="#L861">861</a> {
870 <a class="jxr_linenumber" name="L862" href="#L862">862</a> getLog().error(<span class="jxr_string">"No properties set!"</span>);
871 <a class="jxr_linenumber" name="L863" href="#L863">863</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"Hibernate configuration is missing!"</span>);
872 <a class="jxr_linenumber" name="L864" href="#L864">864</a> }
873 <a class="jxr_linenumber" name="L865" href="#L865">865</a>
874 <a class="jxr_linenumber" name="L866" href="#L866">866</a> getLog().info(<span class="jxr_string">"Gathered hibernate-configuration (turn on debugging for details):"</span>);
875 <a class="jxr_linenumber" name="L867" href="#L867">867</a> <strong class="jxr_keyword">for</strong> (Entry<Object,Object> entry : config.getProperties().entrySet())
876 <a class="jxr_linenumber" name="L868" href="#L868">868</a> getLog().info(<span class="jxr_string">" "</span> + entry.getKey() + <span class="jxr_string">" = "</span> + entry.getValue());
877 <a class="jxr_linenumber" name="L869" href="#L869">869</a>
878 <a class="jxr_linenumber" name="L870" href="#L870">870</a>
879 <a class="jxr_linenumber" name="L871" href="#L871">871</a> getLog().debug(<span class="jxr_string">"Adding explicitly configured mappings..."</span>);
880 <a class="jxr_linenumber" name="L872" href="#L872">872</a> <strong class="jxr_keyword">if</strong> (hibernateMapping != <strong class="jxr_keyword">null</strong>)
881 <a class="jxr_linenumber" name="L873" href="#L873">873</a> {
882 <a class="jxr_linenumber" name="L874" href="#L874">874</a> <strong class="jxr_keyword">try</strong>
883 <a class="jxr_linenumber" name="L875" href="#L875">875</a> {
884 <a class="jxr_linenumber" name="L876" href="#L876">876</a> MessageDigest digest = java.security.MessageDigest.getInstance(<span class="jxr_string">"MD5"</span>);
885 <a class="jxr_linenumber" name="L877" href="#L877">877</a> <strong class="jxr_keyword">for</strong> (String filename : hibernateMapping.split(<span class="jxr_string">"[\\s,]+"</span>))
886 <a class="jxr_linenumber" name="L878" href="#L878">878</a> {
887 <a class="jxr_linenumber" name="L879" href="#L879">879</a> <em class="jxr_comment">// First try the filename as absolute/relative path</em>
888 <a class="jxr_linenumber" name="L880" href="#L880">880</a> File file = <strong class="jxr_keyword">new</strong> File(filename);
889 <a class="jxr_linenumber" name="L881" href="#L881">881</a> <strong class="jxr_keyword">if</strong> (!file.exists())
890 <a class="jxr_linenumber" name="L882" href="#L882">882</a> {
891 <a class="jxr_linenumber" name="L883" href="#L883">883</a> <em class="jxr_comment">// If the file was not found, search for it in the resource-directories</em>
892 <a class="jxr_linenumber" name="L884" href="#L884">884</a> <strong class="jxr_keyword">for</strong> (Resource resource : project.getResources())
893 <a class="jxr_linenumber" name="L885" href="#L885">885</a> {
894 <a class="jxr_linenumber" name="L886" href="#L886">886</a> file = <strong class="jxr_keyword">new</strong> File(resource.getDirectory() + File.separator + filename);
895 <a class="jxr_linenumber" name="L887" href="#L887">887</a> <strong class="jxr_keyword">if</strong> (file.exists())
896 <a class="jxr_linenumber" name="L888" href="#L888">888</a> <strong class="jxr_keyword">break</strong>;
897 <a class="jxr_linenumber" name="L889" href="#L889">889</a> }
898 <a class="jxr_linenumber" name="L890" href="#L890">890</a> }
899 <a class="jxr_linenumber" name="L891" href="#L891">891</a> <strong class="jxr_keyword">if</strong> (file != <strong class="jxr_keyword">null</strong> && file.exists())
900 <a class="jxr_linenumber" name="L892" href="#L892">892</a> {
901 <a class="jxr_linenumber" name="L893" href="#L893">893</a> InputStream is = <strong class="jxr_keyword">new</strong> FileInputStream(file);
902 <a class="jxr_linenumber" name="L894" href="#L894">894</a> byte[] buffer = <strong class="jxr_keyword">new</strong> byte[1024*4]; <em class="jxr_comment">// copy data in 4MB-chunks</em>
903 <a class="jxr_linenumber" name="L895" href="#L895">895</a> <strong class="jxr_keyword">int</strong> i;
904 <a class="jxr_linenumber" name="L896" href="#L896">896</a> <strong class="jxr_keyword">while</strong>((i = is.read(buffer)) > -1)
905 <a class="jxr_linenumber" name="L897" href="#L897">897</a> digest.update(buffer, 0, i);
906 <a class="jxr_linenumber" name="L898" href="#L898">898</a> is.close();
907 <a class="jxr_linenumber" name="L899" href="#L899">899</a> byte[] bytes = digest.digest();
908 <a class="jxr_linenumber" name="L900" href="#L900">900</a> BigInteger bi = <strong class="jxr_keyword">new</strong> BigInteger(1, bytes);
909 <a class="jxr_linenumber" name="L901" href="#L901">901</a> String newMd5 = String.format(<span class="jxr_string">"%0"</span> + (bytes.length << 1) + <span class="jxr_string">"x"</span>, bi);
910 <a class="jxr_linenumber" name="L902" href="#L902">902</a> String oldMd5 = !md5s.containsKey(filename) ? <span class="jxr_string">""</span> : md5s.get(filename);
911 <a class="jxr_linenumber" name="L903" href="#L903">903</a> <strong class="jxr_keyword">if</strong> (!newMd5.equals(oldMd5))
912 <a class="jxr_linenumber" name="L904" href="#L904">904</a> {
913 <a class="jxr_linenumber" name="L905" href="#L905">905</a> getLog().debug(<span class="jxr_string">"Found new or modified mapping-file: "</span> + filename);
914 <a class="jxr_linenumber" name="L906" href="#L906">906</a> modified = <strong class="jxr_keyword">true</strong>;
915 <a class="jxr_linenumber" name="L907" href="#L907">907</a> md5s.put(filename, newMd5);
916 <a class="jxr_linenumber" name="L908" href="#L908">908</a> }
917 <a class="jxr_linenumber" name="L909" href="#L909">909</a> <strong class="jxr_keyword">else</strong>
918 <a class="jxr_linenumber" name="L910" href="#L910">910</a> {
919 <a class="jxr_linenumber" name="L911" href="#L911">911</a> getLog().debug(oldMd5 + <span class="jxr_string">" -> mapping-file unchanged: "</span> + filename);
920 <a class="jxr_linenumber" name="L912" href="#L912">912</a> }
921 <a class="jxr_linenumber" name="L913" href="#L913">913</a> getLog().debug(<span class="jxr_string">"Adding mappings from XML-configurationfile: "</span> + file);
922 <a class="jxr_linenumber" name="L914" href="#L914">914</a> config.addFile(file);
923 <a class="jxr_linenumber" name="L915" href="#L915">915</a> }
924 <a class="jxr_linenumber" name="L916" href="#L916">916</a> <strong class="jxr_keyword">else</strong>
925 <a class="jxr_linenumber" name="L917" href="#L917">917</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"File "</span> + filename + <span class="jxr_string">" could not be found in any of the configured resource-directories!"</span>);
926 <a class="jxr_linenumber" name="L918" href="#L918">918</a> }
927 <a class="jxr_linenumber" name="L919" href="#L919">919</a> }
928 <a class="jxr_linenumber" name="L920" href="#L920">920</a> <strong class="jxr_keyword">catch</strong> (NoSuchAlgorithmException e)
929 <a class="jxr_linenumber" name="L921" href="#L921">921</a> {
930 <a class="jxr_linenumber" name="L922" href="#L922">922</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"Cannot calculate MD5 sums!"</span>, e);
931 <a class="jxr_linenumber" name="L923" href="#L923">923</a> }
932 <a class="jxr_linenumber" name="L924" href="#L924">924</a> <strong class="jxr_keyword">catch</strong> (FileNotFoundException e)
933 <a class="jxr_linenumber" name="L925" href="#L925">925</a> {
934 <a class="jxr_linenumber" name="L926" href="#L926">926</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"Cannot calculate MD5 sums!"</span>, e);
935 <a class="jxr_linenumber" name="L927" href="#L927">927</a> }
936 <a class="jxr_linenumber" name="L928" href="#L928">928</a> <strong class="jxr_keyword">catch</strong> (IOException e)
937 <a class="jxr_linenumber" name="L929" href="#L929">929</a> {
938 <a class="jxr_linenumber" name="L930" href="#L930">930</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"Cannot calculate MD5 sums!"</span>, e);
939 <a class="jxr_linenumber" name="L931" href="#L931">931</a> }
940 <a class="jxr_linenumber" name="L932" href="#L932">932</a> }
941 <a class="jxr_linenumber" name="L933" href="#L933">933</a>
942 <a class="jxr_linenumber" name="L934" href="#L934">934</a> getLog().debug(<span class="jxr_string">"Adding annotated classes to hibernate-mapping-configuration..."</span>);
943 <a class="jxr_linenumber" name="L935" href="#L935">935</a> <em class="jxr_comment">// build annotated packages</em>
944 <a class="jxr_linenumber" name="L936" href="#L936">936</a> Set<String> packages = <strong class="jxr_keyword">new</strong> HashSet<String>();
945 <a class="jxr_linenumber" name="L937" href="#L937">937</a> <strong class="jxr_keyword">for</strong> (Class<?> annotatedClass : classes)
946 <a class="jxr_linenumber" name="L938" href="#L938">938</a> {
947 <a class="jxr_linenumber" name="L939" href="#L939">939</a> String packageName = annotatedClass.getPackage().getName();
948 <a class="jxr_linenumber" name="L940" href="#L940">940</a> <strong class="jxr_keyword">if</strong> (!packages.contains(packageName))
949 <a class="jxr_linenumber" name="L941" href="#L941">941</a> {
950 <a class="jxr_linenumber" name="L942" href="#L942">942</a> getLog().debug(<span class="jxr_string">"Add package "</span> + packageName);
951 <a class="jxr_linenumber" name="L943" href="#L943">943</a> packages.add(packageName);
952 <a class="jxr_linenumber" name="L944" href="#L944">944</a> config.addPackage(packageName);
953 <a class="jxr_linenumber" name="L945" href="#L945">945</a> getLog().debug(<span class="jxr_string">"type definintions"</span> + config.getTypeDefs());
954 <a class="jxr_linenumber" name="L946" href="#L946">946</a> }
955 <a class="jxr_linenumber" name="L947" href="#L947">947</a> getLog().debug(<span class="jxr_string">"Class "</span> + annotatedClass);
956 <a class="jxr_linenumber" name="L948" href="#L948">948</a> config.addAnnotatedClass(annotatedClass);
957 <a class="jxr_linenumber" name="L949" href="#L949">949</a> }
958 <a class="jxr_linenumber" name="L950" href="#L950">950</a>
959 <a class="jxr_linenumber" name="L951" href="#L951">951</a> Target target = <strong class="jxr_keyword">null</strong>;
960 <a class="jxr_linenumber" name="L952" href="#L952">952</a> <strong class="jxr_keyword">try</strong>
961 <a class="jxr_linenumber" name="L953" href="#L953">953</a> {
962 <a class="jxr_linenumber" name="L954" href="#L954">954</a> target = Target.valueOf(<strong class="jxr_keyword">this</strong>.target.toUpperCase());
963 <a class="jxr_linenumber" name="L955" href="#L955">955</a> }
964 <a class="jxr_linenumber" name="L956" href="#L956">956</a> <strong class="jxr_keyword">catch</strong> (IllegalArgumentException e)
965 <a class="jxr_linenumber" name="L957" href="#L957">957</a> {
966 <a class="jxr_linenumber" name="L958" href="#L958">958</a> getLog().error(<span class="jxr_string">"Invalid value for configuration-option \"target\": "</span> + <strong class="jxr_keyword">this</strong>.target);
967 <a class="jxr_linenumber" name="L959" href="#L959">959</a> getLog().error(<span class="jxr_string">"Valid values are: NONE, SCRIPT, EXPORT, BOTH"</span>);
968 <a class="jxr_linenumber" name="L960" href="#L960">960</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(<span class="jxr_string">"Invalid value for configuration-option \"target\""</span>);
969 <a class="jxr_linenumber" name="L961" href="#L961">961</a> }
970 <a class="jxr_linenumber" name="L962" href="#L962">962</a> Type type = <strong class="jxr_keyword">null</strong>;
971 <a class="jxr_linenumber" name="L963" href="#L963">963</a> <strong class="jxr_keyword">try</strong>
972 <a class="jxr_linenumber" name="L964" href="#L964">964</a> {
973 <a class="jxr_linenumber" name="L965" href="#L965">965</a> type = Type.valueOf(<strong class="jxr_keyword">this</strong>.type.toUpperCase());
974 <a class="jxr_linenumber" name="L966" href="#L966">966</a> }
975 <a class="jxr_linenumber" name="L967" href="#L967">967</a> <strong class="jxr_keyword">catch</strong> (IllegalArgumentException e)
976 <a class="jxr_linenumber" name="L968" href="#L968">968</a> {
977 <a class="jxr_linenumber" name="L969" href="#L969">969</a> getLog().error(<span class="jxr_string">"Invalid value for configuration-option \"type\": "</span> + <strong class="jxr_keyword">this</strong>.type);
978 <a class="jxr_linenumber" name="L970" href="#L970">970</a> getLog().error(<span class="jxr_string">"Valid values are: NONE, CREATE, DROP, BOTH"</span>);
979 <a class="jxr_linenumber" name="L971" href="#L971">971</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(<span class="jxr_string">"Invalid value for configuration-option \"type\""</span>);
980 <a class="jxr_linenumber" name="L972" href="#L972">972</a> }
981 <a class="jxr_linenumber" name="L973" href="#L973">973</a>
982 <a class="jxr_linenumber" name="L974" href="#L974">974</a>
983 <a class="jxr_linenumber" name="L975" href="#L975">975</a> <strong class="jxr_keyword">if</strong> (config.getProperty(DIALECT) == <strong class="jxr_keyword">null</strong>)
984 <a class="jxr_linenumber" name="L976" href="#L976">976</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"hibernate-dialect must be set!"</span>);
985 <a class="jxr_linenumber" name="L977" href="#L977">977</a>
986 <a class="jxr_linenumber" name="L978" href="#L978">978</a>
987 <a class="jxr_linenumber" name="L979" href="#L979">979</a> <strong class="jxr_keyword">if</strong> (target.equals(Target.SCRIPT) || target.equals(Target.NONE))
988 <a class="jxr_linenumber" name="L980" href="#L980">980</a> {
989 <a class="jxr_linenumber" name="L981" href="#L981">981</a> project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, <span class="jxr_string">"true"</span>);
990 <a class="jxr_linenumber" name="L982" href="#L982">982</a> }
991 <a class="jxr_linenumber" name="L983" href="#L983">983</a> <strong class="jxr_keyword">if</strong> (
992 <a class="jxr_linenumber" name="L984" href="#L984">984</a> !modified
993 <a class="jxr_linenumber" name="L985" href="#L985">985</a> && !target.equals(Target.SCRIPT)
994 <a class="jxr_linenumber" name="L986" href="#L986">986</a> && !target.equals(Target.NONE)
995 <a class="jxr_linenumber" name="L987" href="#L987">987</a> && !force
996 <a class="jxr_linenumber" name="L988" href="#L988">988</a> )
997 <a class="jxr_linenumber" name="L989" href="#L989">989</a> {
998 <a class="jxr_linenumber" name="L990" href="#L990">990</a> getLog().info(<span class="jxr_string">"No modified annotated classes or mapping-files found and dialect unchanged."</span>);
999 <a class="jxr_linenumber" name="L991" href="#L991">991</a> getLog().info(<span class="jxr_string">"Skipping schema generation!"</span>);
1000 <a class="jxr_linenumber" name="L992" href="#L992">992</a> project.getProperties().setProperty(EXPORT_SKIPPED_PROPERTY, <span class="jxr_string">"true"</span>);
1001 <a class="jxr_linenumber" name="L993" href="#L993">993</a> <strong class="jxr_keyword">return</strong>;
1002 <a class="jxr_linenumber" name="L994" href="#L994">994</a> }
1003 <a class="jxr_linenumber" name="L995" href="#L995">995</a>
1004 <a class="jxr_linenumber" name="L996" href="#L996">996</a>
1005 <a class="jxr_linenumber" name="L997" href="#L997">997</a> <strong class="jxr_keyword">if</strong> ( config.getProperties().containsKey(NAMING_STRATEGY))
1006 <a class="jxr_linenumber" name="L998" href="#L998">998</a> {
1007 <a class="jxr_linenumber" name="L999" href="#L999">999</a> String namingStrategy = config.getProperty(NAMING_STRATEGY);
1008 <a class="jxr_linenumber" name="L1000" href="#L1000">1000</a> getLog().debug(<span class="jxr_string">"Explicitly set NamingStrategy: "</span> + namingStrategy);
1009 <a class="jxr_linenumber" name="L1001" href="#L1001">1001</a> <strong class="jxr_keyword">try</strong>
1010 <a class="jxr_linenumber" name="L1002" href="#L1002">1002</a> {
1011 <a class="jxr_linenumber" name="L1003" href="#L1003">1003</a> List runtimeClasspathElements = project.getRuntimeClasspathElements();
1012 <a class="jxr_linenumber" name="L1004" href="#L1004">1004</a> URL[] runtimeUrls = <strong class="jxr_keyword">new</strong> URL[runtimeClasspathElements.size()];
1013 <a class="jxr_linenumber" name="L1005" href="#L1005">1005</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i < runtimeClasspathElements.size(); i++)
1014 <a class="jxr_linenumber" name="L1006" href="#L1006">1006</a> {
1015 <a class="jxr_linenumber" name="L1007" href="#L1007">1007</a> String element = (String) runtimeClasspathElements.get(i);
1016 <a class="jxr_linenumber" name="L1008" href="#L1008">1008</a> runtimeUrls[i] = <strong class="jxr_keyword">new</strong> File(element).toURI().toURL();
1017 <a class="jxr_linenumber" name="L1009" href="#L1009">1009</a> }
1018 <a class="jxr_linenumber" name="L1010" href="#L1010">1010</a> URLClassLoader newLoader = <strong class="jxr_keyword">new</strong> URLClassLoader(
1019 <a class="jxr_linenumber" name="L1011" href="#L1011">1011</a> runtimeUrls,
1020 <a class="jxr_linenumber" name="L1012" href="#L1012">1012</a> Thread.currentThread().getContextClassLoader()
1021 <a class="jxr_linenumber" name="L1013" href="#L1013">1013</a> );
1022 <a class="jxr_linenumber" name="L1014" href="#L1014">1014</a> @SuppressWarnings(<span class="jxr_string">"unchecked"</span>)
1023 <a class="jxr_linenumber" name="L1015" href="#L1015">1015</a> Class<NamingStrategy> namingStrategyClass =
1024 <a class="jxr_linenumber" name="L1016" href="#L1016">1016</a> (Class<NamingStrategy>) newLoader.loadClass(namingStrategy);
1025 <a class="jxr_linenumber" name="L1017" href="#L1017">1017</a> config.setNamingStrategy(namingStrategyClass.newInstance());
1026 <a class="jxr_linenumber" name="L1018" href="#L1018">1018</a> }
1027 <a class="jxr_linenumber" name="L1019" href="#L1019">1019</a> <strong class="jxr_keyword">catch</strong> (Exception e)
1028 <a class="jxr_linenumber" name="L1020" href="#L1020">1020</a> {
1029 <a class="jxr_linenumber" name="L1021" href="#L1021">1021</a> getLog().error(<span class="jxr_string">"Error setting NamingStrategy"</span>, e);
1030 <a class="jxr_linenumber" name="L1022" href="#L1022">1022</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoExecutionException(e.getMessage());
1031 <a class="jxr_linenumber" name="L1023" href="#L1023">1023</a> }
1032 <a class="jxr_linenumber" name="L1024" href="#L1024">1024</a> }
1033 <a class="jxr_linenumber" name="L1025" href="#L1025">1025</a>
1034 <a class="jxr_linenumber" name="L1026" href="#L1026">1026</a>
1035 <a class="jxr_linenumber" name="L1027" href="#L1027">1027</a> Environment.verifyProperties(config.getProperties());
1036 <a class="jxr_linenumber" name="L1028" href="#L1028">1028</a> ConfigurationHelper.resolvePlaceHolders(config.getProperties());
1037 <a class="jxr_linenumber" name="L1029" href="#L1029">1029</a> registry =
1038 <a class="jxr_linenumber" name="L1030" href="#L1030">1030</a> (StandardServiceRegistryImpl)
1039 <a class="jxr_linenumber" name="L1031" href="#L1031">1031</a> <strong class="jxr_keyword">new</strong> StandardServiceRegistryBuilder()
1040 <a class="jxr_linenumber" name="L1032" href="#L1032">1032</a> .applySettings(config.getProperties())
1041 <a class="jxr_linenumber" name="L1033" href="#L1033">1033</a> .build();
1042 <a class="jxr_linenumber" name="L1034" href="#L1034">1034</a>
1043 <a class="jxr_linenumber" name="L1035" href="#L1035">1035</a> config.buildMappings();
1044 <a class="jxr_linenumber" name="L1036" href="#L1036">1036</a>
1045 <a class="jxr_linenumber" name="L1037" href="#L1037">1037</a> <strong class="jxr_keyword">if</strong> (envers)
1046 <a class="jxr_linenumber" name="L1038" href="#L1038">1038</a> {
1047 <a class="jxr_linenumber" name="L1039" href="#L1039">1039</a> getLog().info(<span class="jxr_string">"Automatic auditing via hibernate-envers enabled!"</span>);
1048 <a class="jxr_linenumber" name="L1040" href="#L1040">1040</a> AuditConfiguration.getFor(config);
1049 <a class="jxr_linenumber" name="L1041" href="#L1041">1041</a> }
1050 <a class="jxr_linenumber" name="L1042" href="#L1042">1042</a>
1051 <a class="jxr_linenumber" name="L1043" href="#L1043">1043</a> SchemaExport export = <strong class="jxr_keyword">new</strong> SchemaExport(registry, config);
1052 <a class="jxr_linenumber" name="L1044" href="#L1044">1044</a> export.setDelimiter(delimiter);
1053 <a class="jxr_linenumber" name="L1045" href="#L1045">1045</a> export.setFormat(format);
1054 <a class="jxr_linenumber" name="L1046" href="#L1046">1046</a>
1055 <a class="jxr_linenumber" name="L1047" href="#L1047">1047</a> File outF = <strong class="jxr_keyword">new</strong> File(outputFile);
1056 <a class="jxr_linenumber" name="L1048" href="#L1048">1048</a>
1057 <a class="jxr_linenumber" name="L1049" href="#L1049">1049</a> <strong class="jxr_keyword">if</strong> (!outF.isAbsolute())
1058 <a class="jxr_linenumber" name="L1050" href="#L1050">1050</a> {
1059 <a class="jxr_linenumber" name="L1051" href="#L1051">1051</a> <em class="jxr_comment">// Interpret relative file path relative to build directory</em>
1060 <a class="jxr_linenumber" name="L1052" href="#L1052">1052</a> outF = <strong class="jxr_keyword">new</strong> File(buildDirectory, outputFile);
1061 <a class="jxr_linenumber" name="L1053" href="#L1053">1053</a> getLog().info(<span class="jxr_string">"Adjusted relative path, resulting path is "</span> + outF.getPath());
1062 <a class="jxr_linenumber" name="L1054" href="#L1054">1054</a> }
1063 <a class="jxr_linenumber" name="L1055" href="#L1055">1055</a>
1064 <a class="jxr_linenumber" name="L1056" href="#L1056">1056</a> <em class="jxr_comment">// Ensure that directory path for specified file exists</em>
1065 <a class="jxr_linenumber" name="L1057" href="#L1057">1057</a> File outFileParentDir = outF.getParentFile();
1066 <a class="jxr_linenumber" name="L1058" href="#L1058">1058</a> <strong class="jxr_keyword">if</strong> (<strong class="jxr_keyword">null</strong> != outFileParentDir && !outFileParentDir.exists())
1067 <a class="jxr_linenumber" name="L1059" href="#L1059">1059</a> {
1068 <a class="jxr_linenumber" name="L1060" href="#L1060">1060</a> <strong class="jxr_keyword">try</strong>
1069 <a class="jxr_linenumber" name="L1061" href="#L1061">1061</a> {
1070 <a class="jxr_linenumber" name="L1062" href="#L1062">1062</a> getLog().info(<span class="jxr_string">"Creating directory path for output file:"</span> + outFileParentDir.getPath());
1071 <a class="jxr_linenumber" name="L1063" href="#L1063">1063</a> outFileParentDir.mkdirs();
1072 <a class="jxr_linenumber" name="L1064" href="#L1064">1064</a> }
1073 <a class="jxr_linenumber" name="L1065" href="#L1065">1065</a> <strong class="jxr_keyword">catch</strong> (Exception e)
1074 <a class="jxr_linenumber" name="L1066" href="#L1066">1066</a> {
1075 <a class="jxr_linenumber" name="L1067" href="#L1067">1067</a> getLog().error(<span class="jxr_string">"Error creating directory path for output file: "</span> + e.getLocalizedMessage());
1076 <a class="jxr_linenumber" name="L1068" href="#L1068">1068</a> }
1077 <a class="jxr_linenumber" name="L1069" href="#L1069">1069</a> }
1078 <a class="jxr_linenumber" name="L1070" href="#L1070">1070</a>
1079 <a class="jxr_linenumber" name="L1071" href="#L1071">1071</a> export.setOutputFile(outF.getPath());
1080 <a class="jxr_linenumber" name="L1072" href="#L1072">1072</a> export.execute(target, type);
1081 <a class="jxr_linenumber" name="L1073" href="#L1073">1073</a>
1082 <a class="jxr_linenumber" name="L1074" href="#L1074">1074</a> <strong class="jxr_keyword">for</strong> (Object exception : export.getExceptions())
1083 <a class="jxr_linenumber" name="L1075" href="#L1075">1075</a> getLog().debug(exception.toString());
1084 <a class="jxr_linenumber" name="L1076" href="#L1076">1076</a> }
1085 <a class="jxr_linenumber" name="L1077" href="#L1077">1077</a> <strong class="jxr_keyword">finally</strong>
1086 <a class="jxr_linenumber" name="L1078" href="#L1078">1078</a> {
1087 <a class="jxr_linenumber" name="L1079" href="#L1079">1079</a> <em class="jxr_javadoccomment">/** Stop Log-Capturing */</em>
1088 <a class="jxr_linenumber" name="L1080" href="#L1080">1080</a> MavenLogAppender.endPluginLog(<strong class="jxr_keyword">this</strong>);
1089 <a class="jxr_linenumber" name="L1081" href="#L1081">1081</a>
1090 <a class="jxr_linenumber" name="L1082" href="#L1082">1082</a> <em class="jxr_javadoccomment">/** Restore the old class-loader (TODO: is this really necessary?) */</em>
1091 <a class="jxr_linenumber" name="L1083" href="#L1083">1083</a> Thread.currentThread().setContextClassLoader(contextClassLoader);
1092 <a class="jxr_linenumber" name="L1084" href="#L1084">1084</a>
1093 <a class="jxr_linenumber" name="L1085" href="#L1085">1085</a> <strong class="jxr_keyword">if</strong> (registry != <strong class="jxr_keyword">null</strong>)
1094 <a class="jxr_linenumber" name="L1086" href="#L1086">1086</a> registry.destroy();
1095 <a class="jxr_linenumber" name="L1087" href="#L1087">1087</a> }
1096 <a class="jxr_linenumber" name="L1088" href="#L1088">1088</a>
1097 <a class="jxr_linenumber" name="L1089" href="#L1089">1089</a> <em class="jxr_javadoccomment">/** Write md5-sums for annotated classes to file */</em>
1098 <a class="jxr_linenumber" name="L1090" href="#L1090">1090</a> <strong class="jxr_keyword">try</strong>
1099 <a class="jxr_linenumber" name="L1091" href="#L1091">1091</a> {
1100 <a class="jxr_linenumber" name="L1092" href="#L1092">1092</a> FileOutputStream fos = <strong class="jxr_keyword">new</strong> FileOutputStream(saved);
1101 <a class="jxr_linenumber" name="L1093" href="#L1093">1093</a> ObjectOutputStream oos = <strong class="jxr_keyword">new</strong> ObjectOutputStream(fos);
1102 <a class="jxr_linenumber" name="L1094" href="#L1094">1094</a> oos.writeObject(md5s);
1103 <a class="jxr_linenumber" name="L1095" href="#L1095">1095</a> oos.close();
1104 <a class="jxr_linenumber" name="L1096" href="#L1096">1096</a> fos.close();
1105 <a class="jxr_linenumber" name="L1097" href="#L1097">1097</a> }
1106 <a class="jxr_linenumber" name="L1098" href="#L1098">1098</a> <strong class="jxr_keyword">catch</strong> (Exception e)
1107 <a class="jxr_linenumber" name="L1099" href="#L1099">1099</a> {
1108 <a class="jxr_linenumber" name="L1100" href="#L1100">1100</a> getLog().error(<span class="jxr_string">"Cannot write md5-sums to file: "</span> + e);
1109 <a class="jxr_linenumber" name="L1101" href="#L1101">1101</a> }
1110 <a class="jxr_linenumber" name="L1102" href="#L1102">1102</a> }
1111 <a class="jxr_linenumber" name="L1103" href="#L1103">1103</a>
1112 <a class="jxr_linenumber" name="L1104" href="#L1104">1104</a> <strong class="jxr_keyword">private</strong> ParsedPersistenceXmlDescriptor getPersistenceUnitDescriptor(
1113 <a class="jxr_linenumber" name="L1105" href="#L1105">1105</a> String name,
1114 <a class="jxr_linenumber" name="L1106" href="#L1106">1106</a> Properties properties,
1115 <a class="jxr_linenumber" name="L1107" href="#L1107">1107</a> ClassLoaderService loader
1116 <a class="jxr_linenumber" name="L1108" href="#L1108">1108</a> )
1117 <a class="jxr_linenumber" name="L1109" href="#L1109">1109</a> <strong class="jxr_keyword">throws</strong>
1118 <a class="jxr_linenumber" name="L1110" href="#L1110">1110</a> MojoFailureException
1119 <a class="jxr_linenumber" name="L1111" href="#L1111">1111</a> {
1120 <a class="jxr_linenumber" name="L1112" href="#L1112">1112</a> PersistenceXmlParser parser =
1121 <a class="jxr_linenumber" name="L1113" href="#L1113">1113</a> <strong class="jxr_keyword">new</strong> PersistenceXmlParser(
1122 <a class="jxr_linenumber" name="L1114" href="#L1114">1114</a> loader,
1123 <a class="jxr_linenumber" name="L1115" href="#L1115">1115</a> PersistenceUnitTransactionType.RESOURCE_LOCAL
1124 <a class="jxr_linenumber" name="L1116" href="#L1116">1116</a> );
1125 <a class="jxr_linenumber" name="L1117" href="#L1117">1117</a>
1126 <a class="jxr_linenumber" name="L1118" href="#L1118">1118</a> List<ParsedPersistenceXmlDescriptor> units = parser.doResolve(properties);
1127 <a class="jxr_linenumber" name="L1119" href="#L1119">1119</a>
1128 <a class="jxr_linenumber" name="L1120" href="#L1120">1120</a> <strong class="jxr_keyword">if</strong> (name == <strong class="jxr_keyword">null</strong>)
1129 <a class="jxr_linenumber" name="L1121" href="#L1121">1121</a> {
1130 <a class="jxr_linenumber" name="L1122" href="#L1122">1122</a> <strong class="jxr_keyword">switch</strong> (units.size())
1131 <a class="jxr_linenumber" name="L1123" href="#L1123">1123</a> {
1132 <a class="jxr_linenumber" name="L1124" href="#L1124">1124</a> <strong class="jxr_keyword">case</strong> 0:
1133 <a class="jxr_linenumber" name="L1125" href="#L1125">1125</a> getLog().info(<span class="jxr_string">"Found no META-INF/persistence.xml."</span>);
1134 <a class="jxr_linenumber" name="L1126" href="#L1126">1126</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
1135 <a class="jxr_linenumber" name="L1127" href="#L1127">1127</a> <strong class="jxr_keyword">case</strong> 1:
1136 <a class="jxr_linenumber" name="L1128" href="#L1128">1128</a> getLog().info(<span class="jxr_string">"Using persistence-unit "</span> + units.get(0).getName());
1137 <a class="jxr_linenumber" name="L1129" href="#L1129">1129</a> <strong class="jxr_keyword">return</strong> units.get(0);
1138 <a class="jxr_linenumber" name="L1130" href="#L1130">1130</a> <strong class="jxr_keyword">default</strong>:
1139 <a class="jxr_linenumber" name="L1131" href="#L1131">1131</a> getLog().warn(<span class="jxr_string">"No name provided and multiple persistence units found:"</span>);
1140 <a class="jxr_linenumber" name="L1132" href="#L1132">1132</a> <strong class="jxr_keyword">for</strong> (ParsedPersistenceXmlDescriptor unit : units)
1141 <a class="jxr_linenumber" name="L1133" href="#L1133">1133</a> getLog().warn(<span class="jxr_string">" - "</span> + unit.getName());
1142 <a class="jxr_linenumber" name="L1134" href="#L1134">1134</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
1143 <a class="jxr_linenumber" name="L1135" href="#L1135">1135</a> }
1144 <a class="jxr_linenumber" name="L1136" href="#L1136">1136</a>
1145 <a class="jxr_linenumber" name="L1137" href="#L1137">1137</a> }
1146 <a class="jxr_linenumber" name="L1138" href="#L1138">1138</a>
1147 <a class="jxr_linenumber" name="L1139" href="#L1139">1139</a> <strong class="jxr_keyword">for</strong> (ParsedPersistenceXmlDescriptor unit : units)
1148 <a class="jxr_linenumber" name="L1140" href="#L1140">1140</a> {
1149 <a class="jxr_linenumber" name="L1141" href="#L1141">1141</a> getLog().debug(<span class="jxr_string">"Found persistence-unit "</span> + unit.getName());
1150 <a class="jxr_linenumber" name="L1142" href="#L1142">1142</a> <strong class="jxr_keyword">if</strong> (!unit.getName().equals(name))
1151 <a class="jxr_linenumber" name="L1143" href="#L1143">1143</a> <strong class="jxr_keyword">continue</strong>;
1152 <a class="jxr_linenumber" name="L1144" href="#L1144">1144</a>
1153 <a class="jxr_linenumber" name="L1145" href="#L1145">1145</a> <em class="jxr_comment">// See if we (Hibernate) are the persistence provider</em>
1154 <a class="jxr_linenumber" name="L1146" href="#L1146">1146</a> <strong class="jxr_keyword">if</strong> (!ProviderChecker.isProvider(unit, properties))
1155 <a class="jxr_linenumber" name="L1147" href="#L1147">1147</a> {
1156 <a class="jxr_linenumber" name="L1148" href="#L1148">1148</a> getLog().debug(<span class="jxr_string">"Wrong provider: "</span> + unit.getProviderClassName());
1157 <a class="jxr_linenumber" name="L1149" href="#L1149">1149</a> <strong class="jxr_keyword">continue</strong>;
1158 <a class="jxr_linenumber" name="L1150" href="#L1150">1150</a> }
1159 <a class="jxr_linenumber" name="L1151" href="#L1151">1151</a>
1160 <a class="jxr_linenumber" name="L1152" href="#L1152">1152</a> getLog().info(<span class="jxr_string">"Using persistence-unit "</span> + unit.getName());
1161 <a class="jxr_linenumber" name="L1153" href="#L1153">1153</a> <strong class="jxr_keyword">return</strong> unit;
1162 <a class="jxr_linenumber" name="L1154" href="#L1154">1154</a> }
1163 <a class="jxr_linenumber" name="L1155" href="#L1155">1155</a>
1164 <a class="jxr_linenumber" name="L1156" href="#L1156">1156</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> MojoFailureException(<span class="jxr_string">"Could not find persistence-unit "</span> + name);
1165 <a class="jxr_linenumber" name="L1157" href="#L1157">1157</a> }
1166 <a class="jxr_linenumber" name="L1158" href="#L1158">1158</a>
1167 <a class="jxr_linenumber" name="L1159" href="#L1159">1159</a>
1168 <a class="jxr_linenumber" name="L1160" href="#L1160">1160</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../de/juplo/plugins/hibernate4/Hbm2DdlMojo.html">MavenProjectClassLoaderService</a> <strong class="jxr_keyword">implements</strong> ClassLoaderService
1169 <a class="jxr_linenumber" name="L1161" href="#L1161">1161</a> {
1170 <a class="jxr_linenumber" name="L1162" href="#L1162">1162</a> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">private</strong> ClassLoader loader;
1171 <a class="jxr_linenumber" name="L1163" href="#L1163">1163</a>
1172 <a class="jxr_linenumber" name="L1164" href="#L1164">1164</a>
1173 <a class="jxr_linenumber" name="L1165" href="#L1165">1165</a> <strong class="jxr_keyword">public</strong> <a href="../../../../de/juplo/plugins/hibernate4/Hbm2DdlMojo.html">MavenProjectClassLoaderService</a>(ClassLoader loader)
1174 <a class="jxr_linenumber" name="L1166" href="#L1166">1166</a> {
1175 <a class="jxr_linenumber" name="L1167" href="#L1167">1167</a> <strong class="jxr_keyword">this</strong>.loader = loader;
1176 <a class="jxr_linenumber" name="L1168" href="#L1168">1168</a> }
1177 <a class="jxr_linenumber" name="L1169" href="#L1169">1169</a>
1178 <a class="jxr_linenumber" name="L1170" href="#L1170">1170</a>
1179 <a class="jxr_linenumber" name="L1171" href="#L1171">1171</a> @Override
1180 <a class="jxr_linenumber" name="L1172" href="#L1172">1172</a> <strong class="jxr_keyword">public</strong> <T> Class<T> classForName(String name)
1181 <a class="jxr_linenumber" name="L1173" href="#L1173">1173</a> {
1182 <a class="jxr_linenumber" name="L1174" href="#L1174">1174</a> <strong class="jxr_keyword">try</strong>
1183 <a class="jxr_linenumber" name="L1175" href="#L1175">1175</a> {
1184 <a class="jxr_linenumber" name="L1176" href="#L1176">1176</a> <strong class="jxr_keyword">return</strong> (Class<T>)loader.loadClass(name);
1185 <a class="jxr_linenumber" name="L1177" href="#L1177">1177</a> }
1186 <a class="jxr_linenumber" name="L1178" href="#L1178">1178</a> <strong class="jxr_keyword">catch</strong> (ClassNotFoundException e)
1187 <a class="jxr_linenumber" name="L1179" href="#L1179">1179</a> {
1188 <a class="jxr_linenumber" name="L1180" href="#L1180">1180</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> ClassLoadingException( <span class="jxr_string">"Unable to load class ["</span> + name + <span class="jxr_string">"]"</span>, e );
1189 <a class="jxr_linenumber" name="L1181" href="#L1181">1181</a> }
1190 <a class="jxr_linenumber" name="L1182" href="#L1182">1182</a> }
1191 <a class="jxr_linenumber" name="L1183" href="#L1183">1183</a>
1192 <a class="jxr_linenumber" name="L1184" href="#L1184">1184</a> @Override
1193 <a class="jxr_linenumber" name="L1185" href="#L1185">1185</a> <strong class="jxr_keyword">public</strong> URL locateResource(String name)
1194 <a class="jxr_linenumber" name="L1186" href="#L1186">1186</a> {
1195 <a class="jxr_linenumber" name="L1187" href="#L1187">1187</a> <strong class="jxr_keyword">return</strong> loader.getResource(name);
1196 <a class="jxr_linenumber" name="L1188" href="#L1188">1188</a> }
1197 <a class="jxr_linenumber" name="L1189" href="#L1189">1189</a>
1198 <a class="jxr_linenumber" name="L1190" href="#L1190">1190</a> @Override
1199 <a class="jxr_linenumber" name="L1191" href="#L1191">1191</a> <strong class="jxr_keyword">public</strong> InputStream locateResourceStream(String name)
1200 <a class="jxr_linenumber" name="L1192" href="#L1192">1192</a> {
1201 <a class="jxr_linenumber" name="L1193" href="#L1193">1193</a> <strong class="jxr_keyword">return</strong> loader.getResourceAsStream(name);
1202 <a class="jxr_linenumber" name="L1194" href="#L1194">1194</a> }
1203 <a class="jxr_linenumber" name="L1195" href="#L1195">1195</a>
1204 <a class="jxr_linenumber" name="L1196" href="#L1196">1196</a> @Override
1205 <a class="jxr_linenumber" name="L1197" href="#L1197">1197</a> <strong class="jxr_keyword">public</strong> List<URL> locateResources(String name)
1206 <a class="jxr_linenumber" name="L1198" href="#L1198">1198</a> {
1207 <a class="jxr_linenumber" name="L1199" href="#L1199">1199</a> <strong class="jxr_keyword">try</strong>
1208 <a class="jxr_linenumber" name="L1200" href="#L1200">1200</a> {
1209 <a class="jxr_linenumber" name="L1201" href="#L1201">1201</a> <strong class="jxr_keyword">return</strong> Collections.list(loader.getResources(name));
1210 <a class="jxr_linenumber" name="L1202" href="#L1202">1202</a> }
1211 <a class="jxr_linenumber" name="L1203" href="#L1203">1203</a> <strong class="jxr_keyword">catch</strong> (IOException e)
1212 <a class="jxr_linenumber" name="L1204" href="#L1204">1204</a> {
1213 <a class="jxr_linenumber" name="L1205" href="#L1205">1205</a> <strong class="jxr_keyword">return</strong> Collections.EMPTY_LIST;
1214 <a class="jxr_linenumber" name="L1206" href="#L1206">1206</a> }
1215 <a class="jxr_linenumber" name="L1207" href="#L1207">1207</a> }
1216 <a class="jxr_linenumber" name="L1208" href="#L1208">1208</a>
1217 <a class="jxr_linenumber" name="L1209" href="#L1209">1209</a> @Override
1218 <a class="jxr_linenumber" name="L1210" href="#L1210">1210</a> <strong class="jxr_keyword">public</strong> <S> LinkedHashSet<S> loadJavaServices(Class<S> serviceContract)
1219 <a class="jxr_linenumber" name="L1211" href="#L1211">1211</a> {
1220 <a class="jxr_linenumber" name="L1212" href="#L1212">1212</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> UnsupportedOperationException(<span class="jxr_string">"Not supported yet."</span>); <em class="jxr_comment">//To change body of generated methods, choose Tools | Templates.</em>
1221 <a class="jxr_linenumber" name="L1213" href="#L1213">1213</a> }
1222 <a class="jxr_linenumber" name="L1214" href="#L1214">1214</a>
1223 <a class="jxr_linenumber" name="L1215" href="#L1215">1215</a> @Override
1224 <a class="jxr_linenumber" name="L1216" href="#L1216">1216</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> stop() { }
1225 <a class="jxr_linenumber" name="L1217" href="#L1217">1217</a>
1226 <a class="jxr_linenumber" name="L1218" href="#L1218">1218</a> }
1227 <a class="jxr_linenumber" name="L1219" href="#L1219">1219</a>
1228 <a class="jxr_linenumber" name="L1220" href="#L1220">1220</a>
1229 <a class="jxr_linenumber" name="L1221" href="#L1221">1221</a> <em class="jxr_javadoccomment">/**</em>
1230 <a class="jxr_linenumber" name="L1222" href="#L1222">1222</a> <em class="jxr_javadoccomment"> * Needed, because DriverManager won't pick up drivers, that were not</em>
1231 <a class="jxr_linenumber" name="L1223" href="#L1223">1223</a> <em class="jxr_javadoccomment"> * loaded by the system-classloader!</em>
1232 <a class="jxr_linenumber" name="L1224" href="#L1224">1224</a> <em class="jxr_javadoccomment"> * See:</em>
1233 <a class="jxr_linenumber" name="L1225" href="#L1225">1225</a> <em class="jxr_javadoccomment"> * <a href="http://stackoverflow.com/questions/288828/how-to-use-a-jdbc-driver-fromodifiedm-an-arbitrary-locatio" target="alexandria_uri">http://stackoverflow.com/questions/288828/how-to-use-a-jdbc-driver-fromodifiedm-an-arbitrary-locatio</a>n</em>
1234 <a class="jxr_linenumber" name="L1226" href="#L1226">1226</a> <em class="jxr_javadoccomment"> */</em>
1235 <a class="jxr_linenumber" name="L1227" href="#L1227">1227</a> <strong class="jxr_keyword">static</strong> <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../de/juplo/plugins/hibernate4/Hbm2DdlMojo.html">DriverProxy</a> <strong class="jxr_keyword">implements</strong> Driver
1236 <a class="jxr_linenumber" name="L1228" href="#L1228">1228</a> {
1237 <a class="jxr_linenumber" name="L1229" href="#L1229">1229</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">final</strong> Driver target;
1238 <a class="jxr_linenumber" name="L1230" href="#L1230">1230</a>
1239 <a class="jxr_linenumber" name="L1231" href="#L1231">1231</a> <a href="../../../../de/juplo/plugins/hibernate4/Hbm2DdlMojo.html">DriverProxy</a>(Driver target)
1240 <a class="jxr_linenumber" name="L1232" href="#L1232">1232</a> {
1241 <a class="jxr_linenumber" name="L1233" href="#L1233">1233</a> <strong class="jxr_keyword">if</strong> (target == <strong class="jxr_keyword">null</strong>)
1242 <a class="jxr_linenumber" name="L1234" href="#L1234">1234</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> NullPointerException();
1243 <a class="jxr_linenumber" name="L1235" href="#L1235">1235</a> <strong class="jxr_keyword">this</strong>.target = target;
1244 <a class="jxr_linenumber" name="L1236" href="#L1236">1236</a> }
1245 <a class="jxr_linenumber" name="L1237" href="#L1237">1237</a>
1246 <a class="jxr_linenumber" name="L1238" href="#L1238">1238</a> <strong class="jxr_keyword">public</strong> java.sql.Driver getTarget()
1247 <a class="jxr_linenumber" name="L1239" href="#L1239">1239</a> {
1248 <a class="jxr_linenumber" name="L1240" href="#L1240">1240</a> <strong class="jxr_keyword">return</strong> target;
1249 <a class="jxr_linenumber" name="L1241" href="#L1241">1241</a> }
1250 <a class="jxr_linenumber" name="L1242" href="#L1242">1242</a>
1251 <a class="jxr_linenumber" name="L1243" href="#L1243">1243</a> @Override
1252 <a class="jxr_linenumber" name="L1244" href="#L1244">1244</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> acceptsURL(String url) <strong class="jxr_keyword">throws</strong> SQLException
1253 <a class="jxr_linenumber" name="L1245" href="#L1245">1245</a> {
1254 <a class="jxr_linenumber" name="L1246" href="#L1246">1246</a> <strong class="jxr_keyword">return</strong> target.acceptsURL(url);
1255 <a class="jxr_linenumber" name="L1247" href="#L1247">1247</a> }
1256 <a class="jxr_linenumber" name="L1248" href="#L1248">1248</a>
1257 <a class="jxr_linenumber" name="L1249" href="#L1249">1249</a> @Override
1258 <a class="jxr_linenumber" name="L1250" href="#L1250">1250</a> <strong class="jxr_keyword">public</strong> java.sql.Connection connect(
1259 <a class="jxr_linenumber" name="L1251" href="#L1251">1251</a> String url,
1260 <a class="jxr_linenumber" name="L1252" href="#L1252">1252</a> java.util.Properties info
1261 <a class="jxr_linenumber" name="L1253" href="#L1253">1253</a> )
1262 <a class="jxr_linenumber" name="L1254" href="#L1254">1254</a> <strong class="jxr_keyword">throws</strong>
1263 <a class="jxr_linenumber" name="L1255" href="#L1255">1255</a> SQLException
1264 <a class="jxr_linenumber" name="L1256" href="#L1256">1256</a> {
1265 <a class="jxr_linenumber" name="L1257" href="#L1257">1257</a> <strong class="jxr_keyword">return</strong> target.connect(url, info);
1266 <a class="jxr_linenumber" name="L1258" href="#L1258">1258</a> }
1267 <a class="jxr_linenumber" name="L1259" href="#L1259">1259</a>
1268 <a class="jxr_linenumber" name="L1260" href="#L1260">1260</a> @Override
1269 <a class="jxr_linenumber" name="L1261" href="#L1261">1261</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> getMajorVersion()
1270 <a class="jxr_linenumber" name="L1262" href="#L1262">1262</a> {
1271 <a class="jxr_linenumber" name="L1263" href="#L1263">1263</a> <strong class="jxr_keyword">return</strong> target.getMajorVersion();
1272 <a class="jxr_linenumber" name="L1264" href="#L1264">1264</a> }
1273 <a class="jxr_linenumber" name="L1265" href="#L1265">1265</a>
1274 <a class="jxr_linenumber" name="L1266" href="#L1266">1266</a> @Override
1275 <a class="jxr_linenumber" name="L1267" href="#L1267">1267</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> getMinorVersion()
1276 <a class="jxr_linenumber" name="L1268" href="#L1268">1268</a> {
1277 <a class="jxr_linenumber" name="L1269" href="#L1269">1269</a> <strong class="jxr_keyword">return</strong> target.getMinorVersion();
1278 <a class="jxr_linenumber" name="L1270" href="#L1270">1270</a> }
1279 <a class="jxr_linenumber" name="L1271" href="#L1271">1271</a>
1280 <a class="jxr_linenumber" name="L1272" href="#L1272">1272</a> @Override
1281 <a class="jxr_linenumber" name="L1273" href="#L1273">1273</a> <strong class="jxr_keyword">public</strong> DriverPropertyInfo[] getPropertyInfo(
1282 <a class="jxr_linenumber" name="L1274" href="#L1274">1274</a> String url,
1283 <a class="jxr_linenumber" name="L1275" href="#L1275">1275</a> Properties info
1284 <a class="jxr_linenumber" name="L1276" href="#L1276">1276</a> )
1285 <a class="jxr_linenumber" name="L1277" href="#L1277">1277</a> <strong class="jxr_keyword">throws</strong>
1286 <a class="jxr_linenumber" name="L1278" href="#L1278">1278</a> SQLException
1287 <a class="jxr_linenumber" name="L1279" href="#L1279">1279</a> {
1288 <a class="jxr_linenumber" name="L1280" href="#L1280">1280</a> <strong class="jxr_keyword">return</strong> target.getPropertyInfo(url, info);
1289 <a class="jxr_linenumber" name="L1281" href="#L1281">1281</a> }
1290 <a class="jxr_linenumber" name="L1282" href="#L1282">1282</a>
1291 <a class="jxr_linenumber" name="L1283" href="#L1283">1283</a> @Override
1292 <a class="jxr_linenumber" name="L1284" href="#L1284">1284</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> jdbcCompliant()
1293 <a class="jxr_linenumber" name="L1285" href="#L1285">1285</a> {
1294 <a class="jxr_linenumber" name="L1286" href="#L1286">1286</a> <strong class="jxr_keyword">return</strong> target.jdbcCompliant();
1295 <a class="jxr_linenumber" name="L1287" href="#L1287">1287</a> }
1296 <a class="jxr_linenumber" name="L1288" href="#L1288">1288</a>
1297 <a class="jxr_linenumber" name="L1289" href="#L1289">1289</a> <em class="jxr_javadoccomment">/**</em>
1298 <a class="jxr_linenumber" name="L1290" href="#L1290">1290</a> <em class="jxr_javadoccomment"> * This Method cannot be annotated with @Override, becaus the plugin</em>
1299 <a class="jxr_linenumber" name="L1291" href="#L1291">1291</a> <em class="jxr_javadoccomment"> * will not compile then under Java 1.6!</em>
1300 <a class="jxr_linenumber" name="L1292" href="#L1292">1292</a> <em class="jxr_javadoccomment"> */</em>
1301 <a class="jxr_linenumber" name="L1293" href="#L1293">1293</a> <strong class="jxr_keyword">public</strong> Logger getParentLogger() <strong class="jxr_keyword">throws</strong> SQLFeatureNotSupportedException
1302 <a class="jxr_linenumber" name="L1294" href="#L1294">1294</a> {
1303 <a class="jxr_linenumber" name="L1295" href="#L1295">1295</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> SQLFeatureNotSupportedException(<span class="jxr_string">"Not supported, for backward-compatibility with Java 1.6"</span>);
1304 <a class="jxr_linenumber" name="L1296" href="#L1296">1296</a> }
1305 <a class="jxr_linenumber" name="L1297" href="#L1297">1297</a>
1306 <a class="jxr_linenumber" name="L1298" href="#L1298">1298</a> @Override
1307 <a class="jxr_linenumber" name="L1299" href="#L1299">1299</a> <strong class="jxr_keyword">public</strong> String toString()
1308 <a class="jxr_linenumber" name="L1300" href="#L1300">1300</a> {
1309 <a class="jxr_linenumber" name="L1301" href="#L1301">1301</a> <strong class="jxr_keyword">return</strong> <span class="jxr_string">"Proxy: "</span> + target;
1310 <a class="jxr_linenumber" name="L1302" href="#L1302">1302</a> }
1311 <a class="jxr_linenumber" name="L1303" href="#L1303">1303</a>
1312 <a class="jxr_linenumber" name="L1304" href="#L1304">1304</a> @Override
1313 <a class="jxr_linenumber" name="L1305" href="#L1305">1305</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> hashCode()
1314 <a class="jxr_linenumber" name="L1306" href="#L1306">1306</a> {
1315 <a class="jxr_linenumber" name="L1307" href="#L1307">1307</a> <strong class="jxr_keyword">return</strong> target.hashCode();
1316 <a class="jxr_linenumber" name="L1308" href="#L1308">1308</a> }
1317 <a class="jxr_linenumber" name="L1309" href="#L1309">1309</a>
1318 <a class="jxr_linenumber" name="L1310" href="#L1310">1310</a> @Override
1319 <a class="jxr_linenumber" name="L1311" href="#L1311">1311</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> equals(Object obj)
1320 <a class="jxr_linenumber" name="L1312" href="#L1312">1312</a> {
1321 <a class="jxr_linenumber" name="L1313" href="#L1313">1313</a> <strong class="jxr_keyword">if</strong> (!(obj instanceof DriverProxy))
1322 <a class="jxr_linenumber" name="L1314" href="#L1314">1314</a> <strong class="jxr_keyword">return</strong> false;
1323 <a class="jxr_linenumber" name="L1315" href="#L1315">1315</a> <a href="../../../../de/juplo/plugins/hibernate4/Hbm2DdlMojo.html">DriverProxy</a> other = (DriverProxy) obj;
1324 <a class="jxr_linenumber" name="L1316" href="#L1316">1316</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.target.equals(other.target);
1325 <a class="jxr_linenumber" name="L1317" href="#L1317">1317</a> }
1326 <a class="jxr_linenumber" name="L1318" href="#L1318">1318</a> }
1327 <a class="jxr_linenumber" name="L1319" href="#L1319">1319</a> }
1330 <div id="footer">Copyright © 2016. All rights reserved.</div>