Class AbstractGemFireAsLastResourceAspectSupport

java.lang.Object
org.springframework.data.gemfire.config.annotation.support.AbstractGemFireAsLastResourceAspectSupport
All Implemented Interfaces:
Ordered
Direct Known Subclasses:
GemFireAsLastResourceConnectionAcquiringAspect, GemFireAsLastResourceConnectionClosingAspect

public class AbstractGemFireAsLastResourceAspectSupport extends Object implements 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
Author:
John Blum
See Also:
  • 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

      protected static final Consumer<String> NO_OP_LOGGER
    • DEFAULT_GEMFIRE_JCA_RESOURCE_ADAPTER_JNDI_NAME

      protected static final String DEFAULT_GEMFIRE_JCA_RESOURCE_ADAPTER_JNDI_NAME
      See Also:
  • Constructor Details

    • AbstractGemFireAsLastResourceAspectSupport

      public AbstractGemFireAsLastResourceAspectSupport()
  • Method Details

    • getContext

      protected Context getContext()
      Returns a reference to the naming Context.
      Returns:
      a reference to the naming Context.
      See Also:
    • getGemFireCache

      protected <T extends GemFireCache> T getGemFireCache()
      Returns a reference to the GemFireCache used to interact with GemFire.
      Type Parameters:
      T - Class sub-type of the GemFireCache in use.
      Returns:
      a reference to the GemFireCache.
      See Also:
    • getGemFireJcaResourceAdapterJndiName

      public String 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

      public String getInitialContextFactory()
      Returns the configured, fully-qualified classname of the InitialContextFactory used to construct the InitialContext 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 the InitialContext.
    • getLogger

      protected org.slf4j.Logger getLogger()
      Returns a reference to the Logger 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:
    • 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 interface Ordered
      Returns:
      an int value specifying the relative order of this Aspect.
      See Also:
    • getDefaultOrder

      protected Integer 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

      public String getProviderUrl()
      Returns the URL of the Naming Context Provider as a String.
      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 identifies Transactional annotated application service types. That is, the Transactional 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 identifies Transactional annotated application service methods. That is, the Transactional annotation is used at the service class, service method level.
      See Also:
      • Pointcut
    • format

      protected String format(String message, Object... args)
      Formats the given message with the provided array of arguments.
      Parameters:
      message - String containing the message to format.
      args - array of arguments used to format the message.
      Returns:
      the message formatted with the provided array of arguments.
      See Also:
    • logDebugInfo

      protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logDebugInfo(String message, Object... args)
      Logs the given message formatted with the given array of arguments at Level.DEBUG level when debugging is enabled.
      Type Parameters:
      T - Class type extension of AbstractGemFireAsLastResourceAspectSupport.
      Parameters:
      message - String containing the message to log.
      args - array of arguments used to format the message.
      Returns:
      this aspect.
      See Also:
    • logInfo

      protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logInfo(String message, Object... args)
      Logs the given message formatted with the given array of arguments at Level.INFO level when info logging is enabled.
      Type Parameters:
      T - Class type extension of AbstractGemFireAsLastResourceAspectSupport.
      Parameters:
      message - String containing the message to log.
      args - array of arguments used to format the message.
      Returns:
      this aspect.
      See Also:
    • logTraceInfo

      protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logTraceInfo(String message, Object... args)
      Logs the given message formatted with the given array of arguments at Level.TRACE level when tracing is enabled.
      Type Parameters:
      T - Class type extension of AbstractGemFireAsLastResourceAspectSupport.
      Parameters:
      message - String containing the message to log.
      args - array of arguments used to format the message.
      Returns:
      this aspect.
      See Also:
    • logTraceInfo

      protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logTraceInfo(Supplier<String> logMessage)
      Logs the given log message at Level.TRACE level when tracing is enabled.
      Type Parameters:
      T - Class type extension of AbstractGemFireAsLastResourceAspectSupport.
      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 given message formatted with the given array of arguments at Level.WARN level when warnings are enabled.
      Type Parameters:
      T - Class type extension of AbstractGemFireAsLastResourceAspectSupport.
      Parameters:
      message - String containing the message to log.
      args - array of arguments used to format the message.
      Returns:
      this aspect.
      See Also:
    • logError

      protected <T extends AbstractGemFireAsLastResourceAspectSupport> T logError(String message, Object... args)
      Logs the given message formatted with the given array of arguments at Level.ERROR level when error logging is enabled.
      Type Parameters:
      T - Class type extension of AbstractGemFireAsLastResourceAspectSupport.
      Parameters:
      message - String containing the message to log.
      args - array of arguments used to format the message.
      Returns:
      this aspect.
      See Also:
    • newInitialContext

      protected InitialContext newInitialContext(Hashtable<?,?> environment) throws NamingException
      Constructs a new instance of the InitialContext configured with the given environment.
      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 given environment.
      Throws:
      NamingException - if the InitialContext could not be initialized with the provided environment.
      See Also:
    • newLogger

      protected org.slf4j.Logger newLogger()
      Constructs a new instance of Logger used by this application to log messages.
      Returns:
      a new, configured instance of Logger.
    • resolveContext

      protected Context resolveContext()
      Resolves the Context 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 the Context could not be resolved.
      See Also:
    • resolveEnvironment

      protected Hashtable<?,?> resolveEnvironment()
      Resolves the environment used by the application to configure the InitialContext.
      Returns:
      the resolved environment used to configure the InitialContext.
      See Also:
    • resolveGemFireCache

      protected GemFireCache resolveGemFireCache()
      Resolves a reference to the GemFireCache required by this Aspect to perform its function. This method either returns the configured GemFireCache instance or looks up the GemFireCache instance using GemFire's API.
      Returns:
      a reference to the resolved GemFireCache instance.
      See Also:
    • resolveGemFireJcaResourceAdapterJndiName

      protected String 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 the throwOnError property. The throwOnError 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 the throwOnError property.
      Returns:
      this Aspect.
      See Also: