diff --git a/build.gradle b/build.gradle
index 8d74752084..a8143365f9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,6 +17,8 @@ allprojects {
apply plugin: 'project-report'
apply plugin: 'checkstyle'
+ jar.dependsOn(checkstyleMain, findbugsMain)
+
repositories {
mavenLocal()
maven {url "http://download.osgeo.org/webdav/geotools"}
@@ -50,7 +52,7 @@ configurations {
project.ext.junitVersion = "4.11"
dependencies {
- def springVersion = "3.1.0.RELEASE"
+ def springVersion = "4.0.2.RELEASE"
def metricsVersion = "3.0.2"
compile (
"org.springframework:spring-context:$springVersion",
@@ -70,6 +72,11 @@ dependencies {
"com.codahale.metrics:metrics-logback:$metricsVersion",
'org.springframework:spring-webmvc:4.0.2.RELEASE')
+
+ // This jsr166 dependendency is here only so long as Java 6 is supported
+ // it is the forkjoin code and can be removed if java 7 is a required library
+ compile ('org.codehaus.jsr166-mirror:jsr166:1.7.0')
+
compile ('org.apache.xmlgraphics:batik-transcoder:1.7'){
exclude module: 'fop'
}
diff --git a/examples/config.yaml b/examples/config.yaml
index daa4536433..c25037fa33 100644
--- a/examples/config.yaml
+++ b/examples/config.yaml
@@ -28,13 +28,13 @@ hosts:
port: 80
security:
- - !basicAuth
- matcher: !dnsMatch
- host: c2cpc61.camptocamp.com
- port: 80
- username: xyz
- password: yxz
- preemptive: true
+# - !basicAuth
+# matcher: !dnsMatch
+# host: c2cpc61.camptocamp.com
+# port: 80
+# username: xyz
+# password: yxz
+# preemptive: true
templates:
A4 portrait: !template
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 3c7abdf127..5838598129 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index cf07ff679d..76e4ea407e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Fri Mar 21 14:22:15 CET 2014
+#Mon Mar 24 09:09:03 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
diff --git a/gradlew b/gradlew
index 9a3acf2bf2..91a7e269e1 100755
--- a/gradlew
+++ b/gradlew
@@ -7,7 +7,7 @@
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS="-XX:MaxPermSize=128m -Xmx512M"
+DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
diff --git a/gradlew.bat b/gradlew.bat
index 6e4992a36e..8a0b282aa6 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -9,7 +9,7 @@
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=-XX:MaxPermSize=128m -Xmx512M
+set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
diff --git a/output.pdf b/output.pdf
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/src/main/java/org/mapfish/print/config/BasicAuthSecurity.java b/src/main/java/org/mapfish/print/config/BasicAuthSecurity.java
deleted file mode 100644
index dfbd147462..0000000000
--- a/src/main/java/org/mapfish/print/config/BasicAuthSecurity.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2014 Camptocamp
- *
- * This file is part of MapFish Print
- *
- * MapFish Print is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * MapFish Print is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MapFish Print. If not, see .
- */
-
-package org.mapfish.print.config;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-
-import java.net.URI;
-
-/**
- * Authenticate using basic auth.
- *
- * @author Jesse
- */
-public class BasicAuthSecurity extends SecurityStrategy implements ConfigurationObject {
-
- private String username = null;
- private String password = null;
- private boolean preemptive = false;
-
- @Override
- public final void configure(final URI uri, final HttpClient httpClient) {
- if (this.username == null || this.password == null) {
- throw new IllegalStateException("username and password configuration of BasicAuthSecurity is required");
- }
-
- if (this.preemptive) {
- httpClient.getParams().setAuthenticationPreemptive(true);
- }
- httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort()),
- new UsernamePasswordCredentials(this.username, this.password));
- }
-
- public final void setUsername(final String username) {
- this.username = username;
- }
-
- public final void setPassword(final String password) {
- this.password = password;
- }
-
- public final void setPreemptive(final boolean preemptive) {
- this.preemptive = preemptive;
- }
-}
diff --git a/src/main/java/org/mapfish/print/config/ConfigurationFactory.java b/src/main/java/org/mapfish/print/config/ConfigurationFactory.java
index 5088b44ad9..0242f5db19 100644
--- a/src/main/java/org/mapfish/print/config/ConfigurationFactory.java
+++ b/src/main/java/org/mapfish/print/config/ConfigurationFactory.java
@@ -29,7 +29,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
-
import javax.annotation.PostConstruct;
/**
diff --git a/src/main/java/org/mapfish/print/config/InetHostMatcher.java b/src/main/java/org/mapfish/print/config/InetHostMatcher.java
index 74fa59c704..b406733f48 100644
--- a/src/main/java/org/mapfish/print/config/InetHostMatcher.java
+++ b/src/main/java/org/mapfish/print/config/InetHostMatcher.java
@@ -20,7 +20,6 @@
package org.mapfish.print.config;
import com.google.common.base.Optional;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/org/mapfish/print/config/SecurityStrategy.java b/src/main/java/org/mapfish/print/config/SecurityStrategy.java
index e757f61a16..6e9a9b3f01 100644
--- a/src/main/java/org/mapfish/print/config/SecurityStrategy.java
+++ b/src/main/java/org/mapfish/print/config/SecurityStrategy.java
@@ -19,7 +19,7 @@
package org.mapfish.print.config;
-import org.apache.commons.httpclient.HttpClient;
+import org.apache.http.client.methods.HttpRequestBase;
import java.io.IOException;
import java.net.URI;
@@ -33,10 +33,10 @@ public abstract class SecurityStrategy implements ConfigurationObject {
/**
* Configure security of the http client for the uri.
*
- * @param uri uri of request
+ * @param uri uri of request
* @param httpClient http client which will make request.
*/
- public abstract void configure(URI uri, HttpClient httpClient);
+ public abstract void configure(URI uri, HttpRequestBase httpClient);
/**
* Return true if this strategy can be used for the provided URI.
@@ -54,6 +54,7 @@ public final boolean matches(final URI uri) {
/**
* Set the matching strategy for determining if this strategy can be used to secure a give URL.
+ *
* @param matcher the matcher.
*/
public final void setMatcher(final HostMatcher matcher) {
diff --git a/src/main/java/org/mapfish/print/config/Template.java b/src/main/java/org/mapfish/print/config/Template.java
index 0c870f397d..c4e9b50244 100644
--- a/src/main/java/org/mapfish/print/config/Template.java
+++ b/src/main/java/org/mapfish/print/config/Template.java
@@ -23,10 +23,13 @@
import org.json.JSONWriter;
import org.mapfish.print.attribute.Attribute;
import org.mapfish.print.processor.Processor;
+import org.mapfish.print.processor.ProcessorDependencyGraph;
+import org.mapfish.print.processor.ProcessorDependencyGraphFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import javax.annotation.Nonnull;
/**
* Represents a report template configuration.
@@ -43,6 +46,8 @@ public class Template implements ConfigurationObject {
private String jdbcUrl;
private String jdbcUser;
private String jdbcPassword;
+ private volatile ProcessorDependencyGraph processorGraph;
+ private volatile ProcessorDependencyGraph iterProcessorGraph;
/**
* Print out the template information that the client needs for performing a request.
@@ -77,10 +82,6 @@ public final void setJasperTemplate(final String jasperTemplate) {
this.jasperTemplate = jasperTemplate;
}
- public final List getProcessors() {
- return this.processors;
- }
-
public final void setProcessors(final List processors) {
this.processors = processors;
}
@@ -124,4 +125,40 @@ public final String getJdbcPassword() {
public final void setJdbcPassword(final String jdbcPassword) {
this.jdbcPassword = jdbcPassword;
}
+
+ /**
+ * Get the processor graph to use for executing all the processors for the template.
+ *
+ * @param factory a factory for creating graphs.
+ *
+ * @return the processor graph.
+ */
+ public final ProcessorDependencyGraph getProcessorGraph(@Nonnull final ProcessorDependencyGraphFactory factory) {
+ if (this.processorGraph == null) {
+ synchronized (this) {
+ if (this.processorGraph == null) {
+ this.processorGraph = factory.build(this.processors);
+ }
+ }
+ }
+ return this.processorGraph;
+ }
+
+ /**
+ * Get the processor graph to use for executing all the iter processors for the template.
+ *
+ * @param factory a factory for creating graphs.
+ *
+ * @return the processor graph.
+ */
+ public final ProcessorDependencyGraph getIterProcessorGraph(@Nonnull final ProcessorDependencyGraphFactory factory) {
+ if (this.iterProcessorGraph == null) {
+ synchronized (this) {
+ if (this.iterProcessorGraph == null) {
+ this.iterProcessorGraph = factory.build(this.iterProcessors);
+ }
+ }
+ }
+ return this.iterProcessorGraph;
+ }
}
diff --git a/src/main/java/org/mapfish/print/metrics/HealthCheckRegistryContextListener.java b/src/main/java/org/mapfish/print/metrics/HealthCheckRegistryContextListener.java
index 1622b053f2..ff99c7228d 100644
--- a/src/main/java/org/mapfish/print/metrics/HealthCheckRegistryContextListener.java
+++ b/src/main/java/org/mapfish/print/metrics/HealthCheckRegistryContextListener.java
@@ -19,10 +19,8 @@
package org.mapfish.print.metrics;
-import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.health.HealthCheckRegistry;
import com.codahale.metrics.servlets.HealthCheckServlet;
-import com.codahale.metrics.servlets.MetricsServlet;
import org.springframework.web.context.WebApplicationContext;
import javax.servlet.ServletContext;
diff --git a/src/main/java/org/mapfish/print/metrics/InstrumentedFilterContextListener.java b/src/main/java/org/mapfish/print/metrics/MapfishPrintInstrumentedFilterContextListener.java
similarity index 87%
rename from src/main/java/org/mapfish/print/metrics/InstrumentedFilterContextListener.java
rename to src/main/java/org/mapfish/print/metrics/MapfishPrintInstrumentedFilterContextListener.java
index 44ddd60029..8dbce4af22 100644
--- a/src/main/java/org/mapfish/print/metrics/InstrumentedFilterContextListener.java
+++ b/src/main/java/org/mapfish/print/metrics/MapfishPrintInstrumentedFilterContextListener.java
@@ -20,8 +20,7 @@
package org.mapfish.print.metrics;
import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.health.HealthCheckRegistry;
-import com.codahale.metrics.servlets.HealthCheckServlet;
+import com.codahale.metrics.servlet.InstrumentedFilterContextListener;
import org.springframework.web.context.WebApplicationContext;
import javax.servlet.ServletContext;
@@ -31,10 +30,10 @@
/**
* Allows the AdminServlet to get access to the MetricRegistry so it can display the statistics via the admin servlet.
- *
+ *
* Created by Jesse on 3/21/2014.
*/
-public class InstrumentedFilterContextListener extends com.codahale.metrics.servlet.InstrumentedFilterContextListener {
+public class MapfishPrintInstrumentedFilterContextListener extends InstrumentedFilterContextListener {
private ServletContext servletContext;
@Override
diff --git a/src/main/java/org/mapfish/print/metrics/MetricsRegistryContextListener.java b/src/main/java/org/mapfish/print/metrics/MetricsRegistryContextListener.java
index 0e9353caaa..14b8e6b3f7 100644
--- a/src/main/java/org/mapfish/print/metrics/MetricsRegistryContextListener.java
+++ b/src/main/java/org/mapfish/print/metrics/MetricsRegistryContextListener.java
@@ -25,11 +25,6 @@
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.http.HttpSessionAttributeListener;
-import javax.servlet.http.HttpSessionEvent;
-import javax.servlet.http.HttpSessionListener;
-import javax.servlet.http.HttpSessionBindingEvent;
import static org.springframework.web.context.support.WebApplicationContextUtils.getWebApplicationContext;
/**
diff --git a/src/main/java/org/mapfish/print/output/JasperReportOutputFormat.java b/src/main/java/org/mapfish/print/output/JasperReportOutputFormat.java
index 9f0aaf6429..9a2c27bfd0 100644
--- a/src/main/java/org/mapfish/print/output/JasperReportOutputFormat.java
+++ b/src/main/java/org/mapfish/print/output/JasperReportOutputFormat.java
@@ -25,15 +25,16 @@
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.data.JRMapCollectionDataSource;
-
import org.mapfish.print.Constants;
import org.mapfish.print.attribute.Attribute;
import org.mapfish.print.config.Configuration;
import org.mapfish.print.config.Template;
import org.mapfish.print.json.PJsonObject;
import org.mapfish.print.processor.Processor;
+import org.mapfish.print.processor.ProcessorDependencyGraphFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import java.io.File;
import java.io.OutputStream;
@@ -41,14 +42,10 @@
import java.sql.DriverManager;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ForkJoinPool;
/**
* An PDF output format that uses Jasper reports to generate the result.
@@ -59,22 +56,11 @@
public class JasperReportOutputFormat implements OutputFormat {
@SuppressWarnings("unused")
private static final Logger LOGGER = LoggerFactory.getLogger(JasperReportOutputFormat.class);
+ @Autowired
+ private ForkJoinPool forkJoinPool;
+ @Autowired
+ private ProcessorDependencyGraphFactory processorGraphFactory;
- private static final int WAIT_TIME = 200;
- private static final int DEFAULT_THREAD_NUMBER = 4;
-
- /**
- * The used number of threads.
- */
- private int threadNumber = DEFAULT_THREAD_NUMBER;
-
- /**
- * Set the used number of threads.
- * @param threadNumber The number of thread.
- */
- public final void setThreadNumber(final int threadNumber) {
- this.threadNumber = threadNumber;
- }
@Override
public final String getContentType() {
@@ -108,13 +94,13 @@ public final void print(final PJsonObject spec, final Configuration config, fina
}
- runProcessors(template.getProcessors(), values);
+ this.forkJoinPool.invoke(template.getProcessorGraph(this.processorGraphFactory).createTask(values));
if (template.getIterValue() != null) {
List