Exemplo n.º 1
0
        /// <summary>
        /// Puts the value from the mapped class into the <see cref="IDbCommand"/>.
        /// </summary>
        /// <param name="cmd">The <see cref="IDbCommand"/> to put the values into.</param>
        /// <param name="value">The object that contains the values.</param>
        /// <param name="index">The index of the <see cref="IDbDataParameter"/> to write the value to.</param>
        /// <remarks>
        /// <para>
        /// This method checks to see if value is null, if it is then the value of
        /// <see cref="DBNull"/> is written to the <see cref="IDbCommand"/>.
        /// </para>
        /// <para>
        /// If the value is not null, then the method <see cref="Set(IDbCommand, object, int)"/>
        /// is called and that method is responsible for setting the value.
        /// </para>
        /// </remarks>
        public void NullSafeSet(IDbCommand cmd, object value, int index)
        {
            if (value == null)
            {
                if (IsDebugEnabled)
                {
                    Log.Debug("binding null to parameter: " + index);
                }

                //Do we check IsNullable?
                // TODO: find out why a certain Parameter would not take a null value...
                // From reading the .NET SDK the default is to NOT accept a null value.
                // I definitely need to look into this more...
                ((IDataParameter)cmd.Parameters[index]).Value = DBNull.Value;
            }
            else
            {
                if (IsDebugEnabled)
                {
                    Log.Debug("binding '" + ToString(value) + "' to parameter: " + index);
                }

                Set(cmd, value, index);
            }
        }
Exemplo n.º 2
0
        static ByteBufferUtil()
        {
            Logger = InternalLoggerFactory.GetInstance(typeof(ByteBufferUtil));

            string allocType = SystemPropertyUtil.Get("io.netty.allocator.type", "pooled");

            allocType = allocType.Trim();

            IByteBufferAllocator alloc;

            if ("unpooled".Equals(allocType, StringComparison.OrdinalIgnoreCase))
            {
                alloc = UnpooledByteBufferAllocator.Default;
                Logger.Debug("-Dio.netty.allocator.type: {}", allocType);
            }
            else if ("pooled".Equals(allocType, StringComparison.OrdinalIgnoreCase))
            {
                alloc = PooledByteBufferAllocator.Default;
                Logger.Debug("-Dio.netty.allocator.type: {}", allocType);
            }
            else if ("arraypooled".Equals(allocType, StringComparison.OrdinalIgnoreCase))
            {
                alloc = ArrayPooledByteBufferAllocator.Default;
                Logger.Debug("-Dio.netty.allocator.type: {}", allocType);
            }
            else
            {
                alloc = PooledByteBufferAllocator.Default;
                Logger.Debug("-Dio.netty.allocator.type: pooled (unknown: {})", allocType);
            }

            DefaultAllocator    = alloc;
            MaxBytesPerCharUtf8 = Encoding.UTF8.GetMaxByteCount(1);
            AsciiByteProcessor  = new FindNonAscii();
        }
        public virtual void OnSaveOrUpdate(SaveOrUpdateEvent @event)
        {
            ISessionImplementor source = @event.Session;
            object obj         = @event.Entity;
            object requestedId = @event.RequestedId;

            if (requestedId != null)
            {
                //assign the requested id to the proxy, *before*
                //reassociating the proxy
                if (obj.IsProxy())
                {
                    ((INHibernateProxy)obj).HibernateLazyInitializer.Identifier = requestedId;
                }
            }

            if (ReassociateIfUninitializedProxy(obj, source))
            {
                log.Debug("reassociated uninitialized proxy");
                // an uninitialized proxy, noop, don't even need to
                // return an id, since it is never a save()
            }
            else
            {
                //initialize properties of the event:
                object entity = source.PersistenceContext.UnproxyAndReassociate(obj);
                @event.Entity = entity;
                @event.Entry  = source.PersistenceContext.GetEntry(entity);
                //return the id in the event object
                @event.ResultId = PerformSaveOrUpdate(@event);
            }
        }
Exemplo n.º 4
0
        public void LoadMappings(IList <MappingConfiguration> configurationMappings)
        {
            if (configurationMappings == null)
            {
                throw new ArgumentNullException("configurationMappings");
            }

            foreach (MappingConfiguration mc in configurationMappings)
            {
                if (!string.IsNullOrEmpty(mc.Assembly) && string.IsNullOrEmpty(mc.Resource))
                {
                    log.Debug("Assembly " + mc.Assembly);
                    AddAssembly(mc.Assembly);
                }
                else if (!string.IsNullOrEmpty(mc.Assembly) && !string.IsNullOrEmpty(mc.Resource))
                {
                    log.Debug("Resource " + mc.Resource + " in " + mc.Assembly);
                    AddResource(Assembly.Load(mc.Assembly), mc.Resource);
                }
                else if (!string.IsNullOrEmpty(mc.File))
                {
                    log.Debug("File " + mc.File);
                    AddFile(mc.File);
                }
                else
                {
                    log.Warn(string.Format("Mapping configuration ignored: Assembly>{0}< Resource>{1}< File>{2}<", mc.Assembly,
                                           mc.Resource, mc.File));
                }
            }
        }
        protected virtual void EntityIsPersistent(PersistEvent @event, IDictionary createCache)
        {
            log.Debug("ignoring persistent instance");
            IEventSource source = @event.Session;

            //TODO: check that entry.getIdentifier().equals(requestedId)
            object entity = source.PersistenceContext.Unproxy(@event.Entity);

            /* NH-2565: the UnProxy may return a "field interceptor proxy". When EntityName is null the session.GetEntityPersister will try to guess it.
             * Instead change a session's method I'll try to guess the EntityName here.
             * Because I'm using a session's method perhaps could be better if each session's method, which implementation forward to a method having the EntityName as parameter,
             * use the BestGuessEntityName directly instead do "70 turns" before call it.
             */
            if (@event.EntityName == null)
            {
                @event.EntityName = source.BestGuessEntityName(entity);
            }
            IEntityPersister persister = source.GetEntityPersister(@event.EntityName, entity);

            object tempObject;

            tempObject          = createCache[entity];
            createCache[entity] = entity;
            if (tempObject == null)
            {
                //TODO: merge into one method!
                CascadeBeforeSave(source, persister, entity, createCache);
                CascadeAfterSave(source, persister, entity, createCache);
            }
        }
        public ICache BuildCache(string regionName, IDictionary <string, string> properties)
        {
            ICache result;

            if (caches.TryGetValue(regionName, out result))
            {
                return(result);
            }

            if (_clientManagerStatic == null)
            {
                if (ConnectionSettings == null)
                {
                    ConnectionSettings = RedisCacheConnection.Default();
                }
                _clientManagerStatic = ConnectionMultiplexer.Connect(ConnectionSettings.Render());
            }

            if (Log.IsDebugEnabled)
            {
                var sb = new StringBuilder();
                foreach (var pair in properties)
                {
                    sb.Append(pair.Key);
                    sb.Append(" = '");
                    sb.Append(pair.Value);
                    sb.AppendLine("';");
                }
                Log.Debug(String.Format("building cache with region: {0}, properties: \n{1}", regionName, sb));
            }
            result = new RedisCache(regionName, properties, _clientManagerStatic, ConnectionSettings);
            caches.Add(regionName, result);
            return(result);
        }
Exemplo n.º 7
0
        /// <summary> Log a IDbCommand. </summary>
        /// <param name="message">Title</param>
        /// <param name="command">The SQL statement. </param>
        /// <param name="style">The requested formatting style. </param>
        public virtual void LogCommand(string message, IDbCommand command, FormatStyle style)
        {
            if (!log.IsDebugEnabled && !LogToStdout || string.IsNullOrEmpty(command.CommandText))
            {
                return;
            }

            style = DetermineActualStyle(style);
            string statement = style.Formatter.Format(GetCommandLineWithParameters(command));
            string logMessage;

            if (string.IsNullOrEmpty(message))
            {
                logMessage = statement;
            }
            else
            {
                logMessage = message + statement;
            }
            log.Debug(logMessage);
            if (LogToStdout)
            {
                Console.Out.WriteLine("NHibernate: " + statement);
            }
        }
        private static void CleanupAnyOrphanedSession(ISessionFactory factory)
        {
            ISession orphan = DoUnbind(factory, false);

            if (orphan != null)
            {
                log.Warn("Already session bound on call to bind(); make sure you clean up your sessions!");

                try
                {
                    if (orphan.Transaction != null && orphan.Transaction.IsActive)
                    {
                        try
                        {
                            orphan.Transaction.Rollback();
                        }
                        catch (Exception ex)
                        {
                            log.Debug("Unable to rollback transaction for orphaned session", ex);
                        }
                    }
                    orphan.Close();
                }
                catch (Exception ex)
                {
                    log.Debug("Unable to close orphaned session", ex);
                }
            }
        }
