<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://jetm.void.fm/schema/jetm_spring_config_1_2"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:beans="http://www.springframework.org/schema/beans"
            targetNamespace="http://jetm.void.fm/schema/jetm_spring_config_1_2"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified">

  <!--
   Enable JETM namespace by using the following namespace declaration.

  <beans xmlns="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:jetm="http://jetm.void.fm/schema/jetm_spring_config_1_2"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                             http://jetm.void.fm/schema/jetm_spring_config_1_2 http://jetm.void.fm/schema/jetm_spring_config_1_2.xsd">

   ...

  </beans>
  -->

  <xsd:import namespace="http://www.springframework.org/schema/beans"/>

  <xsd:element name="runtime">
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:extension base="beans:identifiedType">

          <xsd:sequence>
            <xsd:choice minOccurs="0">
              <xsd:element name="features" type="featuresType"/>
              <xsd:element name="aggregator-chain" type="aggregatorChainType"/>
            </xsd:choice>
            <xsd:sequence minOccurs="0">
              <xsd:element name="extension" type="extensionType"/>
            </xsd:sequence>
          </xsd:sequence>

          <xsd:attribute name="type" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                The type of monitor to use. Either one of the predefined monitors or a full qualified classname can
                be specified. Predefined are
                nested - etm.core.monitor.NestedMonitor
                flat - etm.core.monitor.FlatMonitor
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>

          <xsd:attribute name="timer" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                The type of timer to use. Either one of the predefined timers or full qualified classname can be
                specified. Predefined are
                jdk15 - etm.core.timer.Java15NanoTimer
                sun - etm.core.timer.SunHighResTimer
                default - etm.core.timer.DefaultTimer
              </xsd:documentation>
            </xsd:annotation>

          </xsd:attribute>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="console">
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:extension base="beans:identifiedType">
          <xsd:attribute name="expanded" type="xsd:boolean">
            <xsd:annotation>
              <xsd:documentation>
                Whether the results should be rendered expanded or collapsed by default. Uses
                collapsed rendering if not specified.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
          <xsd:attribute name="listen-port" type="xsd:int">
            <xsd:annotation>
              <xsd:documentation>
                The port the console listens to. Defaults to 40000 if not specified.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
          <xsd:attribute name="worker-size" type="xsd:int">
            <xsd:annotation>
              <xsd:documentation>
                The number of worker threads to be used. Defaults to 2.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
          <xsd:attribute name="runtime-ref" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                Optional reference to JETM runtime, only required if there are more
                than one EtmMonitor.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="monitoring">
    <xsd:complexType>
      <xsd:complexContent>
        <xsd:extension base="beans:identifiedType">
          <xsd:sequence>
            <xsd:element name="bean-pattern" minOccurs="0" maxOccurs="unbounded">
              <xsd:complexType>
                <xsd:simpleContent>
                  <xsd:extension base="xsd:string">
                    <xsd:attribute name="group" type="xsd:string">
                      <xsd:annotation>
                        <xsd:documentation>
                          The name to be used for performance results.
                        </xsd:documentation>
                      </xsd:annotation>
                    </xsd:attribute>
                  </xsd:extension>
                </xsd:simpleContent>
              </xsd:complexType>
            </xsd:element>
            <xsd:element name="signature-pattern" minOccurs="0" maxOccurs="unbounded">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="bean-pattern" type="xsd:string"/>
                  <xsd:element name="method-pattern" type="xsd:string"/>
                </xsd:sequence>
                <xsd:attribute name="group" type="xsd:string">
                  <xsd:annotation>
                    <xsd:documentation>
                      The name to be used for performance results.
                    </xsd:documentation>
                  </xsd:annotation>
                </xsd:attribute>
              </xsd:complexType>
            </xsd:element>
          </xsd:sequence>
          <xsd:attribute name="runtime-ref" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                Optional reference to JETM runtime, only required if there are more
                than one EtmMonitor.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
        </xsd:extension>
      </xsd:complexContent>
    </xsd:complexType>
  </xsd:element>

  <xsd:complexType name="featuresType">
    <xsd:sequence>
      <xsd:choice minOccurs="0">

        <xsd:element name="threshold-buffer">
          <xsd:complexType>
            <xsd:attribute name="threshold" type="xsd:int">
              <xsd:annotation>
                <xsd:documentation>
                  The number of measurements before aggregation is triggered.
                  Defaults to 1000 elements.
                </xsd:documentation>
              </xsd:annotation>
            </xsd:attribute>
          </xsd:complexType>
        </xsd:element>
        <xsd:element name="interval-buffer">
          <xsd:complexType>
            <xsd:attribute name="interval" type="xsd:int">
              <xsd:annotation>
                <xsd:documentation>
                  The time interval in miliseconds before aggregation is triggered.
                  Default is 5000 miliseconds, may not be less that 10 miliseconds.
                </xsd:documentation>
              </xsd:annotation>
            </xsd:attribute>
          </xsd:complexType>
        </xsd:element>
      </xsd:choice>

      <xsd:element name="notifications" minOccurs="0">
        <xsd:complexType>
          <xsd:attribute name="rootOnly" type="xsd:boolean">
            <xsd:annotation>
              <xsd:documentation>
                Whether all collected results or just an measurement root will
                create an notifiation. Default is false.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
          <xsd:attribute name="filter-pattern" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                Optional filter pattern that allows filtering of logged
                measurement points. Uses Java 1.4 regex separated by ;.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
        </xsd:complexType>
      </xsd:element>

      <xsd:element name="persistence" minOccurs="0">
        <xsd:complexType>
          <xsd:choice minOccurs="0">
            <xsd:element name="file-backend">
              <xsd:complexType>
                <xsd:annotation>
                  <xsd:documentation>
                    Enables file based state persistence.
                  </xsd:documentation>
                </xsd:annotation>
                <xsd:attribute name="path" type="xsd:string">
                  <xsd:annotation>
                    <xsd:documentation>
                      The path to the persistence file, defaults to java.io.tmpdir.
                    </xsd:documentation>
                  </xsd:annotation>
                </xsd:attribute>
                <xsd:attribute name="filename" type="xsd:string">
                  <xsd:annotation>
                    <xsd:documentation>
                      The filename to persistence to, defaults to jetm-state.ser.
                    </xsd:documentation>
                  </xsd:annotation>
                </xsd:attribute>
              </xsd:complexType>
            </xsd:element>
            <xsd:element name="custom-backend">
              <xsd:annotation>
                <xsd:documentation>
                  Selects custom backend using specified class for persistence.
                </xsd:documentation>
              </xsd:annotation>
              <xsd:complexType>
                <xsd:complexContent>
                  <xsd:extension base="propertyType">
                    <xsd:attribute name="class" type="xsd:string" use="required">
                      <xsd:annotation>
                        <xsd:documentation>
                          The class to be used as persistence backend. Has to be a valid implementation
                          of PersistenceBackend.
                        </xsd:documentation>
                      </xsd:annotation>
                    </xsd:attribute>
                  </xsd:extension>
                </xsd:complexContent>
              </xsd:complexType>
            </xsd:element>
          </xsd:choice>
        </xsd:complexType>
      </xsd:element>

      <xsd:element name="jmx" minOccurs="0">
        <xsd:complexType>
          <xsd:attribute name="monitorObjectName" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                The name of the MBean representing the EtmMonitor.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
          <xsd:attribute name="mbeanServerName" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                The agent ID of the MBeanServer.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
          <xsd:attribute name="measurementDomain" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                The domain that should be used for registering measurement result MBeans.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
          <xsd:attribute name="overwrite" type="xsd:boolean">
            <xsd:annotation>
              <xsd:documentation>
                Whether already registered MBeans will be overwritten or not.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
        </xsd:complexType>

      </xsd:element>

      <xsd:element name="raw-data-log" minOccurs="0">
        <xsd:complexType>
          <xsd:attribute name="type" use="required">
            <xsd:simpleType>
              <xsd:restriction base="xsd:string">
                <xsd:enumeration value="log4j"/>
                <xsd:enumeration value="commons"/>
                <xsd:enumeration value="jdk14"/>
              </xsd:restriction>
            </xsd:simpleType>
          </xsd:attribute>
          <xsd:attribute name="category" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                The log category to use. Defaults to 'etm-raw-data'.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
          <xsd:attribute name="formatter-class" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                Optional formatter class, defaults to DefaultOutputFormatter.
                Needs to be a valid implementation of LogOutputFormatter.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
          <xsd:attribute name="filter-pattern" type="xsd:string">
            <xsd:annotation>
              <xsd:documentation>
                Optional filter pattern that allows filtering of logged
                measurement points. Uses Java 1.4 regex separated by ;.
              </xsd:documentation>
            </xsd:annotation>
          </xsd:attribute>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="propertyType">
    <xsd:sequence>
      <xsd:element name="property" minOccurs="0" maxOccurs="unbounded">
        <xsd:complexType>
          <xsd:simpleContent>
            <xsd:extension base="xsd:string">
              <xsd:attribute name="name" type="xsd:string" use="required"/>
              <xsd:attribute name="ref" type="xsd:IDREF" use="optional"/>
            </xsd:extension>
          </xsd:simpleContent>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="extensionType">
    <xsd:sequence>
      <xsd:element name="plugin" minOccurs="0" maxOccurs="unbounded">
        <xsd:complexType>
          <xsd:complexContent>
            <xsd:extension base="propertyType">
              <xsd:attribute name="class" type="xsd:string"/>
            </xsd:extension>
          </xsd:complexContent>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="aggregatorChainType">
    <xsd:sequence>
      <xsd:element name="chain-element" minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>
            A chain element. Every chain element should implement the interface Aggregator and
            provide a constructor that takes one argument: the child aggregator.
          </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
          <xsd:complexContent>
            <xsd:extension base="propertyType">
              <xsd:attribute name="class" type="xsd:string"/>
            </xsd:extension>
          </xsd:complexContent>
        </xsd:complexType>
      </xsd:element>
      <xsd:element name="chain-root" minOccurs="0">
        <xsd:annotation>
          <xsd:documentation>
            The root element in the aggregator chain. Should relate to
            the monitor type. Has to implement the interface Aggregator and should
            have a public no-arg constructor. Defaults to RootAggregator if omitted.
          </xsd:documentation>
        </xsd:annotation>
        <xsd:complexType>
          <xsd:complexContent>
            <xsd:extension base="propertyType">
              <xsd:attribute name="class" type="xsd:string"/>
            </xsd:extension>
          </xsd:complexContent>
        </xsd:complexType>

      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

</xsd:schema>
    
