All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yammer.dropwizard.views.View Maven / Gradle / Ivy

There is a newer version: 0.6.2
Show newest version
package com.yammer.dropwizard.views;

import com.yammer.metrics.Metrics;
import com.yammer.metrics.core.Timer;
import org.codehaus.jackson.annotate.JsonIgnore;

public abstract class View {
    private final String templateName;
    private final Timer renderingTimer;

    protected View(String templateName) {

        this.templateName = resolveName(templateName);
        this.renderingTimer = Metrics.newTimer(getClass(), "rendering");
    }

    private String resolveName(String templateName) {
        if (templateName.startsWith("/")) {
            return templateName;
        }
        final String packagePath = getClass().getPackage().getName().replace('.', '/');
        return String.format("/%s/%s", packagePath, templateName);
    }

    @JsonIgnore
    public String getTemplateName() {
        return templateName;
    }

    @JsonIgnore
    Timer getRenderingTimer() {
        return renderingTimer;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy