コード例 #1
0
 public override NeoDatis.Odb.OID WriteNonNativeObjectInfo(NeoDatis.Odb.OID existingOid
                                                           , NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo objectInfo, long position
                                                           , bool writeDataInTransaction, bool isNewObject)
 {
     // To enable object auto-reconnect on the server side
     if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession() && objectInfo.GetHeader
             ().GetOid() != null)
     {
         NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
                                                                            )sessionManager.GetSession(storageEngine.GetBaseIdentification().GetIdentification
                                                                                                           (), true);
         NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = session.GetCache().GetObjectInfoHeaderFromOid
                                                                         (objectInfo.GetOid(), false);
         // only add in th cache if object does not exist in the cache
         if (oih == null)
         {
             session.GetCache().AddObjectInfo(objectInfo.GetHeader());
         }
     }
     NeoDatis.Odb.OID roid = base.WriteNonNativeObjectInfo(existingOid, objectInfo, position
                                                           , writeDataInTransaction, isNewObject);
     if (objectInfo is NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo)
     {
         NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = (NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo
                                                                                        )objectInfo;
         NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
                                                                            )GetSession();
         session.AssociateIds(roid, cnnoi.GetLocalOid());
         // Adds the abstract Objectinfo in the cache
         session.GetCache().AddObjectInfo(cnnoi.GetHeader());
     }
     return(roid);
 }
コード例 #2
0
 public override NeoDatis.Odb.OID UpdateNonNativeObjectInfo(NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
                                                            nnoi, bool forceUpdate)
 {
     // To enable object auto-reconnect on the server side
     if (NeoDatis.Odb.OdbConfiguration.ReconnectObjectsToSession() && nnoi.GetHeader()
         .GetOid() != null)
     {
         NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
                                                                            )sessionManager.GetSession(storageEngine.GetBaseIdentification().GetIdentification
                                                                                                           (), true);
         NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = session.GetCache().GetObjectInfoHeaderFromOid
                                                                         (nnoi.GetOid(), false);
         // only add in th cache if object does not exist in the cache
         if (oih == null)
         {
             session.GetCache().AddObjectInfo(nnoi.GetHeader());
         }
     }
     NeoDatis.Odb.OID roid = base.UpdateNonNativeObjectInfo(nnoi, forceUpdate);
     if (nnoi is NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo)
     {
         NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo cnnoi = (NeoDatis.Odb.Core.Server.Layers.Layer2.Meta.ClientNonNativeObjectInfo
                                                                                        )nnoi;
         NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession session = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
                                                                            )GetSession();
         session.AssociateIds(cnnoi.GetOid(), cnnoi.GetLocalOid());
     }
     return(roid);
 }
コード例 #3
0
 /// <exception cref="System.IO.IOException"></exception>
 public virtual NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo AddClass(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                                                        newClassInfo, bool addDependentClasses)
 {
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = GetObjectWriter().AddClass(newClassInfo
                                                                                    , addDependentClasses);
     NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession lsession = (NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
                                                                         )GetSession(true);
     lsession.SetClassInfoId(newClassInfo.GetFullClassName(), ci.GetId());
     return(ci);
 }
コード例 #4
0
		private NeoDatis.Odb.Core.Server.Layers.Layer3.Engine.Message ManageConnectCommand
			(NeoDatis.Odb.Core.Server.Message.ConnectMessage message)
		{
			// Gets the base identifier
			baseIdentifier = message.GetBaseIdentifier();
			// Gets the connection manager for this base identifier
			NeoDatis.Odb.Core.Server.Connection.ConnectionManager connectionManager = null;
			NeoDatis.Odb.Core.Server.Connection.IConnection connection = null;
			NeoDatis.Tool.Mutex.Mutex mutex = null;
			try
			{
				mutex = NeoDatis.Tool.Mutex.MutexFactory.Get(baseIdentifier).Acquire("connect");
				// Gets the connection manager for this base identifier
				connectionManager = GetConnectionManager(baseIdentifier, message.GetUser(), message
					.GetPassword(), false);
				if (connectionManager == null)
				{
					System.Text.StringBuilder buffer = new System.Text.StringBuilder();
					buffer.Append("Base ").Append(baseIdentifier).Append(" is not registered on this server!"
						);
					return new NeoDatis.Odb.Core.Server.Message.ConnectMessageResponse(baseIdentifier
						, "?", buffer.ToString());
				}
				string ip = message.GetIp();
				long dateTime = message.GetDateTime();
				connection = connectionManager.NewConnection(ip, dateTime, connectionManager.GetNbConnections
					());
				connection.SetCurrentAction(NeoDatis.Odb.Core.Server.Connection.ConnectionAction.
					ActionConnect);
				connectionId = connection.GetId();
				// Creates a new session for this connection
				NeoDatis.Odb.Core.Transaction.ISession session = new NeoDatis.Odb.Impl.Core.Server.Transaction.ServerSession
					(connection.GetStorageEngine(), connectionId);
				NeoDatis.Odb.Core.Layers.Layer3.IStorageEngine engine = connection.GetStorageEngine
					();
				// adds the session to the storage engine (it will be associated to
				// the current thread
				// The add session sets the correct meta model
				engine.AddSession(session, true);
				NeoDatis.Odb.TransactionId transactionId = engine.GetCurrentTransactionId();
				if (debug)
				{
					NeoDatis.Tool.DLogger.Info(new System.Text.StringBuilder("Connection from ").Append
						(ip).Append(" - cid=").Append(connection.GetId()).Append(" - session=").Append(session
						.GetId()).Append(" - Base Id=").Append(baseIdentifier).ToString());
				}
				// Returns the meta-model to the client
				NeoDatis.Odb.Core.Layers.Layer2.Meta.MetaModel metaModel = engine.GetSession(true
					).GetMetaModel();
				NeoDatis.Odb.Core.Server.Message.ConnectMessageResponse cmr = new NeoDatis.Odb.Core.Server.Message.ConnectMessageResponse
					(baseIdentifier, connection.GetId(), metaModel, transactionId);
				return cmr;
			}
			catch (System.Exception e)
			{
				string se = NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, false);
				string msg = baseIdentifier + ":Error while connecting to  " + message.GetBaseIdentifier
					();
				NeoDatis.Tool.DLogger.Error(msg, e);
				return new NeoDatis.Odb.Core.Server.Message.ConnectMessageResponse(baseIdentifier
					, message.GetConnectionId(), msg + ":\n" + se);
			}
			finally
			{
				if (mutex != null)
				{
					mutex.Release("connect");
				}
				if (connection != null)
				{
					connection.EndCurrentAction();
				}
			}
		}