org.wildfly.swarm.batch.jberet

## Class BatchFraction

- java.lang.Object
- - org.wildfly.swarm.config.BatchJBeret<BatchFraction>
  - - org.wildfly.swarm.batch.jberet.BatchFraction

- All Implemented Interfaces:
    Fraction<BatchFraction>

      public class BatchFraction
      extends BatchJBeret<BatchFraction>
      implements Fraction<BatchFraction>

  A batch (JSR-352) fraction implemented by JBeret.
  Author:
    James R. Perkins

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.wildfly.swarm.config.BatchJBeret

      `BatchJBeret.BatchJBeretResources`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DEFAULT_JOB_REPOSITORY_NAME`
    `static String` | `DEFAULT_THREAD_POOL_NAME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BatchFraction()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `BatchFraction` | `applyDefaults()` Apply whatever defaults are required if this fraction was not explicitly configured by a user.
    `static BatchFraction` | `createDefaultFraction()` Creates a default batch fraction.
    `BatchFraction` | `defaultJobRepository(DatasourcesFraction datasource)` Adds a new JDBC job repository using the datasource name as the job repository name and sets it as the default job repository.
    `BatchFraction` | `defaultJobRepository(InMemoryJobRepository<?> jobRepository)` Adds the in-memory job repository as the default job repository.
    `BatchFraction` | `defaultJobRepository(JDBCJobRepository<?> jobRepository)` Adds the JDBC job repository as the default job repository.
    `BatchFraction` | `defaultJobRepository(String name, DatasourcesFraction datasource)` Adds a new JDBC job repository and sets it as the default job repository.
    `BatchFraction` | `defaultThreadPool(int maxThreads, int keepAliveTime, TimeUnit keepAliveUnits)` Creates a new thread-pool using the default name.
    `BatchFraction` | `defaultThreadPool(String name, int maxThreads, int keepAliveTime, TimeUnit keepAliveUnits)` Creates a new thread-pool and sets the created thread-pool as the default thread-pool for batch jobs.
    `BatchFraction` | `jdbcJobRepository(DatasourcesFraction datasource)` Creates a new JDBC job repository using the name of the datasource for the job repository name.
    `BatchFraction` | `jdbcJobRepository(String name, DatasourcesFraction datasource)` Creates a new JDBC job repository.
    `void` | `postConstruct()`
    `BatchFraction` | `threadPool(int maxThreads, int keepAliveTime, TimeUnit keepAliveUnits)` Creates a new thread-pool using the default name that can be used for batch jobs.
    `BatchFraction` | `threadPool(String name, int maxThreads, int keepAliveTime, TimeUnit keepAliveUnits)` Creates a new thread-pool that can be used for batch jobs.

    - ### Methods inherited from class org.wildfly.swarm.config.BatchJBeret

      `addPropertyChangeListener, defaultJobRepository, defaultJobRepository, defaultThreadPool, defaultThreadPool, getKey, inMemoryJobRepositories, inMemoryJobRepository, inMemoryJobRepository, inMemoryJobRepository, inMemoryJobRepository, jdbcJobRepositories, jdbcJobRepository, jdbcJobRepository, jdbcJobRepository, jdbcJobRepository, removePropertyChangeListener, restartJobsOnResume, restartJobsOnResume, securityDomain, securityDomain, subresources, threadFactories, threadFactory, threadFactory, threadFactory, threadFactory, threadPool, threadPool, threadPool, threadPool, threadPools`

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

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

    - ### Methods inherited from interface org.wildfly.swarm.spi.api.Fraction

      `applyDefaults`

