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 on
AbstractAwsProfile
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 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 Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
protected abstract C
createClient
(P profile) void
destroy()
void
void
setShutdownClientAfterIdleSecs
(int shutdownClientAfterIdleSecs) protected void
shutdownClient
(com.google.common.cache.RemovalNotification<P, C> notification)
-
Field Details
-
DEFAULT_SHUTDOWN_CLIENT_AFTER_IDLE_SECS
public static final int DEFAULT_SHUTDOWN_CLIENT_AFTER_IDLE_SECS- See Also:
-
-
Constructor Details
-
AbstractAwsClientCachingFactory
public AbstractAwsClientCachingFactory()
-
-
Method Details
-
setShutdownClientAfterIdleSecs
public void setShutdownClientAfterIdleSecs(int shutdownClientAfterIdleSecs) -
onRemoval
- 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
-
getClient
-
shutdownClient
-
createClient
-