Example #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="backendProviderType">Type of backend provider to create.</param>
 /// <param name="ui">The UI service.</param>
 /// <param name="dirs">The directories service.</param>
 /// <param name="settings">The FDO settings.</param>
 internal FdoServiceLocatorFactory(FDOBackendProviderType backendProviderType, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings)
 {
     m_backendProviderType = backendProviderType;
     m_ui       = ui;
     m_dirs     = dirs;
     m_settings = settings;
 }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// This is the implementation for the static constructor. It is in a separate method
		/// to allow tests to reset it (using reflection).
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static void SetCurrentToDb4OBackend(IFdoUI ui, IFdoDirectories dirs,
			Func<bool> usingDefaultProjectsDirAccessor)
		{
			// This is the "one line" that should need to be changed to configure a different backend :-).
			// Typically a new implementation of IClientServerServices will be needed, as well as the backend itself.
			Current = new Db4OClientServerServices(ui, dirs, usingDefaultProjectsDirAccessor);
		}
		internal SharedXMLBackendProvider(FdoCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc,
			IDataMigrationManager dataMigrationManager, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings)
			: base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
		{
			m_peerProcesses = new Dictionary<int, Process>();
			m_peerID = Guid.NewGuid();
		}
 protected ClientServerBackendProvider(FdoCache cache,
                                       IdentityMap identityMap,
                                       ICmObjectSurrogateFactory surrogateFactory,
                                       IFwMetaDataCacheManagedInternal mdc,
                                       IDataMigrationManager dataMigrationManager,
                                       IFdoUI ui, IFdoDirectories dirs, FdoSettings settings) : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
 {
 }
		protected ClientServerBackendProvider(FdoCache cache,
			IdentityMap identityMap,
			ICmObjectSurrogateFactory surrogateFactory,
			IFwMetaDataCacheManagedInternal mdc,
			IDataMigrationManager dataMigrationManager,
			IFdoUI ui, IFdoDirectories dirs, FdoSettings settings) : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
		{
		}
		internal SharedXMLBackendProvider(FdoCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc,
			IDataMigrationManager dataMigrationManager, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings)
			: base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
		{
			m_peerProcesses = new Dictionary<int, Process>();
			m_peerID = Guid.NewGuid();
#if __MonoCS__
			// /dev/shm is not guaranteed to be available on all systems, so fall back to temp
			m_commitLogDir = Directory.Exists("/dev/shm") ? "/dev/shm" : Path.GetTempPath();
#endif
		}
