Ejemplo n.º 1
0
        /// <summary>
        /// 修改服务注册
        /// </summary>
        /// <param name="context"></param>
        /// <param name="registration"></param>
        internal void ModifyServiceRegistration(BundleContextImpl context, ServiceRegistrationImpl registration)
        {
            // The list of Services published by BundleContextImpl is not sorted, so
            // we do not need to modify it.

            // Remove the ServiceRegistrationImpl from the list of Services published by Class Name
            // and then add at the correct index.
            String[] clazzes = registration.GetClasses();
            int      insertIndex;

            for (int i = 0, size = clazzes.Length; i < size; i++)
            {
                String    clazz    = clazzes[i];
                ArrayList services = (ArrayList)publishedServicesByClass[clazz];
                services.Remove(registration);
                // The list is sorted, so we must find the proper location to insert
                insertIndex = -services.BinarySearch(registration) - 1;
                services.Insert(insertIndex, registration);
            }

            // Remove the ServiceRegistrationImpl from the list of all published Services
            // and then add at the correct index.
            allPublishedServices.Remove(registration);
            // The list is sorted, so we must find the proper location to insert
            insertIndex = -allPublishedServices.BinarySearch(registration) - 1;
            allPublishedServices.Insert(insertIndex, registration);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除服务注册
        /// </summary>
        /// <param name="context"></param>
        /// <param name="registration"></param>
        internal void RemoveServiceRegistration(BundleContextImpl context, ServiceRegistrationImpl registration)
        {
            // Remove the ServiceRegistrationImpl from the list of Services published by BundleContextImpl.
            IList contextServices = (IList)publishedServicesByContext[context];

            if (contextServices != null)
            {
                contextServices.Remove(registration);
            }

            // Remove the ServiceRegistrationImpl from the list of Services published by Class Name.
            String[] clazzes = registration.GetClasses();
            for (int i = 0, size = clazzes.Length; i < size; i++)
            {
                String clazz    = clazzes[i];
                IList  services = (IList)publishedServicesByClass[clazz];
                services.Remove(registration);
                if (services.Count == 0)
                { // remove empty list
                    publishedServicesByClass.Remove(clazz);
                }
            }

            // Remove the ServiceRegistrationImpl from the list of all published Services.
            allPublishedServices.Remove(registration);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加服务注册
        /// </summary>
        /// <param name="context"></param>
        /// <param name="registration"></param>
        internal void AddServiceRegistration(BundleContextImpl context, ServiceRegistrationImpl registration)
        {
            // Add the ServiceRegistrationImpl to the list of Services published by BundleContextImpl.
            ArrayList contextServices = (ArrayList)publishedServicesByContext[context];

            if (contextServices == null)
            {
                contextServices = new ArrayList(initialSubCapacity);
                publishedServicesByContext.Add(context, contextServices);
            }
            // The list is NOT sorted, so we just add
            contextServices.Add(registration);

            // Add the ServiceRegistrationImpl to the list of Services published by Class Name.
            String[] clazzes = registration.GetClasses();
            int      insertIndex;

            for (int i = 0, size = clazzes.Length; i < size; i++)
            {
                String clazz = clazzes[i];

                ArrayList services = (ArrayList)publishedServicesByClass[clazz];

                if (services == null)
                {
                    services = new ArrayList(initialSubCapacity);
                    publishedServicesByClass.Add(clazz, services);
                }

                // The list is sorted, so we must find the proper location to insert
                insertIndex = -services.BinarySearch(registration) - 1;
                services.Insert(insertIndex, registration);
            }

            // Add the ServiceRegistrationImpl to the list of all published Services.
            // The list is sorted, so we must find the proper location to insert
            insertIndex = -allPublishedServices.BinarySearch(registration) - 1;
            allPublishedServices.Insert(insertIndex, registration);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 获取所有服务注册的接口契约
 /// </summary>
 /// <returns></returns>
 internal string[] GetClasses()
 {
     return(registration.GetClasses());
 }