Class AbstractAwsClientCachingFactory<P extends AbstractAwsProfile,​C>

  • All Implemented Interfaces:
    com.google.common.cache.RemovalListener<P,​C>, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean
    Direct Known Subclasses:
    S3ClientCachingFactory

    public abstract class AbstractAwsClientCachingFactory<P extends AbstractAwsProfile,​C>
    extends Object
    implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, com.google.common.cache.RemovalListener<P,​C>
    Factory class that creates AWS clients based on AbstractAwsProfiles. It also caches the clients so instead of creating a new client for the same profile, it will reuse a previous client. Clients that haven't been used for a while will be evicted from the cache and shutdown.

    WARNING: the AbstractAwsProfiles that you pass to getClient(AbstractAwsProfile) should implement equals and hash code methods that take into account most of the properties, so that the clients are cached correctly.

    Author:
    avasquez
    • Field Detail

      • DEFAULT_SHUTDOWN_CLIENT_AFTER_IDLE_SECS

        public static final int DEFAULT_SHUTDOWN_CLIENT_AFTER_IDLE_SECS
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractAwsClientCachingFactory

        public AbstractAwsClientCachingFactory()
    • Method Detail

      • setShutdownClientAfterIdleSecs

        public void setShutdownClientAfterIdleSecs​(int shutdownClientAfterIdleSecs)
      • onRemoval

        public void onRemoval​(com.google.common.cache.RemovalNotification<P,​C> notification)
        Specified by:
        onRemoval in interface com.google.common.cache.RemovalListener<P extends AbstractAwsProfile,​C>
      • destroy

        public void destroy()
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean
      • afterPropertiesSet

        public void afterPropertiesSet()
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      • getClient

        public C getClient​(P profile)
      • shutdownClient

        protected void shutdownClient​(com.google.common.cache.RemovalNotification<P,​C> notification)
      • createClient

        protected abstract C createClient​(P profile)