Example #7
0
        public static void Start(string remotingTcpServerConfigFile, IFdoDirectories dirs, Func <bool> sharedProjectsGetter, Action <bool> sharedProjectsSetter)
        {
            // check if we are already running.
            if (ServerObject != null && ServerObject.IsRunning)
            {
                return;
            }

            Directories          = dirs;
            SharedProjectsGetter = sharedProjectsGetter;
            SharedProjectsSetter = sharedProjectsSetter;

            if (ChannelServices.RegisteredChannels.Length > 0)
            {
                var tcpChannel = ChannelServices.GetChannel("tcp");
                if (tcpChannel is TcpChannel)
                {
                    // Channel got registered before. Don't do it again
                    return;
                }
                if (tcpChannel != null)
                {
                    // We probably have a TcpClientChannel which we can't use, so get rid of it.
                    // This can happen in tests when NUnit runs under .NET 2.0 but has to kick
                    // off a nunit-agent process that can run the tests under .NET 4.0. For some
                    // reason in this case we get a TcpClientChannel and so our tests fail
                    // unless we unregister the client channel.
                    ChannelServices.UnregisterChannel(tcpChannel);
                }
            }

            if (ServerObject == null)
            {
                // TODO: currently running with no security
                // TODO-Linux: security support has not been implemented in Mono
                RemotingConfiguration.Configure(remotingTcpServerConfigFile, false);
            }
            else
            {
                ServerObject.IsRunning = true;
            }
        }
        internal SharedXMLBackendProvider(FdoCache cache, IdentityMap identityMap, ICmObjectSurrogateFactory surrogateFactory, IFwMetaDataCacheManagedInternal mdc,
                                          IDataMigrationManager dataMigrationManager, IFdoUI ui, IFdoDirectories dirs, FdoSettings settings)
            : base(cache, identityMap, surrogateFactory, mdc, dataMigrationManager, ui, dirs, settings)
        {
            m_peerProcesses = new Dictionary <int, Process>();
            m_peerID        = Guid.NewGuid();
#if __MonoCS__
            // /dev/shm is not guaranteed to be available on all systems, so fall back to temp
            m_commitLogDir = Directory.Exists("/dev/shm") ? "/dev/shm" : Path.GetTempPath();
#endif
        }
		public Db4OLocalClientServerServices(IFdoUI ui, IFdoDirectories dirs)
		{
			m_ui = ui;
			m_dirs = dirs;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="Db4OClientServerServices"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		internal Db4OClientServerServices(IFdoUI ui, IFdoDirectories dirs)
		{
			m_dirs = dirs;
			Local = new Db4OLocalClientServerServices(ui, dirs);
		}
Example #11
0
 public ProjectIdentifier(IFdoDirectories fdoDirs, string database)
 {
     FdoDirectories = fdoDirs;
     Path           = GetPathToDatabase(fdoDirs, database);
 }
		private readonly IFwMetaDataCacheManaged m_mdc;	// needed for some data migrations changing over to custom fields.

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="startingModelVersionNumber">The starting model version number for the
		/// migration.</param>
		/// <param name="dtos">DTOs from BEP-land.</param>
		/// <param name="mdc">The MDC.</param>
		/// <param name="projectFolder">The project folder (don't even think about trying to
		/// pass a path on a server other than the local machine, and -- yes -- I CAN control
		/// your thoughts!).</param>
		/// <param name="dirs"></param>
		/// ------------------------------------------------------------------------------------
		internal DomainObjectDtoRepository(int startingModelVersionNumber, HashSet<DomainObjectDTO> dtos,
			IFwMetaDataCacheManaged mdc, string projectFolder, IFdoDirectories dirs)
		{
			if (dtos == null) throw new ArgumentNullException("dtos");
			if (mdc == null) throw new ArgumentNullException("mdc");

			m_currentModelVersionNumber = startingModelVersionNumber;
			m_dtos = dtos;
			m_mdc = mdc;
			m_projectFolder = projectFolder;
			m_dirs = dirs;

			// Add classes from MDC
			foreach (var clsid in mdc.GetClassIds())
			{
				// Leaf classes will have nothing in 'subclasses'.
				var className = mdc.GetClassName(clsid);
				m_dtosByClass.Add(className, new HashSet<DomainObjectDTO>());
				if (className == "CmObject")
					m_classAndSuperClass.Add(className, null);
				var subclasses = new HashSet<string>();
				m_classesAndTheirDirectSubclasses.Add(className, subclasses);
				var subclassIds = mdc.GetDirectSubclasses(clsid);
				if (subclassIds.Count() == 0)
				{
					if (!m_classAndSuperClass.ContainsKey(className))
						m_classAndSuperClass.Add(className, mdc.GetBaseClsName(clsid));
					continue;
				}
				foreach (var directSubClsid in subclassIds)
				{
					var directSubclassName = mdc.GetClassName(directSubClsid);
					subclasses.Add(directSubclassName);

					// added ContainsKey check because of mono bug https://bugzilla.novell.com/show_bug.cgi?id=539288
					// see also change in FdoIFwMetaDataCache.cs (AddClass methods replaced with AddClass1, AddClass2)
					// for simular reasons (order of types obtains via reflection)https://bugzilla.novell.com/show_bug.cgi?id=539288.
					if (!m_classAndSuperClass.ContainsKey(directSubclassName))
					{
						m_classAndSuperClass.Add(directSubclassName, className);
					}
				}
			}

#if ORIGINAL
			foreach (var classname in m_classesAndTheirDirectSubclasses.Keys)
			{
				// Some may have no instances.
				m_dtosByClass.Add(classname, (from dto in m_dtos
											  where dto.Classname == classname
											  select dto).ToList());
			}

			foreach (var dto in m_dtos)
				m_dtoByGuid.Add(dto.Guid.ToLower(), dto);
#else
			m_dtoByGuid = new Dictionary<string, DomainObjectDTO>(m_dtos.Count);
			foreach (var dto in m_dtos)
			{
				m_dtoByGuid.Add(dto.Guid.ToLower(), dto);
				AddToClassList(dto);
			}
#endif
		}
        private readonly IFwMetaDataCacheManaged m_mdc;         // needed for some data migrations changing over to custom fields.

        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="startingModelVersionNumber">The starting model version number for the
        /// migration.</param>
        /// <param name="dtos">DTOs from BEP-land.</param>
        /// <param name="mdc">The MDC.</param>
        /// <param name="projectFolder">The project folder (don't even think about trying to
        /// pass a path on a server other than the local machine, and -- yes -- I CAN control
        /// your thoughts!).</param>
        /// <param name="dirs"></param>
        /// ------------------------------------------------------------------------------------
        internal DomainObjectDtoRepository(int startingModelVersionNumber, HashSet <DomainObjectDTO> dtos,
                                           IFwMetaDataCacheManaged mdc, string projectFolder, IFdoDirectories dirs)
        {
            if (dtos == null)
            {
                throw new ArgumentNullException("dtos");
            }
            if (mdc == null)
            {
                throw new ArgumentNullException("mdc");
            }

            m_currentModelVersionNumber = startingModelVersionNumber;
            m_dtos          = dtos;
            m_mdc           = mdc;
            m_projectFolder = projectFolder;
            m_dirs          = dirs;

            // Add classes from MDC
            foreach (var clsid in mdc.GetClassIds())
            {
                // Leaf classes will have nothing in 'subclasses'.
                var className = mdc.GetClassName(clsid);
                m_dtosByClass.Add(className, new HashSet <DomainObjectDTO>());
                if (className == "CmObject")
                {
                    m_classAndSuperClass.Add(className, null);
                }
                var subclasses = new HashSet <string>();
                m_classesAndTheirDirectSubclasses.Add(className, subclasses);
                var subclassIds = mdc.GetDirectSubclasses(clsid);
                if (subclassIds.Count() == 0)
                {
                    if (!m_classAndSuperClass.ContainsKey(className))
                    {
                        m_classAndSuperClass.Add(className, mdc.GetBaseClsName(clsid));
                    }
                    continue;
                }
                foreach (var directSubClsid in subclassIds)
                {
                    var directSubclassName = mdc.GetClassName(directSubClsid);
                    subclasses.Add(directSubclassName);

                    // added ContainsKey check because of mono bug https://bugzilla.novell.com/show_bug.cgi?id=539288
                    // see also change in FdoIFwMetaDataCache.cs (AddClass methods replaced with AddClass1, AddClass2)
                    // for simular reasons (order of types obtains via reflection)https://bugzilla.novell.com/show_bug.cgi?id=539288.
                    if (!m_classAndSuperClass.ContainsKey(directSubclassName))
                    {
                        m_classAndSuperClass.Add(directSubclassName, className);
                    }
                }
            }

#if ORIGINAL
            foreach (var classname in m_classesAndTheirDirectSubclasses.Keys)
            {
                // Some may have no instances.
                m_dtosByClass.Add(classname, (from dto in m_dtos
                                              where dto.Classname == classname
                                              select dto).ToList());
            }

            foreach (var dto in m_dtos)
            {
                m_dtoByGuid.Add(dto.Guid.ToLower(), dto);
            }
#else
            m_dtoByGuid = new Dictionary <string, DomainObjectDTO>(m_dtos.Count);
            foreach (var dto in m_dtos)
            {
                m_dtoByGuid.Add(dto.Guid.ToLower(), dto);
                AddToClassList(dto);
            }
#endif
        }
		public Db4OLocalClientServerServices(IFdoUI ui, IFdoDirectories dirs, Func<bool> usingDefaultProjectsDirAccessor)
		{
			m_ui = ui;
			m_dirs = dirs;
			m_usingDefaultProjectsDirAccessor = usingDefaultProjectsDirAccessor;
		}
Example #15
0
		public static void Start(string remotingTcpServerConfigFile, IFdoDirectories dirs, Func<bool> sharedProjectsGetter, Action<bool> sharedProjectsSetter)
		{
			// check if we are already running.
			if (ServerObject != null && ServerObject.IsRunning)
				return;

			Directories = dirs;
			SharedProjectsGetter = sharedProjectsGetter;
			SharedProjectsSetter = sharedProjectsSetter;

			if (ChannelServices.RegisteredChannels.Length > 0)
			{
				var tcpChannel = ChannelServices.GetChannel("tcp");
				if (tcpChannel is TcpChannel)
				{
					// Channel got registered before. Don't do it again
					return;
				}
				if (tcpChannel != null)
				{
					// We probably have a TcpClientChannel which we can't use, so get rid of it.
					// This can happen in tests when NUnit runs under .NET 2.0 but has to kick
					// off a nunit-agent process that can run the tests under .NET 4.0. For some
					// reason in this case we get a TcpClientChannel and so our tests fail
					// unless we unregister the client channel.
					ChannelServices.UnregisterChannel(tcpChannel);
				}
			}

			if (ServerObject == null)
			{
			// TODO: currently running with no security
			// TODO-Linux: security support has not been implemented in Mono
				RemotingConfiguration.Configure(remotingTcpServerConfigFile, false);
		}
			else
			{
				ServerObject.IsRunning = true;
			}
		}
Example #16
0
 private static string GetPathToDatabase(IFdoDirectories fdoDirs, string database)
 {
     return(System.IO.Path.Combine(fdoDirs.ProjectsDirectory, database,
                                   database + FdoFileHelper.ksFwDataXmlFileExtension));
 }
Example #17
0
 public ProjectIdentifier(IFdoDirectories fdoDirs, string database)
 {
     FdoDirectories = fdoDirs;
     Path = GetPathToDatabase(fdoDirs, database);
 }
Example #18
0
 private static string GetPathToDatabase(IFdoDirectories fdoDirs, string database)
 {
     return System.IO.Path.Combine(fdoDirs.ProjectsDirectory, database,
         database + FdoFileHelper.ksFwDataXmlFileExtension);
 }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="Db4OClientServerServices"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		internal Db4OClientServerServices(IFdoUI ui, IFdoDirectories dirs, Func<bool> usingDefaultProjectsDirAccessor)
		{
			m_dirs = dirs;
			Local = new Db4OLocalClientServerServices(ui, dirs, usingDefaultProjectsDirAccessor);
		}