- - ### Field Detail

    - #### DEFAULT_JOB_REPOSITORY_NAME

          public static final String DEFAULT_JOB_REPOSITORY_NAME

      See Also:
        Constant Field Values

    - #### DEFAULT_THREAD_POOL_NAME

          public static final String DEFAULT_THREAD_POOL_NAME

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### BatchFraction

          public BatchFraction()

  - ### Method Detail

    - #### postConstruct

          @PostConstruct
          public void postConstruct()

    - #### createDefaultFraction

          public static BatchFraction createDefaultFraction()

      Creates a default batch fraction.

      Uses an `in-memory` job repository with the default name.

      Uses a default thread-pool with a calculated maximum number of threads based on the available number of processors. A keep alive time of 30 seconds is used for the thread-pool.

      Returns:
        a new default batch fraction

    - #### applyDefaults

          public BatchFraction applyDefaults()

      Description copied from interface: `Fraction`
      Apply whatever defaults are required if this fraction was not explicitly configured by a user.
      Specified by:
        `applyDefaults` in interface `Fraction<BatchFraction>`
      Returns:
        this fraction.

    - #### defaultJobRepository

          public BatchFraction defaultJobRepository(InMemoryJobRepository<?> jobRepository)

      Adds the in-memory job repository as the default job repository.
      Parameters:
        `jobRepository` - the job repository to use as the default
      Returns:
        this fraction

    - #### defaultJobRepository

          public BatchFraction defaultJobRepository(JDBCJobRepository<?> jobRepository)

      Adds the JDBC job repository as the default job repository.
      Parameters:
        `jobRepository` - the job repository to use as the default
      Returns:
        this fraction

    - #### defaultJobRepository

          public BatchFraction defaultJobRepository(DatasourcesFraction datasource)

      Adds a new JDBC job repository using the datasource name as the job repository name and sets it as the default job repository.
      Parameters:
        `datasource` - the datasource to use to connect to the database
      Returns:
        this fraction

    - #### defaultJobRepository

          public BatchFraction defaultJobRepository(String name,
                                                    DatasourcesFraction datasource)

      Adds a new JDBC job repository and sets it as the default job repository.
      Parameters:
        `name` - the name for the JDBC job repository
        `datasource` - the datasource to use to connect to the database
      Returns:
        this fraction

    - #### jdbcJobRepository

          public BatchFraction jdbcJobRepository(DatasourcesFraction datasource)

      Creates a new JDBC job repository using the name of the datasource for the job repository name.
      Parameters:
        `datasource` - the datasource to use to connect to the database
      Returns:
        this fraction

    - #### jdbcJobRepository

          public BatchFraction jdbcJobRepository(String name,
                                                 DatasourcesFraction datasource)

      Creates a new JDBC job repository.
      Parameters:
        `name` - the name for the job repository
        `datasource` - the datasource to use to connect to the database
      Returns:
        this fraction

    - #### defaultThreadPool

          public BatchFraction defaultThreadPool(int maxThreads,
                                                 int keepAliveTime,
                                                 TimeUnit keepAliveUnits)

      Creates a new thread-pool using the default name. The thread-pool is then set as the default thread-pool for bath jobs.
      Parameters:
        `maxThreads` - the maximum number of threads to set the pool to
        `keepAliveTime` - the time to keep threads alive
        `keepAliveUnits` - the time unit for the keep alive time
      Returns:
        this fraction

    - #### defaultThreadPool

          public BatchFraction defaultThreadPool(String name,
                                                 int maxThreads,
                                                 int keepAliveTime,
                                                 TimeUnit keepAliveUnits)

      Creates a new thread-pool and sets the created thread-pool as the default thread-pool for batch jobs.
      Parameters:
        `name` - the maximum number of threads to set the pool to
        `keepAliveTime` - the time to keep threads alive
        `keepAliveUnits` - the time unit for the keep alive time
      Returns:
        this fraction

    - #### threadPool

          public BatchFraction threadPool(int maxThreads,
                                          int keepAliveTime,
                                          TimeUnit keepAliveUnits)

      Creates a new thread-pool using the default name that can be used for batch jobs.
      Parameters:
        `keepAliveTime` - the time to keep threads alive
        `keepAliveUnits` - the time unit for the keep alive time
      Returns:
        this fraction

    - #### threadPool

          public BatchFraction threadPool(String name,
                                          int maxThreads,
                                          int keepAliveTime,
                                          TimeUnit keepAliveUnits)

      Creates a new thread-pool that can be used for batch jobs.
      Parameters:
        `name` - the maximum number of threads to set the pool to
        `keepAliveTime` - the time to keep threads alive
        `keepAliveUnits` - the time unit for the keep alive time
      Returns:
        this fraction

Copyright © 2017 JBoss by Red Hat. All rights reserved.