1 | // SECTION-START[License Header] |
2 | // <editor-fold defaultstate="collapsed" desc=" Generated License "> |
3 | /* |
4 | * Copyright (c) 2010 The JOMC Project |
5 | * Copyright (c) 2005 Christian Schulte <cs@jomc.org> |
6 | * All rights reserved. |
7 | * |
8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions |
10 | * are met: |
11 | * |
12 | * o Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. |
14 | * |
15 | * o Redistributions in binary form must reproduce the above copyright |
16 | * notice, this list of conditions and the following disclaimer in |
17 | * the documentation and/or other materials provided with the |
18 | * distribution. |
19 | * |
20 | * THIS SOFTWARE IS PROVIDED BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS" |
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR |
24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
30 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | * |
32 | * $Id: AbstractJomcCommand.java 1452 2010-02-02 05:35:30Z schulte2005 $ |
33 | * |
34 | */ |
35 | // </editor-fold> |
36 | // SECTION-END |
37 | package org.jomc.cli.commands; |
38 | |
39 | import java.io.BufferedReader; |
40 | import java.io.File; |
41 | import java.io.FileInputStream; |
42 | import java.io.FileReader; |
43 | import java.io.IOException; |
44 | import java.io.InputStream; |
45 | import java.io.StringWriter; |
46 | import java.net.URI; |
47 | import java.net.URL; |
48 | import java.net.URLClassLoader; |
49 | import java.util.HashSet; |
50 | import java.util.LinkedList; |
51 | import java.util.List; |
52 | import java.util.Locale; |
53 | import java.util.Set; |
54 | import java.util.logging.Level; |
55 | import javax.xml.bind.JAXBElement; |
56 | import javax.xml.bind.JAXBException; |
57 | import javax.xml.bind.Marshaller; |
58 | import javax.xml.bind.Unmarshaller; |
59 | import javax.xml.transform.stream.StreamSource; |
60 | import org.apache.commons.cli.CommandLine; |
61 | import org.apache.commons.cli.Options; |
62 | import org.jomc.cli.Command; |
63 | import org.jomc.model.DefaultModelProcessor; |
64 | import org.jomc.model.DefaultModelProvider; |
65 | import org.jomc.model.ModelContext; |
66 | import org.jomc.model.ModelException; |
67 | import org.jomc.model.Module; |
68 | import org.jomc.model.Modules; |
69 | import org.jomc.tools.JomcTool; |
70 | import org.jomc.model.ModelValidationReport; |
71 | import org.jomc.model.bootstrap.DefaultSchemaProvider; |
72 | import org.jomc.model.bootstrap.DefaultServiceProvider; |
73 | import org.jomc.tools.JavaBundles; |
74 | import org.jomc.tools.JavaClasses; |
75 | import org.jomc.tools.JavaSources; |
76 | import org.xml.sax.SAXException; |
77 | |
78 | // SECTION-START[Documentation] |
79 | // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> |
80 | /** |
81 | * Base JOMC {@code Command} implementation. |
82 | * <p><b>Specifications</b><ul> |
83 | * <li>{@code org.jomc.cli.Command} {@code 1.0} {@code Multiton}</li> |
84 | * </ul></p> |
85 | * <p><b>Properties</b><ul> |
86 | * <li>"{@link #getAbbreviatedCommandName abbreviatedCommandName}" |
87 | * <blockquote>Property of type {@code java.lang.String}. |
88 | * <p>Abbreviated name of the command.</p> |
89 | * </blockquote></li> |
90 | * <li>"{@link #getCommandName commandName}" |
91 | * <blockquote>Property of type {@code java.lang.String}. |
92 | * <p>Name of the command.</p> |
93 | * </blockquote></li> |
94 | * </ul></p> |
95 | * <p><b>Dependencies</b><ul> |
96 | * <li>"{@link #getClasspathOption ClasspathOption}"<blockquote> |
97 | * Dependency on {@code org.apache.commons.cli.Option} bound to an instance.</blockquote></li> |
98 | * <li>"{@link #getDocumentsOption DocumentsOption}"<blockquote> |
99 | * Dependency on {@code org.apache.commons.cli.Option} bound to an instance.</blockquote></li> |
100 | * <li>"{@link #getLocale Locale}"<blockquote> |
101 | * Dependency on {@code java.util.Locale} at specification level 1.1 bound to an instance.</blockquote></li> |
102 | * <li>"{@link #getModuleLocationOption ModuleLocationOption}"<blockquote> |
103 | * Dependency on {@code org.apache.commons.cli.Option} bound to an instance.</blockquote></li> |
104 | * <li>"{@link #getModuleNameOption ModuleNameOption}"<blockquote> |
105 | * Dependency on {@code org.apache.commons.cli.Option} bound to an instance.</blockquote></li> |
106 | * <li>"{@link #getNoClasspathResolutionOption NoClasspathResolutionOption}"<blockquote> |
107 | * Dependency on {@code org.apache.commons.cli.Option} bound to an instance.</blockquote></li> |
108 | * <li>"{@link #getNoModelProcessingOption NoModelProcessingOption}"<blockquote> |
109 | * Dependency on {@code org.apache.commons.cli.Option} bound to an instance.</blockquote></li> |
110 | * <li>"{@link #getSchemaLocationOption SchemaLocationOption}"<blockquote> |
111 | * Dependency on {@code org.apache.commons.cli.Option} bound to an instance.</blockquote></li> |
112 | * <li>"{@link #getServiceLocationOption ServiceLocationOption}"<blockquote> |
113 | * Dependency on {@code org.apache.commons.cli.Option} bound to an instance.</blockquote></li> |
114 | * <li>"{@link #getTransformerLocationOption TransformerLocationOption}"<blockquote> |
115 | * Dependency on {@code org.apache.commons.cli.Option} bound to an instance.</blockquote></li> |
116 | * </ul></p> |
117 | * <p><b>Messages</b><ul> |
118 | * <li>"{@link #getApplicationTitleMessage applicationTitle}"<table> |
119 | * <tr><td valign="top">English:</td><td valign="top"><pre>JOMC Version 1.0-alpha-16 Build 2010-02-02T05:28:08+0000</pre></td></tr> |
120 | * </table> |
121 | * <li>"{@link #getCannotProcessMessage cannotProcess}"<table> |
122 | * <tr><td valign="top">English:</td><td valign="top"><pre>Cannot process ''{0}'': {1}</pre></td></tr> |
123 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Kann ''{0}'' nicht verarbeiten: {1}</pre></td></tr> |
124 | * </table> |
125 | * <li>"{@link #getClasspathElementMessage classpathElement}"<table> |
126 | * <tr><td valign="top">English:</td><td valign="top"><pre>Classpath element: ''{0}''</pre></td></tr> |
127 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Klassenpfad-Element: ''{0}''</pre></td></tr> |
128 | * </table> |
129 | * <li>"{@link #getDefaultLogLevelInfoMessage defaultLogLevelInfo}"<table> |
130 | * <tr><td valign="top">English:</td><td valign="top"><pre>Default log level: ''{0}''</pre></td></tr> |
131 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Standard-Protokollierungsstufe: ''{0}''</pre></td></tr> |
132 | * </table> |
133 | * <li>"{@link #getDocumentFileMessage documentFile}"<table> |
134 | * <tr><td valign="top">English:</td><td valign="top"><pre>Document file: ''{0}''</pre></td></tr> |
135 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Dokument-Datei: ''{0}''</pre></td></tr> |
136 | * </table> |
137 | * <li>"{@link #getInvalidModelMessage invalidModel}"<table> |
138 | * <tr><td valign="top">English:</td><td valign="top"><pre>Invalid model.</pre></td></tr> |
139 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Ungültiges Modell.</pre></td></tr> |
140 | * </table> |
141 | * <li>"{@link #getLongDescriptionMessage longDescription}"<table> |
142 | * <tr><td valign="top">English:</td><td valign="top"><pre></pre></td></tr> |
143 | * </table> |
144 | * <li>"{@link #getMissingModuleMessage missingModule}"<table> |
145 | * <tr><td valign="top">English:</td><td valign="top"><pre>Module ''{0}'' not found.</pre></td></tr> |
146 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Modul ''{0}'' nicht gefunden.</pre></td></tr> |
147 | * </table> |
148 | * <li>"{@link #getModulesReportMessage modulesReport}"<table> |
149 | * <tr><td valign="top">English:</td><td valign="top"><pre>Modules</pre></td></tr> |
150 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Module</pre></td></tr> |
151 | * </table> |
152 | * <li>"{@link #getSeparatorMessage separator}"<table> |
153 | * <tr><td valign="top">English:</td><td valign="top"><pre>--------------------------------------------------------------------------------</pre></td></tr> |
154 | * </table> |
155 | * <li>"{@link #getShortDescriptionMessage shortDescription}"<table> |
156 | * <tr><td valign="top">English:</td><td valign="top"><pre></pre></td></tr> |
157 | * </table> |
158 | * <li>"{@link #getStartingModuleProcessingMessage startingModuleProcessing}"<table> |
159 | * <tr><td valign="top">English:</td><td valign="top"><pre>Executing command {0} with module ''{1}'' ...</pre></td></tr> |
160 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Führt Befehl {0} mit Modul ''{1}'' aus ... </pre></td></tr> |
161 | * </table> |
162 | * <li>"{@link #getStartingProcessingMessage startingProcessing}"<table> |
163 | * <tr><td valign="top">English:</td><td valign="top"><pre>Executing command {0} ...</pre></td></tr> |
164 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Führt Befehl {0} aus ... </pre></td></tr> |
165 | * </table> |
166 | * <li>"{@link #getToolFailureMessage toolFailure}"<table> |
167 | * <tr><td valign="top">English:</td><td valign="top"><pre>{0} failure.</pre></td></tr> |
168 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>{0} fehlgeschlagen.</pre></td></tr> |
169 | * </table> |
170 | * <li>"{@link #getToolSuccessMessage toolSuccess}"<table> |
171 | * <tr><td valign="top">English:</td><td valign="top"><pre>{0} successful.</pre></td></tr> |
172 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>{0} erfolgreich.</pre></td></tr> |
173 | * </table> |
174 | * </ul></p> |
175 | * |
176 | * @author <a href="mailto:cs@jomc.org">Christian Schulte</a> 1.0 |
177 | * @version $Id: AbstractJomcCommand.java 1452 2010-02-02 05:35:30Z schulte2005 $ |
178 | */ |
179 | // </editor-fold> |
180 | // SECTION-END |
181 | // SECTION-START[Annotations] |
182 | // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> |
183 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
184 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
185 | // </editor-fold> |
186 | // SECTION-END |
187 | public abstract class AbstractJomcCommand implements Command |
188 | { |
189 | // SECTION-START[AbstractJomcCommand] |
190 | |
191 | /** |
192 | * Log level events are logged at by default. |
193 | * @see #getDefaultLogLevel() |
194 | */ |
195 | private static final Level DEFAULT_LOG_LEVEL = Level.WARNING; |
196 | |
197 | /** Default log level. */ |
198 | private static volatile Level defaultLogLevel; |
199 | |
200 | /** The {@code JavaBundles} tool of the instance. */ |
201 | private JavaBundles javaBundles; |
202 | |
203 | /** The {@code JavaClasses} tool of the instance. */ |
204 | private JavaClasses javaClasses; |
205 | |
206 | /** The {@code JavaSources} tool of the instance. */ |
207 | private JavaSources javaSources; |
208 | |
209 | /** The listeners of the instance. */ |
210 | private List<Listener> listeners; |
211 | |
212 | /** Log level of the instance. */ |
213 | private Level logLevel; |
214 | |
215 | /** |
216 | * Gets the list of registered listeners. |
217 | * <p>This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make |
218 | * to the returned list will be present inside the object. This is why there is no {@code set} method for the |
219 | * listeners property.</p> |
220 | * |
221 | * @return The list of registered listeners. |
222 | * |
223 | * @see #log(java.util.logging.Level, java.lang.String, java.lang.Throwable) |
224 | */ |
225 | public List<Listener> getListeners() |
226 | { |
227 | if ( this.listeners == null ) |
228 | { |
229 | this.listeners = new LinkedList<Listener>(); |
230 | } |
231 | |
232 | return this.listeners; |
233 | } |
234 | |
235 | /** |
236 | * Gets the default log level events are logged at. |
237 | * <p>The default log level is controlled by system property |
238 | * {@code org.jomc.cli.command.AbstractJomcCommand.defaultLogLevel} holding the log level to log events at by |
239 | * default. If that property is not set, the {@code WARNING} default is returned.</p> |
240 | * |
241 | * @return The log level events are logged at by default. |
242 | * |
243 | * @see #getLogLevel() |
244 | * @see Level#parse(java.lang.String) |
245 | */ |
246 | public static Level getDefaultLogLevel() |
247 | { |
248 | if ( defaultLogLevel == null ) |
249 | { |
250 | defaultLogLevel = Level.parse( System.getProperty( |
251 | "org.jomc.cli.command.AbstractJomcCommand.defaultLogLevel", DEFAULT_LOG_LEVEL.getName() ) ); |
252 | |
253 | } |
254 | |
255 | return defaultLogLevel; |
256 | } |
257 | |
258 | /** |
259 | * Sets the default log level events are logged at. |
260 | * |
261 | * @param value The new default level events are logged at or {@code null}. |
262 | * |
263 | * @see #getDefaultLogLevel() |
264 | */ |
265 | public static void setDefaultLogLevel( final Level value ) |
266 | { |
267 | defaultLogLevel = value; |
268 | } |
269 | |
270 | /** |
271 | * Gets the log level of the instance. |
272 | * |
273 | * @return The log level of the instance. |
274 | * |
275 | * @see #getDefaultLogLevel() |
276 | * @see #setLogLevel(java.util.logging.Level) |
277 | * @see #isLoggable(java.util.logging.Level) |
278 | */ |
279 | public Level getLogLevel() |
280 | { |
281 | if ( this.logLevel == null ) |
282 | { |
283 | this.logLevel = getDefaultLogLevel(); |
284 | this.log( Level.CONFIG, this.getDefaultLogLevelInfoMessage( |
285 | this.getLocale(), this.logLevel.getLocalizedName() ), null ); |
286 | |
287 | } |
288 | |
289 | return this.logLevel; |
290 | } |
291 | |
292 | /** |
293 | * Sets the log level of the instance. |
294 | * |
295 | * @param value The new log level of the instance or {@code null}. |
296 | * |
297 | * @see #getLogLevel() |
298 | * @see #isLoggable(java.util.logging.Level) |
299 | */ |
300 | public void setLogLevel( final Level value ) |
301 | { |
302 | this.logLevel = value; |
303 | } |
304 | |
305 | public String getName() |
306 | { |
307 | return this.getCommandName(); |
308 | } |
309 | |
310 | public String getAbbreviatedName() |
311 | { |
312 | return this.getAbbreviatedCommandName(); |
313 | } |
314 | |
315 | public String getShortDescription( final Locale locale ) |
316 | { |
317 | return this.getShortDescriptionMessage( locale ); |
318 | } |
319 | |
320 | public String getLongDescription( final Locale locale ) |
321 | { |
322 | return this.getLongDescriptionMessage( locale ); |
323 | } |
324 | |
325 | public Options getOptions() |
326 | { |
327 | final Options options = new Options(); |
328 | options.addOption( this.getClasspathOption() ); |
329 | options.addOption( this.getDocumentsOption() ); |
330 | options.addOption( this.getModuleLocationOption() ); |
331 | options.addOption( this.getSchemaLocationOption() ); |
332 | options.addOption( this.getServiceLocationOption() ); |
333 | options.addOption( this.getTransformerLocationOption() ); |
334 | options.addOption( this.getModuleNameOption() ); |
335 | options.addOption( this.getNoClasspathResolutionOption() ); |
336 | options.addOption( this.getNoModelProcessingOption() ); |
337 | return options; |
338 | } |
339 | |
340 | public final int execute( final CommandLine commandLine ) |
341 | { |
342 | try |
343 | { |
344 | if ( commandLine.hasOption( this.getSchemaLocationOption().getOpt() ) ) |
345 | { |
346 | DefaultSchemaProvider.setDefaultSchemaLocation( |
347 | commandLine.getOptionValue( this.getSchemaLocationOption().getOpt() ) ); |
348 | |
349 | } |
350 | else |
351 | { |
352 | DefaultSchemaProvider.setDefaultSchemaLocation( null ); |
353 | } |
354 | |
355 | if ( commandLine.hasOption( this.getServiceLocationOption().getOpt() ) ) |
356 | { |
357 | DefaultServiceProvider.setDefaultServiceLocation( |
358 | commandLine.getOptionValue( this.getServiceLocationOption().getOpt() ) ); |
359 | |
360 | } |
361 | else |
362 | { |
363 | DefaultServiceProvider.setDefaultServiceLocation( null ); |
364 | } |
365 | |
366 | if ( commandLine.hasOption( this.getTransformerLocationOption().getOpt() ) ) |
367 | { |
368 | DefaultModelProcessor.setDefaultTransformerLocation( |
369 | commandLine.getOptionValue( this.getTransformerLocationOption().getOpt() ) ); |
370 | |
371 | } |
372 | else |
373 | { |
374 | DefaultModelProcessor.setDefaultTransformerLocation( null ); |
375 | } |
376 | |
377 | if ( commandLine.hasOption( this.getModuleLocationOption().getOpt() ) ) |
378 | { |
379 | DefaultModelProvider.setDefaultModuleLocation( |
380 | commandLine.getOptionValue( this.getModuleLocationOption().getOpt() ) ); |
381 | |
382 | } |
383 | else |
384 | { |
385 | DefaultModelProvider.setDefaultModuleLocation( null ); |
386 | } |
387 | |
388 | if ( this.isLoggable( Level.INFO ) ) |
389 | { |
390 | this.log( Level.INFO, this.getSeparatorMessage( this.getLocale() ), null ); |
391 | this.log( Level.INFO, this.getApplicationTitleMessage( this.getLocale() ), null ); |
392 | this.log( Level.INFO, this.getSeparatorMessage( this.getLocale() ), null ); |
393 | } |
394 | |
395 | final int status = this.executeCommand( commandLine ); |
396 | |
397 | if ( this.isLoggable( Level.INFO ) ) |
398 | { |
399 | if ( status == Command.STATUS_SUCCESS ) |
400 | { |
401 | this.log( Level.INFO, this.getToolSuccessMessage( this.getLocale(), this.getCommandName() ), null ); |
402 | } |
403 | else |
404 | { |
405 | this.log( Level.INFO, this.getToolFailureMessage( this.getLocale(), this.getCommandName() ), null ); |
406 | |
407 | } |
408 | |
409 | this.log( Level.INFO, this.getSeparatorMessage( this.getLocale() ), null ); |
410 | } |
411 | |
412 | return status; |
413 | } |
414 | catch ( final Throwable t ) |
415 | { |
416 | this.log( Level.SEVERE, t.getMessage(), t ); |
417 | return Command.STATUS_FAILURE; |
418 | } |
419 | finally |
420 | { |
421 | DefaultSchemaProvider.setDefaultSchemaLocation( null ); |
422 | DefaultServiceProvider.setDefaultServiceLocation( null ); |
423 | DefaultModelProcessor.setDefaultTransformerLocation( null ); |
424 | DefaultModelProvider.setDefaultModuleLocation( null ); |
425 | } |
426 | } |
427 | |
428 | protected abstract int executeCommand( final CommandLine commandLine ) throws Exception; |
429 | |
430 | /** |
431 | * Checks if a message at a given level is provided to the listeners of the instance. |
432 | * |
433 | * @param level The level to test. |
434 | * |
435 | * @return {@code true} if messages at {@code level} are provided to the listeners of the instance; |
436 | * {@code false} if messages at {@code level} are not provided to the listeners of the instance. |
437 | * |
438 | * @throws NullPointerException if {@code level} is {@code null}. |
439 | * |
440 | * @see #getLogLevel() |
441 | * @see #setLogLevel(java.util.logging.Level) |
442 | */ |
443 | protected boolean isLoggable( final Level level ) |
444 | { |
445 | if ( level == null ) |
446 | { |
447 | throw new NullPointerException( "level" ); |
448 | } |
449 | |
450 | return level.intValue() >= this.getLogLevel().intValue(); |
451 | } |
452 | |
453 | /** |
454 | * Notifies registered listeners. |
455 | * |
456 | * @param level The level of the event. |
457 | * @param message The message of the event or {@code null}. |
458 | * @param throwable The throwable of the event {@code null}. |
459 | * |
460 | * @throws NullPointerException if {@code level} is {@code null}. |
461 | * |
462 | * @see #getListeners() |
463 | * @see #isLoggable(java.util.logging.Level) |
464 | */ |
465 | protected void log( final Level level, final String message, final Throwable throwable ) |
466 | { |
467 | if ( level == null ) |
468 | { |
469 | throw new NullPointerException( "level" ); |
470 | } |
471 | |
472 | if ( this.isLoggable( level ) ) |
473 | { |
474 | for ( Listener l : this.getListeners() ) |
475 | { |
476 | l.onLog( level, message, throwable ); |
477 | } |
478 | } |
479 | } |
480 | |
481 | protected void log( final ModelValidationReport validationReport, final Marshaller marshaller ) |
482 | throws JAXBException |
483 | { |
484 | if ( !validationReport.isModelValid() && this.isLoggable( Level.SEVERE ) ) |
485 | { |
486 | this.log( Level.SEVERE, this.getInvalidModelMessage( this.getLocale() ), null ); |
487 | } |
488 | |
489 | marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE ); |
490 | for ( ModelValidationReport.Detail d : validationReport.getDetails() ) |
491 | { |
492 | if ( this.isLoggable( d.getLevel() ) ) |
493 | { |
494 | this.log( d.getLevel(), d.getMessage(), null ); |
495 | |
496 | if ( d.getElement() != null && this.getLogLevel().intValue() < Level.INFO.intValue() ) |
497 | { |
498 | final StringWriter stringWriter = new StringWriter(); |
499 | marshaller.marshal( d.getElement(), stringWriter ); |
500 | this.log( d.getLevel(), stringWriter.toString(), null ); |
501 | } |
502 | } |
503 | } |
504 | } |
505 | |
506 | protected ModelContext getModelContext( final ClassLoader classLoader ) throws ModelException |
507 | { |
508 | final ModelContext modelContext = ModelContext.createModelContext( classLoader ); |
509 | modelContext.setLogLevel( this.getLogLevel() ); |
510 | modelContext.getListeners().add( new ModelContext.Listener() |
511 | { |
512 | |
513 | public void onLog( final Level level, final String message, final Throwable t ) |
514 | { |
515 | log( level, message, t ); |
516 | } |
517 | |
518 | } ); |
519 | |
520 | return modelContext; |
521 | } |
522 | |
523 | protected JavaBundles getJavaBundles() |
524 | { |
525 | if ( this.javaBundles == null ) |
526 | { |
527 | final JavaBundles tool = new JavaBundles(); |
528 | tool.setLogLevel( this.getLogLevel() ); |
529 | tool.getListeners().add( new JomcTool.Listener() |
530 | { |
531 | |
532 | public void onLog( final Level level, final String message, final Throwable throwable ) |
533 | { |
534 | log( level, message, throwable ); |
535 | } |
536 | |
537 | } ); |
538 | |
539 | return tool; |
540 | } |
541 | |
542 | return this.javaBundles; |
543 | } |
544 | |
545 | protected JavaClasses getJavaClasses() |
546 | { |
547 | if ( this.javaClasses == null ) |
548 | { |
549 | final JavaClasses tool = new JavaClasses(); |
550 | tool.setLogLevel( this.getLogLevel() ); |
551 | tool.getListeners().add( new JomcTool.Listener() |
552 | { |
553 | |
554 | public void onLog( final Level level, final String message, final Throwable throwable ) |
555 | { |
556 | log( level, message, throwable ); |
557 | } |
558 | |
559 | } ); |
560 | |
561 | return tool; |
562 | } |
563 | |
564 | return this.javaClasses; |
565 | } |
566 | |
567 | protected JavaSources getJavaSources() |
568 | { |
569 | if ( this.javaSources == null ) |
570 | { |
571 | final JavaSources tool = new JavaSources(); |
572 | tool.setLogLevel( this.getLogLevel() ); |
573 | tool.getListeners().add( new JomcTool.Listener() |
574 | { |
575 | |
576 | public void onLog( final Level level, final String message, final Throwable throwable ) |
577 | { |
578 | log( level, message, throwable ); |
579 | } |
580 | |
581 | } ); |
582 | |
583 | return tool; |
584 | } |
585 | |
586 | return this.javaSources; |
587 | } |
588 | |
589 | protected ClassLoader getClassLoader( final CommandLine commandLine ) throws IOException |
590 | { |
591 | final Set<URI> uris = new HashSet<URI>(); |
592 | |
593 | if ( commandLine.hasOption( this.getClasspathOption().getOpt() ) ) |
594 | { |
595 | final String[] elements = commandLine.getOptionValues( this.getClasspathOption().getOpt() ); |
596 | if ( elements != null ) |
597 | { |
598 | for ( String e : elements ) |
599 | { |
600 | if ( this.isLoggable( Level.FINE ) ) |
601 | { |
602 | this.log( Level.FINE, this.getClasspathElementMessage( this.getLocale(), e ), null ); |
603 | } |
604 | |
605 | if ( e.startsWith( "@" ) ) |
606 | { |
607 | String line = null; |
608 | final File file = new File( e.substring( 1 ) ); |
609 | BufferedReader reader = null; |
610 | |
611 | try |
612 | { |
613 | reader = new BufferedReader( new FileReader( file ) ); |
614 | while ( ( line = reader.readLine() ) != null ) |
615 | { |
616 | if ( !line.startsWith( "#" ) ) |
617 | { |
618 | uris.add( new File( line ).toURI() ); |
619 | } |
620 | } |
621 | } |
622 | finally |
623 | { |
624 | if ( reader != null ) |
625 | { |
626 | reader.close(); |
627 | } |
628 | } |
629 | } |
630 | else |
631 | { |
632 | uris.add( new File( e ).toURI() ); |
633 | } |
634 | } |
635 | } |
636 | } |
637 | |
638 | int i = 0; |
639 | final URL[] urls = new URL[ uris.size() ]; |
640 | for ( URI uri : uris ) |
641 | { |
642 | urls[i++] = uri.toURL(); |
643 | } |
644 | |
645 | return new URLClassLoader( urls ); |
646 | } |
647 | |
648 | protected Set<File> getDocumentFiles( final CommandLine commandLine ) throws IOException |
649 | { |
650 | final Set<File> files = new HashSet<File>(); |
651 | |
652 | if ( commandLine.hasOption( this.getDocumentsOption().getOpt() ) ) |
653 | { |
654 | final String[] elements = commandLine.getOptionValues( this.getDocumentsOption().getOpt() ); |
655 | if ( elements != null ) |
656 | { |
657 | for ( String e : elements ) |
658 | { |
659 | if ( this.isLoggable( Level.FINE ) ) |
660 | { |
661 | this.log( Level.FINE, this.getDocumentFileMessage( this.getLocale(), e ), null ); |
662 | } |
663 | |
664 | if ( e.startsWith( "@" ) ) |
665 | { |
666 | String line = null; |
667 | final File file = new File( e.substring( 1 ) ); |
668 | BufferedReader reader = null; |
669 | |
670 | try |
671 | { |
672 | reader = new BufferedReader( new FileReader( file ) ); |
673 | while ( ( line = reader.readLine() ) != null ) |
674 | { |
675 | if ( !line.startsWith( "#" ) ) |
676 | { |
677 | files.add( new File( line ) ); |
678 | } |
679 | } |
680 | } |
681 | finally |
682 | { |
683 | if ( reader != null ) |
684 | { |
685 | reader.close(); |
686 | } |
687 | } |
688 | } |
689 | else |
690 | { |
691 | files.add( new File( e ) ); |
692 | } |
693 | } |
694 | } |
695 | } |
696 | |
697 | return files; |
698 | } |
699 | |
700 | protected Modules getModules( final ModelContext context, final CommandLine commandLine ) |
701 | throws IOException, SAXException, JAXBException, ModelException |
702 | { |
703 | Modules modules = new Modules(); |
704 | |
705 | if ( commandLine.hasOption( this.getDocumentsOption().getOpt() ) ) |
706 | { |
707 | final Unmarshaller u = context.createUnmarshaller(); |
708 | for ( File f : this.getDocumentFiles( commandLine ) ) |
709 | { |
710 | final InputStream in = new FileInputStream( f ); |
711 | Object o = u.unmarshal( new StreamSource( in ) ); |
712 | if ( o instanceof JAXBElement ) |
713 | { |
714 | o = ( (JAXBElement) o ).getValue(); |
715 | } |
716 | |
717 | in.close(); |
718 | |
719 | if ( o instanceof Module ) |
720 | { |
721 | modules.getModule().add( (Module) o ); |
722 | } |
723 | else if ( o instanceof Modules ) |
724 | { |
725 | modules.getModule().addAll( ( (Modules) o ).getModule() ); |
726 | } |
727 | else if ( this.isLoggable( Level.WARNING ) ) |
728 | { |
729 | this.log( Level.WARNING, this.getCannotProcessMessage( |
730 | this.getLocale(), f.getAbsolutePath(), o.toString() ), null ); |
731 | |
732 | } |
733 | } |
734 | } |
735 | |
736 | if ( commandLine.hasOption( this.getClasspathOption().getOpt() ) ) |
737 | { |
738 | final Modules classpathModules = context.findModules(); |
739 | for ( Module m : classpathModules.getModule() ) |
740 | { |
741 | if ( modules.getModule( m.getName() ) == null ) |
742 | { |
743 | modules.getModule().add( m ); |
744 | } |
745 | } |
746 | } |
747 | |
748 | if ( !commandLine.hasOption( this.getNoClasspathResolutionOption().getOpt() ) ) |
749 | { |
750 | final Module classpathModule = modules.getClasspathModule( |
751 | Modules.getDefaultClasspathModuleName(), context.getClassLoader() ); |
752 | |
753 | if ( classpathModule != null ) |
754 | { |
755 | modules.getModule().add( classpathModule ); |
756 | } |
757 | } |
758 | |
759 | if ( !commandLine.hasOption( this.getNoModelProcessingOption().getOpt() ) ) |
760 | { |
761 | modules = context.processModules( modules ); |
762 | } |
763 | |
764 | if ( this.isLoggable( Level.FINE ) ) |
765 | { |
766 | this.log( Level.FINE, this.getModulesReportMessage( this.getLocale() ), null ); |
767 | for ( Module m : modules.getModule() ) |
768 | { |
769 | this.log( Level.FINE, "\t" + m.getName(), null ); |
770 | } |
771 | } |
772 | |
773 | return modules; |
774 | } |
775 | |
776 | // SECTION-END |
777 | // SECTION-START[Constructors] |
778 | // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> |
779 | |
780 | /** Creates a new {@code AbstractJomcCommand} instance. */ |
781 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
782 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
783 | public AbstractJomcCommand() |
784 | { |
785 | // SECTION-START[Default Constructor] |
786 | super(); |
787 | // SECTION-END |
788 | } |
789 | // </editor-fold> |
790 | // SECTION-END |
791 | // SECTION-START[Dependencies] |
792 | // <editor-fold defaultstate="collapsed" desc=" Generated Dependencies "> |
793 | |
794 | /** |
795 | * Gets the {@code ClasspathOption} dependency. |
796 | * <p>This method returns the "{@code JOMC CLI Classpath Option}" object of the {@code org.apache.commons.cli.Option} specification.</p> |
797 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
798 | * @return The {@code ClasspathOption} dependency. |
799 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
800 | */ |
801 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
802 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
803 | private org.apache.commons.cli.Option getClasspathOption() |
804 | { |
805 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "ClasspathOption" ); |
806 | assert _d != null : "'ClasspathOption' dependency not found."; |
807 | return _d; |
808 | } |
809 | |
810 | /** |
811 | * Gets the {@code DocumentsOption} dependency. |
812 | * <p>This method returns the "{@code JOMC CLI Documents Option}" object of the {@code org.apache.commons.cli.Option} specification.</p> |
813 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
814 | * @return The {@code DocumentsOption} dependency. |
815 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
816 | */ |
817 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
818 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
819 | private org.apache.commons.cli.Option getDocumentsOption() |
820 | { |
821 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "DocumentsOption" ); |
822 | assert _d != null : "'DocumentsOption' dependency not found."; |
823 | return _d; |
824 | } |
825 | |
826 | /** |
827 | * Gets the {@code Locale} dependency. |
828 | * <p>This method returns the "{@code default}" object of the {@code java.util.Locale} specification at specification level 1.1.</p> |
829 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
830 | * @return The {@code Locale} dependency. |
831 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
832 | */ |
833 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
834 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
835 | private java.util.Locale getLocale() |
836 | { |
837 | final java.util.Locale _d = (java.util.Locale) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "Locale" ); |
838 | assert _d != null : "'Locale' dependency not found."; |
839 | return _d; |
840 | } |
841 | |
842 | /** |
843 | * Gets the {@code ModuleLocationOption} dependency. |
844 | * <p>This method returns the "{@code JOMC CLI Module Location Option}" object of the {@code org.apache.commons.cli.Option} specification.</p> |
845 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
846 | * @return The {@code ModuleLocationOption} dependency. |
847 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
848 | */ |
849 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
850 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
851 | private org.apache.commons.cli.Option getModuleLocationOption() |
852 | { |
853 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "ModuleLocationOption" ); |
854 | assert _d != null : "'ModuleLocationOption' dependency not found."; |
855 | return _d; |
856 | } |
857 | |
858 | /** |
859 | * Gets the {@code ModuleNameOption} dependency. |
860 | * <p>This method returns the "{@code JOMC CLI Module Name Option}" object of the {@code org.apache.commons.cli.Option} specification.</p> |
861 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
862 | * @return The {@code ModuleNameOption} dependency. |
863 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
864 | */ |
865 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
866 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
867 | private org.apache.commons.cli.Option getModuleNameOption() |
868 | { |
869 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "ModuleNameOption" ); |
870 | assert _d != null : "'ModuleNameOption' dependency not found."; |
871 | return _d; |
872 | } |
873 | |
874 | /** |
875 | * Gets the {@code NoClasspathResolutionOption} dependency. |
876 | * <p>This method returns the "{@code JOMC CLI No Classpath Resolution Option}" object of the {@code org.apache.commons.cli.Option} specification.</p> |
877 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
878 | * @return The {@code NoClasspathResolutionOption} dependency. |
879 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
880 | */ |
881 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
882 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
883 | private org.apache.commons.cli.Option getNoClasspathResolutionOption() |
884 | { |
885 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "NoClasspathResolutionOption" ); |
886 | assert _d != null : "'NoClasspathResolutionOption' dependency not found."; |
887 | return _d; |
888 | } |
889 | |
890 | /** |
891 | * Gets the {@code NoModelProcessingOption} dependency. |
892 | * <p>This method returns the "{@code JOMC CLI No Model Processing Option}" object of the {@code org.apache.commons.cli.Option} specification.</p> |
893 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
894 | * @return The {@code NoModelProcessingOption} dependency. |
895 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
896 | */ |
897 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
898 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
899 | private org.apache.commons.cli.Option getNoModelProcessingOption() |
900 | { |
901 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "NoModelProcessingOption" ); |
902 | assert _d != null : "'NoModelProcessingOption' dependency not found."; |
903 | return _d; |
904 | } |
905 | |
906 | /** |
907 | * Gets the {@code SchemaLocationOption} dependency. |
908 | * <p>This method returns the "{@code JOMC CLI Schema Location Option}" object of the {@code org.apache.commons.cli.Option} specification.</p> |
909 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
910 | * @return The {@code SchemaLocationOption} dependency. |
911 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
912 | */ |
913 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
914 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
915 | private org.apache.commons.cli.Option getSchemaLocationOption() |
916 | { |
917 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "SchemaLocationOption" ); |
918 | assert _d != null : "'SchemaLocationOption' dependency not found."; |
919 | return _d; |
920 | } |
921 | |
922 | /** |
923 | * Gets the {@code ServiceLocationOption} dependency. |
924 | * <p>This method returns the "{@code JOMC CLI Service Location Option}" object of the {@code org.apache.commons.cli.Option} specification.</p> |
925 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
926 | * @return The {@code ServiceLocationOption} dependency. |
927 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
928 | */ |
929 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
930 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
931 | private org.apache.commons.cli.Option getServiceLocationOption() |
932 | { |
933 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "ServiceLocationOption" ); |
934 | assert _d != null : "'ServiceLocationOption' dependency not found."; |
935 | return _d; |
936 | } |
937 | |
938 | /** |
939 | * Gets the {@code TransformerLocationOption} dependency. |
940 | * <p>This method returns the "{@code JOMC CLI Transformer Location Option}" object of the {@code org.apache.commons.cli.Option} specification.</p> |
941 | * <p>That specification does not apply to any scope. A new object is returned whenever requested and bound to this instance.</p> |
942 | * @return The {@code TransformerLocationOption} dependency. |
943 | * @throws org.jomc.ObjectManagementException if getting the dependency instance fails. |
944 | */ |
945 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
946 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
947 | private org.apache.commons.cli.Option getTransformerLocationOption() |
948 | { |
949 | final org.apache.commons.cli.Option _d = (org.apache.commons.cli.Option) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getDependency( this, "TransformerLocationOption" ); |
950 | assert _d != null : "'TransformerLocationOption' dependency not found."; |
951 | return _d; |
952 | } |
953 | // </editor-fold> |
954 | // SECTION-END |
955 | // SECTION-START[Properties] |
956 | // <editor-fold defaultstate="collapsed" desc=" Generated Properties "> |
957 | |
958 | /** |
959 | * Gets the value of the {@code abbreviatedCommandName} property. |
960 | * @return Abbreviated name of the command. |
961 | * @throws org.jomc.ObjectManagementException if getting the property instance fails. |
962 | */ |
963 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
964 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
965 | private java.lang.String getAbbreviatedCommandName() |
966 | { |
967 | final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "abbreviatedCommandName" ); |
968 | assert _p != null : "'abbreviatedCommandName' property not found."; |
969 | return _p; |
970 | } |
971 | |
972 | /** |
973 | * Gets the value of the {@code commandName} property. |
974 | * @return Name of the command. |
975 | * @throws org.jomc.ObjectManagementException if getting the property instance fails. |
976 | */ |
977 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
978 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
979 | private java.lang.String getCommandName() |
980 | { |
981 | final java.lang.String _p = (java.lang.String) org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getProperty( this, "commandName" ); |
982 | assert _p != null : "'commandName' property not found."; |
983 | return _p; |
984 | } |
985 | // </editor-fold> |
986 | // SECTION-END |
987 | // SECTION-START[Messages] |
988 | // <editor-fold defaultstate="collapsed" desc=" Generated Messages "> |
989 | |
990 | /** |
991 | * Gets the text of the {@code applicationTitle} message. |
992 | * <p><b>Templates</b><br/><table> |
993 | * <tr><td valign="top">English:</td><td valign="top"><pre>JOMC Version 1.0-alpha-16 Build 2010-02-02T05:28:08+0000</pre></td></tr> |
994 | * </table></p> |
995 | * @param locale The locale of the message to return. |
996 | * @return The text of the {@code applicationTitle} message. |
997 | * |
998 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
999 | */ |
1000 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1001 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1002 | private String getApplicationTitleMessage( final java.util.Locale locale ) |
1003 | { |
1004 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "applicationTitle", locale ); |
1005 | assert _m != null : "'applicationTitle' message not found."; |
1006 | return _m; |
1007 | } |
1008 | |
1009 | /** |
1010 | * Gets the text of the {@code cannotProcess} message. |
1011 | * <p><b>Templates</b><br/><table> |
1012 | * <tr><td valign="top">English:</td><td valign="top"><pre>Cannot process ''{0}'': {1}</pre></td></tr> |
1013 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Kann ''{0}'' nicht verarbeiten: {1}</pre></td></tr> |
1014 | * </table></p> |
1015 | * @param locale The locale of the message to return. |
1016 | * @param itemInfo Format argument. |
1017 | * @param detailMessage Format argument. |
1018 | * @return The text of the {@code cannotProcess} message. |
1019 | * |
1020 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1021 | */ |
1022 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1023 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1024 | private String getCannotProcessMessage( final java.util.Locale locale, final java.lang.String itemInfo, final java.lang.String detailMessage ) |
1025 | { |
1026 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "cannotProcess", locale, itemInfo, detailMessage ); |
1027 | assert _m != null : "'cannotProcess' message not found."; |
1028 | return _m; |
1029 | } |
1030 | |
1031 | /** |
1032 | * Gets the text of the {@code classpathElement} message. |
1033 | * <p><b>Templates</b><br/><table> |
1034 | * <tr><td valign="top">English:</td><td valign="top"><pre>Classpath element: ''{0}''</pre></td></tr> |
1035 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Klassenpfad-Element: ''{0}''</pre></td></tr> |
1036 | * </table></p> |
1037 | * @param locale The locale of the message to return. |
1038 | * @param classpathElement Format argument. |
1039 | * @return The text of the {@code classpathElement} message. |
1040 | * |
1041 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1042 | */ |
1043 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1044 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1045 | private String getClasspathElementMessage( final java.util.Locale locale, final java.lang.String classpathElement ) |
1046 | { |
1047 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "classpathElement", locale, classpathElement ); |
1048 | assert _m != null : "'classpathElement' message not found."; |
1049 | return _m; |
1050 | } |
1051 | |
1052 | /** |
1053 | * Gets the text of the {@code defaultLogLevelInfo} message. |
1054 | * <p><b>Templates</b><br/><table> |
1055 | * <tr><td valign="top">English:</td><td valign="top"><pre>Default log level: ''{0}''</pre></td></tr> |
1056 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Standard-Protokollierungsstufe: ''{0}''</pre></td></tr> |
1057 | * </table></p> |
1058 | * @param locale The locale of the message to return. |
1059 | * @param defaultLogLevel Format argument. |
1060 | * @return The text of the {@code defaultLogLevelInfo} message. |
1061 | * |
1062 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1063 | */ |
1064 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1065 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1066 | private String getDefaultLogLevelInfoMessage( final java.util.Locale locale, final java.lang.String defaultLogLevel ) |
1067 | { |
1068 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "defaultLogLevelInfo", locale, defaultLogLevel ); |
1069 | assert _m != null : "'defaultLogLevelInfo' message not found."; |
1070 | return _m; |
1071 | } |
1072 | |
1073 | /** |
1074 | * Gets the text of the {@code documentFile} message. |
1075 | * <p><b>Templates</b><br/><table> |
1076 | * <tr><td valign="top">English:</td><td valign="top"><pre>Document file: ''{0}''</pre></td></tr> |
1077 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Dokument-Datei: ''{0}''</pre></td></tr> |
1078 | * </table></p> |
1079 | * @param locale The locale of the message to return. |
1080 | * @param documentFile Format argument. |
1081 | * @return The text of the {@code documentFile} message. |
1082 | * |
1083 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1084 | */ |
1085 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1086 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1087 | private String getDocumentFileMessage( final java.util.Locale locale, final java.lang.String documentFile ) |
1088 | { |
1089 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "documentFile", locale, documentFile ); |
1090 | assert _m != null : "'documentFile' message not found."; |
1091 | return _m; |
1092 | } |
1093 | |
1094 | /** |
1095 | * Gets the text of the {@code invalidModel} message. |
1096 | * <p><b>Templates</b><br/><table> |
1097 | * <tr><td valign="top">English:</td><td valign="top"><pre>Invalid model.</pre></td></tr> |
1098 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Ungültiges Modell.</pre></td></tr> |
1099 | * </table></p> |
1100 | * @param locale The locale of the message to return. |
1101 | * @return The text of the {@code invalidModel} message. |
1102 | * |
1103 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1104 | */ |
1105 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1106 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1107 | private String getInvalidModelMessage( final java.util.Locale locale ) |
1108 | { |
1109 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "invalidModel", locale ); |
1110 | assert _m != null : "'invalidModel' message not found."; |
1111 | return _m; |
1112 | } |
1113 | |
1114 | /** |
1115 | * Gets the text of the {@code longDescription} message. |
1116 | * <p><b>Templates</b><br/><table> |
1117 | * <tr><td valign="top">English:</td><td valign="top"><pre></pre></td></tr> |
1118 | * </table></p> |
1119 | * @param locale The locale of the message to return. |
1120 | * @return The text of the {@code longDescription} message. |
1121 | * |
1122 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1123 | */ |
1124 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1125 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1126 | private String getLongDescriptionMessage( final java.util.Locale locale ) |
1127 | { |
1128 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "longDescription", locale ); |
1129 | assert _m != null : "'longDescription' message not found."; |
1130 | return _m; |
1131 | } |
1132 | |
1133 | /** |
1134 | * Gets the text of the {@code missingModule} message. |
1135 | * <p><b>Templates</b><br/><table> |
1136 | * <tr><td valign="top">English:</td><td valign="top"><pre>Module ''{0}'' not found.</pre></td></tr> |
1137 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Modul ''{0}'' nicht gefunden.</pre></td></tr> |
1138 | * </table></p> |
1139 | * @param locale The locale of the message to return. |
1140 | * @param moduleName Format argument. |
1141 | * @return The text of the {@code missingModule} message. |
1142 | * |
1143 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1144 | */ |
1145 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1146 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1147 | private String getMissingModuleMessage( final java.util.Locale locale, final java.lang.String moduleName ) |
1148 | { |
1149 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "missingModule", locale, moduleName ); |
1150 | assert _m != null : "'missingModule' message not found."; |
1151 | return _m; |
1152 | } |
1153 | |
1154 | /** |
1155 | * Gets the text of the {@code modulesReport} message. |
1156 | * <p><b>Templates</b><br/><table> |
1157 | * <tr><td valign="top">English:</td><td valign="top"><pre>Modules</pre></td></tr> |
1158 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Module</pre></td></tr> |
1159 | * </table></p> |
1160 | * @param locale The locale of the message to return. |
1161 | * @return The text of the {@code modulesReport} message. |
1162 | * |
1163 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1164 | */ |
1165 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1166 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1167 | private String getModulesReportMessage( final java.util.Locale locale ) |
1168 | { |
1169 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "modulesReport", locale ); |
1170 | assert _m != null : "'modulesReport' message not found."; |
1171 | return _m; |
1172 | } |
1173 | |
1174 | /** |
1175 | * Gets the text of the {@code separator} message. |
1176 | * <p><b>Templates</b><br/><table> |
1177 | * <tr><td valign="top">English:</td><td valign="top"><pre>--------------------------------------------------------------------------------</pre></td></tr> |
1178 | * </table></p> |
1179 | * @param locale The locale of the message to return. |
1180 | * @return The text of the {@code separator} message. |
1181 | * |
1182 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1183 | */ |
1184 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1185 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1186 | private String getSeparatorMessage( final java.util.Locale locale ) |
1187 | { |
1188 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "separator", locale ); |
1189 | assert _m != null : "'separator' message not found."; |
1190 | return _m; |
1191 | } |
1192 | |
1193 | /** |
1194 | * Gets the text of the {@code shortDescription} message. |
1195 | * <p><b>Templates</b><br/><table> |
1196 | * <tr><td valign="top">English:</td><td valign="top"><pre></pre></td></tr> |
1197 | * </table></p> |
1198 | * @param locale The locale of the message to return. |
1199 | * @return The text of the {@code shortDescription} message. |
1200 | * |
1201 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1202 | */ |
1203 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1204 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1205 | private String getShortDescriptionMessage( final java.util.Locale locale ) |
1206 | { |
1207 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "shortDescription", locale ); |
1208 | assert _m != null : "'shortDescription' message not found."; |
1209 | return _m; |
1210 | } |
1211 | |
1212 | /** |
1213 | * Gets the text of the {@code startingModuleProcessing} message. |
1214 | * <p><b>Templates</b><br/><table> |
1215 | * <tr><td valign="top">English:</td><td valign="top"><pre>Executing command {0} with module ''{1}'' ...</pre></td></tr> |
1216 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Führt Befehl {0} mit Modul ''{1}'' aus ... </pre></td></tr> |
1217 | * </table></p> |
1218 | * @param locale The locale of the message to return. |
1219 | * @param toolName Format argument. |
1220 | * @param moduleName Format argument. |
1221 | * @return The text of the {@code startingModuleProcessing} message. |
1222 | * |
1223 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1224 | */ |
1225 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1226 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1227 | private String getStartingModuleProcessingMessage( final java.util.Locale locale, final java.lang.String toolName, final java.lang.String moduleName ) |
1228 | { |
1229 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "startingModuleProcessing", locale, toolName, moduleName ); |
1230 | assert _m != null : "'startingModuleProcessing' message not found."; |
1231 | return _m; |
1232 | } |
1233 | |
1234 | /** |
1235 | * Gets the text of the {@code startingProcessing} message. |
1236 | * <p><b>Templates</b><br/><table> |
1237 | * <tr><td valign="top">English:</td><td valign="top"><pre>Executing command {0} ...</pre></td></tr> |
1238 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>Führt Befehl {0} aus ... </pre></td></tr> |
1239 | * </table></p> |
1240 | * @param locale The locale of the message to return. |
1241 | * @param toolName Format argument. |
1242 | * @return The text of the {@code startingProcessing} message. |
1243 | * |
1244 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1245 | */ |
1246 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1247 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1248 | private String getStartingProcessingMessage( final java.util.Locale locale, final java.lang.String toolName ) |
1249 | { |
1250 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "startingProcessing", locale, toolName ); |
1251 | assert _m != null : "'startingProcessing' message not found."; |
1252 | return _m; |
1253 | } |
1254 | |
1255 | /** |
1256 | * Gets the text of the {@code toolFailure} message. |
1257 | * <p><b>Templates</b><br/><table> |
1258 | * <tr><td valign="top">English:</td><td valign="top"><pre>{0} failure.</pre></td></tr> |
1259 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>{0} fehlgeschlagen.</pre></td></tr> |
1260 | * </table></p> |
1261 | * @param locale The locale of the message to return. |
1262 | * @param toolName Format argument. |
1263 | * @return The text of the {@code toolFailure} message. |
1264 | * |
1265 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1266 | */ |
1267 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1268 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1269 | private String getToolFailureMessage( final java.util.Locale locale, final java.lang.String toolName ) |
1270 | { |
1271 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "toolFailure", locale, toolName ); |
1272 | assert _m != null : "'toolFailure' message not found."; |
1273 | return _m; |
1274 | } |
1275 | |
1276 | /** |
1277 | * Gets the text of the {@code toolSuccess} message. |
1278 | * <p><b>Templates</b><br/><table> |
1279 | * <tr><td valign="top">English:</td><td valign="top"><pre>{0} successful.</pre></td></tr> |
1280 | * <tr><td valign="top">Deutsch:</td><td valign="top"><pre>{0} erfolgreich.</pre></td></tr> |
1281 | * </table></p> |
1282 | * @param locale The locale of the message to return. |
1283 | * @param toolName Format argument. |
1284 | * @return The text of the {@code toolSuccess} message. |
1285 | * |
1286 | * @throws org.jomc.ObjectManagementException if getting the message instance fails. |
1287 | */ |
1288 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
1289 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-16/jomc-tools" ) |
1290 | private String getToolSuccessMessage( final java.util.Locale locale, final java.lang.String toolName ) |
1291 | { |
1292 | final String _m = org.jomc.ObjectManagerFactory.getObjectManager( this.getClass().getClassLoader() ).getMessage( this, "toolSuccess", locale, toolName ); |
1293 | assert _m != null : "'toolSuccess' message not found."; |
1294 | return _m; |
1295 | } |
1296 | // </editor-fold> |
1297 | // SECTION-END |
1298 | } |