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 onAbstractAwsProfile
s. 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
AbstractAwsProfile
s 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 int
DEFAULT_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 void
afterPropertiesSet()
protected abstract C
createClient(P profile)
void
destroy()
C
getClient(P profile)
void
onRemoval(com.google.common.cache.RemovalNotification<P,C> notification)
void
setShutdownClientAfterIdleSecs(int shutdownClientAfterIdleSecs)
protected void
shutdownClient(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:
onRemoval
in interfacecom.google.common.cache.RemovalListener<P extends AbstractAwsProfile,C>
-
destroy
public void destroy()
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
-
shutdownClient
protected void shutdownClient(com.google.common.cache.RemovalNotification<P,C> notification)
-
-