Spring Data for VMware GemFire
Class AbstractGemFireAsLastResourceAspectSupport
java.lang.Object
org.springframework.data.gemfire.config.annotation.support.AbstractGemFireAsLastResourceAspectSupport
- All Implemented Interfaces:
org.springframework.core.Ordered
- Direct Known Subclasses:
GemFireAsLastResourceConnectionAcquiringAspect,GemFireAsLastResourceConnectionClosingAspect
public class AbstractGemFireAsLastResourceAspectSupport
extends Object
implements org.springframework.core.Ordered
AbstractGemFireAsLastResourceAspectSupport is an abstract base class encapsulating functionality common
to all AOP Aspect extensions/implementations involving the Apache Geode JCA ResourceAdapter object registered in
the JNDI context of a managed environment.- Since:
- 1.0.0
- See Also:
-
ContextGemFireCacheGFConnectionLoggerOrdered
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final intprotected static final booleanFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDefines an AOP Pointcut identifying Join Points during the execution of the application's components on which this Aspect should be applied.protected voidDefines an AOP Pointcut identifying Join Points during the execution of the application's components on which this Aspect should be applied.protected Stringprotected ContextReturns a reference to the namingContext.protected IntegerReturns the default order used by this AOP Aspect in the chain of Aspects configured in Spring's Transaction Management.protected <T extends org.apache.geode.cache.GemFireCache>
TReturns a reference to theGemFireCacheused to interact with GemFire.Returns the configured reference to GemFire's JCA ResourceAdapter registered in the managed environment's JNDI context.Returns the configured, fully-qualified classname of theInitialContextFactoryused to construct theInitialContextthat is then used to lookup managed objects registered in the JNDI context of the managed environment.protected org.slf4j.LoggerReturns a reference to theLoggerused to record debug, info, warning and error messages logged by the application.intgetOrder()Returns the order of this AOP Aspect relative to other Aspects in the chain of Aspects configured in Spring's Transaction Management.Returns the URL of the Naming Context Provider as aString.booleanDetermines whether an Exception should be thrown when this Aspect is unable to perform its function.protected <T extends AbstractGemFireAsLastResourceAspectSupport>
TlogDebugInfo(String message, Object... args) protected <T extends AbstractGemFireAsLastResourceAspectSupport>
Tprotected <T extends AbstractGemFireAsLastResourceAspectSupport>
Tprotected <T extends AbstractGemFireAsLastResourceAspectSupport>
TlogTraceInfo(String message, Object... args) protected <T extends AbstractGemFireAsLastResourceAspectSupport>
TlogTraceInfo(Supplier<String> logMessage) Logs the givenlog messageatLevel.TRACElevel when tracing is enabled.protected <T extends AbstractGemFireAsLastResourceAspectSupport>
TlogWarning(String message, Object... args) protected InitialContextnewInitialContext(Hashtable<?, ?> environment) Constructs a new instance of theInitialContextconfigured with the givenenvironment.protected org.slf4j.LoggerConstructs a new instance ofLoggerused by this application to log messages.protected ContextResolves theContextused to perform lookups of registered, managed objects in a management environment.protected Hashtable<?,?> Resolves theenvironmentused by the application to configure theInitialContext.protected org.apache.geode.cache.GemFireCacheResolves a reference to theGemFireCacherequired by this Aspect to perform its function.protected StringResolves the configured JNDI name used to lookup and resolve the GemFire JCA ResourceAdapter object from the JNDI context in the managed environment.voidsetOrder(int order) Sets the order of this AOP Aspect relative to other Aspects in the chain of Aspects configured in Spring's Transaction Management.<T extends AbstractGemFireAsLastResourceAspectSupport>
TwithThrowOnError(boolean throwOnError) Builder method used to set thethrowOnErrorproperty.
-
Field Details
-
DEFAULT_THROW_ON_ERROR
protected static final boolean DEFAULT_THROW_ON_ERROR- See Also:
-
DEFAULT_ORDER
protected static final int DEFAULT_ORDER- See Also:
-
NO_OP_LOGGER
-
DEFAULT_GEMFIRE_JCA_RESOURCE_ADAPTER_JNDI_NAME
- See Also:
-
-
Constructor Details
-
AbstractGemFireAsLastResourceAspectSupport
public AbstractGemFireAsLastResourceAspectSupport()
-
-
Method Details
-
getContext
Returns a reference to the namingContext. -
getGemFireCache
protected <T extends org.apache.geode.cache.GemFireCache> T getGemFireCache()Returns a reference to theGemFireCacheused to interact with GemFire.- Type Parameters:
T-Classsub-type of theGemFireCachein use.- Returns:
- a reference to the
GemFireCache. - See Also:
-
GemFireCache
-
getGemFireJcaResourceAdapterJndiName
Returns the configured reference to GemFire's JCA ResourceAdapter registered in the managed environment's JNDI context.- Returns:
- a
Stringcontaining the configured reference to GemFire's JCA ResourceAdapter registered in the managed environment's JNDI context.
-
getInitialContextFactory
Returns the configured, fully-qualified classname of theInitialContextFactoryused to construct theInitialContextthat is then used to lookup managed objects registered in the JNDI context of the managed environment.- Returns:
- the configured, fully-qualified classname of the
InitialContextFactoryused to construct theInitialContext.
-
getLogger
protected org.slf4j.Logger getLogger()Returns a reference to theLoggerused to record debug, info, warning and error messages logged by the application.- Returns:
- a reference to the configured
Loggerused by the application for logging purposes. - See Also:
-
Logger
-
setOrder
public void setOrder(int order) Sets the order of this AOP Aspect relative to other Aspects in the chain of Aspects configured in Spring's Transaction Management.- Parameters:
order- int value specifying the relative order of this Aspect.- See Also:
-
Ordered
-
getOrder
public int getOrder()Returns the order of this AOP Aspect relative to other Aspects in the chain of Aspects configured in Spring's Transaction Management.- Specified by:
getOrderin interfaceorg.springframework.core.Ordered- Returns:
- an int value specifying the relative order of this Aspect.
- See Also:
-
Ordered
-
getDefaultOrder
Returns the default order used by this AOP Aspect in the chain of Aspects configured in Spring's Transaction Management.- Returns:
- an int value specifying the default order used by this AOP Aspect in the chain of Aspects configured in Spring's Transaction Management.
-
getProviderUrl
Returns the URL of the Naming Context Provider as aString.- Returns:
- the URL of the Naming Context Provider.
-
isThrowOnError
public boolean isThrowOnError()Determines whether an Exception should be thrown when this Aspect is unable to perform its function. Alternatively (and by default) the error condition is simply logged. Defaults to false.- Returns:
- a boolean value indicating whether this Aspect should throw an Exception when an error occurs preventing this Aspect from performing its normal function.
-
atTransactionalType
protected void atTransactionalType()Defines an AOP Pointcut identifying Join Points during the execution of the application's components on which this Aspect should be applied. This particular Pointcut identifiesTransactionalannotated application servicetypes. That is, theTransactionalannotation is used at the class level.- See Also:
-
Pointcut
-
atTransactionalMethod
protected void atTransactionalMethod()Defines an AOP Pointcut identifying Join Points during the execution of the application's components on which this Aspect should be applied. This particular Pointcut identifiesTransactionalannotated application servicemethods. That is, theTransactionalannotation is used at the service class, servicemethodlevel.- See Also:
-
Pointcut
-
format
-
logDebugInfo
protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logDebugInfo(String message, Object... args) Logs the givenmessageformatted with the given array ofargumentsatLevel.DEBUGlevel when debugging is enabled.- Type Parameters:
T-Classtype extension ofAbstractGemFireAsLastResourceAspectSupport.- Parameters:
message-Stringcontaining the message to log.args- array ofargumentsused to format the message.- Returns:
- this aspect.
- See Also:
-
Logger.isDebugEnabled()Logger.debug(String, Object...)format(String, Object...)
-
logInfo
protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logInfo(String message, Object... args) Logs the givenmessageformatted with the given array ofargumentsatLevel.INFOlevel when info logging is enabled.- Type Parameters:
T-Classtype extension ofAbstractGemFireAsLastResourceAspectSupport.- Parameters:
message-Stringcontaining the message to log.args- array ofargumentsused to format the message.- Returns:
- this aspect.
- See Also:
-
Logger.isInfoEnabled()Logger.info(String, Object...)format(String, Object...)
-
logTraceInfo
protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logTraceInfo(String message, Object... args) Logs the givenmessageformatted with the given array ofargumentsatLevel.TRACElevel when tracing is enabled.- Type Parameters:
T-Classtype extension ofAbstractGemFireAsLastResourceAspectSupport.- Parameters:
message-Stringcontaining the message to log.args- array ofargumentsused to format the message.- Returns:
- this aspect.
- See Also:
-
logTraceInfo
protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logTraceInfo(Supplier<String> logMessage) Logs the givenlog messageatLevel.TRACElevel when tracing is enabled.- Type Parameters:
T-Classtype extension ofAbstractGemFireAsLastResourceAspectSupport.- Parameters:
logMessage-Supplierof the message to log.- Returns:
- this aspect.
- See Also:
-
SupplierLogger.isTraceEnabled()Logger.trace(String)
-
logWarning
protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logWarning(String message, Object... args) Logs the givenmessageformatted with the given array ofargumentsatLevel.WARNlevel when warnings are enabled.- Type Parameters:
T-Classtype extension ofAbstractGemFireAsLastResourceAspectSupport.- Parameters:
message-Stringcontaining the message to log.args- array ofargumentsused to format the message.- Returns:
- this aspect.
- See Also:
-
Logger.isWarnEnabled()Logger.warn(String, Object...)format(String, Object...)
-
logError
protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logError(String message, Object... args) Logs the givenmessageformatted with the given array ofargumentsatLevel.ERRORlevel when error logging is enabled.- Type Parameters:
T-Classtype extension ofAbstractGemFireAsLastResourceAspectSupport.- Parameters:
message-Stringcontaining the message to log.args- array ofargumentsused to format the message.- Returns:
- this aspect.
- See Also:
-
Logger.isErrorEnabled()Logger.error(String, Object...)format(String, Object...)
-
newInitialContext
Constructs a new instance of theInitialContextconfigured with the givenenvironment.- Parameters:
environment-Hashtablecontaining environment configuration meta-data used to access the JNDI context in a managed environment.- Returns:
- a new instance of the
InitialContextconfigured with the givenenvironment. - Throws:
NamingException- if theInitialContextcould not be initialized with the providedenvironment.- See Also:
-
newLogger
protected org.slf4j.Logger newLogger()Constructs a new instance ofLoggerused by this application to log messages.- Returns:
- a new, configured instance of
Logger.
-
resolveContext
Resolves theContextused to perform lookups of registered, managed objects in a management environment.- Returns:
- the
Contextused to perform lookups of registered, managed objects in a managed environment. - Throws:
IllegalStateException- if theContextcould not be resolved.- See Also:
-
GemFireCache.getJNDIContext()newInitialContext(Hashtable)resolveEnvironment()resolveGemFireCache()getContext()Context
-
resolveEnvironment
Resolves theenvironmentused by the application to configure theInitialContext.- Returns:
- the resolved
environmentused to configure theInitialContext. - See Also:
-
resolveGemFireCache
protected org.apache.geode.cache.GemFireCache resolveGemFireCache()Resolves a reference to theGemFireCacherequired by this Aspect to perform its function. This method either returns the configuredGemFireCacheinstance or looks up theGemFireCacheinstance using GemFire's API.- Returns:
- a reference to the resolved
GemFireCacheinstance. - See Also:
-
CacheUtils.resolveGemFireCache()GemFireCachegetGemFireCache()
-
resolveGemFireJcaResourceAdapterJndiName
Resolves the configured JNDI name used to lookup and resolve the GemFire JCA ResourceAdapter object from the JNDI context in the managed environment.- Returns:
- a
Stringcontaining the JNDI name used to lookup and resolve the GemFire JCA ResourceAdapter object from the JNDI context in the managed environment. - See Also:
-
withThrowOnError
public <T extends AbstractGemFireAsLastResourceAspectSupport> T withThrowOnError(boolean throwOnError) Builder method used to set thethrowOnErrorproperty. ThethrowOnErrorproperty is used to indicate whether an Exception should be thrown when an error occurs during the normal operation and function of this Aspect. By default, the error condition is simply logged.- Type Parameters:
T-sub-typeof this Aspect.- Parameters:
throwOnError- boolean value used to set thethrowOnErrorproperty.- Returns:
- this Aspect.
- See Also:
-