1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.javagen.agile.core.emitter;
17
18 import org.javagen.agile.core.context.Context;
19 import org.javagen.agile.core.context.ContextHolder;
20
21 /***
22 * An emitter is anything that emits code or data files.
23 * <p>
24 * When the <code>emit</code> method is
25 * called by the framework, it is passed a context containing properties needed to generate an artifact.
26 * The emitter will typically bind the context to an associated template.
27 * <p>
28 * The <code>artifact</code> property contains the location and name of the resulting
29 * generated file. Artifacts are typically passed the same context handed to the template
30 * which allows the file name and path to be determined by the same properties that the
31 * template uses.
32 * <p>
33 * An emitter can also hold its own local context which can be used to customize it's behavior.
34 *
35 * @author Richard Easterling
36 */
37 public interface Emitter extends ContextHolder {
38
39 /***
40 * invoke an emitter
41 * @param context - usually a composite of leaf, parent and template contexts.
42 */
43 void emit(Context context);
44
45 /***
46 * The unique artifact instance that provides the file name and path to this emitter.
47 * <p>WARNING: Artifact instances should not be shared between different emitters.
48 * @return the artifact associated with this emitter
49 */
50 Artifact getArtifact();
51
52 }