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:
-
Context
GemFireCache
GFConnection
Logger
Ordered
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final int
protected static final boolean
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Defines an AOP Pointcut identifying Join Points during the execution of the application's components on which this Aspect should be applied.protected void
Defines an AOP Pointcut identifying Join Points during the execution of the application's components on which this Aspect should be applied.protected String
protected Context
Returns a reference to the namingContext
.protected Integer
Returns 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 theGemFireCache
used 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 theInitialContextFactory
used to construct theInitialContext
that is then used to lookup managed objects registered in the JNDI context of the managed environment.protected org.slf4j.Logger
Returns a reference to theLogger
used to record debug, info, warning and error messages logged by the application.int
getOrder()
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
.boolean
Determines 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 message
atLevel.TRACE
level when tracing is enabled.protected <T extends AbstractGemFireAsLastResourceAspectSupport>
TlogWarning
(String message, Object... args) protected InitialContext
newInitialContext
(Hashtable<?, ?> environment) Constructs a new instance of theInitialContext
configured with the givenenvironment
.protected org.slf4j.Logger
Constructs a new instance ofLogger
used by this application to log messages.protected Context
Resolves theContext
used to perform lookups of registered, managed objects in a management environment.protected Hashtable<?,
?> Resolves theenvironment
used by the application to configure theInitialContext
.protected org.apache.geode.cache.GemFireCache
Resolves a reference to theGemFireCache
required by this Aspect to perform its function.protected String
Resolves the configured JNDI name used to lookup and resolve the GemFire JCA ResourceAdapter object from the JNDI context in the managed environment.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.<T extends AbstractGemFireAsLastResourceAspectSupport>
TwithThrowOnError
(boolean throwOnError) Builder method used to set thethrowOnError
property.
-
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 theGemFireCache
used to interact with GemFire.- Type Parameters:
T
-Class
sub-type of theGemFireCache
in 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
String
containing the configured reference to GemFire's JCA ResourceAdapter registered in the managed environment's JNDI context.
-
getInitialContextFactory
Returns the configured, fully-qualified classname of theInitialContextFactory
used to construct theInitialContext
that is then used to lookup managed objects registered in the JNDI context of the managed environment.- Returns:
- the configured, fully-qualified classname of the
InitialContextFactory
used to construct theInitialContext
.
-
getLogger
protected org.slf4j.Logger getLogger()Returns a reference to theLogger
used to record debug, info, warning and error messages logged by the application.- Returns:
- a reference to the configured
Logger
used 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:
getOrder
in 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 identifiesTransactional
annotated application servicetypes
. That is, theTransactional
annotation 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 identifiesTransactional
annotated application servicemethods
. That is, theTransactional
annotation is used at the service class, servicemethod
level.- See Also:
-
Pointcut
-
format
-
logDebugInfo
protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logDebugInfo(String message, Object... args) Logs the givenmessage
formatted with the given array ofarguments
atLevel.DEBUG
level when debugging is enabled.- Type Parameters:
T
-Class
type extension ofAbstractGemFireAsLastResourceAspectSupport
.- Parameters:
message
-String
containing the message to log.args
- array ofarguments
used 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 givenmessage
formatted with the given array ofarguments
atLevel.INFO
level when info logging is enabled.- Type Parameters:
T
-Class
type extension ofAbstractGemFireAsLastResourceAspectSupport
.- Parameters:
message
-String
containing the message to log.args
- array ofarguments
used 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 givenmessage
formatted with the given array ofarguments
atLevel.TRACE
level when tracing is enabled.- Type Parameters:
T
-Class
type extension ofAbstractGemFireAsLastResourceAspectSupport
.- Parameters:
message
-String
containing the message to log.args
- array ofarguments
used to format the message.- Returns:
- this aspect.
- See Also:
-
logTraceInfo
protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logTraceInfo(Supplier<String> logMessage) Logs the givenlog message
atLevel.TRACE
level when tracing is enabled.- Type Parameters:
T
-Class
type extension ofAbstractGemFireAsLastResourceAspectSupport
.- Parameters:
logMessage
-Supplier
of the message to log.- Returns:
- this aspect.
- See Also:
-
Supplier
Logger.isTraceEnabled()
Logger.trace(String)
-
logWarning
protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logWarning(String message, Object... args) Logs the givenmessage
formatted with the given array ofarguments
atLevel.WARN
level when warnings are enabled.- Type Parameters:
T
-Class
type extension ofAbstractGemFireAsLastResourceAspectSupport
.- Parameters:
message
-String
containing the message to log.args
- array ofarguments
used 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 givenmessage
formatted with the given array ofarguments
atLevel.ERROR
level when error logging is enabled.- Type Parameters:
T
-Class
type extension ofAbstractGemFireAsLastResourceAspectSupport
.- Parameters:
message
-String
containing the message to log.args
- array ofarguments
used to format the message.- Returns:
- this aspect.
- See Also:
-
Logger.isErrorEnabled()
Logger.error(String, Object...)
format(String, Object...)
-
newInitialContext
Constructs a new instance of theInitialContext
configured with the givenenvironment
.- Parameters:
environment
-Hashtable
containing environment configuration meta-data used to access the JNDI context in a managed environment.- Returns:
- a new instance of the
InitialContext
configured with the givenenvironment
. - Throws:
NamingException
- if theInitialContext
could not be initialized with the providedenvironment
.- See Also:
-
newLogger
protected org.slf4j.Logger newLogger()Constructs a new instance ofLogger
used by this application to log messages.- Returns:
- a new, configured instance of
Logger
.
-
resolveContext
Resolves theContext
used to perform lookups of registered, managed objects in a management environment.- Returns:
- the
Context
used to perform lookups of registered, managed objects in a managed environment. - Throws:
IllegalStateException
- if theContext
could not be resolved.- See Also:
-
GemFireCache.getJNDIContext()
newInitialContext(Hashtable)
resolveEnvironment()
resolveGemFireCache()
getContext()
Context
-
resolveEnvironment
Resolves theenvironment
used by the application to configure theInitialContext
.- Returns:
- the resolved
environment
used to configure theInitialContext
. - See Also:
-
resolveGemFireCache
protected org.apache.geode.cache.GemFireCache resolveGemFireCache()Resolves a reference to theGemFireCache
required by this Aspect to perform its function. This method either returns the configuredGemFireCache
instance or looks up theGemFireCache
instance using GemFire's API.- Returns:
- a reference to the resolved
GemFireCache
instance. - See Also:
-
CacheUtils.resolveGemFireCache()
GemFireCache
getGemFireCache()
-
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
String
containing 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 thethrowOnError
property. ThethrowOnError
property 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-type
of this Aspect.- Parameters:
throwOnError
- boolean value used to set thethrowOnError
property.- Returns:
- this Aspect.
- See Also:
-