Beispiel #1
0
 public void TestInvalidSecondAdd()
 {
     try
     {
         testIndex.Add(testEventType, handleSetNode);
         Assert.IsTrue(false);
     }
     catch (IllegalStateException)
     {
         // Expected
     }
 }
Beispiel #2
0
        public void SetUp()
        {
            SupportBean testBean = new SupportBean();

            testEventBean = SupportEventBeanFactory
                            .GetInstance(container)
                            .CreateObject(testBean);
            testEventType = testEventBean.EventType;

            handleSetNode  = new FilterHandleSetNode(new SlimReaderWriterLock());
            filterCallback = new SupportFilterHandle();
            handleSetNode.Add(filterCallback);

            testIndex = new EventTypeIndex(new FilterServiceGranularLockFactoryReentrant(
                                               container.RWLockManager()));
            testIndex.Add(testEventType, handleSetNode);
        }
        /// <summary>
        ///     Add a filter to the event type index structure, and to the filter subtree.
        ///     Throws an IllegalStateException exception if the callback is already registered.
        /// </summary>
        /// <param name="valueSet">is the filter information</param>
        /// <param name="filterCallback">is the callback</param>
        /// <param name="lockFactory">lock factory</param>
        /// <param name="eventType">event type</param>
        public void Add(
            EventType eventType,
            FilterValueSetParam[][] valueSet,
            FilterHandle filterCallback,
            FilterServiceGranularLockFactory lockFactory)
        {
            // Check if a filter tree exists for this event type
            var rootNode = eventTypeIndex.Get(eventType);

            // Make sure we have a root node
            if (rootNode == null) {
                using (callbacksLock.Acquire()) {
                    rootNode = eventTypeIndex.Get(eventType);
                    if (rootNode == null) {
                        rootNode = new FilterHandleSetNode(lockFactory.ObtainNew());
                        eventTypeIndex.Add(eventType, rootNode);
                    }
                }
            }

            // Now add to tree
            IndexTreeBuilderAdd.Add(valueSet, filterCallback, rootNode, lockFactory);
        }