org.apache.jmeter.protocol.http.util.accesslog

## Class StandardGenerator

- java.lang.Object
- - org.apache.jmeter.protocol.http.util.accesslog.StandardGenerator

- All Implemented Interfaces:
    java.io.Serializable, Generator

      public class StandardGenerator
      extends java.lang.Object
      implements Generator, java.io.Serializable

  Description:
  StandardGenerator will be the default generator used to pre-process logs. It uses JMeter classes to generate the .jmx file. The first version of the utility only generated the HTTP requests as XML, but it required users to copy and paste it into a blank jmx file. Doing that way isn't flexible and would require changes to keep the format in sync.

  This version is a completely new class with a totally different implementation, since generating the XML is no longer handled by the generator. The generator is only responsible for handling the parsed results and passing it to the appropriate JMeter class.

  Notes:
  the class needs to first create a thread group and add it to the HashTree. Then the samplers should be added to the thread group. Listeners shouldn't be added and should be left up to the user. One option is to provide parameters, so the user can pass the desired listener to the tool.

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.io.File` | `FILE`
    `protected java.lang.String` | `FILENAME`
    `protected java.io.OutputStream` | `OUTPUT`
    `protected HTTPSamplerBase` | `SAMPLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StandardGenerator()` The constructor is used by GUI and samplers to generate request objects.
    `StandardGenerator(java.lang.String file)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` close the generator
    `java.lang.Object` | `generateRequest()` The method is responsible for calling the necessary methods to generate a valid request.
    `protected void` | `initStream()` Create the OutputStream to save the JMX file.
    `void` | `reset()` Reset the HTTPSampler to make sure it is a new instance.
    `void` | `save()` save must be called to write the jmx file, otherwise it will not be saved.
    `void` | `setHost(java.lang.String host)` The host is the name of the server.
    `void` | `setLabel(java.lang.String label)` This is the label for the request, which is used in the logs and results.
    `void` | `setMethod(java.lang.String post_get)` The method is the HTTP request method.
    `void` | `setParams(NVPair[] params)` Set the request parameters
    `void` | `setPath(java.lang.String path)` The path is the web page you want to test.
    `void` | `setPort(int port)` The default port for HTTP is 80, but not all servers run on that port.
    `void` | `setQueryString(java.lang.String querystring)` Set the querystring for the request if the method is GET.
    `void` | `setSourceLogs(java.lang.String sourcefile)` The source logs is the location where the access log resides.
    `void` | `setTarget(java.lang.Object target)` The target can be either a java.io.File or a Sampler.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SAMPLE

          protected HTTPSamplerBase SAMPLE

    - #### OUTPUT

          protected transient java.io.OutputStream OUTPUT

    - #### FILENAME

          protected java.lang.String FILENAME

    - #### FILE

          protected java.io.File FILE

  - ### Constructor Detail

    - #### StandardGenerator

          public StandardGenerator()

      The constructor is used by GUI and samplers to generate request objects.

    - #### StandardGenerator

          public StandardGenerator(java.lang.String file)

      Parameters:
        `file` - name of a file (TODO seems not to be used anywhere)

  - ### Method Detail

    - #### initStream

          protected void initStream()

      Create the OutputStream to save the JMX file.

    - #### close

          public void close()

      close the generator
      Specified by:
        `close` in interface `Generator`

    - #### setHost

          public void setHost(java.lang.String host)

      The host is the name of the server.
      Specified by:
        `setHost` in interface `Generator`
      Parameters:
        `host` - name of the server

    - #### setLabel

          public void setLabel(java.lang.String label)

      This is the label for the request, which is used in the logs and results.
      Specified by:
        `setLabel` in interface `Generator`
      Parameters:
        `label` - label of the request

    - #### setMethod

          public void setMethod(java.lang.String post_get)

      The method is the HTTP request method. It's normally POST or GET.
      Specified by:
        `setMethod` in interface `Generator`
      Parameters:
        `post_get` - method of the HTTP request

    - #### setParams

          public void setParams(NVPair[] params)

      Set the request parameters
      Specified by:
        `setParams` in interface `Generator`
      Parameters:
        `params` - request parameter

    - #### setPath

          public void setPath(java.lang.String path)

      The path is the web page you want to test.
      Specified by:
        `setPath` in interface `Generator`
      Parameters:
        `path` - path of the web page

    - #### setPort

          public void setPort(int port)

      The default port for HTTP is 80, but not all servers run on that port.
      Specified by:
        `setPort` in interface `Generator`
      Parameters:
        `port` - - port number

    - #### setQueryString

          public void setQueryString(java.lang.String querystring)

      Set the querystring for the request if the method is GET.
      Specified by:
        `setQueryString` in interface `Generator`
      Parameters:
        `querystring` - query string of the request

    - #### setSourceLogs

          public void setSourceLogs(java.lang.String sourcefile)

      The source logs is the location where the access log resides.
      Specified by:
        `setSourceLogs` in interface `Generator`
      Parameters:
        `sourcefile` - path to the access log file

    - #### setTarget

          public void setTarget(java.lang.Object target)

      The target can be either a java.io.File or a Sampler. We make it generic, so that later on we can use these classes directly from a HTTPSampler.
      Specified by:
        `setTarget` in interface `Generator`
      Parameters:
        `target` - target to generate into

    - #### generateRequest

          public java.lang.Object generateRequest()

      The method is responsible for calling the necessary methods to generate a valid request. If the generator is used to pre-process access logs, the method wouldn't return anything. If the generator is used by a control element, it should return the correct Sampler class with the required fields set.
      Specified by:
        `generateRequest` in interface `Generator`
      Returns:
        prefilled sampler

    - #### save

          public void save()

      save must be called to write the jmx file, otherwise it will not be saved.
      Specified by:
        `save` in interface `Generator`

    - #### reset

          public void reset()

      Reset the HTTPSampler to make sure it is a new instance.

      The purpose of the reset is so Samplers can explicitly call reset to create a new instance of HTTPSampler.

      Specified by:
        `reset` in interface `Generator`

Copyright © 1998-2019 Apache Software Foundation. All Rights Reserved.