Package org.craftercms.commons.aws
Class AbstractAwsClientCachingFactory<P extends AbstractAwsProfile,C>
- java.lang.Object
-
- org.craftercms.commons.aws.AbstractAwsClientCachingFactory<P,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 onAbstractAwsProfiles. 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 togetClient(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 Summary
Fields Modifier and Type Field Description static intDEFAULT_SHUTDOWN_CLIENT_AFTER_IDLE_SECS
-
Constructor Summary
Constructors Constructor Description AbstractAwsClientCachingFactory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()protected abstract CcreateClient(P profile)voiddestroy()CgetClient(P profile)voidonRemoval(com.google.common.cache.RemovalNotification<P,C> notification)voidsetShutdownClientAfterIdleSecs(int shutdownClientAfterIdleSecs)protected voidshutdownClient(com.google.common.cache.RemovalNotification<P,C> notification)
-
-
-
Field Detail
-
DEFAULT_SHUTDOWN_CLIENT_AFTER_IDLE_SECS
public static final int DEFAULT_SHUTDOWN_CLIENT_AFTER_IDLE_SECS
- See Also:
- Constant Field Values
-
-
Method Detail
-
setShutdownClientAfterIdleSecs
public void setShutdownClientAfterIdleSecs(int shutdownClientAfterIdleSecs)
-
onRemoval
public void onRemoval(com.google.common.cache.RemovalNotification<P,C> notification)
- Specified by:
onRemovalin interfacecom.google.common.cache.RemovalListener<P extends AbstractAwsProfile,C>
-
destroy
public void destroy()
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
shutdownClient
protected void shutdownClient(com.google.common.cache.RemovalNotification<P,C> notification)
-
-