Class AbstractDBMediator

    • Constructor Detail

      • AbstractDBMediator

        public AbstractDBMediator()
    • Method Detail

      • init

        public void init​(SynapseEnvironment se)
        Initializes the mediator - either an existing data source will be looked up from an in- or external JNDI provider or a custom data source will be created based on the provide configuration (using Apache DBCP).
        Specified by:
        init in interface ManagedLifecycle
        Parameters:
        se - the Synapse environment reference
      • destroy

        public void destroy()
        Destroys the mediator. If we are using our custom DataSource, then shut down the connections
        Specified by:
        destroy in interface ManagedLifecycle
      • mediate

        public boolean mediate​(MessageContext synCtx)
        Process each SQL statement against the current message
        Specified by:
        mediate in interface Mediator
        Parameters:
        synCtx - the current message
        Returns:
        true, always
      • processStatement

        protected abstract void processStatement​(Statement query,
                                                 MessageContext msgCtx)
        Subclasses must specify how each SQL statement is processed
        Parameters:
        query - the SQL statement
        msgCtx - current message
      • closeConnection

        protected abstract void closeConnection​(long key)
        Close the connection of the current thread id
        Parameters:
        key - current thread id
      • getDSName

        protected String getDSName()
        Return the name or (hopefully) unique connection URL specific to the DataSource being used This is used for logging purposes only
        Returns:
        a unique name or URL to refer to the DataSource being used
      • setDataSourceInformation

        public void setDataSourceInformation​(org.apache.synapse.commons.datasource.DataSourceInformation dataSourceInformation)
      • setJndiProperties

        public void setJndiProperties​(Properties jndiProperties)
      • getDataSource

        public DataSource getDataSource()
      • setDataSource

        public void setDataSource​(DataSource dataSource)
      • setDataSourceName

        public void setDataSourceName​(String dataSourceName)
      • addDataSourceProperty

        public void addDataSourceProperty​(QName name,
                                          String value)
      • addDataSourceProperty

        public void addDataSourceProperty​(String name,
                                          String value)
      • addStatement

        public void addStatement​(Statement stmnt)
      • getDbPoolView

        public org.apache.synapse.commons.datasource.DBPoolView getDbPoolView()
      • setDbPoolView

        public void setDbPoolView​(org.apache.synapse.commons.datasource.DBPoolView dbPoolView)
      • getPreparedStatement

        protected PreparedStatement getPreparedStatement​(Statement stmnt,
                                                         Connection con,
                                                         MessageContext msgCtx)
                                                  throws SQLException
        Return a Prepared statement for the given Statement object, which is ready to be executed
        Parameters:
        stmnt - SQL stataement to be executed
        con - The connection to be used
        msgCtx - Current message context
        Returns:
        a PreparedStatement
        Throws:
        SQLException - on error
      • createCustomDataSource

        protected DataSource createCustomDataSource​(org.apache.synapse.commons.datasource.DataSourceInformation dataSourceInformation)
        Create a custom DataSource using the specified data source information.
        Parameters:
        dataSourceInformation - the data source information to create a data source
        Returns:
        a DataSource created using specified properties
      • handleException

        protected void handleException​(String message)
      • isRegistryBasedDriverConfig

        public boolean isRegistryBasedDriverConfig()
      • setRegistryBasedDriverConfig

        public void setRegistryBasedDriverConfig​(boolean registryBasedDriverConfig)
      • isRegistryBasedUrlConfig

        public boolean isRegistryBasedUrlConfig()
      • setRegistryBasedUrlConfig

        public void setRegistryBasedUrlConfig​(boolean registryBasedUrlConfig)
      • isRegistryBasedUserConfig

        public boolean isRegistryBasedUserConfig()
      • setRegistryBasedUserConfig

        public void setRegistryBasedUserConfig​(boolean registryBasedUserConfig)
      • isRegistryBasedPassConfig

        public boolean isRegistryBasedPassConfig()
      • setRegistryBasedPassConfig

        public void setRegistryBasedPassConfig​(boolean registryBasedPassConfig)