Exemplo n.º 9
0
        static DefaultChannelId()
        {
            int    processId       = -1;
            string customProcessId = SystemPropertyUtil.Get("io.netty.processId");

            if (customProcessId is object)
            {
                if (!int.TryParse(customProcessId, out processId))
                {
                    processId = -1;
                }
                if (processId < 0 || processId > MaxProcessId)
                {
                    processId = -1;
                    Logger.Warn("-Dio.netty.processId: {} (malformed)", customProcessId);
                }
                else if (Logger.DebugEnabled)
                {
                    Logger.Debug("-Dio.netty.processId: {} (user-set)", processId);
                }
            }
            if (processId < 0)
            {
                processId = DefaultProcessId();
                if (Logger.DebugEnabled)
                {
                    Logger.Debug("-Dio.netty.processId: {} (auto-detected)", processId);
                }
            }
            ProcessId = processId;
            byte[] machineId       = null;
            string customMachineId = SystemPropertyUtil.Get("io.netty.machineId");

            if (customMachineId is object)
            {
                if (MachineIdPattern.Match(customMachineId).Success)
                {
                    machineId = ParseMachineId(customMachineId);
                    if (Logger.DebugEnabled)
                    {
                        Logger.Debug("-Dio.netty.machineId: {} (user-set)", customMachineId);
                    }
                }
                else
                {
                    Logger.Warn("-Dio.netty.machineId: {} (malformed)", customMachineId);
                }
            }

            if (machineId is null)
            {
                machineId = DefaultMachineId();
                if (Logger.DebugEnabled)
                {
                    Logger.Debug("-Dio.netty.machineId: {} (auto-detected)", MacAddressUtil.FormatAddress(machineId));
                }
            }
            MachineId = machineId;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Clear the Cache
        /// </summary>
        /// <exception cref="T:NHibernate.Cache.CacheException"></exception>
        public void Clear()
        {
            //remove the root cache item, this will cause all of the individual items to be removed from the cache
            _webCache.Remove(_rootCacheKey);
            _isRootItemCached = false;

            log.Debug("All items cleared from the cache.");
        }
Exemplo n.º 11
0
		public void ReportError(RecognitionException e)
		{
			ReportError( e.ToString() );
			_recognitionExceptions.Add( e );
			if ( log.IsDebugEnabled ) {
				log.Debug( e.ToString(), e );
			}
		}
Exemplo n.º 12
0
        public void Handshake(IChannel channel, IFullHttpRequest req, HttpHeaders responseHeaders, TaskCompletionSource completion)
        {
            if (Logger.DebugEnabled)
            {
                Logger.Debug("{} WebSocket version {} server handshake", channel, this.version);
            }

            IFullHttpResponse response = this.NewHandshakeResponse(req, responseHeaders);
            IChannelPipeline  p        = channel.Pipeline;

            if (p.Get <HttpObjectAggregator>() != null)
            {
                p.Remove <HttpObjectAggregator>();
            }

            if (p.Get <HttpContentCompressor>() != null)
            {
                p.Remove <HttpContentCompressor>();
            }

            IChannelHandlerContext ctx = p.Context <HttpRequestDecoder>();
            string encoderName;

            if (ctx == null)
            {
                // this means the user use a HttpServerCodec
                ctx = p.Context <HttpServerCodec>();
                if (ctx == null)
                {
                    completion.TrySetException(new InvalidOperationException("No HttpDecoder and no HttpServerCodec in the pipeline"));
                    return;
                }

                p.AddBefore(ctx.Name, "wsdecoder", this.NewWebsocketDecoder());
                p.AddBefore(ctx.Name, "wsencoder", this.NewWebSocketEncoder());
                encoderName = ctx.Name;
            }
            else
            {
                p.Replace(ctx.Name, "wsdecoder", this.NewWebsocketDecoder());

                encoderName = p.Context <HttpResponseEncoder>().Name;
                p.AddBefore(encoderName, "wsencoder", this.NewWebSocketEncoder());
            }

            channel.WriteAndFlushAsync(response).ContinueWith(t =>
            {
                if (t.Status == TaskStatus.RanToCompletion)
                {
                    p.Remove(encoderName);
                    completion.TryComplete();
                }
                else
                {
                    completion.TrySetException(t.Exception);
                }
            });
        }
Exemplo n.º 13
0
        private void AddPersister(string alias, IDictionary <string, string[]> propertyResult, ISqlLoadable persister)
        {
            alias2Persister[alias] = persister;
            string suffix = GenerateEntitySuffix();

            log.Debug("mapping alias [" + alias + "] to entity-suffix [" + suffix + "]");
            alias2Suffix[alias]             = suffix;
            entityPropertyResultMaps[alias] = propertyResult;
        }
Exemplo n.º 14
0
        public void AddJoinByPathMap(string path, FromElement destination)
        {
            if (Log.IsDebugEnabled)
            {
                Log.Debug("addJoinByPathMap() : " + path + " -> " + destination);
            }

            _fromElementsByPath.Add(path, destination);
        }
Exemplo n.º 15
0
        public object Get(CacheKey key, long timestamp)
        {
            object result = cache.Get(key);

            if (result != null && log.IsDebugEnabled)
            {
                log.Debug("Cache hit: " + key);
            }
            return(result);
        }
Exemplo n.º 16
0
        protected DefaultCookie InitCookie(string header, int nameBegin, int nameEnd, int valueBegin, int valueEnd)
        {
            if (nameBegin == -1 || nameBegin == nameEnd)
            {
                Logger.Debug("Skipping cookie with null name");
                return(null);
            }

            if (valueBegin == -1)
            {
                Logger.Debug("Skipping cookie with null value");
                return(null);
            }

            var           sequence       = new StringCharSequence(header, valueBegin, valueEnd - valueBegin);
            ICharSequence unwrappedValue = UnwrapValue(sequence);

            if (unwrappedValue == null)
            {
                Logger.Debug("Skipping cookie because starting quotes are not properly balanced in '{}'", sequence);
                return(null);
            }

            string name = header.Substring(nameBegin, nameEnd - nameBegin);

            int invalidOctetPos;

            if (this.Strict && (invalidOctetPos = FirstInvalidCookieNameOctet(name)) >= 0)
            {
                if (Logger.DebugEnabled)
                {
                    Logger.Debug("Skipping cookie because name '{}' contains invalid char '{}'",
                                 name, name[invalidOctetPos]);
                }
                return(null);
            }

            bool wrap = unwrappedValue.Count != valueEnd - valueBegin;

            if (this.Strict && (invalidOctetPos = FirstInvalidCookieValueOctet(unwrappedValue)) >= 0)
            {
                if (Logger.DebugEnabled)
                {
                    Logger.Debug("Skipping cookie because value '{}' contains invalid char '{}'",
                                 unwrappedValue, unwrappedValue[invalidOctetPos]);
                }

                return(null);
            }

            var cookie = new DefaultCookie(name, unwrappedValue.ToString());

            cookie.Wrap = wrap;
            return(cookie);
        }
Exemplo n.º 17
0
        static void Close(IntPtr handle)
        {
            if (handle == IntPtr.Zero)
            {
                return;
            }

            // Get gc handle before close loop
            IntPtr pHandle = ((uv_loop_t *)handle)->data;

            // Fully close the loop, similar to
            //https://github.com/libuv/libuv/blob/v1.x/test/task.h#L190

            int count = 0;

            while (true)
            {
                Logger.Debug($"Loop {handle} walking handles, count = {count}.");
                NativeMethods.uv_walk(handle, WalkCallback, handle);

                Logger.Debug($"Loop {handle} running default to call close callbacks, count = {count}.");
                NativeMethods.uv_run(handle, uv_run_mode.UV_RUN_DEFAULT);

                int result = NativeMethods.uv_loop_close(handle);
                Logger.Debug($"Loop {handle} close result = {result}, count = {count}.");
                if (result == 0)
                {
                    break;
                }

                count++;
                if (count >= 20)
                {
                    Logger.Warn($"Loop {handle} close all handles limit 20 times exceeded.");
                    break;
                }
            }
            Logger.Info($"Loop {handle} closed, count = {count}.");

            // Free GCHandle
            if (pHandle != IntPtr.Zero)
            {
                GCHandle nativeHandle = GCHandle.FromIntPtr(pHandle);
                if (nativeHandle.IsAllocated)
                {
                    nativeHandle.Free();
                    ((uv_loop_t *)handle)->data = IntPtr.Zero;
                    Logger.Info($"Loop {handle} GCHandle released.");
                }
            }

            // Release memory
            NativeMethods.FreeMemory(handle);
            Logger.Info($"Loop {handle} memory released.");
        }
Exemplo n.º 18
0
        public SqlString ToSqlString()
        {
            // will for sure have 3 parts and then each item in the WhereStrings
            int initialCapacity = 3;

            // add an "AND" for each whereString except the first one.
            initialCapacity += (whereStrings.Count - 1);

            for (int i = 0; i < whereStrings.Count; i++)
            {
                initialCapacity += whereStrings[i].Count;
            }

            if (!string.IsNullOrEmpty(comment))
            {
                initialCapacity++;
            }

            SqlStringBuilder sqlBuilder = new SqlStringBuilder(initialCapacity + 2);

            if (!string.IsNullOrEmpty(comment))
            {
                sqlBuilder.Add("/* " + comment + " */ ");
            }

            sqlBuilder.Add("DELETE FROM ")
            .Add(tableName)
            .Add(" WHERE ");

            if (whereStrings.Count > 1)
            {
                sqlBuilder.Add(whereStrings.ToArray(), null, "AND", null, false);
            }
            else
            {
                sqlBuilder.Add(whereStrings[0]);
            }

            if (log.IsDebugEnabled)
            {
                if (initialCapacity < sqlBuilder.Count)
                {
                    log.Debug(
                        "The initial capacity was set too low at: " + initialCapacity + " for the DeleteSqlBuilder " +
                        "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName);
                }
                else if (initialCapacity > 16 && ((float)initialCapacity / sqlBuilder.Count) > 1.2)
                {
                    log.Debug(
                        "The initial capacity was set too high at: " + initialCapacity + " for the DeleteSqlBuilder " +
                        "that needed a capacity of: " + sqlBuilder.Count + " for the table " + tableName);
                }
            }
            return(sqlBuilder.ToSqlString());
        }
Exemplo n.º 19
0
        private static void ProcessDereferencedCollection(IPersistentCollection coll, ISessionImplementor session)
        {
            IPersistenceContext  persistenceContext = session.PersistenceContext;
            CollectionEntry      entry           = persistenceContext.GetCollectionEntry(coll);
            ICollectionPersister loadedPersister = entry.LoadedPersister;

            if (log.IsDebugEnabled && loadedPersister != null)
            {
                log.Debug("Collection dereferenced: " + MessageHelper.CollectionInfoString(loadedPersister, coll, entry.LoadedKey, session));
            }

            // do a check
            bool hasOrphanDelete = loadedPersister != null && loadedPersister.HasOrphanDelete;

            if (hasOrphanDelete)
            {
                object ownerId = loadedPersister.OwnerEntityPersister.GetIdentifier(coll.Owner);
                // TODO NH Different behavior
                //if (ownerId == null)
                //{
                //  // the owning entity may have been deleted and its identifier unset due to
                //  // identifier-rollback; in which case, try to look up its identifier from
                //  // the persistence context
                //  if (session.Factory.Settings.IsIdentifierRollbackEnabled)
                //  {
                //    EntityEntry ownerEntry = persistenceContext.GetEntry(coll.Owner);
                //    if (ownerEntry != null)
                //    {
                //      ownerId = ownerEntry.Id;
                //    }
                //  }
                //  if (ownerId == null)
                //  {
                //    throw new AssertionFailure("Unable to determine collection owner identifier for orphan-delete processing");
                //  }
                //}
                EntityKey key   = session.GenerateEntityKey(ownerId, loadedPersister.OwnerEntityPersister);
                object    owner = persistenceContext.GetEntity(key);
                if (owner == null)
                {
                    throw new AssertionFailure("collection owner not associated with session: " + loadedPersister.Role);
                }
                EntityEntry e = persistenceContext.GetEntry(owner);
                //only collections belonging to deleted entities are allowed to be dereferenced in the case of orphan delete
                if (e != null && e.Status != Status.Deleted && e.Status != Status.Gone)
                {
                    throw new HibernateException("A collection with cascade=\"all-delete-orphan\" was no longer referenced by the owning entity instance: " + loadedPersister.Role);
                }
            }

            // do the work
            entry.CurrentPersister = null;
            entry.CurrentKey       = null;
            PrepareCollectionForUpdate(coll, entry, session.Factory);
        }
Exemplo n.º 20
0
 /// <summary>
 /// Reads all of the contents into memory because another <see cref="IDataReader"/>
 /// needs to be opened.
 /// </summary>
 /// <remarks>
 /// This will result in a no op if the reader is closed or is already in memory.
 /// </remarks>
 public void ReadIntoMemory()
 {
     if (_reader.IsClosed == false && _reader.GetType() != typeof(NDataReader))
     {
         if (log.IsDebugEnabled)
         {
             log.Debug("Moving IDataReader into an NDataReader.  It was converted in midstream " + _isMidstream.ToString());
         }
         _reader = new NDataReader(_reader, _isMidstream);
     }
 }
Exemplo n.º 21
0
        /// <summary>
        /// Register the "hydrated" state of an entity instance, after the first step of 2-phase loading.
        ///
        /// Add the "hydrated state" (an array) of an uninitialized entity to the session. We don't try
        /// to resolve any associations yet, because there might be other entities waiting to be
        /// read from the JDBC result set we are currently processing
        /// </summary>
        public static void PostHydrate(IEntityPersister persister, object id, object[] values, object rowId, object obj, LockMode lockMode, bool lazyPropertiesAreUnfetched, ISessionImplementor session)
        {
            object version = Versioning.GetVersion(values, persister);

            session.PersistenceContext.AddEntry(obj, Status.Loading, values, rowId, id, version, lockMode, true, persister, false, lazyPropertiesAreUnfetched);

            if (log.IsDebugEnabled && version != null)
            {
                System.String versionStr = persister.IsVersioned ? persister.VersionType.ToLoggableString(version, session.Factory) : "null";
                log.Debug("Version: " + versionStr);
            }
        }
Exemplo n.º 22
0
 /// <summary>
 /// Closes the <see cref="IDbConnection"/>.
 /// </summary>
 /// <param name="conn">The <see cref="IDbConnection"/> to clean up.</param>
 public virtual void CloseConnection(IDbConnection conn)
 {
     log.Debug("Closing connection");
     try
     {
         conn.Close();
     }
     catch (Exception e)
     {
         throw new ADOException("Could not close " + conn.GetType() + " connection", e);
     }
 }
Exemplo n.º 23
0
        /// <summary>
        /// Increment the given version number
        /// </summary>
        /// <param name="version">The value of the current version.</param>
        /// <param name="versionType">The <see cref="IVersionType"/> of the versioned property.</param>
        /// <param name="session">The current <see cref="ISession" />.</param>
        /// <returns>Returns the next value for the version.</returns>
        public static object Increment(object version, IVersionType versionType, ISessionImplementor session)
        {
            object next = versionType.Next(version, session);

            if (log.IsDebugEnabled)
            {
                log.Debug(
                    string.Format("Incrementing: {0} to {1}", versionType.ToLoggableString(version, session.Factory),
                                  versionType.ToLoggableString(next, session.Factory)));
            }
            return(next);
        }
Exemplo n.º 24
0
 private static string GetRegionPrefix(IDictionary <string, string> props)
 {
     if (props.TryGetValue("regionPrefix", out var result))
     {
         Log.DebugFormat("new regionPrefix: {0}", result);
     }
     else
     {
         result = DefaultRegionPrefix;
         Log.Debug("no regionPrefix value given, using defaults");
     }
     return(result);
 }
Exemplo n.º 25
0
 protected override IInstantiator BuildInstantiator(PersistentClass persistentClass)
 {
     if (optimizer == null)
     {
         log.Debug("Create Instantiator without optimizer for:" + persistentClass.MappedClass.FullName);
         return(new PocoInstantiator(persistentClass, null, ProxyFactory, EntityMetamodel.HasLazyProperties || EntityMetamodel.HasUnwrapProxyForProperties));
     }
     else
     {
         log.Debug("Create Instantiator using optimizer for:" + persistentClass.MappedClass.FullName);
         return(new PocoInstantiator(persistentClass, optimizer.InstantiationOptimizer, ProxyFactory, EntityMetamodel.HasLazyProperties || EntityMetamodel.HasUnwrapProxyForProperties));
     }
 }
        internal IByteBuffer Allocate(PooledByteBufferAllocator allocator)
        {
            Debug.Assert(allocator is object);

#if DEBUG
            if (Log.DebugEnabled)
            {
                Log.Debug("{} allocate, estimated size = {}", nameof(ReceiveBufferSizeEstimate), _receiveBufferSize);
            }
#endif

            return(allocator.Buffer(_receiveBufferSize));
        }
Exemplo n.º 27
0
        /// <summary>
        /// Enlist the <see cref="IDbCommand"/> in the current <see cref="ITransaction"/>.
        /// </summary>
        /// <param name="command">The <see cref="IDbCommand"/> to enlist in this Transaction.</param>
        /// <remarks>
        /// <para>
        /// This takes care of making sure the <see cref="IDbCommand"/>'s Transaction property
        /// contains the correct <see cref="IDbTransaction"/> or <see langword="null" /> if there is no
        /// Transaction for the ISession - ie <c>BeginTransaction()</c> not called.
        /// </para>
        /// <para>
        /// This method may be called even when the transaction is disposed.
        /// </para>
        /// </remarks>
        public void Enlist(IDbCommand command)
        {
            if (trans == null)
            {
                if (log.IsWarnEnabled)
                {
                    if (command.Transaction != null)
                    {
                        log.Warn("set a nonnull IDbCommand.Transaction to null because the Session had no Transaction");
                    }
                }

                command.Transaction = null;
                return;
            }
            else
            {
                if (log.IsWarnEnabled)
                {
                    // got into here because the command was being initialized and had a null Transaction - probably
                    // don't need to be confused by that - just a normal part of initialization...
                    if (command.Transaction != null && command.Transaction != trans)
                    {
                        log.Warn("The IDbCommand had a different Transaction than the Session.  This can occur when " +
                                 "Disconnecting and Reconnecting Sessions because the PreparedCommand Cache is Session specific.");
                    }
                }
                log.Debug("Enlist Command");

                // If you try to assign a disposed transaction to a command with MSSQL, it will leave the command's
                // transaction as null and not throw an error.  With SQLite, for example, it will throw an exception
                // here instead.  Because of this, we set the trans field to null in when Dispose is called.
                command.Transaction = trans;
            }
        }
Exemplo n.º 28
0
        public object Get(object key)
        {
            if (key == null)
            {
                return(null);
            }

            var cacheKey = GetCacheKey(key);

            if (log.IsDebugEnabled)
            {
                log.Debug(string.Format("Fetching object '{0}' from the cache.", cacheKey));
            }

            var obj = cache.Get(cacheKey);

            if (obj == null)
            {
                return(null);
            }

            var de = (DictionaryEntry)obj;

            if (key.Equals(de.Key))
            {
                return(de.Value);
            }

            return(null);
        }
Exemplo n.º 29
0
        public void LogParameters(ISessionFactoryImplementor factory)
        {
            var print = new Printer(factory);

            if (_positionalParameterValues.Length != 0)
            {
                log.Debug("parameters: " + print.ToString(_positionalParameterTypes, _positionalParameterValues));
            }

            if (_namedParameters != null)
            {
                log.Debug("named parameters: " + print.ToString(_namedParameters));
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Creates the metadata document.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="sign">if set to <c>true</c> sign the document.</param>
        public string CreateMetadataDocument(Encoding encoding, bool sign)
        {
            logger.Debug(TraceMessages.MetadataDocumentBeingCreated);

            var keyinfo   = new System.Security.Cryptography.Xml.KeyInfo();
            var keyClause = new System.Security.Cryptography.Xml.KeyInfoX509Data(configuration.ServiceProvider.SigningCertificate, X509IncludeOption.EndCertOnly);

            keyinfo.AddClause(keyClause);

            var doc = new Saml20MetadataDocument(configuration, keyinfo, sign);

            logger.Debug(TraceMessages.MetadataDocumentCreated);
            return(doc.ToXml(encoding, configuration.ServiceProvider.SigningCertificate));
        }
Exemplo n.º 31
0
		public static void LogMapped(this Mapping.Property property, IInternalLogger log)
		{
			if (log.IsDebugEnabled)
			{
				string msg = "Mapped property: " + property.Name;
				string columns = string.Join(",", property.Value.ColumnIterator.Select(c => c.Text).ToArray());
				if (columns.Length > 0)
					msg += " -> " + columns;
				if (property.Type != null)
					msg += ", type: " + property.Type.Name;
				log.Debug(msg);
			}
		}
		/// <summary></summary>
		static SessionFactoryObjectFactory()
		{
			log = LoggerProvider.LoggerFor(typeof(SessionFactoryObjectFactory));
			log.Debug("initializing class SessionFactoryObjectFactory");
		}