Author: rdonkin
Date: Sat Mar 30 16:41:43 2013
New Revision: 1462794
URL: http://svn.apache.org/r1462794
Log:
Inject templates
Modified:
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java
Modified:
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
URL:
http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java?rev=1462794&r1=1462793&r2=1462794&view=diff
==============================================================================
---
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
(original)
+++
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
Sat Mar 30 16:41:43 2013
@@ -65,6 +65,7 @@ public class Main {
private final Configuration configuration;
private final FileSystem fileSystem;
private final IOSystem ioSystem;
+ private final Templates templates;
public Main(final String... args) throws Exception {
this(new Configuration(args), new FileSystem(), new IOSystem());
@@ -73,15 +74,17 @@ public class Main {
public Main(final Configuration configuration, final FileSystem fileSystem,
final IOSystem ioSystem) throws Exception {
this(configuration, fileSystem, new NexusClient(fileSystem, ioSystem),
- ioSystem);
+ ioSystem, new Templates(ioSystem));
}
public Main(final Configuration configuration, final FileSystem fileSystem,
- final NexusClient client, final IOSystem ioSystem) throws
Exception {
+ final NexusClient client, final IOSystem ioSystem,
+ final Templates templates) throws Exception {
this.client = client;
this.configuration = configuration;
this.fileSystem = fileSystem;
this.ioSystem = ioSystem;
+ this.templates = templates;
this.local =
new File(this.configuration.getRootDirectoryForLocalOutput());
@@ -138,8 +141,8 @@ public class Main {
archives.add(archive);
}
- Templates.template("legal/archives.vm", this.ioSystem)
- .add("archives", archives).add("reports", this.reports)
+ this.templates.template("legal/archives.vm").add("archives", archives)
+ .add("reports", this.reports)
.write(new File(this.local, "archives.html"));
reportLicenses(archives);
@@ -152,7 +155,7 @@ public class Main {
throws IOException {
initLicenses(archives);
- Templates.template("legal/licenses.vm", this.ioSystem)
+ this.templates.template("legal/licenses.vm")
.add("licenses", getLicenses(archives))
.add("reports", this.reports)
.write(new File(this.local, "licenses.html"));
@@ -198,8 +201,8 @@ public class Main {
}
for (final Archive archive : archives) {
- Templates
- .template("legal/archive-licenses.vm", this.ioSystem)
+ this.templates
+ .template("legal/archive-licenses.vm")
.add("archive", archive)
.add("reports", this.reports)
.write(new File(this.local,
this.reports.licenses(archive)));
@@ -277,7 +280,7 @@ public class Main {
}
}
- Templates.template("legal/archive-notices.vm", this.ioSystem)
+ this.templates.template("legal/archive-notices.vm")
.add("archive", archive).add("reports", this.reports)
.write(new File(this.local,
this.reports.notices(archive)));
}
@@ -305,7 +308,7 @@ public class Main {
}
}
- Templates.template("legal/notices.vm", this.ioSystem)
+ this.templates.template("legal/notices.vm")
.add("notices", notices.values()).add("reports", this.reports)
.write(new File(this.local, "notices.html"));
}
Modified:
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java
URL:
http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java?rev=1462794&r1=1462793&r2=1462794&view=diff
==============================================================================
---
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java
(original)
+++
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Templates.java
Sat Mar 30 16:41:43 2013
@@ -23,11 +23,11 @@ import org.apache.velocity.runtime.log.C
public final class Templates {
- private static final Templates INSTANCE = new Templates();
-
+ private final IOSystem ioSystem;
private final VelocityEngine engine;
- private Templates() {
+ public Templates(final IOSystem ioSystem) {
+ this.ioSystem = ioSystem;
final Properties properties = new Properties();
properties.setProperty("file.resource.loader.cache", "true");
properties.setProperty("resource.loader", "file, class");
@@ -45,11 +45,7 @@ public final class Templates {
this.engine.init(properties);
}
- public static TemplateBuilder template(final String name, final IOSystem
ioSystem) {
- return INSTANCE.builder(name, ioSystem);
- }
-
- private TemplateBuilder builder(final String name, final IOSystem
ioSystem) {
- return new TemplateBuilder(name, ioSystem, this.engine);
+ public TemplateBuilder template(final String name) {
+ return new TemplateBuilder(name, this.ioSystem, this.engine);
}
}