示例#1
0
        /// <summary>
        /// Get a object pool for this connector if it supports connector pooling.
        /// </summary>
        public static ObjectPool <PoolableConnector> GetPool(APIConfigurationImpl impl,
                                                             LocalConnectorInfoImpl localInfo)
        {
            ObjectPool <PoolableConnector> pool = null;

            // determine if this connector wants generic connector pooling..
            if (impl.IsConnectorPoolingSupported)
            {
                ConnectorPoolKey key =
                    new ConnectorPoolKey(
                        impl.ConnectorInfo.ConnectorKey,
                        (ConfigurationPropertiesImpl)impl.ConfigurationProperties,
                        impl.ConnectorPoolConfiguration);

                lock (_pools)
                {
                    // get the pool associated..
                    pool = CollectionUtil.GetValue(_pools, key, null);
                    // create a new pool if it doesn't exist..
                    if (pool == null)
                    {
                        Trace.TraceInformation("Creating new pool: " +
                                               impl.ConnectorInfo.ConnectorKey);
                        // this instance is strictly used for the pool..
                        pool = new ObjectPool <PoolableConnector>(
                            new ConnectorPoolHandler(impl, localInfo),
                            impl.ConnectorPoolConfiguration);
                        // add back to the map of _pools..
                        _pools[key] = pool;
                    }
                }
            }
            return(pool);
        }
示例#2
0
 public override bool Equals(Object o)
 {
     if (o is ConnectorPoolKey)
     {
         ConnectorPoolKey other = (ConnectorPoolKey)o;
         if (!_connectorKey.Equals(other._connectorKey))
         {
             return(false);
         }
         if (!_configProperties.Equals(other._configProperties))
         {
             return(false);
         }
         if (!_poolingConfig.Equals(other._poolingConfig))
         {
             return(false);
         }
         return(true);
     }
     return(false);
 }