Class ServiceContainer.Factory

  • Enclosing interface:
    ServiceContainer

    public static class ServiceContainer.Factory
    extends java.lang.Object
    The factory class for service containers.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int MAX_THREADS_COUNT  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Factory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static int calculateCoreSize()  
      private static int calculateCoreSize​(int coreSize)  
      static ServiceContainer create()
      Create a new instance with a generated name and default thread pool.
      static ServiceContainer create​(boolean autoShutdown)
      Create a new instance with a generated name and default thread pool.
      static ServiceContainer create​(int coreSize, long keepAliveTime, java.util.concurrent.TimeUnit keepAliveTimeUnit)
      Create a new instance with a generated name and specified initial thread pool settings.
      static ServiceContainer create​(int coreSize, long keepAliveTime, java.util.concurrent.TimeUnit keepAliveTimeUnit, boolean autoShutdown)
      Create a new instance with a generated name and specified initial thread pool settings.
      static ServiceContainer create​(java.lang.String name)
      Create a new instance with a given name and default thread pool.
      static ServiceContainer create​(java.lang.String name, boolean autoShutdown)
      Create a new instance with a given name and default thread pool.
      static ServiceContainer create​(java.lang.String name, int coreSize, long keepAliveTime, java.util.concurrent.TimeUnit keepAliveTimeUnit)
      Create a new instance with a given name and specified initial thread pool settings.
      static ServiceContainer create​(java.lang.String name, int coreSize, long keepAliveTime, java.util.concurrent.TimeUnit keepAliveTimeUnit, boolean autoShutdown)
      Create a new instance with a given name and specified initial thread pool settings.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAX_THREADS_COUNT

        private static final int MAX_THREADS_COUNT
    • Constructor Detail

      • Factory

        private Factory()
    • Method Detail

      • create

        public static ServiceContainer create()
        Create a new instance with a generated name and default thread pool.
        Returns:
        a new service container instance
      • create

        public static ServiceContainer create​(java.lang.String name)
        Create a new instance with a given name and default thread pool.
        Parameters:
        name - the name of the new container
        Returns:
        a new service container instance
      • create

        public static ServiceContainer create​(int coreSize,
                                              long keepAliveTime,
                                              java.util.concurrent.TimeUnit keepAliveTimeUnit)
        Create a new instance with a generated name and specified initial thread pool settings.
        Parameters:
        coreSize - the core pool size (must be greater than zero)
        keepAliveTime - the amount of time that non-core threads should linger without tasks
        keepAliveTimeUnit - the time unit for keepAliveTime
        Returns:
        a new service container instance
      • create

        public static ServiceContainer create​(java.lang.String name,
                                              int coreSize,
                                              long keepAliveTime,
                                              java.util.concurrent.TimeUnit keepAliveTimeUnit)
        Create a new instance with a given name and specified initial thread pool settings.
        Parameters:
        name - the name of the new container
        coreSize - the core pool size (must be greater than zero)
        keepAliveTime - the amount of time that non-core threads should linger without tasks
        keepAliveTimeUnit - the time unit for keepAliveTime
        Returns:
        a new service container instance
      • create

        public static ServiceContainer create​(boolean autoShutdown)
        Create a new instance with a generated name and default thread pool.
        Parameters:
        autoShutdown - true to automatically shut down the container at VM exit, false otherwise
        Returns:
        a new service container instance
      • create

        public static ServiceContainer create​(java.lang.String name,
                                              boolean autoShutdown)
        Create a new instance with a given name and default thread pool.
        Parameters:
        name - the name of the new container
        autoShutdown - true to automatically shut down the container at VM exit, false otherwise
        Returns:
        a new service container instance
      • create

        public static ServiceContainer create​(int coreSize,
                                              long keepAliveTime,
                                              java.util.concurrent.TimeUnit keepAliveTimeUnit,
                                              boolean autoShutdown)
        Create a new instance with a generated name and specified initial thread pool settings.
        Parameters:
        coreSize - the core pool size (must be greater than zero)
        keepAliveTime - the amount of time that non-core threads should linger without tasks
        keepAliveTimeUnit - the time unit for keepAliveTime
        autoShutdown - true to automatically shut down the container at VM exit, false otherwise
        Returns:
        a new service container instance
      • create

        public static ServiceContainer create​(java.lang.String name,
                                              int coreSize,
                                              long keepAliveTime,
                                              java.util.concurrent.TimeUnit keepAliveTimeUnit,
                                              boolean autoShutdown)
        Create a new instance with a given name and specified initial thread pool settings.
        Parameters:
        name - the name of the new container
        coreSize - the core pool size (must be greater than zero)
        keepAliveTime - the amount of time that non-core threads should linger without tasks
        keepAliveTimeUnit - the time unit for keepAliveTime
        autoShutdown - true to automatically shut down the container at VM exit, false otherwise
        Returns:
        a new service container instance
      • calculateCoreSize

        private static int calculateCoreSize()
      • calculateCoreSize

        private static int calculateCoreSize​(int coreSize)