Skip to content

Commit

Permalink
User fork join for running processor
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Eichar committed Mar 24, 2014
1 parent 0b242c9 commit f0f4f9c
Show file tree
Hide file tree
Showing 31 changed files with 439 additions and 221 deletions.
9 changes: 8 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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",
Expand All @@ -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'
}
Expand Down
14 changes: 7 additions & 7 deletions examples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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=.
Expand Down
Empty file added output.pdf
Empty file.
63 changes: 0 additions & 63 deletions src/main/java/org/mapfish/print/config/BasicAuthSecurity.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;

import javax.annotation.PostConstruct;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.mapfish.print.config;

import com.google.common.base.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/mapfish/print/config/SecurityStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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) {
Expand Down
45 changes: 41 additions & 4 deletions src/main/java/org/mapfish/print/config/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -77,10 +82,6 @@ public final void setJasperTemplate(final String jasperTemplate) {
this.jasperTemplate = jasperTemplate;
}

public final List<Processor> getProcessors() {
return this.processors;
}

public final void setProcessors(final List<Processor> processors) {
this.processors = processors;
}
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -31,10 +30,10 @@

/**
* Allows the AdminServlet to get access to the MetricRegistry so it can display the statistics via the admin servlet.
*
* <p/>
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand Down
Loading

0 comments on commit f0f4f9c

Please sign in to comment.