Skip to content

Latest commit

 

History

History
70 lines (47 loc) · 2.72 KB

File metadata and controls

70 lines (47 loc) · 2.72 KB

How to Import/Export Statistics to Your URI

As default the ClazzStatistic exports the statistic to ClazzStatistic.csv in a temporary directory. But you can also define the system property clazzfish.dump.uri to use another directory or another location like e.g. sftp://fritz.box/log to export your statistic.

Support Your Wanted Protocol

Let’s assume you want only to print out the dead classes to stderr. Your clazzfish.dump.uri may look like

print://localhost

If you start your application with this URI you probably will get the following execption:

Caused by: java.lang.IllegalArgumentException: Unsupported protocol: print
    at clazzfish.monitor.spi.XPorter.createCsvXPorter(XPorter.java:46)
    at clazzfish.core.stat.ClazzStatistic.<init>(ClazzStatistic.java:101)
    at clazzfish.core.stat.ClazzStatistic.<init>(ClazzStatistic.java:94)
    at clazzfish.core.stat.ClazzStatistic.<init>(ClazzStatistic.java:90)
    at clazzfish.core.stat.ClazzStatistic.<clinit>(ClazzStatistic.java:74)

To support the print protocol you have to

Implement Interfaces

. In the sample project you’ll find an example how to support the print protocol. CsvPrinter implements the CsvXPorter interface, whereas CsvPrinterProvider the CsvXPorterProvider interface.

Register Provider

To register your provider for the printer protocol you have to create in the META-INF directory in the service package a property file with the name of the implemented interface (CsvXPorterProvider):

# Provider for CSV-Exports
clazzfish.sample.spi.CsvPrintProvider

The content of this property file is the name of your provider.

Bank Example

In the Bank example the ClazzFish statistic is set up in the static initializer:

    static {
        Starter.record(URI.create("print://localhost"));
    }

This will trigger CsvPrinter at the end of the program to print the dead classes of this run to stderr:

===== DEAD CLASSES =====
clazzfish.sample.DeadClass